mod

constexpr double mod(const Complex &z) noexcept

Returns the magnitude [1] of a complex number \(z\).

Parameters

const Complex &z

A complex number.

Returns

type Complex

A complex number.

The mod, or magnitude of a complex number, is defined as follows:

\[|z| = \sqrt{x^2 + y^2}\]

for \(\Re(z) = x\) and \(\Im(z) = y\).

Example

Complex z = 3 + 4_j;
std::cout << mod(z) << "\n";

Output:

5

References