Table of Contents

Struct ComplexF

Namespace
CMath
Assembly
QuantumLibrary.dll

Represents an immutable complex number using float components.

public struct ComplexF : IEquatable<ComplexF>
Implements
Inherited Members

Constructors

ComplexF(float, float)

Creates a complex number.

public ComplexF(float real, float imaginary)

Parameters

real float

The real component.

imaginary float

The imaginary component.

Fields

I

Represents a complex number with unity imaginary part and zero real part.

public static readonly ComplexF I

Field Value

ComplexF

NaN

public static readonly ComplexF NaN

Field Value

ComplexF

NegativeImaginaryInfinity

Represents a complex number with an imaginary component of negative infinity and zero real part.

public static readonly ComplexF NegativeImaginaryInfinity

Field Value

ComplexF

NegativeRealInfinity

Represents a complex number with a real component of negative infinity and zero imaginary part.

public static readonly ComplexF NegativeRealInfinity

Field Value

ComplexF

One

Represents a complex number with unity real part and zero imaginary part.

public static readonly ComplexF One

Field Value

ComplexF

PositiveImaginaryInfinity

Represents a complex number with an imaginary component of positive infinity and zero real part.

public static readonly ComplexF PositiveImaginaryInfinity

Field Value

ComplexF

PositiveRealInfinity

Represents a complex number with a real component of positive infinity and zero imaginary part.

public static readonly ComplexF PositiveRealInfinity

Field Value

ComplexF

Zero

Represents a complex number with zero components.

public static readonly ComplexF Zero

Field Value

ComplexF

Properties

Conjugate

Gets the complex conjugate.

public readonly ComplexF Conjugate { get; }

Property Value

ComplexF

A new complex number with a negated imaginary part.

Imaginary

Gets the imaginary component.

public readonly float Imaginary { get; }

Property Value

float

IsFinite

Gets whether both components are finite.

public readonly bool IsFinite { get; }

Property Value

bool

IsInfinity

Gets whether either component is infinite.

public readonly bool IsInfinity { get; }

Property Value

bool

IsNaN

Gets whether either component is NaN.

public readonly bool IsNaN { get; }

Property Value

bool

Magnitude

Gets the magnitude of the complex number.

public readonly float Magnitude { get; }

Property Value

float

Remarks

Computed as sqrt(Re^2 + Im^2).

MagnitudeSqr

Gets the squared magnitude of the complex number.

public readonly float MagnitudeSqr { get; }

Property Value

float

Normalized

Gets a normalized version of the complex number.

public readonly ComplexF Normalized { get; }

Property Value

ComplexF

The complex number divided by its own magnitude, NaN if magnitude is zero.

Real

Gets the real component.

public readonly float Real { get; }

Property Value

float

Methods

Equals(ComplexF)

Determines whether the specified complex number is equal to the current complex number.

public readonly bool Equals(ComplexF other)

Parameters

other ComplexF

The other complex number to compare.

Returns

bool

Component-wise equality.

Equals(object?)

Determines whether the specified object instance is equal to the complex number.

public override readonly bool Equals(object? obj)

Parameters

obj object

The object to compare.

Returns

bool

Only true if both are component-wise equal complex numbers.

GetHashCode()

Combines the hash code of the real and imaginary components.

public override readonly int GetHashCode()

Returns

int

A hash code for the current complex number.

ToString()

Returns a string that represents the complex number.

public override readonly string ToString()

Returns

string

Remarks

The string is formatted as "a + bi" or "a - bi". Special floating-point values (NaN, Infinity) use their default string representations.

Operators

operator +(ComplexF, ComplexF)

Component wise addition of two complex numbers.

public static ComplexF operator +(ComplexF a, ComplexF b)

Parameters

a ComplexF
b ComplexF

Returns

ComplexF

operator /(ComplexF, ComplexF)

Divides one complex number by another.

public static ComplexF operator /(ComplexF a, ComplexF b)

Parameters

a ComplexF
b ComplexF

Returns

ComplexF

Remarks

Returns NaN if the divisor is zero or if either operand contains NaN.

operator ==(ComplexF, ComplexF)

Determines whether two complex numbers are equal.

public static bool operator ==(ComplexF a, ComplexF b)

Parameters

a ComplexF
b ComplexF

Returns

bool

Remarks

This uses exact component comparison. If either component is NaN, the comparison returns false.

implicit operator ComplexF(float)

Implicitly converts a real number to a complex number: value + 0*i.

public static implicit operator ComplexF(float value)

Parameters

value float

Returns

ComplexF

operator !=(ComplexF, ComplexF)

Determines whether two complex numbers are not equal.

public static bool operator !=(ComplexF a, ComplexF b)

Parameters

a ComplexF
b ComplexF

Returns

bool

Remarks

This uses exact component comparison. If either component is NaN, the comparison returns true.

operator *(ComplexF, ComplexF)

Distributed multiplication of two complex numbers.

public static ComplexF operator *(ComplexF a, ComplexF b)

Parameters

a ComplexF
b ComplexF

Returns

ComplexF

operator -(ComplexF, ComplexF)

Component wise subtraction of two complex numbers.

public static ComplexF operator -(ComplexF a, ComplexF b)

Parameters

a ComplexF
b ComplexF

Returns

ComplexF

operator -(ComplexF)

Component wise unary negation of a complex number.

public static ComplexF operator -(ComplexF z)

Parameters

z ComplexF

Returns

ComplexF