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

📄 complex

📁 realview22.rar
💻
📖 第 1 页 / 共 3 页
字号:
  inline complex<double>&
  complex<double>::operator+= (const complex<float>& __rhs) 
  {
    _C_re += __rhs.real(); _C_im += __rhs.imag(); return *this;
  }

  inline complex<double>&
  complex<double>::operator-= (const complex<float>& __rhs) 
  {
    _C_re -= __rhs.real(); _C_im -= __rhs.imag(); return *this;
  }

  inline complex<double>&
  complex<double>::operator*= (const complex<float>& __rhs) 
  {     
    double __tmp = _C_re*__rhs.real()-_C_im*__rhs.imag(); 
    _C_im        = _C_im*__rhs.real()+_C_re*__rhs.imag(); 
    _C_re        = __tmp;
    return *this;
  }

  inline complex<double>&
  complex<double>::operator= (const complex<double>& __rhs) 
  {
    _C_re = __rhs.real(); _C_im = __rhs.imag(); return *this;
  }

  inline complex<double>&
  complex<double>::operator+= (const complex<double>& __rhs) 
  {
    _C_re += __rhs.real(); _C_im += __rhs.imag(); return *this;
  }

  inline complex<double>&
  complex<double>::operator-= (const complex<double>& __rhs) 
  {     
    _C_re -= __rhs.real(); _C_im -= __rhs.imag(); return *this;
  }

  inline complex<double>& 
  complex<double>::operator*= (const complex<double>& __rhs) 
  {     
    double __tmp = _C_re*__rhs.real()-_C_im*__rhs.imag(); 
    _C_im       = _C_im*__rhs.real()+_C_re*__rhs.imag(); 
    _C_re       = __tmp;
    return *this;
  }


# ifndef _RWSTD_NO_LONG_DOUBLE
  inline complex<double>&
  complex<double>::operator= (const complex<long double>& __rhs) 
  {     
    _C_re = _RWSTD_STATIC_CAST(double,__rhs.real()); 
    _C_im = _RWSTD_STATIC_CAST(double,__rhs.imag()); 
    return *this;
  }

  inline complex<double>&
  complex<double>::operator+= (const complex<long double>& __rhs) 
  {     
    _C_re += _RWSTD_STATIC_CAST(double,__rhs.real()); 
    _C_im += _RWSTD_STATIC_CAST(double,__rhs.imag()); 
    return *this;
  }

  inline complex<double>& 
  complex<double>::operator-= (const complex<long double>& __rhs) 
  {
    _C_re -= _RWSTD_STATIC_CAST(double,__rhs.real()); 
    _C_im -= _RWSTD_STATIC_CAST(double,__rhs.imag()); 
    return *this;
  }

  inline complex<double>& 
  complex<double>::operator*= (const complex<long double>& __rhs) 
  {     
    double __tmp = _C_re*_RWSTD_STATIC_CAST(double,__rhs.real())-
    _C_im*_RWSTD_STATIC_CAST(double,__rhs.imag()); 
    _C_im       = _C_im*_RWSTD_STATIC_CAST(double,__rhs.real())+
    _C_re*_RWSTD_STATIC_CAST(double,__rhs.imag()); 
    _C_re       = __tmp; 
    return *this;
  }
# endif
#endif /* _RWSTD_NO_MEMBER_TEMPLATES */

//
// complex<long double> specializations.
//

#ifndef _RWSTD_NO_LONG_DOUBLE
  inline 
  complex<long double>::complex (const complex<float>& cf)
  : _C_re(cf.real()), _C_im(cf.imag()) {}

  inline 
  complex<long double>::complex (const complex<double>& cd)
  : _C_re(cd.real()), _C_im(cd.imag()) {}

  inline complex<long double>&
  complex<long double>::operator+= (long double __rhs) 
  {
    _C_re += __rhs; return *this;
  }

  inline complex<long double>&
  complex<long double>::operator= (long double __rhs) 
  {
    _C_re = __rhs; _C_im = 0.0; return *this;
  }

  inline complex<long double>&
  complex<long double>::operator-= (long double __rhs) 
  {
    _C_re -= __rhs;  return *this;
  }

  inline complex<long double>&
  complex<long double>::operator*= (long double __rhs) 
  {     
    long double __tmp = _C_re*__rhs; 
    _C_im       = _C_im*__rhs; 
    _C_re       = __tmp;
    return *this;
  }


