This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

V3 PATCH to std_complex.h


This patch makes V3 complex<> operations forward to GCC built-ins, now
that they are available in GCC-3.5.0.

One missing candiate is __builtin_clog.  gcc/builtins.def contains
an explanation but we need to fix that.

Tested on an i686-pc-linux-gnu.


I usually prefer dispatching through class templates, but in this case
I found the overloading exceptionally simple.


-- Gaby
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/ChangeLog,v
retrieving revision 1.2499
diff -p -r1.2499 ChangeLog
*** ChangeLog	29 May 2004 14:40:58 -0000	1.2499
--- ChangeLog	30 May 2004 14:40:55 -0000
***************
*** 1,3 ****
--- 1,33 ----
+ 2004-05-30  Gabriel Dos Reis  <gdr@integrable-solutions.net>
+ 
+ 	* include/std/std_complex.h (complex<_Tp>): Properly indent
+ 	to follow C++STYLE. 
+ 	(complex<>::__rep): New.
+ 	(__complex_abs): New.  Dispatch to built-ins.
+ 	(abs): Use them.
+ 	(__complex_arg): New. Dispatch to built-ins.
+ 	(arg): Use it.
+ 	(__complex_cos): New. Dispatch to built-ins.
+ 	(cos): Use it.
+ 	(__complex_cosh): New. Dispatch to built-ins.
+ 	(cosh): Use it.
+ 	(__complex_exp): New. Dispatch to built-ins.
+ 	(exp): Use it.
+ 	(__complex_log): New. Dispatch to built-ins.
+ 	(log): Use it.
+ 	(__complex_sin): New. Dispatch to built-ins.
+ 	(sin): Use it.
+ 	(__complex_sinh): New. Dispatch to built-ins.
+ 	(sinh): Use it.
+ 	(__complex_sqrt): New. Dispatch to built-ins.
+ 	(sqrt): Use it.
+ 	(__complex_tan): New. Dispatch to built-ins.
+ 	(tan): Use it.
+ 	(__complex_tanh): New. Dispatch to built-ins.
+ 	(tanh): Use it.
+ 	(__complex_pow): New. Dispatch to built-ins.
+ 	(pow): Use it.
+ 
  2004-05-29  Richard B. Kreckel  <Richard.Kreckel@Framatome-ANP.com>
              Benjamin Kosnik  <bkoz@redhat.com>
  	
Index: include/std/std_complex.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/std/std_complex.h,v
retrieving revision 1.14
diff -p -r1.14 std_complex.h
*** include/std/std_complex.h	11 Mar 2004 19:05:18 -0000	1.14
--- include/std/std_complex.h	30 May 2004 14:40:56 -0000
*************** namespace std
*** 87,93 ****
    template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, const _Tp&);
    /// Return @a x to the @a y'th power.
    template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, 
! 					   const complex<_Tp>&);
    /// Return @a x to the @a y'th power.
    template<typename _Tp> complex<_Tp> pow(const _Tp&, const complex<_Tp>&);
    /// Return complex sine of @a z.
--- 87,93 ----
    template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, const _Tp&);
    /// Return @a x to the @a y'th power.
    template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, 
!                                           const complex<_Tp>&);
    /// Return @a x to the @a y'th power.
    template<typename _Tp> complex<_Tp> pow(const _Tp&, const complex<_Tp>&);
    /// Return complex sine of @a z.
*************** namespace std
*** 113,121 ****
     *  @param  Tp  Type of real and imaginary values.
    */
    template<typename _Tp>
