<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
1 2 3 4 5 6 7 8 9 10 11 12 13
|
// norm example
#include <iostream>
#include <complex>
using namespace std;
int main ()
{
complex<double> mycomplex (3.0,4.0);
cout << "The norm of " << mycomplex << " is " << norm(mycomplex) << endl;
return 0;
}
|
Output:
See also
abs | Return absolute value of complex (function template) |
complex | Return complex power (function template) |
|