Namespaces
Variants
Views
Actions

Standard library header <complex>

From cppreference.com
< cpp‎ | header
Revision as of 05:25, 10 January 2013 by Bazzy (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This header is part of the numeric library.

Contents

Classes

a complex number type
(class template)
a complex number type
(class template specialization)

Functions

Template:cpp/numeric/complex/dcl list operator arith2Template:cpp/numeric/complex/dcl list operator arith3Template:cpp/numeric/complex/dcl list operator cmpTemplate:cpp/numeric/complex/dcl list operator ltltgtgtTemplate:cpp/numeric/complex/dcl list real2Template:cpp/numeric/complex/dcl list imag2Template:cpp/numeric/complex/dcl list absTemplate:cpp/numeric/complex/dcl list argTemplate:cpp/numeric/complex/dcl list normTemplate:cpp/numeric/complex/dcl list conjTemplate:cpp/numeric/complex/dcl list projTemplate:cpp/numeric/complex/dcl list polarTemplate:cpp/numeric/complex/dcl list expTemplate:cpp/numeric/complex/dcl list logTemplate:cpp/numeric/complex/dcl list log10Template:cpp/numeric/complex/dcl list powTemplate:cpp/numeric/complex/dcl list sqrtTemplate:cpp/numeric/complex/dcl list sinTemplate:cpp/numeric/complex/dcl list cosTemplate:cpp/numeric/complex/dcl list tanTemplate:cpp/numeric/complex/dcl list asinTemplate:cpp/numeric/complex/dcl list acosTemplate:cpp/numeric/complex/dcl list atanTemplate:cpp/numeric/complex/dcl list sinhTemplate:cpp/numeric/complex/dcl list coshTemplate:cpp/numeric/complex/dcl list tanhTemplate:cpp/numeric/complex/dcl list asinhTemplate:cpp/numeric/complex/dcl list acoshTemplate:cpp/numeric/complex/dcl list atanh
Operations
Exponential functions
Power functions
Trigonometric functions
Hyperbolic functions


Synopsis

namespace std {
 
    template<class T> class complex;
 
    template<> class complex<float>;
    template<> class complex<double>;
    template<> class complex<long double>;
 
    // operators:
    template<class T>
    complex<T> operator+(const complex<T>&, const complex<T>&);
    template<class T> complex<T> operator+(const complex<T>&, const T&);
    template<class T> complex<T> operator+(const T&, const complex<T>&);
 
    template<class T> complex<T> operator-(
        const complex<T>&, const complex<T>&);
    template<class T> complex<T> operator-(const complex<T>&, const T&);
    template<class T> complex<T> operator-(const T&, const complex<T>&);
 
    template<class T> complex<T> operator*(
        const complex<T>&, const complex<T>&);
    template<class T> complex<T> operator*(const complex<T>&, const T&);
    template<class T> complex<T> operator*(const T&, const complex<T>&);
 
    template<class T> complex<T> operator/(
        const complex<T>&, const complex<T>&);
    template<class T> complex<T> operator/(const complex<T>&, const T&);
    template<class T> complex<T> operator/(const T&, const complex<T>&);
 
    template<class T> complex<T> operator+(const complex<T>&);
    template<class T> complex<T> operator-(const complex<T>&);
 
    template<class T> bool operator==(
        const complex<T>&, const complex<T>&);
    template<class T> bool operator==(const complex<T>&, const T&);
    template<class T> bool operator==(const T&, const complex<T>&);
 
    template<class T> bool operator!=(const complex<T>&, const complex<T>&);
    template<class T> bool operator!=(const complex<T>&, const T&);
    template<class T> bool operator!=(const T&, const complex<T>&);
 
    template<class T, class charT, class traits>
    basic_istream<charT, traits>&
    operator>>(basic_istream<charT, traits>&, complex<T>&);
 
    template<class T, class charT, class traits>
    basic_ostream<charT, traits>&
    operator<<(basic_ostream<charT, traits>&, const complex<T>&);
 
    // values:
    template<class T> T real(const complex<T>&);
    template<class T> T imag(const complex<T>&);
 
    template<class T> T abs(const complex<T>&);
    template<class T> T arg(const complex<T>&);
    template<class T> T norm(const complex<T>&);
 
    template<class T> complex<T> conj(const complex<T>&);
    template <class T> complex<T> proj(const complex<T>&);
    template<class T> complex<T> polar(const T&, const T& = 0);
 
    // transcendentals:
    template<class T> complex<T> acos(const complex<T>&);
    template<class T> complex<T> asin(const complex<T>&);
    template<class T> complex<T> atan(const complex<T>&);
 
    template<class T> complex<T> acosh(const complex<T>&);
    template<class T> complex<T> asinh(const complex<T>&);
    template<class T> complex<T> atanh(const complex<T>&);
 
    template<class T> complex<T> cos  (const complex<T>&);
    template<class T> complex<T> cosh (const complex<T>&);
    template<class T> complex<T> exp  (const complex<T>&);
    template<class T> complex<T> log  (const complex<T>&);
    template<class T> complex<T> log10(const complex<T>&);
 
    template<class T> complex<T> pow(const complex<T>&, const T&);
    template<class T> complex<T> pow(const complex<T>&, const complex<T>&);
    template<class T> complex<T> pow(const T&, const complex<T>&);
 
    template<class T> complex<T> sin    (const complex<T>&);
    template<class T> complex<T> sinh   (const complex<T>&);
    template<class T> complex<T> sqrt   (const complex<T>&);
    template<class T> complex<T> tan    (const complex<T>&);
    template<class T> complex<T> tanh   (const complex<T>&);
 
 
}


Class std::complex

template<class T>
class complex {
public:
    typedef T value_type;
    complex(const T& re = T(), const T& im = T());
    complex(const complex&);
    template<class X> complex(const complex<X>&);
 
    T real() const;
    void real(T);
    T imag() const;
    void imag(T);
 
    complex<T>& operator= (const T&);
    complex<T>& operator+=(const T&);
    complex<T>& operator-=(const T&);
    complex<T>& operator*=(const T&);
    complex<T>& operator/=(const T&);
 
    complex& operator=(const complex&);     
    template<class X> complex<T>& operator= (const complex<X>&);   
    template<class X> complex<T>& operator+=(const complex<X>&);   
    template<class X> complex<T>& operator-=(const complex<X>&);   
    template<class X> complex<T>& operator*=(const complex<X>&);   
    template<class X> complex<T>& operator/=(const complex<X>&);   
 
};

std::complex specializations

template<> class complex<float> {
public:
    typedef float value_type;
 
    constexpr complex(float re = 0.0f, float im = 0.0f);
    explicit constexpr complex(const complex<double>&);
    explicit constexpr complex(const complex<long double>&);
 
    constexpr float real();
    void real(float);
    constexpr float imag();
    void imag(float);
 
    complex<float>& operator= (float);
    complex<float>& operator+=(float);
    complex<float>& operator-=(float);
    complex<float>& operator*=(float);
    complex<float>& operator/=(float);
 
    complex<float>& operator=(const complex<float>&);
    template<class X> complex<float>& operator= (const complex<X>&);
    template<class X> complex<float>& operator+=(const complex<X>&);
    template<class X> complex<float>& operator-=(const complex<X>&);
    template<class X> complex<float>& operator*=(const complex<X>&);
    template<class X> complex<float>& operator/=(const complex<X>&);
};
 
template<> class complex<double> {
public:
    typedef double value_type;
 
    constexpr complex(double re = 0.0, double im = 0.0);
    constexpr complex(const complex<float>&);
    explicit constexpr complex(const complex<long double>&);
 
    constexpr double real();
    void real(double);
    constexpr double imag();
    void imag(double);
 
    complex<double>& operator= (double);
    complex<double>& operator+=(double);
    complex<double>& operator-=(double);
    complex<double>& operator*=(double);
    complex<double>& operator/=(double);
 
    complex<double>& operator=(const complex<double>&);
    template<class X> complex<double>& operator= (const complex<X>&);
    template<class X> complex<double>& operator+=(const complex<X>&);
    template<class X> complex<double>& operator-=(const complex<X>&);
    template<class X> complex<double>& operator*=(const complex<X>&);
    template<class X> complex<double>& operator/=(const complex<X>&);
};
 
template<> class complex<long double> {
public:
    typedef long double value_type;
 
    constexpr complex(long double re = 0.0L, long double im = 0.0L);
    constexpr complex(const complex<float>&);
    constexpr complex(const complex<double>&);
 
    constexpr long double real();
    void real(long double);
    constexpr long double imag();
    void imag(long double);
 
    complex<long double>& operator=(const complex<long double>&);
    complex<long double>& operator= (long double);
    complex<long double>& operator+=(long double);
    complex<long double>& operator-=(long double);
    complex<long double>& operator*=(long double);
    complex<long double>& operator/=(long double);
 
    template<class X> complex<long double>& operator= (const complex<X>&);
    template<class X> complex<long double>& operator+=(const complex<X>&);
    template<class X> complex<long double>& operator-=(const complex<X>&);
    template<class X> complex<long double>& operator*=(const complex<X>&);
    template<class X> complex<long double>& operator/=(const complex<X>&);
 
};