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
Fields
I
Represents a complex number with unity imaginary part and zero real part.
public static readonly ComplexF I
Field Value
NaN
public static readonly ComplexF NaN
Field Value
NegativeImaginaryInfinity
Represents a complex number with an imaginary component of negative infinity and zero real part.
public static readonly ComplexF NegativeImaginaryInfinity
Field Value
NegativeRealInfinity
Represents a complex number with a real component of negative infinity and zero imaginary part.
public static readonly ComplexF NegativeRealInfinity
Field Value
One
Represents a complex number with unity real part and zero imaginary part.
public static readonly ComplexF One
Field Value
PositiveImaginaryInfinity
Represents a complex number with an imaginary component of positive infinity and zero real part.
public static readonly ComplexF PositiveImaginaryInfinity
Field Value
PositiveRealInfinity
Represents a complex number with a real component of positive infinity and zero imaginary part.
public static readonly ComplexF PositiveRealInfinity
Field Value
Zero
Represents a complex number with zero components.
public static readonly ComplexF Zero
Field Value
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
IsFinite
Gets whether both components are finite.
public readonly bool IsFinite { get; }
Property Value
IsInfinity
Gets whether either component is infinite.
public readonly bool IsInfinity { get; }
Property Value
IsNaN
Gets whether either component is NaN.
public readonly bool IsNaN { get; }
Property Value
Magnitude
Gets the magnitude of the complex number.
public readonly float Magnitude { get; }
Property Value
Remarks
Computed as sqrt(Re^2 + Im^2).
MagnitudeSqr
Gets the squared magnitude of the complex number.
public readonly float MagnitudeSqr { get; }
Property Value
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
Methods
Equals(ComplexF)
Determines whether the specified complex number is equal to the current complex number.
public readonly bool Equals(ComplexF other)
Parameters
otherComplexFThe 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
objobjectThe 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
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
Returns
operator /(ComplexF, ComplexF)
Divides one complex number by another.
public static ComplexF operator /(ComplexF a, ComplexF b)
Parameters
Returns
Remarks
operator ==(ComplexF, ComplexF)
Determines whether two complex numbers are equal.
public static bool operator ==(ComplexF a, ComplexF b)
Parameters
Returns
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
valuefloat
Returns
operator !=(ComplexF, ComplexF)
Determines whether two complex numbers are not equal.
public static bool operator !=(ComplexF a, ComplexF b)
Parameters
Returns
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
Returns
operator -(ComplexF, ComplexF)
Component wise subtraction of two complex numbers.
public static ComplexF operator -(ComplexF a, ComplexF b)
Parameters
Returns
operator -(ComplexF)
Component wise unary negation of a complex number.
public static ComplexF operator -(ComplexF z)
Parameters
zComplexF