!     class complex
      {
-     public:
        /// Value typedef.
        typedef _Tp value_type;
        
--- 113,120 ----
     *  @param  Tp  Type of real and imaginary values.
    */
    template<typename _Tp>
!     struct complex
      {
        /// Value typedef.
        typedef _Tp value_type;
        
*************** namespace std
*** 168,173 ****
--- 167,174 ----
        template<typename _Up>
          complex<_Tp>& operator/=(const complex<_Up>&);
  
+       const complex& __rep() const;
+ 
      private:
        _Tp _M_real;
        _Tp _M_imag;
*************** namespace std
*** 305,310 ****
--- 306,315 ----
        _M_real = __r / __n;
        return *this;
      }
+ 
+   template<typename _Tp>
+     inline const complex<_Tp>&
+     complex<_Tp>::__rep() const { return *this; }
      
    // Operators:
    //@{
*************** namespace std
*** 542,550 ****
      imag(const complex<_Tp>& __z)
      { return __z.imag(); }
  
    template<typename _Tp>
      inline _Tp
!     abs(const complex<_Tp>& __z)
      {
        _Tp __x = __z.real();
        _Tp __y = __z.imag();
--- 547,556 ----
      imag(const complex<_Tp>& __z)
      { return __z.imag(); }
  
+   // 26.2.7/3 abs(__z):  Returns the magnitude of __z.
    template<typename _Tp>
      inline _Tp
!     __complex_abs(const complex<_Tp>& __z)
      {
        _Tp __x = __z.real();
        _Tp __y = __z.imag();
*************** namespace std
*** 553,565 ****
          return __s;
        __x /= __s; 
        __y /= __s;
!       return __s * sqrt(__x * __x + __y * __y);
      }
  
    template<typename _Tp>
      inline _Tp
!     arg(const complex<_Tp>& __z)
!     { return atan2(__z.imag(), __z.real()); }
  
    // 26.2.7/5: norm(__z) returns the squared magintude of __z.
    //     As defined, norm() is -not- a norm is the common mathematical
--- 559,605 ----
          return __s;
        __x /= __s; 
        __y /= __s;
!           return __s * sqrt(__x * __x + __y * __y);
      }
  
+   inline float
+   __complex_abs(__complex__ float __z) { return __builtin_cabsf(__z); }
+ 
+   inline double
+   __complex_abs(__complex__ double __z) { return __builtin_cabs(__z); }
+ 
+   inline long double
+   __complex_abs(const __complex__ long double& __z)
+   {
+     return __builtin_cabsl(__z);
+   }
+   
+   template<typename _Tp>
+     inline _Tp
+     abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); }
+ 
+ 
+   // 26.2.7/4: arg(__z): Returns the phase angle of __z.
    template<typename _Tp>
      inline _Tp
!     __complex_arg(const complex<_Tp>& __z)
!     {
!       return  atan2(__z.imag(), __z.real()); 
!     }
! 
!   inline float
!   __complex_arg(__complex__ float __z) { return __builtin_cargf(__z); }
! 
!   inline double
!   __complex_arg(__complex__ double __z) { return __builtin_carg(__z); }
! 
!   inline long double
!   __complex_arg(const __complex__ long double& __z)
!   { return __builtin_cargl(__z); }
! 
!   template<typename _Tp>
!     inline _Tp
!     arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
  
    // 26.2.7/5: norm(__z) returns the squared magintude of __z.
    //     As defined, norm() is -not- a norm is the common mathematical
*************** namespace std
*** 607,666 ****
      { return complex<_Tp>(__z.real(), -__z.imag()); }
    
    // Transcendentals
    template<typename _Tp>
      inline complex<_Tp>
!     cos(const complex<_Tp>& __z)
      {
        const _Tp __x = __z.real();
        const _Tp __y = __z.imag();
        return complex<_Tp>(cos(__x) * cosh(__y), -sin(__x) * sinh(__y));
      }
  
    template<typename _Tp>
      inline complex<_Tp>
!     cosh(const complex<_Tp>& __z)
!     {
!       const _Tp __x = __z.real();
!       const _Tp __y = __z.imag();
!       return complex<_Tp>(cosh(__x) * cos(__y), sinh(__x) * sin(__y));
!     }
  
    template<typename _Tp>
      inline complex<_Tp>
