Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
Miscellaneous
complex
exception
functional
iterator
limits
locale
memory
new
numeric
stdexcept
typeinfo
utility
valarray
complex
abs
arg
complex
conj
cos
cosh
exp
imag
log
log10
norm
polar
pow
real
sin
sinh
sqrt
tan
tanh


imag

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

Return imaginary part of complex

Returns the imaginary part of the complex number x.
The imaginary part is the factor by which the imaginary unit is multiplied.

The function simply calls x's member function imag.

Parameters

x
Complex value.


Return value

Imaginary part 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
// complex::imag example
#include <iostream>
#include <complex>
using namespace std;
int main ()
{
  complex<double> mycomplex (20.0,2.0);
  cout << "Imaginary part: " << imag(mycomplex) << endl;
  return 0;
} 


Output:

Imaginary part: 2

See also