function template
std::norm
<complex>
template<class T> T norm (const complex<T>& x);
Return norm of complex number
Returns the norm value of the complex number
x.
The norm value of a complex number is the squared magnitude, defined as the addition of the square of both the real part and the imaginary part (without the imaginary unit). This is the square of abs (x).
Parameters
x Complex value.
Return value
Norm value of x.T is x's complex template type (i.e., its value type).
Example
| |
Output:
The norm of (3,4) is 25 |
测试结果:
本文介绍C++标准库中计算复数模长平方的方法std::norm,并通过示例展示其用法。模长平方即复数的实部与虚部平方和,等于复数的绝对值平方。
2592