!     exp(const complex<_Tp>& __z)
      { return std::polar(exp(__z.real()), __z.imag()); }
  
    template<typename _Tp>
      inline complex<_Tp>
!     log(const complex<_Tp>& __z)
      { return complex<_Tp>(log(std::abs(__z)), std::arg(__z)); }
  
    template<typename _Tp>
      inline complex<_Tp>
      log10(const complex<_Tp>& __z)
      { return std::log(__z) / log(_Tp(10.0)); }
  
    template<typename _Tp>
      inline complex<_Tp>
!     sin(const complex<_Tp>& __z)
      {
        const _Tp __x = __z.real();
        const _Tp __y = __z.imag();
        return complex<_Tp>(sin(__x) * cosh(__y), cos(__x) * sinh(__y)); 
      }
  
    template<typename _Tp>
      inline complex<_Tp>
!     sinh(const complex<_Tp>& __z)
      {
        const _Tp __x = __z.real();
        const _Tp  __y = __z.imag();
        return complex<_Tp>(sinh(__x) * cos(__y), cosh(__x) * sin(__y));
      }
  
    template<typename _Tp>
      complex<_Tp>
!     sqrt(const complex<_Tp>& __z)
      {
        _Tp __x = __z.real();
        _Tp __y = __z.imag();
--- 647,801 ----
      { return complex<_Tp>(__z.real(), -__z.imag()); }
    
    // Transcendentals
+ 
+   // 26.2.8/1 cos(__z):  Returns the cosine of __z.
    template<typename _Tp>
      inline complex<_Tp>
!     __complex_cos(const complex<_Tp>& __z)
      {
        const _Tp __x = __z.real();
        const _Tp __y = __z.imag();
        return complex<_Tp>(cos(__x) * cosh(__y), -sin(__x) * sinh(__y));
      }
  
+   inline __complex__ float
+   __complex_cos(__complex__ float __z) { return __builtin_ccosf(__z); }
+ 
+   inline __complex__ double
+   __complex_cos(__complex__ double __z) { return __builtin_ccos(__z); }
+ 
+   inline __complex__ long double
+   __complex_cos(const __complex__ long double& __z)
+   { return __builtin_ccosl(__z); }
+   
    template<typename _Tp>
      inline complex<_Tp>
!     cos(const complex<_Tp>& __z) { return __complex_cos(__z.__rep()); }
! 
!   // 26.2.8/2 cosh(__z): Returns the hyperbolic cosine of __z.
!   template<typename _Tp>
!     inline complex<_Tp>
!     __complex_cosh(const complex<_Tp>& __z)
!       {
!         const _Tp __x = __z.real();
!         const _Tp __y = __z.imag();
!         return complex<_Tp>(cosh(__x) * cos(__y), sinh(__x) * sin(__y));
!       }
! 
!   inline __complex__ float
!   __complex_cosh(__complex__ float __z) { return __builtin_ccoshf(__z); }
! 
!   inline __complex__ double
!   __complex_cosh(__complex__ double __z) { return __builtin_ccosh(__z); }
! 
!   inline __complex__ long double
!   __complex_cosh(const __complex__ long double& __z)
!   { return __builtin_ccoshl(__z); }
  
    template<typename _Tp>
      inline complex<_Tp>
!     cosh(const complex<_Tp>& __z) { return __complex_cosh(__z.__rep()); }
! 
!   // 26.2.8/3 exp(__z): Returns the complex base e exponential of x
!   template<typename _Tp>
!     inline complex<_Tp>
!     __complex_exp(const complex<_Tp>& __z)
      { return std::polar(exp(__z.real()), __z.imag()); }
  
+   inline __complex__ float
+   __complex_exp(__complex__ float __z) { return __builtin_cexpf(__z); }
+ 
+   inline __complex__ double
+   __complex_exp(__complex__ double __z) { return __builtin_cexp(__z); }
+ 
+   inline __complex__ long double
+     __complex_exp(const __complex__ long double& __z)
+     { return __builtin_cexpl(__z); }
+   
    template<typename _Tp>
      inline complex<_Tp>
!     exp(const complex<_Tp>& __z) { return __complex_exp(__z.__rep()); }
! 
!   // 26.2.8/5 log(__z): Reurns the natural complex logaritm of __z.
!   //                    The branch cut is along the negative axis.
!   template<typename _Tp>
!     inline complex<_Tp>
!     __complex_log(const complex<_Tp>& __z)
      { return complex<_Tp>(log(std::abs(__z)), std::arg(__z)); }
  
+   /*
+   inline __complex__ float
+   __complex_log(__complex__ float __z) { return __builtin_clogf(__z); }
+ 
+   inline __complex__ double
+   __complex_log(__complex__ double __z) { return __builtin_clog(__z); }
+ 
+   inline __complex__ long double
+   __complex_log(const __complex__ long double& __z)
+   { return __builtin_clog(__z); } */
+ 
+   template<typename _Tp>
+     inline complex<_Tp>
+     log(const complex<_Tp>& __z) { return __complex_log(__z.__rep()); }
+ 
    template<typename _Tp>
      inline complex<_Tp>
      log10(const complex<_Tp>& __z)
      { return std::log(__z) / log(_Tp(10.0)); }
  
+   // 26.2.8/10 sin(__z): Returns the sine of __z.
    template<typename _Tp>
      inline complex<_Tp>
!     __complex_sin(const complex<_Tp>& __z)
      {
        const _Tp __x = __z.real();
        const _Tp __y = __z.imag();
        return complex<_Tp>(sin(__x) * cosh(__y), cos(__x) * sinh(__y)); 
      }
  
+   inline __complex__ float
+   __complex_sin(__complex__ float __z) { return __builtin_csinf(__z); }
+ 
+   inline __complex__ double
+   __complex_sin(__complex__ double __z) { return __builtin_csin(__z); }
+ 
+   inline __complex__ long double
+   __complex_sin(const __complex__ long double& __z)
+   { return __builtin_csinl(__z); }
+ 
    template<typename _Tp>
      inline complex<_Tp>
!     sin(const complex<_Tp>& __z) { __complex_sin(__z.__rep()); }
! 
!   // 26.2.8/11 sinh(__z): Returns the hyperbolic sine of __z.
!   template<typename _Tp>
!     inline complex<_Tp>
!     __complex_sinh(const complex<_Tp>& __z)
      {
        const _Tp __x = __z.real();
        const _Tp  __y = __z.imag();
        return complex<_Tp>(sinh(__x) * cos(__y), cosh(__x) * sin(__y));
      }
  
+   inline __complex__ float
+   __complex_sinh(__complex__ float __z) { return __builtin_csinhf(__z); }      
+ 
+   inline __complex__ double
+   __complex_sinh(__complex__ double __z) { return __builtin_csinh(__z); }      
+ 
+   inline __complex__ long double
+   __complex_sinh(const __complex__ long double& __z)
+   { return __builtin_csinhl(__z); }      
+ 
+   template<typename _Tp>
+     inline complex<_Tp>
+     sinh(const complex<_Tp>& __z) { return __complex_sinh(__z.__rep()); }
+ 
+   // 26.2.8/13 sqrt(__z): Returns the complex square root of __z.
+   //                     The branch cut is on the negative axis.
    template<typename _Tp>
      complex<_Tp>
!     __complex_sqrt(const complex<_Tp>& __z)
      {
        _Tp __x = __z.real();
        _Tp __y = __z.imag();
*************** namespace std
*** 680,701 ****
          }
      }
  
    template<typename _Tp>
      inline complex<_Tp>
