math::complex
math::complex provides functions for working with complex floating-point numbers.
Index
Types
type c128 = (f64, f64);
type c64 = (f32, f32);
type complex = (c64 | c128);
Functions
fn absc128(z: c128) f64;
fn acosc128(z: c128) c128;
fn acoshc128(z: c128) c128;
fn addc128(a: c128, b: c128) c128;
fn addc64(a: c64, b: c64) c64;
fn argc128(z: c128) f64;
fn asinc128(z: c128) c128;
fn asinhc128(z: c128) c128;
fn atanc128(x: c128) c128;
fn atanhc128(x: c128) c128;
fn c128to64(z: c128) c64;
fn c64to128(z: c64) c128;
fn conjc128(z: c128) c128;
fn conjc64(z: c64) c64;
fn cosc128(z: c128) c128;
fn coshc128(z: c128) c128;
fn divc128(a: c128, b: c128) c128;
fn divc64(a: c64, b: c64) c64;
fn equal(a: complex, b: complex) bool;
fn equalc128(a: c128, b: c128) bool;
fn equalc64(a: c64, b: c64) bool;
fn expc128(z: c128) c128;
fn isinf(z: c128) bool;
fn isnan(z: c128) bool;
fn logc128(z: c128) c128;
fn mulc128(a: c128, b: c128) c128;
fn mulc64(a: c64, b: c64) c64;
fn negc128(z: c128) c128;
fn negc64(z: c64) c64;
fn polarc128(z: c128) (f64, f64);
fn powc128(a: c128, b: c128) c128;
fn projc128(z: c128) c128;
fn projc64(z: c64) c64;
fn rectc128(r: f64, theta: f64) c128;
fn sinc128(z: c128) c128;
fn sinhc128(z: c128) c128;
fn sqrtc128(z: c128) c128;
fn subc128(a: c128, b: c128) c128;
fn subc64(a: c64, b: c64) c64;
fn tanc128(x: c128) c128;
fn tanhc128(x: c128) c128;
Types
type c128
type c128 = (f64, f64);
A complex number containing a real component and an imaginary component, represented as two double-precision floating point numbers.
type c64
type c64 = (f32, f32);
A complex number containing a real component and an imaginary component, represented as two single-precision floating point numbers.
type complex
type complex = (c64 | c128);
A tagged union of all complex types.
Functions
fn absc128
fn absc128(z: c128) f64;
Takes the absolute value of a complex number.
fn acosc128
fn acosc128(z: c128) c128;
Returns the arccosine, in radians, of z.
fn acoshc128
fn acoshc128(z: c128) c128;
Returns the inverse hyperbolic cosine of z.
fn addc128
fn addc128(a: c128, b: c128) c128;
Adds two complex numbers.
fn addc64
fn addc64(a: c64, b: c64) c64;
Adds two complex numbers
fn argc128
fn argc128(z: c128) f64;
Gets the argument, or phase, of a complex number.
fn asinc128
fn asinc128(z: c128) c128;
Returns the arcsine, in radians, of z.
fn asinhc128
fn asinhc128(z: c128) c128;
Returns the inverse hyperbolic sine of z.
fn atanc128
fn atanc128(x: c128) c128;
Returns the inverse tangent of x.
fn atanhc128
fn atanhc128(x: c128) c128;
Returns the inverse hyperbolic tangent of x.
fn c128to64
fn c128to64(z: c128) c64;
Truncates a c128 to a c64. Precision may be lost.
fn c64to128
fn c64to128(z: c64) c128;
Converts a c64 to a c128.
fn conjc128
fn conjc128(z: c128) c128;
Takes the conjugate of a complex number by negating the imaginary component.
fn conjc64
fn conjc64(z: c64) c64;
Takes the conjugate of a complex number by negating the imaginary component.
fn cosc128
fn cosc128(z: c128) c128;
Returns the cosine of z, in radians.
fn coshc128
fn coshc128(z: c128) c128;
Returns the hyperbolic cosine of z.
fn divc128
fn divc128(a: c128, b: c128) c128;
Divides two complex numbers.
fn divc64
fn divc64(a: c64, b: c64) c64;
Divides two complex numbers.
fn equal
fn equal(a: complex, b: complex) bool;
Checks if two complex numbers are equal. Be sure to take floating point round-off errors into account.
fn equalc128
fn equalc128(a: c128, b: c128) bool;
Checks if two complex numbers are equal. Be sure to take floating point round-off errors into account.
fn equalc64
fn equalc64(a: c64, b: c64) bool;
Checks if two complex numbers are equal. Be sure to take floating point round-off errors into account.
fn expc128
fn expc128(z: c128) c128;
Returns math::E raised to the power of z.
fn isinf
fn isinf(z: c128) bool;
Returns true if the given complex number is infinite.
fn isnan
fn isnan(z: c128) bool;
Returns true if the given complex number is NaN -- that is -- either component is NaN and neither component is an infinity.
fn logc128
fn logc128(z: c128) c128;
Returns the natural logarithm of z.
fn mulc128
fn mulc128(a: c128, b: c128) c128;
Multiplies two complex numbers.
fn mulc64
fn mulc64(a: c64, b: c64) c64;
Multiplies two complex numbers.
fn negc128
fn negc128(z: c128) c128;
Negates z.
fn negc64
fn negc64(z: c64) c64;
Negates z.
fn polarc128
fn polarc128(z: c128) (f64, f64);
Returns the polar coordinates of z.
fn powc128
fn powc128(a: c128, b: c128) c128;
Returns a raised to the power of b.
fn projc128
fn projc128(z: c128) c128;
Projects z onto the surface of a Riemann Sphere. If z is finite, it projects to itself. If z is infinite, it projects to positive infinity on the real axis.
fn projc64
fn projc64(z: c64) c64;
Projects z onto the surface of a Riemann Sphere. If z is finite, it projects to itself. If z is infinite, it projects to positive infinity on the real axis.
fn rectc128
fn rectc128(r: f64, theta: f64) c128;
Creates a new c128 from the polar coordinates (r, theta).
fn sinc128
fn sinc128(z: c128) c128;
Returns the sine of z, in radians.
fn sinhc128
fn sinhc128(z: c128) c128;
Returns the hyperbolic sine of z.
fn sqrtc128
fn sqrtc128(z: c128) c128;
Returns the square root of z.
fn subc128
fn subc128(a: c128, b: c128) c128;
Subtracts two complex numbers.
fn subc64
fn subc64(a: c64, b: c64) c64;
Subtracts two complex numbers.
fn tanc128
fn tanc128(x: c128) c128;
Returns the tangent of x.
fn tanhc128
fn tanhc128(x: c128) c128;
Returns the hyperbolic tangent of x.