Table of Contents

Class MathC

Namespace
CMath
Assembly
QuantumLibrary.dll

A collection of common complex math functions.

public static class MathC
Inheritance
MathC
Inherited Members

Methods

Abs(ComplexF)

Returns the magnitude of the specified complex number.

public static float Abs(ComplexF z)

Parameters

z ComplexF

The complex number.

Returns

float

The magnitude of z.

AbsSqr(ComplexF)

Returns the squared magnitude of the specified complex number.

public static float AbsSqr(ComplexF z)

Parameters

z ComplexF

The complex number.

Returns

float

The squared magnitude of z.

Approximately(ComplexF, ComplexF, float)

Returns whether two complex numbers are within the specified tolerance.

public static bool Approximately(ComplexF a, ComplexF b, float tolerance = 1E-05)

Parameters

a ComplexF

The first complex number.

b ComplexF

The second complex number.

tolerance float

The maximum allowed distance between the two values.

Returns

bool

true if the magnitude of a - b is less than or equal to tolerance, otherwise false.

Exceptions

ArgumentOutOfRangeException

Thrown if tolerance is less or equal to zero.

Arg(ComplexF)

Returns the argument of the specified complex number.

public static float Arg(ComplexF z)

Parameters

z ComplexF

The complex number.

Returns

float

The phase angle of z, in radians.

Cis(float)

Returns cos(angle) + i sin(angle).

public static ComplexF Cis(float angle)

Parameters

angle float

The angle, in radians.

Returns

ComplexF

A complex number on the unit circle with the specified argument.

Clamp(ComplexF, ComplexF, ComplexF)

Clamps the given value component-wise between the given minimum and maximum values.

public static ComplexF Clamp(ComplexF value, ComplexF min, ComplexF max)

Parameters

value ComplexF

The complex value to clamp.

min ComplexF

The minimum component values.

max ComplexF

The maximum component values.

Returns

ComplexF

The component-wise clamped complex value.

Clamp01(ComplexF)

Clamps the value component-wise between 0 and 1.

public static ComplexF Clamp01(ComplexF value)

Parameters

value ComplexF

The complex value to clamp.

Returns

ComplexF

The component-wise clamped complex value.

Cos(ComplexF)

Returns the cosine of the specified complex number.

public static ComplexF Cos(ComplexF z)

Parameters

z ComplexF

The complex number.

Returns

ComplexF

The cosine of z.

Exp(ComplexF)

Returns e raised to the specified complex power.

public static ComplexF Exp(ComplexF z)

Parameters

z ComplexF

The complex exponent.

Returns

ComplexF

The value of e raised to z.

FromPolar(float, float)

Returns a complex number based on its polar form.

public static ComplexF FromPolar(float radius, float angle)

Parameters

radius float

The distance from the origin.

angle float

The phase angle, in radians.

Returns

ComplexF

The complex number represented by the specified polar coordinates.

Lerp(ComplexF, ComplexF, float)

Linearly interpolates component-wise between two complex numbers.

public static ComplexF Lerp(ComplexF a, ComplexF b, float t)

Parameters

a ComplexF

The start value.

b ComplexF

The end value.

t float

The interpolation factor.

Returns

ComplexF

The component-wise interpolated complex value.

Remarks

The interpolation factor t is clamped to the range [0, 1].

LerpUnclamped(ComplexF, ComplexF, float)

Linearly interpolates component-wise between two complex numbers without clamping the interpolation factor.

public static ComplexF LerpUnclamped(ComplexF a, ComplexF b, float t)

Parameters

a ComplexF

The start value.

b ComplexF

The end value.

t float

The interpolation factor.

Returns

ComplexF

The component-wise interpolated complex value.

Ln(ComplexF)

Returns the natural logarithm of the specified complex number.

public static ComplexF Ln(ComplexF z)

Parameters

z ComplexF

The complex number.

Returns

ComplexF

The principal natural logarithm of z.

Remarks

Returns the principal value of the complex logarithm.

Log(ComplexF, ComplexF)

Returns the logarithm of a specified complex value in a specified base.

public static ComplexF Log(ComplexF value, ComplexF baseValue)

Parameters

value ComplexF

The complex value whose logarithm is calculated.

baseValue ComplexF

The base of the logarithm.

Returns

ComplexF

The logarithm of value in base baseValue.

Remarks

Equivalent to Ln(value) / Ln(baseValue). Uses the principal value of the complex logarithm.

Pow(ComplexF, ComplexF)

Returns the result of raising a complex number to a complex power.

public static ComplexF Pow(ComplexF baseValue, ComplexF exponent)

Parameters

baseValue ComplexF

The base value.

exponent ComplexF

The exponent.

Returns

ComplexF

The result of the exponentiation operation.

Remarks

Uses the principal value of the complex logarithm.

Sin(ComplexF)

Returns the sine of the specified complex number.

public static ComplexF Sin(ComplexF z)

Parameters

z ComplexF

The complex number.

Returns

ComplexF

The sine of z.

Sqrt(ComplexF)

Returns the principal square root of the specified complex number.

public static ComplexF Sqrt(ComplexF z)

Parameters

z ComplexF

The complex number.

Returns

ComplexF

The principal value whose square is equal to z.

Tan(ComplexF)

Returns the tangent of the specified complex number.

public static ComplexF Tan(ComplexF z)

Parameters

z ComplexF

The complex number.

Returns

ComplexF

The tangent of z.

Remarks

If the cosine of z has zero components returns NaN.

ToPolar(ComplexF)

Returns the polar representation of a complex number.

public static (float radius, float angle) ToPolar(ComplexF z)

Parameters

z ComplexF

The complex number.

Returns

(float radius, float angle)

A tuple containing the magnitude and phase angle, in radians.