!     tan(const complex<_Tp>& __z)
!     {
!       return std::sin(__z) / std::cos(__z);
!     }
  
    template<typename _Tp>
      inline complex<_Tp>
!     tanh(const complex<_Tp>& __z)
!     {
!       return std::sinh(__z) / std::cosh(__z);
!     }
  
    template<typename _Tp>
      inline complex<_Tp>
      pow(const complex<_Tp>& __z, int __n)
      {
        return std::__pow_helper(__z, __n);
--- 815,881 ----
          }
      }
  
+   inline __complex__ float
+   __complex_sqrt(__complex__ float __z) { return __builtin_csqrtf(__z); }
+ 
+   inline __complex__ double
+   __complex_sqrt(__complex__ double __z) { return __builtin_csqrt(__z); }
+ 
+   inline __complex__ long double
+   __complex_sqrt(const __complex__ long double& __z)
+   { return __builtin_csqrtl(__z); }
+ 
    template<typename _Tp>
      inline complex<_Tp>
!     sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z.__rep()); }
  
+   // 26.2.8/14 tan(__z):  Return the complex tangent of __z.
+   
    template<typename _Tp>
      inline complex<_Tp>
!     __complex_tan(const complex<_Tp>& __z)
!     { return std::sin(__z) / std::cos(__z); }
! 
!   inline __complex__ float
!   __complex_tan(__complex__ float __z) { return __builtin_ctanf(__z); }
! 
!   inline __complex__ double
!   __complex_tan(__complex__ double __z) { return __builtin_ctan(__z); }
! 
!   inline __complex__ long double
!   __complex_tan(const __complex__ long double& __z)
!   { return __builtin_ctanl(__z); }
  
    template<typename _Tp>
      inline complex<_Tp>
