sqAbs

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

Parameters

x T

A real 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