From c14286b068b0dd35349304b82e50085144253c25 Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Tue, 4 Jul 2000 01:20:04 +0000 Subject: [PATCH] [multiple changes] 2000-07-03 Benjamin Kosnik * bits/std_memory.h: Revert. 2000-07-03 Brendan Kehoe * bits/std_complex.h: Fix parens. Format. From-SVN: r34857 --- libstdc++-v3/ChangeLog | 8 + libstdc++-v3/bits/std_complex.h | 1303 +++++++++++++++++++-------------------- 2 files changed, 657 insertions(+), 654 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d98deaf..f7f65d0 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2000-07-03 Benjamin Kosnik + + * bits/std_memory.h: Revert. + +2000-07-03 Brendan Kehoe + + * bits/std_complex.h: Fix parens. Format. + 2000-07-01 Benjamin Kosnik Ulrich Drepper diff --git a/libstdc++-v3/bits/std_complex.h b/libstdc++-v3/bits/std_complex.h index 5064efa..63f7351 100644 --- a/libstdc++-v3/bits/std_complex.h +++ b/libstdc++-v3/bits/std_complex.h @@ -1,6 +1,6 @@ // The template and inlines for the -*- C++ -*- complex number classes. -// Copyright (C) 1997-1999 Free Software Foundation, Inc. +// Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -40,904 +40,897 @@ #include #include - namespace std { - // Forward declarations - template class complex; - template<> class complex; - template<> class complex; - template<> class complex; - template _Tp abs(const complex<_Tp>&); - template _Tp arg(const complex<_Tp>&); + // Forward declarations + template class complex; + template<> class complex; + template<> class complex; + template<> class complex; + + template _Tp abs(const complex<_Tp>&); + template _Tp arg(const complex<_Tp>&); - template complex<_Tp> conj(const complex<_Tp>&); - template complex<_Tp> polar(const _Tp&, const _Tp&); + template complex<_Tp> conj(const complex<_Tp>&); + template complex<_Tp> polar(const _Tp&, const _Tp&); // Transcendentals: - template complex<_Tp> cos(const complex<_Tp>&); - template complex<_Tp> cosh(const complex<_Tp>&); - template complex<_Tp> exp(const complex<_Tp>&); - template complex<_Tp> log(const complex<_Tp>&); - template complex<_Tp> log10(const complex<_Tp>&); - template complex<_Tp> pow(const complex<_Tp>&, int); - template complex<_Tp> pow(const complex<_Tp>&, const _Tp&); - template complex<_Tp> pow (const complex<_Tp>&, - const complex<_Tp>&); - template complex<_Tp> pow(const _Tp&, const complex<_Tp>&); - template complex<_Tp> sin(const complex<_Tp>&); - template complex<_Tp> sinh(const complex<_Tp>&); - template complex<_Tp> sqrt(const complex<_Tp>&); - template complex<_Tp> tan(const complex<_Tp>&); - template complex<_Tp> tanh(const complex<_Tp>&); + template complex<_Tp> cos(const complex<_Tp>&); + template complex<_Tp> cosh(const complex<_Tp>&); + template complex<_Tp> exp(const complex<_Tp>&); + template complex<_Tp> log(const complex<_Tp>&); + template complex<_Tp> log10(const complex<_Tp>&); + template complex<_Tp> pow(const complex<_Tp>&, int); + template complex<_Tp> pow(const complex<_Tp>&, const _Tp&); + template complex<_Tp> pow (const complex<_Tp>&, + const complex<_Tp>&); + template complex<_Tp> pow(const _Tp&, const complex<_Tp>&); + template complex<_Tp> sin(const complex<_Tp>&); + template complex<_Tp> sinh(const complex<_Tp>&); + template complex<_Tp> sqrt(const complex<_Tp>&); + template complex<_Tp> tan(const complex<_Tp>&); + template complex<_Tp> tanh(const complex<_Tp>&); - // - // 26.2.2 Primary template class complex - // - template + // + // 26.2.2 Primary template class complex + // + template class complex { public: - typedef _Tp value_type; - - complex (const _Tp& = _Tp(), const _Tp & = _Tp()); - - // Let's the compiler synthetize the copy constructor - // complex (const complex<_Tp>&); - - template - complex (const complex<_Up>&); + typedef _Tp value_type; + + complex(const _Tp& = _Tp(), const _Tp & = _Tp()); + + // Let's the compiler synthetize the copy constructor + // complex (const complex<_Tp>&); + template + complex(const complex<_Up>&); - _Tp real () const; - _Tp imag () const; - - complex<_Tp>& operator= (const _Tp&); - complex<_Tp>& operator+= (const _Tp&); - complex<_Tp>& operator-= (const _Tp&); - complex<_Tp>& operator*= (const _Tp&); - complex<_Tp>& operator/= (const _Tp&); - - // Let's the compiler synthetize the - // copy and assignment operator - // complex<_Tp>& operator= (const complex<_Tp>&); - - template - complex<_Tp>& operator= (const complex<_Up>&); - template - complex<_Tp>& operator+= (const complex<_Up>&); - template - complex<_Tp>& operator-= (const complex<_Up>&); - template - complex<_Tp>& operator*= (const complex<_Up>&); - template - complex<_Tp>& operator/= (const complex<_Up>&); + _Tp real() const; + _Tp imag() const; + + complex<_Tp>& operator=(const _Tp&); + complex<_Tp>& operator+=(const _Tp&); + complex<_Tp>& operator-=(const _Tp&); + complex<_Tp>& operator*=(const _Tp&); + complex<_Tp>& operator/=(const _Tp&); + + // Let's the compiler synthetize the + // copy and assignment operator + // complex<_Tp>& operator= (const complex<_Tp>&); + template + complex<_Tp>& operator=(const complex<_Up>&); + template + complex<_Tp>& operator+=(const complex<_Up>&); + template + complex<_Tp>& operator-=(const complex<_Up>&); + template + complex<_Tp>& operator*=(const complex<_Up>&); + template + complex<_Tp>& operator/=(const complex<_Up>&); private: - _Tp _M_real, _M_imag; + _Tp _M_real, _M_imag; }; - template + template inline _Tp complex<_Tp>::real() const { return _M_real; } - template + template inline _Tp complex<_Tp>::imag() const { return _M_imag; } - // - // 26.2.3 complex specializations - // - - // - // complex specialization - // - template<> class complex - { - public: - typedef float value_type; - - complex(float = 0.0f, float = 0.0f); + // + // 26.2.3 complex specializations + // + + // + // complex specialization + // + template<> class complex + { + public: + typedef float value_type; + + complex(float = 0.0f, float = 0.0f); #ifdef _GLIBCPP_BUGGY_COMPLEX - complex(const complex& __z) : _M_value(__z._M_value) {} + complex(const complex& __z) : _M_value(__z._M_value) { } #endif - explicit complex(const complex&); - explicit complex(const complex&); + explicit complex(const complex&); + explicit complex(const complex&); - float real() const; - float imag() const; + float real() const; + float imag() const; - complex& operator= (float); - complex& operator+= (float); - complex& operator-= (float); - complex& operator*= (float); - complex& operator/= (float); + complex& operator=(float); + complex& operator+=(float); + complex& operator-=(float); + complex& operator*=(float); + complex& operator/=(float); - // Let's the compiler synthetize the copy and assignment - // operator. It always does a pretty good job. - // complex& operator= (const complex&); - - template - complex&operator= (const complex<_Tp>&); - template - complex& operator+= (const complex<_Tp>&); - template - complex& operator-= (const complex<_Tp>&); - template - complex& operator*= (const complex<_Tp>&); - template - complex&operator/= (const complex<_Tp>&); - - private: - typedef __complex__ float _ComplexT; - _ComplexT _M_value; - - complex(_ComplexT __z) : _M_value(__z) {} + // Let's the compiler synthetize the copy and assignment + // operator. It always does a pretty good job. + // complex& operator= (const complex&); + template + complex&operator=(const complex<_Tp>&); + template + complex& operator+=(const complex<_Tp>&); + template + complex& operator-=(const complex<_Tp>&); + template + complex& operator*=(const complex<_Tp>&); + template + complex&operator/=(const complex<_Tp>&); + + private: + typedef __complex__ float _ComplexT; + _ComplexT _M_value; + + complex(_ComplexT __z) : _M_value(__z) { } - friend class complex; - friend class complex; - - friend float abs<>(const complex&); - friend float arg<>(const complex&); - - friend complex conj<>(const complex&); - - friend complex cos<>(const complex&); - friend complex cosh<>(const complex&); - friend complex exp<>(const complex&); - friend complex log<>(const complex&); - friend complex log10<>(const complex&); - friend complex pow<>(const complex&, int); - friend complex pow<>(const complex&, const float&); - friend complex pow<>(const complex&, - const complex&); - friend complex pow<>(const float&, const complex&); - friend complex sin<>(const complex&); - friend complex sinh<>(const complex&); - friend complex sqrt<>(const complex&); - friend complex tan<>(const complex&); - friend complex tanh<>(const complex&); + friend class complex; + friend class complex; + + friend float abs<>(const complex&); + friend float arg<>(const complex&); + + friend complex conj<>(const complex&); + + friend complex cos<>(const complex&); + friend complex cosh<>(const complex&); + friend complex exp<>(const complex&); + friend complex log<>(const complex&); + friend complex log10<>(const complex&); + friend complex pow<>(const complex&, int); + friend complex pow<>(const complex&, const float&); + friend complex pow<>(const complex&, + const complex&); + friend complex pow<>(const float&, const complex&); + friend complex sin<>(const complex&); + friend complex sinh<>(const complex&); + friend complex sqrt<>(const complex&); + friend complex tan<>(const complex&); + friend complex tanh<>(const complex&); }; - inline float - complex::real() const - { return __real__ _M_value; } + inline float + complex::real() const + { return __real__ _M_value; } - inline float - complex::imag() const - { return __imag__ _M_value; } + inline float + complex::imag() const + { return __imag__ _M_value; } - // - // complex specialization - // - template<> class complex - { - public: - typedef double value_type; + // + // complex specialization + // + template<> class complex + { + public: + typedef double value_type; - complex(double =0.0, double =0.0); + complex(double =0.0, double =0.0); #ifdef _GLIBCPP_BUGGY_COMPLEX - complex(const complex& __z) : _M_value(__z._M_value) {} + complex(const complex& __z) : _M_value(__z._M_value) { } #endif - complex(const complex&); - explicit complex(const complex&); + complex(const complex&); + explicit complex(const complex&); - double real () const; - double imag () const; + double real() const; + double imag() const; - complex& operator= (double); - complex& operator+= (double); - complex& operator-= (double); - complex& operator*= (double); - complex& operator/= (double); - - // The compiler will synthetize this, efficiently. - // complex& operator= (const complex&); - - template - complex& operator= (const complex<_Tp>&); - template - complex& operator+= (const complex<_Tp>&); - template - complex& operator-= (const complex<_Tp>&); - template - complex& operator*= (const complex<_Tp>&); - template - complex& operator/= (const complex<_Tp>&); + complex& operator=(double); + complex& operator+=(double); + complex& operator-=(double); + complex& operator*=(double); + complex& operator/=(double); + + // The compiler will synthetize this, efficiently. + // complex& operator= (const complex&); + template + complex& operator=(const complex<_Tp>&); + template + complex& operator+=(const complex<_Tp>&); + template + complex& operator-=(const complex<_Tp>&); + template + complex& operator*=(const complex<_Tp>&); + template + complex& operator/=(const complex<_Tp>&); - private: - typedef __complex__ double _ComplexT; - _ComplexT _M_value; + private: + typedef __complex__ double _ComplexT; + _ComplexT _M_value; - complex(_ComplexT __z) : _M_value(__z) {} + complex(_ComplexT __z) : _M_value(__z) { } - friend class complex; - friend class complex; - - friend double abs<>(const complex&); - friend double arg<>(const complex&); - - friend complex conj<>(const complex&); - - friend complex cos<>(const complex&); - friend complex cosh<>(const complex&); - friend complex exp<>(const complex&); - friend complex log<>(const complex&); - friend complex log10<>(const complex&); - friend complex pow<>(const complex&, int); - friend complex pow<>(const complex&, const double&); - friend complex pow<>(const complex&, - const complex&); - friend complex pow<>(const double&, const complex&); - friend complex sin<>(const complex&); - friend complex sinh<>(const complex&); - friend complex sqrt<>(const complex&); - friend complex tan<>(const complex&); - friend complex tanh<>(const complex&); - }; + friend class complex; + friend class complex; + + friend double abs<>(const complex&); + friend double arg<>(const complex&); + + friend complex conj<>(const complex&); + friend complex cos<>(const complex&); + friend complex cosh<>(const complex&); + friend complex exp<>(const complex&); + friend complex log<>(const complex&); + friend complex log10<>(const complex&); + friend complex pow<>(const complex&, int); + friend complex pow<>(const complex&, const double&); + friend complex pow<>(const complex&, + const complex&); + friend complex pow<>(const double&, const complex&); + friend complex sin<>(const complex&); + friend complex sinh<>(const complex&); + friend complex sqrt<>(const complex&); + friend complex tan<>(const complex&); + friend complex tanh<>(const complex&); + }; - inline double - complex::real() const - { return __real__ _M_value; } + inline double + complex::real() const + { return __real__ _M_value; } - inline double - complex::imag() const - { return __imag__ _M_value; } + inline double + complex::imag() const + { return __imag__ _M_value; } - // - // complex specialization - // - template<> class complex - { - public: - typedef long double value_type; + // + // complex specialization + // + template<> class complex + { + public: + typedef long double value_type; - complex(long double = 0.0L, long double = 0.0L); + complex(long double = 0.0L, long double = 0.0L); #ifdef _GLIBCPP_BUGGY_COMPLEX - complex(const complex& __z) : _M_value(__z._M_value) {} + complex(const complex& __z) : _M_value(__z._M_value) { } #endif - complex(const complex&); - complex(const complex&); - - long double real() const; - long double imag() const; - - complex& operator= (long double); - complex& operator+= (long double); - complex& operator-= (long double); - complex& operator*= (long double); - complex& operator/= (long double); - - // The compiler knows how to do this efficiently - // complex& operator= (const complex&); - - template - complex& operator= (const complex<_Tp>&); - template - complex& operator+= (const complex<_Tp>&); - template - complex& operator-= (const complex<_Tp>&); - template - complex& operator*= (const complex<_Tp>&); - template - complex& operator/= (const complex<_Tp>&); + complex(const complex&); + complex(const complex&); - private: - typedef __complex__ long double _ComplexT; - _ComplexT _M_value; - - complex(_ComplexT __z) : _M_value(__z) {} - - friend class complex; - friend class complex; - - friend long double abs<>(const complex&); - friend long double arg<>(const complex&); - - friend complex conj<>(const complex&); - - friend complex cos<>(const complex&); - friend complex cosh<>(const complex&); - friend complex exp<>(const complex&); - friend complex log<>(const complex&); - friend complex log10<>(const complex&); - friend complex pow<>(const complex&, int); - friend complex pow<>(const complex&, - const long double&); - friend complex pow<>(const complex&, - const complex&); - friend complex pow<>(const long double&, - const complex&); - friend complex sin<>(const complex&); - friend complex sinh<>(const complex&); - friend complex sqrt<>(const complex&); - friend complex tan<>(const complex&); - friend complex tanh<>(const complex&); - }; + long double real() const; + long double imag() const; - inline - complex::complex(long double __r, long double __i) - { - __real__ _M_value = __r; - __imag__ _M_value = __i; - } + complex& operator= (long double); + complex& operator+= (long double); + complex& operator-= (long double); + complex& operator*= (long double); + complex& operator/= (long double); - inline - complex::complex(const complex& __z) - : _M_value(_ComplexT(__z._M_value)) {} + // The compiler knows how to do this efficiently + // complex& operator= (const complex&); - inline - complex::complex(const complex& __z) - : _M_value(_ComplexT(__z._M_value)) {} + template + complex& operator=(const complex<_Tp>&); + template + complex& operator+=(const complex<_Tp>&); + template + complex& operator-=(const complex<_Tp>&); + template + complex& operator*=(const complex<_Tp>&); + template + complex& operator/=(const complex<_Tp>&); - inline long double - complex::real() const - { return __real__ _M_value; } + private: + typedef __complex__ long double _ComplexT; + _ComplexT _M_value; - inline long double - complex::imag() const - { return __imag__ _M_value; } + complex(_ComplexT __z) : _M_value(__z) { } - inline complex& - complex::operator= (long double __r) - { - __real__ _M_value = __r; - __imag__ _M_value = 0.0L; - return *this; - } + friend class complex; + friend class complex; - inline complex& - complex::operator+= (long double __r) - { - __real__ _M_value += __r; - return *this; - } + friend long double abs<>(const complex&); + friend long double arg<>(const complex&); - inline complex& - complex::operator-= (long double __r) - { - __real__ _M_value -= __r; - return *this; - } - - inline complex& - complex::operator*= (long double __r) - { - __real__ _M_value *= __r; - return *this; - } + friend complex conj<>(const complex&); + friend complex cos<>(const complex&); + friend complex cosh<>(const complex&); + friend complex exp<>(const complex&); + friend complex log<>(const complex&); + friend complex log10<>(const complex&); + friend complex pow<>(const complex&, int); + friend complex pow<>(const complex&, + const long double&); + friend complex pow<>(const complex&, + const complex&); + friend complex pow<>(const long double&, + const complex&); + friend complex sin<>(const complex&); + friend complex sinh<>(const complex&); + friend complex sqrt<>(const complex&); + friend complex tan<>(const complex&); + friend complex tanh<>(const complex&); + }; + inline + complex::complex(long double __r, long double __i) + { + __real__ _M_value = __r; + __imag__ _M_value = __i; + } + + inline + complex::complex(const complex& __z) + : _M_value(_ComplexT(__z._M_value)) { } + + inline + complex::complex(const complex& __z) + : _M_value(_ComplexT(__z._M_value)) { } + + inline long double + complex::real() const + { return __real__ _M_value; } + + inline long double + complex::imag() const + { return __imag__ _M_value; } + + inline complex& + complex::operator=(long double __r) + { + __real__ _M_value = __r; + __imag__ _M_value = 0.0L; + return *this; + } + + inline complex& + complex::operator+=(long double __r) + { + __real__ _M_value += __r; + return *this; + } + + inline complex& + complex::operator-=(long double __r) + { + __real__ _M_value -= __r; + return *this; + } + + inline complex& + complex::operator*=(long double __r) + { + __real__ _M_value *= __r; + return *this; + } + + inline complex& + complex::operator/=(long double __r) + { + __real__ _M_value /= __r; + return *this; + } + + template inline complex& - complex::operator/= (long double __r) + complex::operator=(const complex<_Tp>& __z) { - __real__ _M_value /= __r; - return *this; + __real__ _M_value = __z.real(); + __imag__ _M_value = __z.imag(); + return *this; } - template + template inline complex& - complex::operator= (const complex<_Tp>& __z) + complex::operator+=(const complex<_Tp>& __z) { - __real__ _M_value = __z.real(); - __imag__ _M_value = __z.imag(); - return *this; + __real__ _M_value += __z.real(); + __imag__ _M_value += __z.imag(); + return *this; } - template + template inline complex& - complex::operator+= (const complex<_Tp>& __z) + complex::operator-=(const complex<_Tp>& __z) { - __real__ _M_value += __z.real(); - __imag__ _M_value += __z.imag(); - return *this; - } - - template - inline complex& - complex::operator-= (const complex<_Tp>& __z) - { - __real__ _M_value -= __z.real(); - __imag__ _M_value -= __z.imag(); - return *this; + __real__ _M_value -= __z.real(); + __imag__ _M_value -= __z.imag(); + return *this; } - template + template inline complex& - complex::operator*= (const complex<_Tp>& __z) + complex::operator*=(const complex<_Tp>& __z) { - _ComplexT __t; - __real__ __t = __z.real(); - __imag__ __t = __z.imag(); - _M_value *= __t; - return *this; + _ComplexT __t; + __real__ __t = __z.real(); + __imag__ __t = __z.imag(); + _M_value *= __t; + return *this; } - template + template inline complex& - complex::operator/= (const complex<_Tp>& __z) - { - _ComplexT __t; - __real__ __t = __z.real(); - __imag__ __t = __z.imag(); - _M_value /= __t; - return *this; - } - - // - // complex continued. - // - inline - complex::complex(float r, float i) - { - __real__ _M_value = r; - __imag__ _M_value = i; - } - - inline - complex::complex(const complex& __z) - : _M_value(_ComplexT(__z._M_value)) {} - - inline - complex::complex(const complex& __z) - : _M_value(_ComplexT(__z._M_value)) {} - - inline complex& - complex::operator= (float __f) - { - __real__ _M_value = __f; - __imag__ _M_value = 0.0f; - return *this; - } - - inline complex& - complex::operator+= (float __f) - { - __real__ _M_value += __f; - return *this; - } - - inline complex& - complex::operator-= (float __f) - { - __real__ _M_value -= __f; - return *this; - } - - inline complex& - complex::operator*= (float __f) - { - _M_value *= __f; - return *this; - } - - inline complex& - complex::operator/= (float __f) - { - _M_value /= __f; - return *this; - } - - template - inline complex& - complex::operator= (const complex<_Tp>& __z) - { - __real__ _M_value = __z.real(); - __imag__ _M_value = __z.imag(); - return *this; - } - - template - inline complex& - complex::operator+= (const complex<_Tp>& __z) - { - __real__ _M_value += __z.real(); - __imag__ _M_value += __z.imag(); - return *this; - } + complex::operator/=(const complex<_Tp>& __z) + { + _ComplexT __t; + __real__ __t = __z.real(); + __imag__ __t = __z.imag(); + _M_value /= __t; + return *this; + } + + // + // complex continued. + // + inline + complex::complex(float r, float i) + { + __real__ _M_value = r; + __imag__ _M_value = i; + } + + inline + complex::complex(const complex& __z) + : _M_value(_ComplexT(__z._M_value)) { } + + inline + complex::complex(const complex& __z) + : _M_value(_ComplexT(__z._M_value)) { } + + inline complex& + complex::operator=(float __f) + { + __real__ _M_value = __f; + __imag__ _M_value = 0.0f; + return *this; + } + + inline complex& + complex::operator+=(float __f) + { + __real__ _M_value += __f; + return *this; + } + + inline complex& + complex::operator-=(float __f) + { + __real__ _M_value -= __f; + return *this; + } + + inline complex& + complex::operator*=(float __f) + { + _M_value *= __f; + return *this; + } + + inline complex& + complex::operator/=(float __f) + { + _M_value /= __f; + return *this; + } + + template + inline complex& + complex::operator=(const complex<_Tp>& __z) + { + __real__ _M_value = __z.real(); + __imag__ _M_value = __z.imag(); + return *this; + } + + template + inline complex& + complex::operator+=(const complex<_Tp>& __z) + { + __real__ _M_value += __z.real(); + __imag__ _M_value += __z.imag(); + return *this; + } - template + template inline complex& - complex::operator-= (const complex<_Tp>& __z) + complex::operator-=(const complex<_Tp>& __z) { - __real__ _M_value -= __z.real(); - __imag__ _M_value -= __z.real(); - return *this; - } + __real__ _M_value -= __z.real(); + __imag__ _M_value -= __z.real(); + return *this; + } - template + template inline complex& - complex::operator*= (const complex<_Tp>& __z) + complex::operator*=(const complex<_Tp>& __z) { - _ComplexT __t; - __real__ __t = __z.real(); - __imag__ __t = __z.imag(); - _M_value *= __t; - return *this; + _ComplexT __t; + __real__ __t = __z.real(); + __imag__ __t = __z.imag(); + _M_value *= __t; + return *this; } - template + template inline complex& - complex::operator/= (const complex<_Tp>& __z) - { - _ComplexT __t; - __real__ __t = __z.real(); - __imag__ __t = __z.imag(); - _M_value /= __t; - return *this; - } - - - // - // complex continued. - // - inline - complex::complex(double __r, double __i) - { - __real__ _M_value = __r; - __imag__ _M_value = __i; - } - - inline - complex::complex(const complex& __z) - : _M_value(_ComplexT(__z._M_value)) {} - - inline - complex::complex(const complex& __z) - { - __real__ _M_value = __z.real(); - __imag__ _M_value = __z.imag(); - } - - inline complex& - complex::operator= (double __d) - { - __real__ _M_value = __d; - __imag__ _M_value = 0.0; - return *this; - } - - inline complex& - complex::operator+= (double __d) - { - __real__ _M_value += __d; - return *this; - } - - inline complex& - complex::operator-= (double __d) - { - __real__ _M_value -= __d; - return *this; - } - + complex::operator/=(const complex<_Tp>& __z) + { + _ComplexT __t; + __real__ __t = __z.real(); + __imag__ __t = __z.imag(); + _M_value /= __t; + return *this; + } + + + // + // complex continued. + // + inline + complex::complex(double __r, double __i) + { + __real__ _M_value = __r; + __imag__ _M_value = __i; + } + + inline + complex::complex(const complex& __z) + : _M_value(_ComplexT(__z._M_value)) { } + + inline + complex::complex(const complex& __z) + { + __real__ _M_value = __z.real(); + __imag__ _M_value = __z.imag(); + } + + inline complex& + complex::operator=(double __d) + { + __real__ _M_value = __d; + __imag__ _M_value = 0.0; + return *this; + } + + inline complex& + complex::operator+=(double __d) + { + __real__ _M_value += __d; + return *this; + } + + inline complex& + complex::operator-=(double __d) + { + __real__ _M_value -= __d; + return *this; + } + + inline complex& + complex::operator*=(double __d) + { + _M_value *= __d; + return *this; + } + + inline complex& + complex::operator/=(double __d) + { + _M_value /= __d; + return *this; + } + + template inline complex& - complex::operator*= (double __d) + complex::operator=(const complex<_Tp>& __z) { - _M_value *= __d; - return *this; - } - - inline complex& - complex::operator/= (double __d) - { - _M_value /= __d; - return *this; - } - - template - inline complex& - complex::operator= (const complex<_Tp>& __z) - { - __real__ _M_value = __z.real(); - __imag__ _M_value = __z.imag(); - return *this; + __real__ _M_value = __z.real(); + __imag__ _M_value = __z.imag(); + return *this; } - template + template inline complex& - complex::operator+= (const complex<_Tp>& __z) + complex::operator+=(const complex<_Tp>& __z) { - __real__ _M_value += __z.real(); - __imag__ _M_value += __z.imag(); - return *this; + __real__ _M_value += __z.real(); + __imag__ _M_value += __z.imag(); + return *this; } - template + template inline complex& - complex::operator-= (const complex<_Tp>& __z) + complex::operator-=(const complex<_Tp>& __z) { - __real__ _M_value -= __z.real(); - __imag__ _M_value -= __z.imag(); - return *this; + __real__ _M_value -= __z.real(); + __imag__ _M_value -= __z.imag(); + return *this; } - template + template inline complex& - complex::operator*= (const complex<_Tp>& __z) + complex::operator*=(const complex<_Tp>& __z) { - _ComplexT __t; - __real__ __t = __z.real(); - __imag__ __t = __z.imag(); - _M_value *= __t; - return *this; + _ComplexT __t; + __real__ __t = __z.real(); + __imag__ __t = __z.imag(); + _M_value *= __t; + return *this; } - template + template inline complex& - complex::operator/= (const complex<_Tp>& __z) + complex::operator/=(const complex<_Tp>& __z) { - _ComplexT __t; - __real__ __t = __z.real(); - __imag__ __t = __z.imag(); - _M_value /= __t; - return *this; + _ComplexT __t; + __real__ __t = __z.real(); + __imag__ __t = __z.imag(); + _M_value /= __t; + return *this; } - // - // Primary template class complex continued. - // - // 26.2.4 - template + // + // Primary template class complex continued. + // + // 26.2.4 + template inline complex<_Tp>::complex(const _Tp& __r, const _Tp& __i) - : _M_real(__r), _M_imag(__i) {} + : _M_real(__r), _M_imag(__i) { } - template - template + template + template inline complex<_Tp>::complex(const complex<_Up>& __z) - : _M_real(__z.real()), _M_imag(__z.imag()) {} + : _M_real(__z.real()), _M_imag(__z.imag()) { } - // 26.2.7/6 - template + // 26.2.7/6 + template inline complex<_Tp> conj(const complex<_Tp>& __z) { return complex<_Tp>(__z.real(), -__z.imag()); } - // 26.2.7/4 - template + // 26.2.7/4 + template inline _Tp norm(const complex<_Tp>& __z) { - // XXX: Grammar school computation - return __z.real() * __z.real() + __z.imag() * __z.imag(); + // XXX: Grammar school computation + return __z.real() * __z.real() + __z.imag() * __z.imag(); } - template + template complex<_Tp>& - complex<_Tp>::operator= (const _Tp& __t) + complex<_Tp>::operator=(const _Tp& __t) { - _M_real = __t; - _M_imag = _Tp(); - return *this; - } + _M_real = __t; + _M_imag = _Tp(); + return *this; + } - // 26.2.5/1 - template + // 26.2.5/1 + template inline complex<_Tp>& - complex<_Tp>::operator+= (const _Tp& __t) + complex<_Tp>::operator+=(const _Tp& __t) { - _M_real += __t; - return *this; + _M_real += __t; + return *this; } - // 26.2.5/3 - template + // 26.2.5/3 + template inline complex<_Tp>& - complex<_Tp>::operator-= (const _Tp& __t) + complex<_Tp>::operator-=(const _Tp& __t) { - _M_real -= __t; - return *this; + _M_real -= __t; + return *this; } - // 26.2.5/5 - template + // 26.2.5/5 + template complex<_Tp>& - complex<_Tp>::operator*= (const _Tp& __t) + complex<_Tp>::operator*=(const _Tp& __t) { - _M_real *= __t; - _M_imag *= __t; - return *this; + _M_real *= __t; + _M_imag *= __t; + return *this; } - // 26.2.5/7 - template + // 26.2.5/7 + template complex<_Tp>& - complex<_Tp>::operator/= (const _Tp& __t) + complex<_Tp>::operator/=(const _Tp& __t) { - _M_real /= __t; - _M_imag /= __t; - return *this; + _M_real /= __t; + _M_imag /= __t; + return *this; } - template - template + template + template complex<_Tp>& - complex<_Tp>::operator= (const complex<_Up>& __z) + complex<_Tp>::operator=(const complex<_Up>& __z) { - _M_real = __z.real(); - _M_imag = __z.imag(); - return *this; + _M_real = __z.real(); + _M_imag = __z.imag(); + return *this; } - // 26.2.5/9 - template - template + // 26.2.5/9 + template + template complex<_Tp>& - complex<_Tp>::operator+= (const complex<_Up>& __z) + complex<_Tp>::operator+=(const complex<_Up>& __z) { - _M_real += __z.real(); - _M_imag += __z.imag(); - return *this; + _M_real += __z.real(); + _M_imag += __z.imag(); + return *this; } - // 26.2.5/11 - template - template + // 26.2.5/11 + template + template complex<_Tp>& - complex<_Tp>::operator-= (const complex<_Up>& __z) + complex<_Tp>::operator-=(const complex<_Up>& __z) { - _M_real -= __z.real(); - _M_imag -= __z.imag(); - return *this; + _M_real -= __z.real(); + _M_imag -= __z.imag(); + return *this; } - // 26.2.5/13 - // XXX: this is a grammar school implementation. - template - template + // 26.2.5/13 + // XXX: this is a grammar school implementation. + template + template complex<_Tp>& - complex<_Tp>::operator*= (const complex<_Up>& __z) + 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; + _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 - template + // 26.2.5/15 + // XXX: this is a grammar school implementation. + template + template complex<_Tp>& - complex<_Tp>::operator/= (const complex<_Up>& __z) + 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; + _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 + // Operators: + template inline complex<_Tp> operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) { return complex<_Tp> (__x) += __y; } - template + template inline complex<_Tp> operator+(const complex<_Tp>& __x, const _Tp& __y) { return complex<_Tp> (__x) += __y; } - template + template inline complex<_Tp> operator+(const _Tp& __x, const complex<_Tp>& __y) { return complex<_Tp> (__y) += __x; } - template + template inline complex<_Tp> operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) { return complex<_Tp> (__x) -= __y; } - template + template inline complex<_Tp> operator-(const complex<_Tp>& __x, const _Tp& __y) { return complex<_Tp> (__x) -= __y; } - template + template inline complex<_Tp> operator-(const _Tp& __x, const complex<_Tp>& __y) { return complex<_Tp> (__x) -= __y; } - template + template inline complex<_Tp> operator*(const complex<_Tp>& __x, const complex<_Tp>& __y) { return complex<_Tp> (__x) *= __y; } - template + template inline complex<_Tp> operator*(const complex<_Tp>& __x, const _Tp& __y) { return complex<_Tp> (__x) *= __y; } - template + template inline complex<_Tp> operator*(const _Tp& __x, const complex<_Tp>& __y) { return complex<_Tp> (__y) *= __x; } - template + template inline complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y) { return complex<_Tp> (__x) /= __y; } - template + template inline complex<_Tp> operator/(const complex<_Tp>& __x, const _Tp& __y) { return complex<_Tp> (__x) /= __y; } - template + template inline complex<_Tp> operator/(const _Tp& __x, const complex<_Tp>& __y) { return complex<_Tp> (__x) /= __y; } - template + template inline complex<_Tp> operator+(const complex<_Tp>& __x) { return __x; } - template + template inline complex<_Tp> operator-(const complex<_Tp>& __x) { return complex<_Tp>(-__x.real(), -__x.imag()); } - template + template inline bool operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) - { return __x.real() == __y.real() && __x.imag == __y.imag(); } + { return __x.real() == __y.real() && __x.imag() == __y.imag(); } - template + template inline bool operator==(const complex<_Tp>& __x, const _Tp& __y) { return __x.real() == __y && __x.imag() == 0; } - template + template inline bool operator==(const _Tp& __x, const complex<_Tp>& __y) { return __x == __y.real() && 0 == __y.imag(); } - template + template inline bool operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) { return __x.real() != __y.real() || __x.imag() != __y.imag(); } - template + template inline bool operator!=(const complex<_Tp>& __x, const _Tp& __y) - { return __x.real() != __y || __x.imag() != 0; } + { return __x.real() != __y || __x.imag() != 0; } - template + template inline bool operator!=(const _Tp& __x, const complex<_Tp>& __y) { return __x != __y.real() || 0 != __y.imag(); } - template + template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>&, complex<_Tp>&); - template + template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>&, const complex<_Tp>&); - // Values: - template + // Values: + template inline _Tp - real (const complex<_Tp>& __z) + real(const complex<_Tp>& __z) { return __z.real(); } - template + template inline _Tp - imag (const complex<_Tp>& __z) + imag(const complex<_Tp>& __z) { return __z.imag(); } - // We use here a few more specializations. - template<> + // We use here a few more specializations. + template<> inline complex conj(const complex &__x) #ifdef _GLIBCPP_BUGGY_FLOAT_COMPLEX @@ -946,21 +939,23 @@ namespace std return __tmpf; } #else - { return complex(~__x._M_value); } + { return complex(~__x._M_value); } #endif - template<> + template<> inline complex conj(const complex &__x) { return complex (~__x._M_value); } - template<> + template<> inline complex conj(const complex &__x) - { - return complex (~__x._M_value); - } + { return complex (~__x._M_value); } } // namespace std #endif /* _CPP_COMPLEX */ + + + + -- 2.7.4