+     tan(const complex<_Tp>& __z) { return __complex_tan(__z.__rep()); }
+ 
+   // 26.2.8/15 tanh(__z):  Returns the hyperbolic tangent of __z.
+   
+   template<typename _Tp>
+     inline complex<_Tp>
+     __complex_tanh(const complex<_Tp>& __z)
+     { return std::sinh(__z) / std::cosh(__z); }
+ 
+   inline __complex__ float
+   __complex_tanh(__complex__ float __z) { return __builtin_ctanhf(__z); }
+ 
+   inline __complex__ double
+   __complex_tanh(__complex__ double __z) { return __builtin_ctanh(__z); }
+ 
+   inline __complex__ long double
+   __complex_tanh(const __complex__ long double& __z)
+   { return __builtin_ctanhl(__z); }
+ 
+   template<typename _Tp>
+     inline complex<_Tp>
+     tanh(const complex<_Tp>& __z) { return __complex_tanh(__z.__rep()); }
+ 
+   // 26.2.8/9  pow(__x, __y): Returns the complex power base of __x
+   //                          raised to the __y-th power.  The branch
+   //                          cut is on the negative axis.
+   template<typename _Tp>
+     inline complex<_Tp>
      pow(const complex<_Tp>& __z, int __n)
      {
        return std::__pow_helper(__z, __n);
*************** namespace std
*** 714,723 ****
  
    template<typename _Tp>
      inline complex<_Tp>
      pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
!     {
!       return __x == _Tp() ? _Tp() : std::exp(__y * std::log(__x));
!     }
  
    template<typename _Tp>
      inline complex<_Tp>
--- 894,918 ----
  
    template<typename _Tp>
      inline complex<_Tp>
+     __complex_pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
+     { return __x == _Tp() ? _Tp() : std::exp(__y * std::log(__x)); }
+ 
+   inline __complex__ float
+   __complex_pow(__complex__ float __x, __complex__ float __y)
+   { return __builtin_cpowf(__x, __y); }
+ 
+   inline __complex__ double
+   __complex_pow(__complex__ double __x, __complex__ double __y)
+   { return __builtin_cpow(__x, __y); }
+ 
+   inline __complex__ long double
+   __complex_pow(__complex__ long double& __x, __complex__ long double& __y)
+   { return __builtin_cpowl(__x, __y); }
+   
+   template<typename _Tp>
+     inline complex<_Tp>
      pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
!     { return __complex_pow(__x, __y); }
  
    template<typename _Tp>
      inline complex<_Tp>
*************** namespace std
*** 730,781 ****
  
    // 26.2.3  complex specializations
    // complex<float> specialization
!   template<> class complex<float>
!   {
!   public:
!     typedef float value_type;
!     
!     complex(float = 0.0f, float = 0.0f);
  #ifdef _GLIBCXX_BUGGY_COMPLEX
!     complex(const complex& __z) : _M_value(__z._M_value) { }
  #endif
!     explicit complex(const complex<double>&);
!     explicit complex(const complex<long double>&);
  
!     float& real();
!     const float& real() const;
!     float& imag();
!     const float& imag() const;
! 
!     complex<float>& operator=(float);
!     complex<float>& operator+=(float);
!     complex<float>& operator-=(float);
!     complex<float>& operator*=(float);
!     complex<float>& operator/=(float);
!         
!     // Let's the compiler synthetize the copy and assignment
!     // operator.  It always does a pretty good job.
!     // complex& operator= (const complex&);
!     template<typename _Tp>
!       complex<float>&operator=(const complex<_Tp>&);
!     template<typename _Tp>
!       complex<float>& operator+=(const complex<_Tp>&);
!     template<class _Tp>
!       complex<float>& operator-=(const complex<_Tp>&);
!     template<class _Tp>
!       complex<float>& operator*=(const complex<_Tp>&);
!     template<class _Tp>
!       complex<float>&operator/=(const complex<_Tp>&);
! 
!   private:
!     typedef __complex__ float _ComplexT;
!     _ComplexT _M_value;
  
!     complex(_ComplexT __z) : _M_value(__z) { }
!         
!     friend class complex<double>;
!     friend class complex<long double>;
!   };
  
    inline float&
    complex<float>::real()
--- 925,975 ----
  
    // 26.2.3  complex specializations
    // complex<float> specialization
!   template<>
!     struct complex<float>
!     {
!       typedef float value_type;
!       typedef __complex__ float _ComplexT;
! 
!       complex(_ComplexT __z) : _M_value(__z) { }
! 
!       complex(float = 0.0f, float = 0.0f);
  #ifdef _GLIBCXX_BUGGY_COMPLEX
!       complex(const complex& __z) : _M_value(__z._M_value) { }
  #endif
!       explicit complex(const complex<double>&);
!       explicit complex(const complex<long double>&);
  
!       float& real();
!       const float& real() const;
!       float& imag();
!       const float& imag() const;
! 
!       complex<float>& operator=(float);
!       complex<float>& operator+=(float);
!       complex<float>& operator-=(float);
!       complex<float>& operator*=(float);
!       complex<float>& operator/=(float);
! 
!       // Let's the compiler synthetize the copy and assignment
!       // operator.  It always does a pretty good job.
!       // complex& operator= (const complex&);
!       template<typename _Tp>
!         complex<float>&operator=(const complex<_Tp>&);
!       template<typename _Tp>
!         complex<float>& operator+=(const complex<_Tp>&);
!       template<class _Tp>
!         complex<float>& operator-=(const complex<_Tp>&);
!       template<class _Tp>
!         complex<float>& operator*=(const complex<_Tp>&);
!       template<class _Tp>
!         complex<float>&operator/=(const complex<_Tp>&);
  
!       const _ComplexT& __rep() const { return _M_value; }
! 
!     private:
!       _ComplexT _M_value;
!     };
  
    inline float&
    complex<float>::real()
*************** namespace std
*** 887,937 ****
  
    // 26.2.3  complex specializations
    // complex<double> specialization
!   template<> class complex<double>
!   {
!   public:
!     typedef double value_type;
  
!     complex(double  =0.0, double =0.0);
  #ifdef _GLIBCXX_BUGGY_COMPLEX
!     complex(const complex& __z) : _M_value(__z._M_value) { }
  #endif
!     complex(const complex<float>&);
!     explicit complex(const complex<long double>&);
  
!     double& real();
!     const double& real() const;
!     double& imag();
!     const double& imag() const;
!         
!     complex<double>& operator=(double);
!     complex<double>& operator+=(double);
!     complex<double>& operator-=(double);
!     complex<double>& operator*=(double);
!     complex<double>& operator/=(double);
! 
!     // The compiler will synthetize this, efficiently.
!     // complex& operator= (const complex&);
!     template<typename _Tp>
!       complex<double>& operator=(const complex<_Tp>&);
!     template<typename _Tp>
!       complex<double>& operator+=(const complex<_Tp>&);
!     template<typename _Tp>
!       complex<double>& operator-=(const complex<_Tp>&);
!     template<typename _Tp>
!       complex<double>& operator*=(const complex<_Tp>&);
!     template<typename _Tp>
!       complex<double>& operator/=(const complex<_Tp>&);
! 
!   private:
!     typedef __complex__ double _ComplexT;
!     _ComplexT _M_value;
  
!     complex(_ComplexT __z) : _M_value(__z) { }
!         
!     friend class complex<float>;
!     friend class complex<long double>;
!   };
  
    inline double&
    complex<double>::real()
--- 1081,1130 ----
  
    // 26.2.3  complex specializations
    // complex<double> specialization
!   template<>
!     struct complex<double>
!     {
!       typedef double value_type;
!       typedef __complex__ double _ComplexT;
! 
!       complex(_ComplexT __z) : _M_value(__z) { }
  
!       complex(double  = 0.0, double = 0.0);
  #ifdef _GLIBCXX_BUGGY_COMPLEX
!       complex(const complex& __z) : _M_value(__z._M_value) { }
  #endif
!       complex(const complex<float>&);
!       explicit complex(const complex<long double>&);
  
!       double& real();
!       const double& real() const;
!       double& imag();
!       const double& imag() const;
! 
!       complex<double>& operator=(double);
!       complex<double>& operator+=(double);
!       complex<double>& operator-=(double);
!       complex<double>& operator*=(double);
!       complex<double>& operator/=(double);
  
!       // The compiler will synthetize this, efficiently.
!       // complex& operator= (const complex&);
!       template<typename _Tp>
!         complex<double>& operator=(const complex<_Tp>&);
!       template<typename _Tp>
!         complex<double>& operator+=(const complex<_Tp>&);
!       template<typename _Tp>
!         complex<double>& operator-=(const complex<_Tp>&);
!       template<typename _Tp>
!         complex<double>& operator*=(const complex<_Tp>&);
!       template<typename _Tp>
!         complex<double>& operator/=(const complex<_Tp>&);
! 
!       const _ComplexT& __rep() const { return _M_value; }
! 
!     private:
!       _ComplexT _M_value;
!     };
  
    inline double&
    complex<double>::real()
*************** namespace std
*** 1043,1093 ****
  
    // 26.2.3  complex specializations
    // complex<long double> specialization
!   template<> class complex<long double>
!   {
!   public:
!     typedef long double value_type;
  
!     complex(long double = 0.0L, long double = 0.0L);
  #ifdef _GLIBCXX_BUGGY_COMPLEX
!     complex(const complex& __z) : _M_value(__z._M_value) { }
  #endif
!     complex(const complex<float>&);
!     complex(const complex<double>&);
  
!     long double& real();
!     const long double& real() const;
!     long double& imag();
!     const long double& imag() const;
! 
!     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);
! 
!     // The compiler knows how to do this efficiently
!     // complex& operator= (const complex&);
!     template<typename _Tp>
!       complex<long double>& operator=(const complex<_Tp>&);
!     template<typename _Tp>
!       complex<long double>& operator+=(const complex<_Tp>&);
!     template<typename _Tp>
!       complex<long double>& operator-=(const complex<_Tp>&);
!     template<typename _Tp>
!       complex<long double>& operator*=(const complex<_Tp>&);
!     template<typename _Tp>
!       complex<long double>& operator/=(const complex<_Tp>&);
! 
!   private:
!     typedef __complex__ long double _ComplexT;
!     _ComplexT _M_value;
! 
!     complex(_ComplexT __z) : _M_value(__z) { }
! 
!     friend class complex<float>;
!     friend class complex<double>;
!   };
  
    inline
    complex<long double>::complex(long double __r, long double __i)
