C++ Complex Library - Norm



Description

It is a norm of complex and 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).

Declaration

Following is the declaration for std::norm.

template<class T> T norm (const complex<T>& x);

C++11

	
template<class T> T norm (const complex<T>& x);

Parameters

x It is a complex value.

Return Value

It returns the norm value of the complex number x.

Exceptions

none

Example

In below example for std::norm.

#include <iostream>     
#include <complex>      

int main () {
   std::complex<double> mycomplex (1.0,5.0);
   std::cout << "The norm of " << mycomplex << " is " << std::norm(mycomplex)
      << '\n';
   return 0;
}

The sample output should be like this −

The norm of (1,5) is 26
complex.htm
Advertisements