Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

complex


Complex Number Library

Summary

C++ complex number library

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Specializations

complex <float>
complex <double>
complex <long double>

Synopsis

#include <complex>
template <class T>
class complex;
class complex<float>;
class complex<double>;
class complex<long double>;

Description

complex<T> 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());
template <class X> complex
(const complex<X>&);

Assignment 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); 
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;

Non-member 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);

Non-member 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

Program Output

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 non-converting constructors permit unsafe downcasts (for example, long double to double, double to float, long double to float).

If your compiler does not support namespaces, then you do not need the using declaration for std.



Previous fileTop of documentContentsIndexNext file
©Copyright 1998, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.
OEM Release, June 1998