# ifdef _RWSTD_NO_MEMBER_TEMPLATES
  inline complex<long double>& 
  complex<long double>::operator= (const complex<float>& __rhs) 
  {
    _C_re = __rhs.real(); _C_im = __rhs.imag(); return *this;
  }

  inline complex<long double>& 
  complex<long double>::operator+= (const complex<float>& __rhs) 
  {
    _C_re += __rhs.real(); _C_im += __rhs.imag(); return *this;
  }

  inline complex<long double>&
  complex<long double>::operator-= (const complex<float>& __rhs) 
  {
    _C_re -= __rhs.real(); _C_im -= __rhs.imag(); return *this;
  }

  inline complex<long double>& 
  complex<long double>::operator*= (const complex<float>& __rhs) 
  {     
    long double __tmp = _C_re*__rhs.real()-_C_im*__rhs.imag(); 
    _C_im             = _C_im*__rhs.real()+_C_re*__rhs.imag(); 
    _C_re             = __tmp;
    return *this;
  }

  inline complex<long double>& 
  complex<long double>::operator= (const complex<double>& __rhs) 
  {
    _C_re = __rhs.real(); _C_im = __rhs.imag(); return *this;
  }

  inline complex<long double>& 
  complex<long double>::operator+= (const complex<double>& __rhs) 
  {
    _C_re += __rhs.real(); _C_im += __rhs.imag(); return *this;
  }

  inline complex<long double>&
  complex<long double>::operator-= (const complex<double>& __rhs) 
  {     
    _C_re -= __rhs.real(); _C_im -= __rhs.imag(); return *this;
  }

  inline complex<long double>& 
  complex<long double>::operator*= (const complex<double>& __rhs) 
  {     
    long double __tmp = _C_re*__rhs.real()-_C_im*__rhs.imag(); 
    _C_im             = _C_im*__rhs.real()+_C_re*__rhs.imag(); 
    _C_re             = __tmp;
    return *this;
  }

  inline complex<long double>&
  complex<long double>::operator= (const complex<long double>& __rhs) 
  {     
    _C_re = __rhs.real(); _C_im = __rhs.imag(); return *this;
  }

  inline complex<long double>&
  complex<long double>::operator+= (const complex<long double>& __rhs) 
  {     
    _C_re += __rhs.real(); _C_im += __rhs.imag(); return *this;
  }

  inline complex<long double>& 
  complex<long double>::operator-= (const complex<long double>& __rhs) 
  {
    _C_re -= __rhs.real(); _C_im -= __rhs.imag(); return *this;
  }

  inline complex<long double>& 
  complex<long double>::operator*= (const complex<long double>& __rhs) 
  {     
    long double __tmp = _C_re*__rhs.real()-_C_im*__rhs.imag(); 
    _C_im            = _C_im*__rhs.real()+_C_re*__rhs.imag(); 
    _C_re            = __tmp; 
    return *this;
  }
# endif
#endif /* _RWSTD_NO_MEMBER_TEMPLATES */

#ifndef _RWSTD_NO_MEMBER_TEMPLATES
  template <class _TypeT>
  template <class _TypeX>
  complex<_TypeT>&
  complex<_TypeT>::operator/= (const complex<_TypeX>& __rhs)
  {
    _TypeT denom = __rhs.real()*__rhs.real() + __rhs.imag()*__rhs.imag();
    _TypeT re    = (_C_re*__rhs.real()+_C_im*__rhs.imag())/denom;
    _TypeT im    = (__rhs.real()*_C_im-_C_re*__rhs.imag())/denom;
    _C_re    = re;
    _C_im    = im;
    return *this;
  }

  template <class _TypeX>
  inline complex<float>& 
  complex<float>::operator/= (const complex<_TypeX>& __rhs)  
  {
    float denom = __rhs.real()*__rhs.real() + __rhs.imag()*__rhs.imag();
    float re    = (_C_re*__rhs.real()+_C_im*__rhs.imag())/denom;
    float im    = (__rhs.real()*_C_im-_C_re*__rhs.imag())/denom;
    _C_re        = re;
    _C_im        = im;
    return *this;
  }

  template <class _TypeX>
  inline complex<double>& 
  complex<double>::operator/= (const complex<_TypeX>& __rhs)  
  {
    double denom = __rhs.real()*__rhs.real() + __rhs.imag()*__rhs.imag();
    double re    = (_C_re*__rhs.real()+_C_im*__rhs.imag())/denom;
    double im    = (__rhs.real()*_C_im-_C_re*__rhs.imag())/denom;
    _C_re        = re;
    _C_im        = im;
    return *this;
  }

