diff options
author | Gabriel Dos Reis <gdr@codesourcery.com> | 2000-11-02 00:21:07 +0000 |
---|---|---|
committer | Gabriel Dos Reis <gdr@gcc.gnu.org> | 2000-11-02 00:21:07 +0000 |
commit | c987141022dacc33ac01298c7a4cdd265e985f7d (patch) | |
tree | a6bbfb11720c5b9d02c11cad36a442ffc2b36470 | |
parent | a97c960093d8b6db44ea89e537af3b6df4df9516 (diff) | |
download | gcc-c987141022dacc33ac01298c7a4cdd265e985f7d.zip gcc-c987141022dacc33ac01298c7a4cdd265e985f7d.tar.gz gcc-c987141022dacc33ac01298c7a4cdd265e985f7d.tar.bz2 |
std_complex.h (complex<>): Remove (cos<>, cosh<>, exp<>, log<>, log<>, sin, sinh<>) friend declarations.
* include/bits/std_complex.h (complex<>): Remove (cos<>, cosh<>,
exp<>, log<>, log<>, sin, sinh<>) friend declarations.
(cos, cosh, sin, sinh): Define primary templates.
* src/complex.cc (cos<>, cosh<>, sin<>, sinh<>): Comment out
definitions.
From-SVN: r37197
-rw-r--r-- | libstdc++-v3/ChangeLog | 9 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/std_complex.h | 73 | ||||
-rw-r--r-- | libstdc++-v3/src/complex.cc | 32 |
3 files changed, 65 insertions, 49 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c68a9eb..2967ba0 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2000-11-02 Gabriel Dos Reis <gdr@codesourcery.com> + + * include/bits/std_complex.h (complex<>): Remove (cos<>, cosh<>, + exp<>, log<>, log<>, sin, sinh<>) friend declarations. + (cos, cosh, sin, sinh): Define primary templates. + + * src/complex.cc (cos<>, cosh<>, sin<>, sinh<>): Comment out + definitions. + 2000-11-01 Benjamin Kosnik <bkoz@purist.soma.redhat.com> * bits/basic_file.h (_M_open_mode): Change signature, move diff --git a/libstdc++-v3/include/bits/std_complex.h b/libstdc++-v3/include/bits/std_complex.h index f82deb7..b2aaa4e 100644 --- a/libstdc++-v3/include/bits/std_complex.h +++ b/libstdc++-v3/include/bits/std_complex.h @@ -177,21 +177,11 @@ namespace std friend class complex<double>; friend class complex<long double>; - // friend float abs<>(const complex<float>&); - //friend complex<float> conj<>(const complex<float>&); - - friend complex<float> cos<>(const complex<float>&); - friend complex<float> cosh<>(const complex<float>&); - friend complex<float> exp<>(const complex<float>&); - friend complex<float> log<>(const complex<float>&); - friend complex<float> log10<>(const complex<float>&); friend complex<float> pow<>(const complex<float>&, int); friend complex<float> pow<>(const complex<float>&, const float&); friend complex<float> pow<>(const complex<float>&, const complex<float>&); friend complex<float> pow<>(const float&, const complex<float>&); - friend complex<float> sin<>(const complex<float>&); - friend complex<float> sinh<>(const complex<float>&); friend complex<float> sqrt<>(const complex<float>&); friend complex<float> tan<>(const complex<float>&); friend complex<float> tanh<>(const complex<float>&); @@ -252,20 +242,11 @@ namespace std friend class complex<float>; friend class complex<long double>; - // friend double abs<>(const complex<double>&); - // friend complex<double> conj<>(const complex<double>&); - friend complex<double> cos<>(const complex<double>&); - friend complex<double> cosh<>(const complex<double>&); - friend complex<double> exp<>(const complex<double>&); - friend complex<double> log<>(const complex<double>&); - friend complex<double> log10<>(const complex<double>&); friend complex<double> pow<>(const complex<double>&, int); friend complex<double> pow<>(const complex<double>&, const double&); friend complex<double> pow<>(const complex<double>&, const complex<double>&); friend complex<double> pow<>(const double&, const complex<double>&); - friend complex<double> sin<>(const complex<double>&); - friend complex<double> sinh<>(const complex<double>&); friend complex<double> sqrt<>(const complex<double>&); friend complex<double> tan<>(const complex<double>&); friend complex<double> tanh<>(const complex<double>&); @@ -327,13 +308,6 @@ namespace std friend class complex<float>; friend class complex<double>; - // friend long double abs<>(const complex<long double>&); - //friend complex<long double> conj<>(const complex<long double>&); - friend complex<long double> cos<>(const complex<long double>&); - friend complex<long double> cosh<>(const complex<long double>&); - friend complex<long double> exp<>(const complex<long double>&); - friend complex<long double> log<>(const complex<long double>&); - friend complex<long double> log10<>(const complex<long double>&); friend complex<long double> pow<>(const complex<long double>&, int); friend complex<long double> pow<>(const complex<long double>&, const long double&); @@ -341,8 +315,6 @@ namespace std const complex<long double>&); friend complex<long double> pow<>(const long double&, const complex<long double>&); - friend complex<long double> sin<>(const complex<long double>&); - friend complex<long double> sinh<>(const complex<long double>&); friend complex<long double> sqrt<>(const complex<long double>&); friend complex<long double> tan<>(const complex<long double>&); friend complex<long double> tanh<>(const complex<long double>&); @@ -776,7 +748,7 @@ namespace std complex<_Tp>& complex<_Tp>::operator*=(const complex<_Up>& __z) { - _Tp __r = _M_real * __z.real() - _M_imag * __z.imag(); + const _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; @@ -789,8 +761,8 @@ namespace std complex<_Tp>& complex<_Tp>::operator/=(const complex<_Up>& __z) { - _Tp __r = _M_real * __z.real() + _M_imag * __z.imag(); - _Tp __n = norm(__z); + const _Tp __r = _M_real * __z.real() + _M_imag * __z.imag(); + const _Tp __n = norm(__z); _M_imag = (_M_real * __z.imag() - _M_imag * __z.real()) / __n; _M_real = __r / __n; return *this; @@ -923,7 +895,7 @@ namespace std { _Tp __x = __z.real(); _Tp __y = __z.imag(); - _Tp __s = abs(__x) + abs(__y); + const _Tp __s = abs(__x) + abs(__y); if (__s == _Tp()) // well ... return __s; __x /= __s; __y /= __s; @@ -962,6 +934,24 @@ namespace std // 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 polar(exp(__z.real()), __z.imag()); } @@ -974,7 +964,24 @@ namespace std inline complex<_Tp> log10(const complex<_Tp>& __z) { return 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)); + } } // namespace std #endif /* _CPP_COMPLEX */ diff --git a/libstdc++-v3/src/complex.cc b/libstdc++-v3/src/complex.cc index 381f73c..f57aa75 100644 --- a/libstdc++-v3/src/complex.cc +++ b/libstdc++-v3/src/complex.cc @@ -76,15 +76,15 @@ namespace std // #endif // } - template<> - complex<FLT> - cos(const complex<FLT>& __x) - { return complex<FLT>(ccos(__x._M_value)); } +// template<> +// complex<FLT> +// cos(const complex<FLT>& __x) +// { return complex<FLT>(ccos(__x._M_value)); } - template<> - complex<FLT> - cosh(const complex<FLT>& __x) - { return complex<FLT>(ccosh(__x._M_value)); } +// template<> +// complex<FLT> +// cosh(const complex<FLT>& __x) +// { return complex<FLT>(ccosh(__x._M_value)); } // template<> // complex<FLT> @@ -121,15 +121,15 @@ namespace std pow(const FLT& __x, const complex<FLT>& __y) { return complex<FLT>(cexp(__y._M_value * log(__x))); } - template<> - complex<FLT> - sin(const complex<FLT>& __x) - { return complex<FLT>(csin(__x._M_value)); } +// template<> +// complex<FLT> +// sin(const complex<FLT>& __x) +// { return complex<FLT>(csin(__x._M_value)); } - template<> - complex<FLT> - sinh(const complex<FLT>& __x) - { return complex<FLT>(csinh(__x._M_value)); } +// template<> +// complex<FLT> +// sinh(const complex<FLT>& __x) +// { return complex<FLT>(csinh(__x._M_value)); } template<> complex<FLT> |