complex.cc (arg, polar): Comment out specializations.
authorGabriel Dos Reis <gdr@codesourcery.com>
Tue, 31 Oct 2000 15:54:00 +0000 (15:54 +0000)
committerGabriel Dos Reis <gdr@gcc.gnu.org>
Tue, 31 Oct 2000 15:54:00 +0000 (15:54 +0000)
* src/complex.cc (arg, polar): Comment out specializations.

* include/bits/std_complex.h (complex<>): Remove arg<> friend
declaration.
(arg): Define primary template.
(polar): Likewise.
(conj): Likewise.

From-SVN: r37159

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/std_complex.h
libstdc++-v3/src/complex.cc

index 416204166e09f7f0598d67d7d66e8413c7844c1f..ea5cc1d2992acffc09303ad27c6e15c1fe9f1e86 100644 (file)
@@ -1,3 +1,13 @@
+2000-10-31  Gabriel Dos Reis  <gdr@codesourcery.com>
+
+       * src/complex.cc (arg, polar): Comment out specializations.
+
+       * include/bits/std_complex.h (complex<>): Remove arg<> friend
+       declaration. 
+       (arg): Define primary template.
+       (polar): Likewise.
+       (conj): Likewise.
+
 2000-10-31  Gabriel Dos Reis  <gdr@codesourcery.com>
 
        * include/c/bits/std_cwctype.h: #undef possible function-like
index 056b12076f4c25c0a91ee235c71410ee7be51bf8..349d2dc6fd6a83d176dcd7fb85ebfafb261a4761 100644 (file)
@@ -177,7 +177,6 @@ namespace std
     friend class complex<long double>;
 
     // friend float abs<>(const complex<float>&);
-    friend float arg<>(const complex<float>&);
 
     friend complex<float> conj<>(const complex<float>&);
 
@@ -254,7 +253,6 @@ namespace std
     friend class complex<long double>;
 
     // friend double abs<>(const complex<double>&);
-    friend double arg<>(const complex<double>&);
 
     friend complex<double> conj<>(const complex<double>&);
     friend complex<double> cos<>(const complex<double>&);
@@ -331,7 +329,6 @@ namespace std
     friend class complex<double>;
 
     // friend long double abs<>(const complex<long double>&);
-    friend long double arg<>(const complex<long double>&);
 
     friend complex<long double> conj<>(const complex<long double>&);
     friend complex<long double> cos<>(const complex<long double>&);
@@ -886,12 +883,12 @@ namespace std
   template<typename _Tp>
     inline bool
     operator==(const complex<_Tp>& __x, const _Tp& __y)
-    { return __x.real() == __y && __x.imag() == 0; }
+    { return __x.real() == __y && __x.imag() == _Tp(); }
 
   template<typename _Tp>
     inline bool
     operator==(const _Tp& __x, const complex<_Tp>& __y)
-    { return __x == __y.real() && 0 == __y.imag(); }
+    { return __x == __y.real() && _Tp() == __y.imag(); }
 
   template<typename _Tp>
     inline bool
@@ -901,12 +898,12 @@ namespace std
   template<typename _Tp>
     inline bool
     operator!=(const complex<_Tp>& __x, const _Tp& __y)
-    { return __x.real() != __y || __x.imag() != 0; }
+    { return __x.real() != __y || __x.imag() != _Tp(); }
 
   template<typename _Tp>
     inline bool
     operator!=(const _Tp& __x, const complex<_Tp>& __y)
-    { return __x != __y.real() || 0 != __y.imag(); }
+    { return __x != __y.real() || _Tp() != __y.imag(); }
 
   template<typename _Tp, typename _CharT, class _Traits>
     basic_istream<_CharT, _Traits>&
@@ -940,7 +937,22 @@ namespace std
       __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()); }
+
+
+  template<typename _Tp>
+    inline complex<_Tp>
+    polar(const _Tp& __rho, const _Tp& __theta)
+    { return complex<_Tp>(__rho * cos(__theta), __rho * sin(__theta)); }
+
+  template<typename _Tp>
+    inline complex<_Tp>
+    conj(const complex<_Tp>& __z)
+    { return complex<_Tp>(__z.real(), -__z.imag()); }
 
   // We use here a few more specializations.
   template<>
index 2f7cfc48a60b514ce9cf92f3337204c0c4ce08a1..d1c5df237d49b9338713ad465529283302ce85d0 100644 (file)
@@ -54,27 +54,27 @@ namespace std
 //      return hypot (__real__ __x._M_value, __imag__ __x._M_value); 
 //    }
 
-  template<>
-  FLT
-  arg(const complex<FLT>& __x)
-  { return carg(__x._M_value); }
+//    template<>
+//    FLT
+//    arg(const complex<FLT>& __x)
+//    { return carg(__x._M_value); }
 
-  template<>
-  complex<FLT>
-  polar(const FLT& __rho, const FLT& __theta)
-  {
-#if 0
-// XXX
-// defined(_GLIBCPP_HAVE_SINCOS) && !defined(__osf__)
-    // Although sincos does exist on OSF3.2 and OSF4.0 we cannot use it
-    // since the necessary types are not defined in the headers.
-    FLT __sinx, __cosx;
-    sincos(__theta, &__sinx, &__cosx);
-    return complex<FLT>(__rho * __cosx, __rho * __sinx);
-#else
-    return complex<FLT>(__rho * cos(__theta), __rho * sin(__theta));
-#endif
-  }
+//    template<>
+//    complex<FLT>
+//    polar(const FLT& __rho, const FLT& __theta)
+//    {
+//  #if 0
+//  // XXX
+//  // defined(_GLIBCPP_HAVE_SINCOS) && !defined(__osf__)
+//      // Although sincos does exist on OSF3.2 and OSF4.0 we cannot use it
+//      // since the necessary types are not defined in the headers.
+//      FLT __sinx, __cosx;
+//      sincos(__theta, &__sinx, &__cosx);
+//      return complex<FLT>(__rho * __cosx, __rho * __sinx);
+//  #else
+//      return complex<FLT>(__rho * cos(__theta), __rho * sin(__theta));
+//  #endif
+//    }
 
   template<>
   complex<FLT>
@@ -147,8 +147,3 @@ namespace std
   { return complex<FLT>(ctanh(__x._M_value)); }
   
 } // namespace std
-
-
-
-
-