# ifndef _RWSTD_NO_LONG_DOUBLE
  template <class _TypeX>
  inline complex<long double>& 
  complex<long double>::operator/= (const complex<_TypeX>& __rhs)  
  {
    long double denom = __rhs.real()*__rhs.real() + __rhs.imag()*__rhs.imag();
    long double re    = (_C_re*__rhs.real()+_C_im*__rhs.imag())/denom;
    long double im    = (__rhs.real()*_C_im-_C_re*__rhs.imag())/denom;
    _C_re        = re;
    _C_im        = im;
    return *this;
  }
# endif

#else /* No member function templates, have to specialize :-( */

  inline complex<float>& 
  complex<float>::operator/= (const complex<float>& __rhs)  
  {
    float denom = __rhs.real()*__rhs.real() + __rhs.imag()*__rhs.imag();
    float re    = (_C_re*__rhs.real()+_C_im*__rhs.imag())/denom;
    float im    = (__rhs.real()*_C_im-_C_re*__rhs.imag())/denom;
    _C_re         = re;
    _C_im         = im;
    return *this;
  }

  inline complex<float>& 
  complex<float>::operator/= (const complex<double>& __rhs)  
  {
    float denom = _RWSTD_STATIC_CAST(float,__rhs.real())*
    _RWSTD_STATIC_CAST(float,__rhs.real()) + 
    _RWSTD_STATIC_CAST(float,__rhs.imag())*
    _RWSTD_STATIC_CAST(float,__rhs.imag());
    float re    = (_C_re*_RWSTD_STATIC_CAST(float,__rhs.real())+
                   _C_im*_RWSTD_STATIC_CAST(float,__rhs.imag()))/denom;
    float im    = (_RWSTD_STATIC_CAST(float,__rhs.real())*_C_im-_C_re*
                   _RWSTD_STATIC_CAST(float,__rhs.imag()))/denom;
    _C_re        = re;
    _C_im        = im;
    return *this;
  }

# ifndef _RWSTD_NO_LONG_DOUBLE
  inline complex<float>& 
  complex<float>::operator/= (const complex<long double>& __rhs)  
  {
    float denom = _RWSTD_STATIC_CAST(float,__rhs.real())*
    _RWSTD_STATIC_CAST(float,__rhs.real()) + 
    _RWSTD_STATIC_CAST(float,__rhs.imag())*
    _RWSTD_STATIC_CAST(float,__rhs.imag());
    float re    = (_C_re*_RWSTD_STATIC_CAST(float,__rhs.real())+
                   _C_im*_RWSTD_STATIC_CAST(float,__rhs.imag()))/denom;
    float im    = (_RWSTD_STATIC_CAST(float,__rhs.real())*_C_im-
                   _C_re*_RWSTD_STATIC_CAST(float,__rhs.imag()))/denom;
    _C_re        = re;
    _C_im        = im;
    return *this;
  }
# endif 

  inline complex<double>& 
  complex<double>::operator/= (const complex<float>& __rhs)  
  {
    double denom = __rhs.real()*__rhs.real() + __rhs.imag()*__rhs.imag();
    double re    = (_C_re*__rhs.real()+_C_im*__rhs.imag())/denom;
    double im    = (__rhs.real()*_C_im-_C_re*__rhs.imag())/denom;
    _C_re         = re;
    _C_im         = im;
    return *this;
  }

  inline complex<double>&
  complex<double>::operator/= (const complex<double>& __rhs)
  {
    double denom = __rhs.real()*__rhs.real() + __rhs.imag()*__rhs.imag();
    double re    = (_C_re*__rhs.real()+_C_im*__rhs.imag())/denom;
    double im    = (__rhs.real()*_C_im-_C_re*__rhs.imag())/denom;
    _C_re         = re;
    _C_im         = im;
    return *this;
  }

