Previous fileTop of DocumentContentsIndex pageNext file
Apache C++ Standard Library Reference Guide

complex

Library:  Numerics


Does not inherit

Local Index

Members

Non-Members

Summary

Class that supports the complex numbers

Synopsis

#include <complex>

namespace std {
  template <class T>
  class complex;
  template<> class complex<float>;
  template<> class complex<double>;
  template<> class complex<long double>;
}

Specializations

namespace std {
template<> complex <float>
template<> complex <double>
template<> complex <long double>
}

Description

complex is a class that supports complex numbers. A complex number has a real part and an imaginary part. The complex class supports equality, comparison, and basic arithmetic operations. In addition, mathematical functions such as exponents, logarithms, powers, and square roots are also available.

Interface

Constructors

complex(const T& re_arg = T(), const T& im_arg = T());
complex(const complex&);
template <class X> 
complex(const complex<X>&);

Member Operators

complex<T>& 
operator=(const T& v); 
complex<T>& 
operator+=(const T& v); 
complex<T>& 
operator-=(const T& v); 
complex<T>& 
operator*=(const T& v); 
complex<T>& 
operator/=(const T& v); 
complex& 
operator=(const complex& c);
template <class X>
complex<T> 
operator=(const complex<X>& c);
template <class X>
complex<T> 
operator+=(const complex<X>& c);
template <class X>
complex<T> 
operator-=(const complex<X>& c);
template <class X>
complex<T> 
operator*=(const complex<X>& c);
template <class X>
complex<T>
operator/=(const complex<X>& c);

Member Functions

T 
imag() const;
T 
real() const;

Nonmember Operators

template<class T> complex<T>
operator+(const complex<T>& lhs,const complex<T>& rhs);
template<class T> complex<T>
operator+(const complex<T>& lhs, const T& rhs);
template<class T> complex<T>
operator+(const T& lhs, const complex<T>& rhs);
template<class T> complex<T>
operator-(const complex<T>& lhs,const complex<T>& rhs);
template<class T> complex<T>
operator-(const complex<T>& lhs, const T& rhs);
template<class T> complex<T>
operator-(const T& lhs, const complex<T>& rhs);
template<class T> complex<T>
operator*(const complex<T>& lhs,const complex<T>& rhs);
template<class T> complex<T>
operator*(const complex<T>& lhs, const T& rhs);
template<class T> complex<T>
operator* (const T& lhs, const complex<T>& rhs);
template<class T> complex<T>
operator/(const complex<T>& lhs,const complex<T>& rhs);
template<class T> complex<T>
operator/(const complex<T>& lhs, const T& rhs);
template<class T> complex<T>
operator/(const T& lhs, const complex<T>& rhs);
template<class T> complex<T>
operator+(const complex<T>& rhs);
template<class T> complex<T>
operator-(const complex<T>& lhs);
template<class T> bool
operator==(const complex<T>& x, const complex<T>& y);
template<class T> bool
operator==(const complex<T>& x, const T& y);
template<class T> bool
operator==(const T& x, const complex<T>& y);
template<class T> bool
operator!=(const complex<T>& x, const complex<T>& y);
template<class T> bool
operator!=(const complex<T>& x, const T& y);
template<class T> bool
operator!=(const T& x, const complex<T>& y);
template <class T, class charT, class traits>
          basic_istream<charT, traits>&
operator>>(basic_istream<charT, traits>& is, complex<T>& x);
template <class T, class charT, class traits>
          basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, 
           const complex<T>& x);

Nonmember Functions

template<class T> T 
abs(const complex<T>& c);
template<class T> T 
arg(const complex<T>& x);
template<class T> complex<T> 
conj(const complex<T>& c);
template<class T> complex<T> 
cos(const complex<T>& c);
template<class T> complex<T> 
cosh(const complex<T>& c);
template<class T> complex<T> 
exp(const complex<T>& x);
template<class T> T 
imag(const complex<T>& c) const;
template<class T> complex<T> 
log(const complex<T>& x);
template<class T> complex<T> 
log10(const complex<T>& x);
template<class T> T 
norm(const complex<T>& c);
template<class T> complex<T>
polar(const T& m, const T& a = 0);
template<class T> complex<T>
pow(const complex<T>& x, int y);
template<class T> complex<T>
pow(const complex<T>& x, const T& y);
template<class T> complex<T>
pow(const complex<T>& x, const complex<T>& y);
template<class T> complex<T>
pow(const T& x, const complex<T>& y);
template<class T> T 
real(const complex<T>& c);
template<class T> complex<T> 
sin(const complex<T>& c);
template<class T> complex<T> 
sinh(const complex<T>& c);
template<class T> complex<T> 
sqrt(const complex<T>& x);
template<class T> complex<T> 
tan(const complex<T>& x);
template<class T> complex<T> 
tanh(const complex<T>& x);

Example

Warnings

On compilers that don't support member function templates, the arithmetic operators do not work on any arbitrary type; they work only on float, double and long doubles. Also, you can perform binary arithmetic only on types that are the same.

Compilers that don't support nonconverting constructors permit unsafe downcasts; for example, long double to double, double to float, long double to float.

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, 26.6.2



Previous fileTop of DocumentContentsIndex pageNext file