function template
<complex>

std::norm

complex (1)
template<class T> T norm (const complex<T>& x);
complex (1)
template<class T> T norm (const complex<T>& x);
arithmetic type (2)
double norm (ArithmeticType x);  // additional overloads
Norm of complex
Returns the norm value of the complex number x.

The norm value of a complex number is its squared magnitude, defined as the addition of the square of both its real and its imaginary part (without the imaginary unit). This is the square of abs(x).

Only available for instantiations of complex.
附加過載為任何 基本算術型別 提供:在這種情況下,函式假定該值為零 虛部
The return type is double, except if the argument is float or long double (in which case, the return type is of the same type as the argument).

引數

x
Complex value.

返回值

Norm value of x.
Tcomplex 型別的分量型別(即其值型別)。

示例

1
2
3
4
5
6
7
8
9
10
11
12
// norm example
#include <iostream>     // std::cout
#include <complex>      // std::complex, std::norm

int main ()
{
  std::complex<double> mycomplex (3.0,4.0);

  std::cout << "The norm of " << mycomplex << " is " << std::norm(mycomplex) << '\n';

  return 0;
}

輸出

The norm of (3,4) is 25


另見