#ifndef _RWSTD_NO_LONG_DOUBLE
  inline complex<double>& 
  complex<double>::operator/= (const complex<long double>& __rhs)  
  {
    double denom = _RWSTD_STATIC_CAST(double,__rhs.real())*
    _RWSTD_STATIC_CAST(double,__rhs.real()) + 
    _RWSTD_STATIC_CAST(double,__rhs.imag())*
    _RWSTD_STATIC_CAST(double,__rhs.imag());
    double re    = (_C_re*_RWSTD_STATIC_CAST(double,__rhs.real())+
                    _C_im*_RWSTD_STATIC_CAST(double,__rhs.imag()))/denom;
    double im    = (_RWSTD_STATIC_CAST(double,__rhs.real())*_C_im-
                    _C_re*_RWSTD_STATIC_CAST(double,__rhs.imag()))/denom;
    _C_re         = re;
    _C_im         = im;
    return *this;
  }
#endif 

#ifndef _RWSTD_NO_LONG_DOUBLE
  inline complex<long double>& 
  complex<long double>::operator/= (const complex<float>& __rhs)  
  {
    long double denom = __rhs.real()*__rhs.real() + __rhs.imag()*__rhs.imag();
    long double re    = (_C_re*__rhs.real()+_C_im*__rhs.imag())/denom;
    long double im    = (__rhs.real()*_C_im-_C_re*__rhs.imag())/denom;
    _C_re              = re;
    _C_im              = im;
    return *this;
  }

  inline complex<long double>& 
  complex<long double>::operator/= (const complex<double>& __rhs)  
  {
    long double denom = __rhs.real()*__rhs.real() + __rhs.imag()*__rhs.imag();
    long double re    = (_C_re*__rhs.real()+_C_im*__rhs.imag())/denom;
    long double im    = (__rhs.real()*_C_im-_C_re*__rhs.imag())/denom;
    _C_re              = re;
    _C_im              = im;
    return *this;
  }

  inline complex<long double>& 
  complex<long double>::operator/= (const complex<long double>& __rhs)  
  {
    long double denom = __rhs.real()*__rhs.real() + __rhs.imag()*__rhs.imag();
    long double re    = (_C_re*__rhs.real()+_C_im*__rhs.imag())/denom;
    long double im    = (__rhs.real()*_C_im-_C_re*__rhs.imag())/denom;
    _C_re              = re;
    _C_im              = im;
    return *this;
  }
#endif
#endif

  inline complex<float>& 
  complex<float>::operator/= (float __rhs)  
  {
    float denom = __rhs*__rhs;
    float re    = (_C_re*__rhs)/denom;
    float im    = (__rhs*_C_im)/denom;
    _C_re        = re;
    _C_im        = im;
    return *this;
  }

  inline complex<double>& 
  complex<double>::operator/= (double __rhs)  
  {
    double denom = __rhs*__rhs;
    double re    = (_C_re*__rhs)/denom;
    double im    = (__rhs*_C_im)/denom;
    _C_re         = re;
    _C_im         = im;
    return *this;
  }


#ifndef _RWSTD_NO_LONG_DOUBLE
  inline complex<long double>& 
  complex<long double>::operator/= (long double __rhs)  
  {
    long double denom = __rhs*__rhs;
    long double re    = (_C_re*__rhs)/denom;
    long double im    = (__rhs*_C_im)/denom;
    _C_re              = re;
    _C_im              = im;
    return *this;
  }
#endif


//
// complex non-member operations
//

  template <class _TypeT>
  inline complex<_TypeT> operator+ (const complex<_TypeT>& __lhs, const complex<_TypeT>& __rhs)
  {
    complex<_TypeT> __tmp = __lhs; return __tmp += __rhs;
  }

  template <class _TypeT>
  inline complex<_TypeT> operator+ (const complex<_TypeT>& __lhs, const _TypeT& __rhs)
  {
    return complex<_TypeT>(__rhs+__lhs.real(), __lhs.imag());
  }

  template <class _TypeT>
  inline complex<_TypeT> operator+ (const _TypeT& __lhs, const complex<_TypeT>& __rhs)
  {
    return complex<_TypeT>(__lhs+__rhs.real(), __rhs.imag());
  }

  template <class _TypeT>
  inline complex<_TypeT> operator- (const complex<_TypeT>& __lhs, const complex<_TypeT>& __rhs)
  {
    complex<_TypeT> __tmp = __lhs; return __tmp -= __rhs;
  }

  template <class _TypeT>
  inline complex<_TypeT> operator- (const complex<_TypeT>& __lhs, const _TypeT& __rhs)
  {

⌨️ 快捷键说明

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