The OpenD Programming Language

norm

Extracts the norm of a complex number.

@safe pure nothrow @nogc
T
norm
(
T
)

Parameters

z Complex!T

A complex number

Return Value

Type: T

The squared magnitude of z.

Examples

import std.math.operations : isClose;
import std.math.constants : PI;
assert(norm(complex(3.0, 4.0)) == 25.0);
assert(norm(fromPolar(5.0, 0.0)) == 25.0);
assert(isClose(norm(fromPolar(5.0L, PI / 6)), 25.0L));
assert(isClose(norm(fromPolar(5.0L, 13 * PI / 6)), 25.0L));

Meta