⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 std_complex.h

📁 c++编程宝典源码及Quincy99编译器 是《标准C++编程宝典》电子工业出版社的光盘
💻 H
📖 第 1 页 / 共 2 页
字号:
        __imag__ _M_value = 0.0f;        return *this;    }    inline complex<float>&    complex<float>::operator+= (float __f)    {        __real__ _M_value += __f;        return *this;    }    inline complex<float>&    complex<float>::operator-= (float __f)    {        __real__ _M_value -= __f;        return *this;    }    inline complex<float>&    complex<float>::operator*= (float __f)    {        _M_value *= __f;        return *this;    }    inline complex<float>&    complex<float>::operator/= (float __f)    {        _M_value /= __f;        return *this;    }    template<typename _Tp>    inline complex<float>&    complex<float>::operator= (const complex<_Tp>& __z)    {        __real__ _M_value = __z.real();        __imag__ _M_value = __z.imag();        return *this;    }    template<typename _Tp>    inline complex<float>&    complex<float>::operator+= (const complex<_Tp>& __z)    {        __real__ _M_value += __z.real();        __imag__ _M_value += __z.imag();        return *this;    }        template<typename _Tp>    inline complex<float>&    complex<float>::operator-= (const complex<_Tp>& __z)    {        __real__ _M_value -= __z.real();        __imag__ _M_value -= __z.real();        return *this;    }    template<typename _Tp>    inline complex<float>&    complex<float>::operator*= (const complex<_Tp>& __z)    {        _ComplexT __t;        __real__ __t = __z.real();        __imag__ __t = __z.imag();        _M_value *= __t;        return *this;    }    template<typename _Tp>    inline complex<float>&    complex<float>::operator/= (const complex<_Tp>& __z)    {        _ComplexT __t;        __real__ __t = __z.real();        __imag__ __t = __z.imag();        _M_value /= __t;        return *this;    }    //    // complex<double> continued.    //    inline    complex<double>::complex(double __r, double __i)    {        __real__ _M_value = __r;        __imag__ _M_value = __i;    }    inline    complex<double>::complex(const complex<float>& __z)            : _M_value(_ComplexT(__z._M_value)) {}    inline    complex<double>::complex(const complex<long double>& __z)    {        __real__ _M_value = __z.real();        __imag__ _M_value = __z.imag();    }    inline complex<double>&    complex<double>::operator= (double __d)    {        __real__ _M_value = __d;        __imag__ _M_value = 0.0;        return *this;    }    inline complex<double>&    complex<double>::operator+= (double __d)    {        __real__ _M_value += __d;        return *this;    }    inline complex<double>&    complex<double>::operator-= (double __d)    {        __real__ _M_value -= __d;        return *this;    }    inline complex<double>&    complex<double>::operator*= (double __d)    {        _M_value *= __d;        return *this;    }    inline complex<double>&    complex<double>::operator/= (double __d)    {        _M_value /= __d;        return *this;    }    template<typename _Tp>    inline complex<double>&    complex<double>::operator= (const complex<_Tp>& __z)    {        __real__ _M_value = __z.real();        __imag__ _M_value = __z.imag();        return *this;    }        template<typename _Tp>    inline complex<double>&    complex<double>::operator+= (const complex<_Tp>& __z)    {        __real__ _M_value += __z.real();        __imag__ _M_value += __z.imag();        return *this;    }    template<typename _Tp>    inline complex<double>&    complex<double>::operator-= (const complex<_Tp>& __z)    {        __real__ _M_value -= __z.real();        __imag__ _M_value -= __z.imag();        return *this;    }    template<typename _Tp>    inline complex<double>&    complex<double>::operator*= (const complex<_Tp>& __z)    {        _ComplexT __t;        __real__ __t = __z.real();        __imag__ __t = __z.imag();        _M_value *= __t;        return *this;    }    template<typename _Tp>    inline complex<double>&    complex<double>::operator/= (const complex<_Tp>& __z)    {        _ComplexT __t;        __real__ __t = __z.real();        __imag__ __t = __z.imag();        _M_value /= __t;        return *this;    }    //    // Primary template class complex continued.    //    // 26.2.4    template<typename _Tp>    inline     complex<_Tp>::complex(const _Tp& __r, const _Tp& __i)            : _M_real(__r), _M_imag(__i) {}    template<typename _Tp>       template<typename _Up>    inline     complex<_Tp>::complex(const complex<_Up>& __z)            : _M_real(__z.real()), _M_imag(__z.imag()) {}    // 26.2.7/6    template<typename _Tp>    inline complex<_Tp>    conj(const complex<_Tp>& __z)    { return complex<_Tp>(__z.real(), -__z.imag()); }    // 26.2.7/4    template<typename _Tp>    inline _Tp    norm(const complex<_Tp>& __z)    {        // XXX: Grammar school computation        return __z.real() * __z.real() + __z.imag() * __z.imag();    }            template<typename _Tp>    complex<_Tp>&    complex<_Tp>::operator= (const _Tp& __t)    {        _M_real = __t;        _M_imag = _Tp();        return *this;    }    // 26.2.5/1    template<typename _Tp>    inline complex<_Tp>&    complex<_Tp>::operator+= (const _Tp& __t)    {        _M_real += __t;        return *this;    }    // 26.2.5/3    template<typename _Tp>    inline complex<_Tp>&    complex<_Tp>::operator-= (const _Tp& __t)    {        _M_real -= __t;        return *this;    }    // 26.2.5/5    template<typename _Tp>    complex<_Tp>&    complex<_Tp>::operator*= (const _Tp& __t)    {        _M_real *= __t;        _M_imag *= __t;        return *this;    }    // 26.2.5/7    template<typename _Tp>    complex<_Tp>&    complex<_Tp>::operator/= (const _Tp& __t)    {        _M_real /= __t;        _M_imag /= __t;        return *this;    }    template<typename _Tp>       template<typename _Up>    complex<_Tp>&    complex<_Tp>::operator= (const complex<_Up>& __z)    {        _M_real = __z.real();        _M_imag = __z.imag();        return *this;    }    // 26.2.5/9    template<typename _Tp>       template<typename _Up>    complex<_Tp>&    complex<_Tp>::operator+= (const complex<_Up>& __z)    {        _M_real += __z.real();        _M_imag += __z.imag();        return *this;    }    // 26.2.5/11    template<typename _Tp>       template<typename _Up>    complex<_Tp>&    complex<_Tp>::operator-= (const complex<_Up>& __z)    {        _M_real -= __z.real();        _M_imag -= __z.imag();        return *this;    }    // 26.2.5/13    // XXX: this is a grammar school implementation.    template<typename _Tp>       template<typename _Up>    complex<_Tp>&    complex<_Tp>::operator*= (const complex<_Up>& __z)    {        _Tp __r = _M_real * __z.real() - _M_imag * __z.imag();        _M_imag = _M_real * __z.imag() + _M_imag * __z.real();        _M_real = __r;        return *this;    }    // 26.2.5/15    // XXX: this is a grammar school implementation.    template<typename _Tp>       template<typename _Up>    complex<_Tp>&    complex<_Tp>::operator/= (const complex<_Up>& __z)    {        _Tp __r =  _M_real * __z.real() + _M_imag * __z.imag();        _Tp __n = norm(__z);        _M_imag = (_M_real * __z.imag() - _M_imag * __z.real()) / __n;        _M_real = __r / __n;        return *this;    }        // Operators:    template<typename _Tp>    inline complex<_Tp>    operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)    { return complex<_Tp> (__x) += __y; }    template<typename _Tp>    inline complex<_Tp>    operator+(const complex<_Tp>& __x, const _Tp& __y)    { return complex<_Tp> (__x) += __y; }    template<typename _Tp>    inline complex<_Tp>    operator+(const _Tp& __x, const complex<_Tp>& __y)    { return complex<_Tp> (__y) += __x; }    template<typename _Tp>    inline complex<_Tp>    operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)    { return complex<_Tp> (__x) -= __y; }        template<typename _Tp>    inline complex<_Tp>    operator-(const complex<_Tp>& __x, const _Tp& __y)    { return complex<_Tp> (__x) -= __y; }    template<typename _Tp>    inline complex<_Tp>    operator-(const _Tp& __x, const complex<_Tp>& __y)    { return complex<_Tp> (__x) -= __y; }    template<typename _Tp>    inline complex<_Tp>    operator*(const complex<_Tp>& __x, const complex<_Tp>& __y)    { return complex<_Tp> (__x) *= __y; }    template<typename _Tp>    inline complex<_Tp>    operator*(const complex<_Tp>& __x, const _Tp& __y)    { return complex<_Tp> (__x) *= __y; }    template<typename _Tp>    inline complex<_Tp>    operator*(const _Tp& __x, const complex<_Tp>& __y)    { return complex<_Tp> (__y) *= __x; }    template<typename _Tp>    inline complex<_Tp>    operator/(const complex<_Tp>& __x, const complex<_Tp>& __y)    { return complex<_Tp> (__x) /= __y; }        template<typename _Tp>    inline complex<_Tp>    operator/(const complex<_Tp>& __x, const _Tp& __y)    { return complex<_Tp> (__x) /= __y; }    template<typename _Tp>    inline complex<_Tp>    operator/(const _Tp& __x, const complex<_Tp>& __y)    { return complex<_Tp> (__x) /= __y; }    template<typename _Tp>    inline complex<_Tp>    operator+(const complex<_Tp>& __x)    { return __x; }    template<typename _Tp>    inline complex<_Tp>    operator-(const complex<_Tp>& __x)    {  return complex<_Tp>(-__x.real(), -__x.imag()); }    template<typename _Tp>    inline bool    operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)    { return __x.real() == __y.real() && __x.imag == __y.imag(); }    template<typename _Tp>    inline bool    operator==(const complex<_Tp>& __x, const _Tp& __y)    { return __x.real() == __y && __x.imag() == 0; }    template<typename _Tp>    inline bool    operator==(const _Tp& __x, const complex<_Tp>& __y)    { return __x == __y.real() && 0 == __y.imag(); }    template<typename _Tp>    inline bool    operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y)    { return __x.real() != __y.real() || __x.imag() != __y.imag(); }    template<typename _Tp>    inline bool    operator!=(const complex<_Tp>& __x, const _Tp& __y)    {  return __x.real() != __y || __x.imag() != 0; }    template<typename _Tp>    inline bool    operator!=(const _Tp& __x, const complex<_Tp>& __y)    { return __x != __y.real() || 0 != __y.imag(); }    template<typename _Tp, typename _CharT, class _Traits>    basic_istream<_CharT, _Traits>&    operator>>(basic_istream<_CharT, _Traits>&, complex<_Tp>&);    template<typename _Tp, typename _CharT, class _Traits>    basic_ostream<_CharT, _Traits>&    operator<<(basic_ostream<_CharT, _Traits>&, const complex<_Tp>&);    // Values:    template <typename _Tp>    inline _Tp    real (const complex<_Tp>& __z)    { return __z.real(); }        template <typename _Tp>    inline _Tp    imag (const complex<_Tp>& __z)    { return __z.imag(); }        // We use here a few more specializations.    template<>    inline complex<float>    conj(const complex<float> &__x)#if defined (__CYGWIN__) || defined (__MINGW32__)    { complex<float> __f (~__x._M_value); return __f; }#else    { return complex<float>(~__x._M_value); }#endif    template<>    inline complex<double>    conj(const complex<double> &__x)    {  return complex<double> (~__x._M_value); }    template<>    inline complex<long double>    conj(const complex<long double> &__x)    {        return complex<long double> (~__x._M_value);    }} // namespace std#endif	/* _CPP_COMPLEX */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -