A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/complex/norm/ below:

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

.


Additional overloads

are provided for arguments of any

fundamental arithmetic type

: In this case, the function assumes the value has a zero

imaginary

component.

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).



Parameters
x
Complex value.

Return value Norm value of x.
T is the type of the components of the complex type (i.e., its value type).

Example
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;
}

Output:


See also
abs
Absolute value of complex (function template)
pow
Power of complex (function template)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4