当前头文件是数值库(Numeric library)中的 复数(Complex)相关 主题中的部分内容。

数值库(参考手册) ​数值库(标准)

  • complex 浮点数类型
    complex<float> complexfloat 类型的特例化
    complex<double> complexdouble 类型的特例化
    complex<long double> complexlong double 类型的特例化
  • 值相关函数

    std::real 返回复数的实部(Real part)
    std::imag 返回复数的虚部(Imaginary)
    std::abs(std::complex) 返回复数的模
    std::arg 返回复数的相角(Phase angle)
    std::norm 返回复数的模的平方
    std::conj 返回复数的共轭复数(或复共轭)
    std::proj C++11 返回复数在黎曼球面(Riemann sphere)上的投影(Projection)(该投影也是一个复数)
    std::polar 提供一对表示复数幅度和角度的极坐标,并返回对应的复数

    超越函数重载

    std::cos(std::complex) 返回复数的余弦(Cosine)值
    std::cosh(std::complex) 返回复数的双曲余弦(Hyperbolic cosine)
    std::exp(std::complex) 返回以 e (欧拉常数)为底,以复数参数为幂的指数函数的值(该值也是一个复数)
    std::log(std::complex) 返回复数的自然对数
    std::log10(std::complex) 返回复数的常用对数
    std::pow(std::complex) 复数的幂运算
    std::sin(std::complex) 返回复数的正弦(Sine)值
    std::sinh(std::complex) 返回复数的双曲正弦(Hyperbolic sine)值
    std::sqrt(std::complex) 返回复数的平方根(Square root)
    std::tan(std::complex) 返回复数的正切(Tangent)值
    std::tanh(std::complex) 返回复数的双曲正切(Hyperbolic tangent)值
    std::asin(std::complex) C++11 返回复数的反正弦(Arc sine)值
    std::acos(std::complex) C++11 返回复数的反余弦(Arc cosine)
    std::atan(std::complex) C++11 返回复数的反正切(Arc tangent)值
    std::asinh(std::complex) C++11 返回复数的双曲反正弦(Hyperbolic arc sine)值
    std::acosh(std::complex) C++11 返回复数的双曲反余弦(Hyperbolic arc cosine)值
    std::atanh(std::complex) C++11 返回复数的双曲反正切(Hyperbolic arc tangent)值

    全局操作符重载

    operator+
    operator-
    operator+
    operator-
    operator*
    operator/
    operator==
    operator!=
    operator<<
    operator>>
    复数操作符
  • 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>&);
     
     
    }
  • 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>&);   
     
    };
  • 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>&);
     
    };