W3cubDocs

/C++

std::norm(std::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)

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

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

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/numeric/complex/norm