sqAbs

  1. T sqAbs(Complex!T z)
    @safe pure nothrow @nogc
    T
    sqAbs
    (
    T
    )
  2. T sqAbs(T x)

Parameters

z Complex!T

A complex number.

Return Value

Type: T

The squared modulus of z. For genericity, if called on a real number, returns its square.

Examples

import std.math.operations : isClose;
assert(sqAbs(complex(0.0)) == 0.0);
assert(sqAbs(complex(1.0)) == 1.0);
assert(sqAbs(complex(0.0, 1.0)) == 1.0);
assert(isClose(sqAbs(complex(1.0L, -2.0L)), 5.0L));
assert(isClose(sqAbs(complex(-3.0L, 1.0L)), 10.0L));
assert(isClose(sqAbs(complex(1.0f,-1.0f)), 2.0f));

Meta