C++ Standard Library C++ STL Library

C++ - <complex>



The C++ has <complex> library which implements the complex class to contain complex numbers in Cartesian form and several functions and overloads to operate with them. The library can be included in the current program by using - #include <complex>.

C++ <complex> - Member Functions

The C++ complex has a number of member functions which are listed below:

FunctionsDescription
real() Accesses the real part of a complex number.
imag() Accesses the imaginary part of a complex number.

Operators

FunctionsDescription
operator= assignment operator of two complex numbers or a complex and a scalar.
operator+= plus AND assignment operator of two complex numbers or a complex and a scalar.
operator-= minus AND assignment operator of two complex numbers or a complex and a scalar.
operator*= multiply AND assignment operator of two complex numbers or a complex and a scalar.
operator/= divide AND assignment operator of two complex numbers or a complex and a scalar.

C++ <complex> - Non-member Functions

Complex values Functions

FunctionsDescription
arg() Returns the phase angle of a complex number.
norm() Returns the squared magnitude of a complex number.
conj() Returns the complex conjugate of a complex number.
polar() Returns a complex number with specified magnitude and phase angle.
proj() Returns the projection onto the Riemann sphere of a complex number.
real() Returns the real part of a complex number.
imag() Returns the imaginary part of a complex number.

Trigonometric Functions

FunctionsDescription
sin() Returns the complex sine of a complex number.
cos() Returns the complex cosine of a complex number.
tan() Returns the complex tangent of a complex number.
asin() Returns the complex arc sine of a complex number.
acos() Returns the complex arc cosine of a complex number.
atan() Returns the complex arc tangent of a complex number.

Hyperbolic Functions

FunctionsDescription
sinh() Returns the complex hyperbolic sine of a complex number.
cosh() Returns the complex hyperbolic cosine of a complex number.
tanh() Returns the complex hyperbolic tangent of a complex number.
asinh() Returns the complex inverse hyperbolic sine of a complex number.
acosh() Returns the complex inverse hyperbolic cosine of a complex number.
atanh() Returns the complex inverse hyperbolic tangent of a complex number.

Operators

FunctionsDescription
operator+ Applies unary plus operator to a complex number.
operator- Applies unary minus operator to a complex number.
operator+ Applies binary plus operator to two complex numbers or a complex and a scalar.
operator- Applies binary plus operator to two complex numbers or a complex and a scalar.
operator* Applies binary plus operator to two complex numbers or a complex and a scalar.
operator/ Applies binary plus operator to two complex numbers or a complex and a scalar.
operator== compares two complex numbers or a complex and a scalar.
operator!= compares two complex numbers or a complex and a scalar.
operator<< Write a complex number to output stream in the form (real,imaginary).
operator>> Reads a complex number from input stream.

Other Functions

FunctionsDescription
abs() Returns the absolute value of a complex number.
exp() Returns base-e exponential of a complex number.
log() Returns natural logarithm of a complex number.
log10() Returns base-10 logarithm of a complex number.
pow() Returns power of a complex number.
sqrt() Returns square root of a complex number.