std.complex
This module contains the Complex type, which is used to represent complex numbers, along with related mathematical operations and functions.
Complex will eventuallydeprecate, Deprecated Features, replace the built-in types cfloat, cdouble, creal, ifloat, idouble, and ireal.
Types 1
structComplex(T) if (isFloatingPoint!T)
A complex number parametrised by a type T, which must be either float, double or real.
Fields
T reThe real part of the number.T imThe imaginary part of the number.Methods
void toString(Writer, Char)(scope Writer w, scope const ref FormatSpec!Char formatSpec) if (isOutputRange!(Writer, const(Char)[])) constdittoComplex!(CommonType!(T, R)) opBinaryRight(string op, R)(const R r) if ((op == "+" || op == "*") && (isNumeric!R)) constComplex!(CommonType!(T, R)) opBinaryRight(string op, R)(const R r) if (op == "-" && isNumeric!R) constComplex!(CommonType!(T, R)) opBinaryRight(string op, R)(const R r) if (op == "/" && isNumeric!R) constComplex!(CommonType!(T, R)) opBinaryRight(string op, R)(const R lhs) if (op == "^^" && isNumeric!R) constComplex opOpAssign(string op, C)(const C z) if ((op == "+" || op == "-") && is(C R == Complex!R)) refComplex opOpAssign(string op, C)(const C z) if (op == "*" && is(C R == Complex!R)) refComplex opOpAssign(string op, C)(const C z) if (op == "/" && is(C R == Complex!R)) refComplex opOpAssign(string op, C)(const C z) if (op == "^^" && is(C R == Complex!R)) refComplex opOpAssign(string op, U : T)(const U a) if (op == "+" || op == "-") refComplex opOpAssign(string op, U : T)(const U a) if (op == "*" || op == "/") refComplex opOpAssign(string op, R)(const R r) if (op == "^^" && isFloatingPoint!R) refComplex opOpAssign(string op, U)(const U i) if (op == "^^" && isIntegral!U) refauto toNative()Returns a complex number instance that correponds in size and in ABI to the associated C compiler's `Complex` type.Functions 32
fn
auto complex(R)(const R re) if (is(R : double)) @safe pure nothrow @nogcHelper function that returns a complex number with the specified real and imaginary parts.fn
auto complex(R, I)(const R re, const I im) if (is(R : double) && is(I : double)) @safe pure nothrow @nogcdittofn
T abs(T)(Complex!T z) @safe pure nothrow @nogcCalculates the absolute value (or modulus) of a complex number.fn
T sqAbs(T)(Complex!T z) @safe pure nothrow @nogcParams: z = A complex number. x = A real number. Returns: The squared modulus of `z`. For genericity, if called on a real number, returns its square.fn
T arg(T)(Complex!T z) @safe pure nothrow @nogcParams: z = A complex number. Returns: The argument (or phase) of `z`.fn
T norm(T)(Complex!T z) @safe pure nothrow @nogcExtracts the norm of a complex number. Params: z = A complex number Returns: The squared magnitude of `z`.fn
Complex!T conj(T)(Complex!T z) @safe pure nothrow @nogcParams: z = A complex number. Returns: The complex conjugate of `z`.fn
Complex!T proj(T)(Complex!T z)Returns the projection of `z` onto the Riemann sphere. Params: z = A complex number Returns: The projection of `z` onto the Riemann sphere.fn
Complex!(CommonType!(T, U)) fromPolar(T, U)(const T modulus, const U argument) @safe pure nothrow @nogcConstructs a complex number given its absolute value and argument. Params: modulus = The modulus argument = The argument Returns: The complex number with the given modulus and argument.fn
Complex!T asin(T)(Complex!T z) @safe pure nothrow @nogcInverse trigonometric functions on complex numbers.fn
Complex!T sinh(T)(Complex!T z) @safe pure nothrow @nogcHyperbolic trigonometric functions on complex numbers.fn
Complex!T asinh(T)(Complex!T z) @safe pure nothrow @nogcInverse hyperbolic trigonometric functions on complex numbers.fn
Complex!real expi(real y) @trusted pure nothrow @nogcParams: y = A real number. Returns: The value of cos(y) + i sin(y).fn
Complex!real coshisinh(real y) @safe pure nothrow @nogcParams: y = A real number. Returns: The value of cosh(y) + i sinh(y)fn
Complex!T sqrt(T)(Complex!T z) @safe pure nothrow @nogcParams: z = A complex number. Returns: The square root of `z`.fn
Complex!T exp(T)(Complex!T x) @trusted pure nothrow @nogcCalculates ex. Params: x = A complex number Returns: The complex base e exponential of `x`fn
Complex!T log(T)(Complex!T x) @safe pure nothrow @nogcCalculate the natural logarithm of x. The branch cut is along the negative axis. Params: x = A complex number Returns: The complex natural logarithm of `x`fn
Complex!T log10(T)(Complex!T x) @safe pure nothrow @nogcCalculate the base-10 logarithm of x. Params: x = A complex number Returns: The complex base 10 logarithm of `x`