stdnormstdcomplex(3)
std::norm(std::complex) - std::norm(std::complex)
Synopsis
Defined in header<complex>
template <class T>
(until C++ 20)
T norm(const std::complex<T> &z);
template <class T>
(since C++ 20)
constexpr T norm(const std::complex<T> &z);
float norm(float z);
template <class DoubleOrInteger>
(1)(since C++ 11)
double norm(DoubleOrInteger z);
(until C++ 20)
long double norm(long double z);
(2)
constexpr float norm(float z);
template <class DoubleOrInteger>
(since C++ 20)
constexpr double norm(DoubleOrInteger z);
constexpr long double norm(long double z);- Returns the squared magnitude of the complex number z.
- Additional overloads are provided for float, double, long double, and all integer types, which are treated as complex numbers with zero imaginary component. (since C++11)
Parameters
z - complex value
Return value
the squared magnitude of z
Notes
The norm calculated by this function is also known as field_norm or absolute_square. The Euclidean norm of a complex number is provided by std::abs, which is more costly to compute. In some situations, it may be replaced by std::norm, for example, if abs(z1) > abs(z2) then norm(z1) > norm(z2).
See also