--- 1236,1285 ----
  
    // 26.2.3  complex specializations
    // complex<long double> specialization
!   template<>
!     struct complex<long double>
!     {
!       typedef long double value_type;
!       typedef __complex__ long double _ComplexT;
! 
!       complex(_ComplexT __z) : _M_value(__z) { }
  
!       complex(long double = 0.0L, long double = 0.0L);
  #ifdef _GLIBCXX_BUGGY_COMPLEX
!       complex(const complex& __z) : _M_value(__z._M_value) { }
  #endif
!       complex(const complex<float>&);
!       complex(const complex<double>&);
  
!       long double& real();
!       const long double& real() const;
!       long double& imag();
!       const long double& imag() const;
! 
!       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);
! 
!       // The compiler knows how to do this efficiently
!       // complex& operator= (const complex&);
!       template<typename _Tp>
!         complex<long double>& operator=(const complex<_Tp>&);
!       template<typename _Tp>
!         complex<long double>& operator+=(const complex<_Tp>&);
!       template<typename _Tp>
!         complex<long double>& operator-=(const complex<_Tp>&);
!       template<typename _Tp>
!         complex<long double>& operator*=(const complex<_Tp>&);
!       template<typename _Tp>
!         complex<long double>& operator/=(const complex<_Tp>&);
! 
!       const _ComplexT& __rep() const { return _M_value; }
! 
!     private:
!       _ComplexT _M_value;
!     };
  
    inline
    complex<long double>::complex(long double __r, long double __i)
