Namespaces
Variants
Views
Actions

std::norm(std::complex)

From cppreference.com
< cpp‎ | numeric‎ | complex
Defined in header <complex>
(1)
template< class T >
T norm( const std::complex<T>& z );
(until C++20)
template< class T >
constexpr T norm( const std::complex<T>& z );
(since C++20)
(2)
float norm( float z );

template< class DoubleOrInteger >
double norm( DoubleOrInteger z );

long double norm( long double z );
(since C++11)
(until C++20)
constexpr float norm( float z );

template< class DoubleOrInteger >
constexpr double norm( DoubleOrInteger z );

constexpr long double norm( long double z );
(since C++20)
1) Returns the squared magnitude of the complex number z.
2) 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)

Contents

[edit] Parameters

z - complex value

[edit] Return value

the squared magnitude of z

[edit] 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).

[edit] See also

returns the magnitude of a complex number
(function template) [edit]
returns the complex conjugate
(function template) [edit]
constructs a complex number from magnitude and phase angle
(function template) [edit]