norm - C complex.h

C examples for complex.h:norm

type

function template

From


<complex>
<complex.h>

Prototype


template<class T> T norm (const complex<T>& x);
double norm (ArithmeticType x);  // additional overloads

Description

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.

Parameters

Parameter Description
x Complex value.

Return value

Norm value of x.

Demo Code


#include <iostream>
#include <complex>

int main ()/*from   w w w .j av  a  2  s.  com*/
{
  std::complex<double> mycomplex (3.0,4.0);

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

  return 0;
}

Related Tutorials