Skip to content
FutureBlitz

    Install

    Import std.math.big.complex

    std.math.big.complex

    Complex: a complex number, Real + Imaginary times i, as two Doubles, and worked out as Python's cmath does: Arg is from -pi to pi, and Log, Sqrt, and Pow give the principal value, scaled near the largest Doubles and among the subnormals as cmath scales them, with C99's values at infinities. Like a Double's, its arithmetic never panics, and what has no value, like dividing by 0, has NaN parts. A Double on either side of an operator works too.

    std/math/big/complex.fb

    Types

    Complex struct

    Public Struct Complex Implements Equatable, Hashable, Printable, Numeric, Defaultable

    A complex number, of a real and an imaginary part, each a Double.

    std/math/big/complex.fb, line 32

    • Public ReadOnly Field Real: Double field #

      Its real part.

    • Public ReadOnly Field Imaginary: Double field #

      Its imaginary part.

    • Public Static Method Zero(): Complex static method #

      The number that adding leaves alone: 0.

      Doc from std.core.interfaces.Numeric.Zero.

    • Public Static Method One(): Complex static method #

      The number that multiplying leaves alone: 1.

      Doc from std.core.interfaces.Numeric.One.

    • Public Static Method DefaultValue(): Complex static method #

      The value to start from, like 0 for a number, "" for a String, or an empty collection.

      Doc from std.core.interfaces.Defaultable.DefaultValue.

    • Public Static Method FromPolar(magnitude: Double, angle: Double): Complex static method #

      The number of the magnitude, at the angle in radians from the positive real axis, as cmath.rect gives it: an angle of 0 has a Real part of the magnitude, even an infinite one.

    • Public Method ToString(): String method #

      "1+2i", "0-1.5i", or "-3+0i", the Imaginary part's sign always shown.

    • Public Method Abs(): Double method #

      Its distance from 0.

    • Public Method Arg(): Double method #

      Its angle from the positive real axis, from -pi to pi.

    • Public Method Conjugate(): Complex method #

      The same number with its imaginary part negated.

    • Public Method Exp(): Complex method #

      e to its power. A real number's is real, and one that a Double holds isn't infinite on the way, as e to past 709 would be.

    • Public Method Log(): Complex method #

      Its natural logarithm: the log of its magnitude, and its Arg. Near a magnitude of 1, the log comes from log1p, which keeps the digits that log would lose; past a quarter of the largest Double, from half of it; and among the subnormals, from it scaled up by 2^53.

    • Public Method Sqrt(): Complex method #

      Its square root with a Real part 0 or more, and the Imaginary part's sign, scaled as cmath scales it, so the largest and the subnormal numbers keep their digits.

    • Public Method Pow(exponent: Complex): Complex method #

      It to the power: anything to 0 is 1, and 0 to a power with a Real part above 0 and no Imaginary part is 0, but to any other power has NaN parts.

    • Operator ==(a: Complex, b: Complex): Bool operator #

      Whether a and b are equal.

      Doc from std.core.interfaces.Equatable.Operator==.

    • Operator ==(a: Complex, b: Double): Bool operator #

      Whether a and b are equal.

    • Operator ==(a: Double, b: Complex): Bool operator #

      Whether a and b are equal.

    • Public Method Hash(): UInt64 method #

      Its hash, the same for values that are equal.

      Doc from std.core.interfaces.Hashable.Hash.

    • Operator +(a: Complex, b: Complex): Complex operator #

      a and b added up.

      Doc from std.core.interfaces.Numeric.Operator+.

    • Operator +(a: Complex, b: Double): Complex operator #

      a plus b.

    • Operator +(a: Double, b: Complex): Complex operator #

      a plus b.

    • Operator -(a: Complex, b: Complex): Complex operator #

      b taken away from a.

      Doc from std.core.interfaces.Numeric.Operator-.

    • Operator -(a: Complex, b: Double): Complex operator #

      a minus b.

    • Operator -(a: Double, b: Complex): Complex operator #

      a minus b.

    • Operator *(a: Complex, b: Complex): Complex operator #

      a and b multiplied together.

      Doc from std.core.interfaces.Numeric.Operator*.

    • Operator *(a: Complex, b: Double): Complex operator #

      a times b.

    • Operator *(a: Double, b: Complex): Complex operator #

      a times b.

    • Operator /(a: Complex, b: Complex): Complex operator #

      Smith's division, which scales by the larger part of b, so no product overflows on the way.

    • Operator /(a: Complex, b: Double): Complex operator #

      a divided by b.

    • Operator /(a: Double, b: Complex): Complex operator #

      a divided by b.

    • Operator **(a: Complex, b: Int64): Complex operator #

      To a whole power, by squaring, which can be below 0.

    • Operator -(a: Complex): Complex operator #

      a negated.

    Report an issue with this page or with FutureBlitz on GitHub.