Namespaces
Variants
Views
Actions

std::norm(std::complex)

From cppreference.com
< cpp‎ | numeric‎ | complex
Revision as of 08:29, 7 December 2017 by Cubbi (Talk | contribs)

 
 
 
 
Defined in header <complex>
(1)
template< class T >
T norm( const complex<T>& z );
(until C++20)
template< class T >
constexpr T norm( const 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

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) [edit]
returns the complex conjugate
(function template) [edit]
constructs a complex number from magnitude and phase angle
(function template) [edit]