*************** namespace std
*** 1203,1232 ****
    // inlining.  It suffices that class specializations be defined.
    inline
    complex<float>::complex(const complex<double>& __z)
!   : _M_value(_ComplexT(__z._M_value)) { }
  
    inline
    complex<float>::complex(const complex<long double>& __z)
!   : _M_value(_ComplexT(__z._M_value)) { }
  
    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<long double>::complex(const complex<float>& __z)
!   : _M_value(_ComplexT(__z._M_value)) { }
  
    inline
    complex<long double>::complex(const complex<double>& __z)
!   : _M_value(_ComplexT(__z._M_value)) { }
  } // namespace std
  
  #endif	/* _GLIBCXX_COMPLEX */
--- 1395,1421 ----
    // inlining.  It suffices that class specializations be defined.
    inline
    complex<float>::complex(const complex<double>& __z)
!   : _M_value(__z.__rep()) { }
  
    inline
    complex<float>::complex(const complex<long double>& __z)
!   : _M_value(__z.__rep()) { }
  
    inline
    complex<double>::complex(const complex<float>& __z) 
!   : _M_value(__z.__rep()) { }
  
    inline
    complex<double>::complex(const complex<long double>& __z)
!     : _M_value(__z.__rep()) { }
  
    inline
    complex<long double>::complex(const complex<float>& __z)
!   : _M_value(__z.__rep()) { }
  
    inline
    complex<long double>::complex(const complex<double>& __z)
!   : _M_value(__z.__rep()) { }
  } // namespace std
  
  #endif	/* _GLIBCXX_COMPLEX */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]