summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/std/complex
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include/std/complex')
-rw-r--r--libstdc++-v3/include/std/complex797
1 files changed, 341 insertions, 456 deletions
diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex
index e3feef0918f..947ab0ec9ef 100644
--- a/libstdc++-v3/include/std/complex
+++ b/libstdc++-v3/include/std/complex
@@ -121,29 +121,53 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
/// Default constructor. First parameter is x, second parameter is y.
/// Unspecified parameters default to 0.
- complex(const _Tp& = _Tp(), const _Tp & = _Tp());
+ complex(const _Tp& __r = _Tp(), const _Tp& __i = _Tp())
+ : _M_real(__r), _M_imag(__i) { }
// Lets the compiler synthesize the copy constructor
// complex (const complex<_Tp>&);
/// Copy constructor.
template<typename _Up>
- complex(const complex<_Up>&);
+ complex(const complex<_Up>& __z)
+ : _M_real(__z.real()), _M_imag(__z.imag()) { }
/// Return real part of complex number.
- _Tp& real();
+ _Tp& real()
+ { return _M_real; }
+
/// Return real part of complex number.
- const _Tp& real() const;
+ const _Tp& real() const
+ { return _M_real; }
+
/// Return imaginary part of complex number.
- _Tp& imag();
+ _Tp& imag()
+ { return _M_imag; }
+
/// Return imaginary part of complex number.
- const _Tp& imag() const;
+ const _Tp& imag() const
+ { return _M_imag; }
/// Assign this complex number to scalar @a t.
complex<_Tp>& operator=(const _Tp&);
+
/// Add @a t to this complex number.
- complex<_Tp>& operator+=(const _Tp&);
+ // 26.2.5/1
+ complex<_Tp>&
+ operator+=(const _Tp& __t)
+ {
+ _M_real += __t;
+ return *this;
+ }
+
/// Subtract @a t from this complex number.
- complex<_Tp>& operator-=(const _Tp&);
+ // 26.2.5/3
+ complex<_Tp>&
+ operator-=(const _Tp& __t)
+ {
+ _M_real -= __t;
+ return *this;
+ }
+
/// Multiply this complex number by @a t.
complex<_Tp>& operator*=(const _Tp&);
/// Divide this complex number by @a t.
@@ -168,7 +192,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Up>
complex<_Tp>& operator/=(const complex<_Up>&);
- const complex& __rep() const;
+ const complex& __rep() const
+ { return *this; }
private:
_Tp _M_real;
@@ -176,33 +201,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
};
template<typename _Tp>
- inline _Tp&
- complex<_Tp>::real() { return _M_real; }
-
- template<typename _Tp>
- inline const _Tp&
- complex<_Tp>::real() const { return _M_real; }
-
- template<typename _Tp>
- inline _Tp&
- complex<_Tp>::imag() { return _M_imag; }
-
- template<typename _Tp>
- inline const _Tp&
- complex<_Tp>::imag() const { return _M_imag; }
-
- template<typename _Tp>
- inline
- complex<_Tp>::complex(const _Tp& __r, const _Tp& __i)
- : _M_real(__r), _M_imag(__i) { }
-
- template<typename _Tp>
- template<typename _Up>
- inline
- complex<_Tp>::complex(const complex<_Up>& __z)
- : _M_real(__z.real()), _M_imag(__z.imag()) { }
-
- template<typename _Tp>
complex<_Tp>&
complex<_Tp>::operator=(const _Tp& __t)
{
@@ -211,24 +209,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
return *this;
}
- // 26.2.5/1
- template<typename _Tp>
- inline complex<_Tp>&
- complex<_Tp>::operator+=(const _Tp& __t)
- {
- _M_real += __t;
- return *this;
- }
-
- // 26.2.5/3
- template<typename _Tp>
- inline complex<_Tp>&
- complex<_Tp>::operator-=(const _Tp& __t)
- {
- _M_real -= __t;
- return *this;
- }
-
// 26.2.5/5
template<typename _Tp>
complex<_Tp>&
@@ -307,10 +287,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_M_real = __r / __n;
return *this;
}
-
- template<typename _Tp>
- inline const complex<_Tp>&
- complex<_Tp>::__rep() const { return *this; }
// Operators:
//@{
@@ -995,7 +971,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{
return __x > _Tp() ? std::polar(pow(__x, __y.real()),
__y.imag() * log(__x))
- : std::pow(complex<_Tp>(__x, _Tp()), __y);
+ : std::pow(complex<_Tp>(__x), __y);
}
// 26.2.3 complex specializations
@@ -1008,35 +984,115 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
complex(_ComplexT __z) : _M_value(__z) { }
- complex(float = 0.0f, float = 0.0f);
+ complex(float __r = 0.0f, float __i = 0.0f)
+ {
+ __real__ _M_value = __r;
+ __imag__ _M_value = __i;
+ }
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);
+ explicit complex(const complex<long double>&);
+
+ float& real()
+ { return __real__ _M_value; }
+
+ const float& real() const
+ { return __real__ _M_value; }
+
+ float& imag()
+ { return __imag__ _M_value; }
+
+ const float& imag() const
+ { return __imag__ _M_value; }
+
+ complex<float>&
+ operator=(float __f)
+ {
+ __real__ _M_value = __f;
+ __imag__ _M_value = 0.0f;
+ return *this;
+ }
+
+ complex<float>&
+ operator+=(float __f)
+ {
+ __real__ _M_value += __f;
+ return *this;
+ }
+
+ complex<float>&
+ operator-=(float __f)
+ {
+ __real__ _M_value -= __f;
+ return *this;
+ }
+
+ complex<float>&
+ operator*=(float __f)
+ {
+ _M_value *= __f;
+ return *this;
+ }
+
+ complex<float>&
+ operator/=(float __f)
+ {
+ _M_value /= __f;
+ return *this;
+ }
// Let the compiler synthesize the copy and assignment
// operator. It always does a pretty good job.
- // complex& operator= (const complex&);
+ // complex& operator=(const complex&);
+
template<typename _Tp>
- complex<float>&operator=(const complex<_Tp>&);
+ complex<float>&
+ operator=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value = __z.real();
+ __imag__ _M_value = __z.imag();
+ return *this;
+ }
+
template<typename _Tp>
- complex<float>& operator+=(const complex<_Tp>&);
+ complex<float>&
+ operator+=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value += __z.real();
+ __imag__ _M_value += __z.imag();
+ return *this;
+ }
+
template<class _Tp>
- complex<float>& operator-=(const complex<_Tp>&);
+ complex<float>&
+ operator-=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value -= __z.real();
+ __imag__ _M_value -= __z.imag();
+ return *this;
+ }
+
template<class _Tp>
- complex<float>& operator*=(const complex<_Tp>&);
+ complex<float>&
+ operator*=(const complex<_Tp>& __z)
+ {
+ _ComplexT __t;
+ __real__ __t = __z.real();
+ __imag__ __t = __z.imag();
+ _M_value *= __t;
+ return *this;
+ }
+
template<class _Tp>
- complex<float>&operator/=(const complex<_Tp>&);
+ complex<float>&
+ operator/=(const complex<_Tp>& __z)
+ {
+ _ComplexT __t;
+ __real__ __t = __z.real();
+ __imag__ __t = __z.imag();
+ _M_value /= __t;
+ return *this;
+ }
const _ComplexT& __rep() const { return _M_value; }
@@ -1044,114 +1100,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_ComplexT _M_value;
};
- inline float&
- complex<float>::real()
- { return __real__ _M_value; }
-
- inline const float&
- complex<float>::real() const
- { return __real__ _M_value; }
-
- inline float&
- complex<float>::imag()
- { return __imag__ _M_value; }
-
- inline const float&
- complex<float>::imag() const
- { return __imag__ _M_value; }
-
- inline
- complex<float>::complex(float __r, float __i)
- {
- __real__ _M_value = __r;
- __imag__ _M_value = __i;
- }
-
- inline complex<float>&
- complex<float>::operator=(float __f)
- {
- __real__ _M_value = __f;
- __imag__ _M_value = 0.0f;
- return *this;
- }
-
- inline complex<float>&
- complex<float>::operator+=(float __f)
- {
- __real__ _M_value += __f;
- return *this;
- }
-
- inline complex<float>&
- complex<float>::operator-=(float __f)
- {
- __real__ _M_value -= __f;
- return *this;
- }
-
- inline complex<float>&
- complex<float>::operator*=(float __f)
- {
- _M_value *= __f;
- return *this;
- }
-
- inline complex<float>&
- complex<float>::operator/=(float __f)
- {
- _M_value /= __f;
- return *this;
- }
-
- template<typename _Tp>
- inline complex<float>&
- complex<float>::operator=(const complex<_Tp>& __z)
- {
- __real__ _M_value = __z.real();
- __imag__ _M_value = __z.imag();
- return *this;
- }
-
- template<typename _Tp>
- inline complex<float>&
- complex<float>::operator+=(const complex<_Tp>& __z)
- {
- __real__ _M_value += __z.real();
- __imag__ _M_value += __z.imag();
- return *this;
- }
-
- template<typename _Tp>
- inline complex<float>&
- complex<float>::operator-=(const complex<_Tp>& __z)
- {
- __real__ _M_value -= __z.real();
- __imag__ _M_value -= __z.imag();
- return *this;
- }
-
- template<typename _Tp>
- inline complex<float>&
- complex<float>::operator*=(const complex<_Tp>& __z)
- {
- _ComplexT __t;
- __real__ __t = __z.real();
- __imag__ __t = __z.imag();
- _M_value *= __t;
- return *this;
- }
-
- template<typename _Tp>
- inline complex<float>&
- complex<float>::operator/=(const complex<_Tp>& __z)
- {
- _ComplexT __t;
- __real__ __t = __z.real();
- __imag__ __t = __z.imag();
- _M_value /= __t;
- return *this;
- }
-
// 26.2.3 complex specializations
// complex<double> specialization
template<>
@@ -1162,34 +1110,116 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
complex(_ComplexT __z) : _M_value(__z) { }
- complex(double = 0.0, double = 0.0);
-
- 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);
+ complex(double __r = 0.0, double __i = 0.0)
+ {
+ __real__ _M_value = __r;
+ __imag__ _M_value = __i;
+ }
+
+ complex(const complex<float>& __z)
+ : _M_value(__z.__rep()) { }
+
+ explicit complex(const complex<long double>&);
+
+ double& real()
+ { return __real__ _M_value; }
+
+ const double& real() const
+ { return __real__ _M_value; }
+
+ double& imag()
+ { return __imag__ _M_value; }
+
+ const double& imag() const
+ { return __imag__ _M_value; }
+
+ complex<double>&
+ operator=(double __d)
+ {
+ __real__ _M_value = __d;
+ __imag__ _M_value = 0.0;
+ return *this;
+ }
+
+ complex<double>&
+ operator+=(double __d)
+ {
+ __real__ _M_value += __d;
+ return *this;
+ }
+
+ complex<double>&
+ operator-=(double __d)
+ {
+ __real__ _M_value -= __d;
+ return *this;
+ }
+
+ complex<double>&
+ operator*=(double __d)
+ {
+ _M_value *= __d;
+ return *this;
+ }
+
+ complex<double>&
+ operator/=(double __d)
+ {
+ _M_value /= __d;
+ return *this;
+ }
// The compiler will synthesize this, efficiently.
- // complex& operator= (const complex&);
+ // complex& operator=(const complex&);
+
template<typename _Tp>
- complex<double>& operator=(const complex<_Tp>&);
+ complex<double>&
+ operator=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value = __z.real();
+ __imag__ _M_value = __z.imag();
+ return *this;
+ }
+
template<typename _Tp>
- complex<double>& operator+=(const complex<_Tp>&);
+ complex<double>&
+ operator+=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value += __z.real();
+ __imag__ _M_value += __z.imag();
+ return *this;
+ }
+
template<typename _Tp>
- complex<double>& operator-=(const complex<_Tp>&);
+ complex<double>&
+ operator-=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value -= __z.real();
+ __imag__ _M_value -= __z.imag();
+ return *this;
+ }
+
template<typename _Tp>
- complex<double>& operator*=(const complex<_Tp>&);
+ complex<double>&
+ operator*=(const complex<_Tp>& __z)
+ {
+ _ComplexT __t;
+ __real__ __t = __z.real();
+ __imag__ __t = __z.imag();
+ _M_value *= __t;
+ return *this;
+ }
+
template<typename _Tp>
- complex<double>& operator/=(const complex<_Tp>&);
+ complex<double>&
+ operator/=(const complex<_Tp>& __z)
+ {
+ _ComplexT __t;
+ __real__ __t = __z.real();
+ __imag__ __t = __z.imag();
+ _M_value /= __t;
+ return *this;
+ }
const _ComplexT& __rep() const { return _M_value; }
@@ -1197,114 +1227,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_ComplexT _M_value;
};
- inline double&
- complex<double>::real()
- { return __real__ _M_value; }
-
- inline const double&
- complex<double>::real() const
- { return __real__ _M_value; }
-
- inline double&
- complex<double>::imag()
- { return __imag__ _M_value; }
-
- inline const double&
- complex<double>::imag() const
- { return __imag__ _M_value; }
-
- inline
- complex<double>::complex(double __r, double __i)
- {
- __real__ _M_value = __r;
- __imag__ _M_value = __i;
- }
-
- inline complex<double>&
- complex<double>::operator=(double __d)
- {
- __real__ _M_value = __d;
- __imag__ _M_value = 0.0;
- return *this;
- }
-
- inline complex<double>&
- complex<double>::operator+=(double __d)
- {
- __real__ _M_value += __d;
- return *this;
- }
-
- inline complex<double>&
- complex<double>::operator-=(double __d)
- {
- __real__ _M_value -= __d;
- return *this;
- }
-
- inline complex<double>&
- complex<double>::operator*=(double __d)
- {
- _M_value *= __d;
- return *this;
- }
-
- inline complex<double>&
- complex<double>::operator/=(double __d)
- {
- _M_value /= __d;
- return *this;
- }
-
- template<typename _Tp>
- inline complex<double>&
- complex<double>::operator=(const complex<_Tp>& __z)
- {
- __real__ _M_value = __z.real();
- __imag__ _M_value = __z.imag();
- return *this;
- }
-
- template<typename _Tp>
- inline complex<double>&
- complex<double>::operator+=(const complex<_Tp>& __z)
- {
- __real__ _M_value += __z.real();
- __imag__ _M_value += __z.imag();
- return *this;
- }
-
- template<typename _Tp>
- inline complex<double>&
- complex<double>::operator-=(const complex<_Tp>& __z)
- {
- __real__ _M_value -= __z.real();
- __imag__ _M_value -= __z.imag();
- return *this;
- }
-
- template<typename _Tp>
- inline complex<double>&
- complex<double>::operator*=(const complex<_Tp>& __z)
- {
- _ComplexT __t;
- __real__ __t = __z.real();
- __imag__ __t = __z.imag();
- _M_value *= __t;
- return *this;
- }
-
- template<typename _Tp>
- inline complex<double>&
- complex<double>::operator/=(const complex<_Tp>& __z)
- {
- _ComplexT __t;
- __real__ __t = __z.real();
- __imag__ __t = __z.imag();
- _M_value /= __t;
- return *this;
- }
-
// 26.2.3 complex specializations
// complex<long double> specialization
template<>
@@ -1315,34 +1237,117 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
complex(_ComplexT __z) : _M_value(__z) { }
- complex(long double = 0.0L, long double = 0.0L);
-
- 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);
+ complex(long double __r = 0.0L, long double __i = 0.0L)
+ {
+ __real__ _M_value = __r;
+ __imag__ _M_value = __i;
+ }
+
+ complex(const complex<float>& __z)
+ : _M_value(__z.__rep()) { }
+
+ complex(const complex<double>& __z)
+ : _M_value(__z.__rep()) { }
+
+ long double& real()
+ { return __real__ _M_value; }
+
+ const long double& real() const
+ { return __real__ _M_value; }
+
+ long double& imag()
+ { return __imag__ _M_value; }
+
+ const long double& imag() const
+ { return __imag__ _M_value; }
+
+ complex<long double>&
+ operator=(long double __r)
+ {
+ __real__ _M_value = __r;
+ __imag__ _M_value = 0.0L;
+ return *this;
+ }
+
+ complex<long double>&
+ operator+=(long double __r)
+ {
+ __real__ _M_value += __r;
+ return *this;
+ }
+
+ complex<long double>&
+ operator-=(long double __r)
+ {
+ __real__ _M_value -= __r;
+ return *this;
+ }
+
+ complex<long double>&
+ operator*=(long double __r)
+ {
+ _M_value *= __r;
+ return *this;
+ }
+
+ complex<long double>&
+ operator/=(long double __r)
+ {
+ _M_value /= __r;
+ return *this;
+ }
// The compiler knows how to do this efficiently
- // complex& operator= (const complex&);
+ // complex& operator=(const complex&);
+
template<typename _Tp>
- complex<long double>& operator=(const complex<_Tp>&);
+ complex<long double>&
+ operator=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value = __z.real();
+ __imag__ _M_value = __z.imag();
+ return *this;
+ }
+
template<typename _Tp>
- complex<long double>& operator+=(const complex<_Tp>&);
+ complex<long double>&
+ operator+=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value += __z.real();
+ __imag__ _M_value += __z.imag();
+ return *this;
+ }
+
template<typename _Tp>
- complex<long double>& operator-=(const complex<_Tp>&);
+ complex<long double>&
+ operator-=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value -= __z.real();
+ __imag__ _M_value -= __z.imag();
+ return *this;
+ }
+
template<typename _Tp>
- complex<long double>& operator*=(const complex<_Tp>&);
+ complex<long double>&
+ operator*=(const complex<_Tp>& __z)
+ {
+ _ComplexT __t;
+ __real__ __t = __z.real();
+ __imag__ __t = __z.imag();
+ _M_value *= __t;
+ return *this;
+ }
+
template<typename _Tp>
- complex<long double>& operator/=(const complex<_Tp>&);
+ complex<long double>&
+ operator/=(const complex<_Tp>& __z)
+ {
+ _ComplexT __t;
+ __real__ __t = __z.real();
+ __imag__ __t = __z.imag();
+ _M_value /= __t;
+ return *this;
+ }
const _ComplexT& __rep() const { return _M_value; }
@@ -1350,114 +1355,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_ComplexT _M_value;
};
- inline
- complex<long double>::complex(long double __r, long double __i)
- {
- __real__ _M_value = __r;
- __imag__ _M_value = __i;
- }
-
- inline long double&
- complex<long double>::real()
- { return __real__ _M_value; }
-
- inline const long double&
- complex<long double>::real() const
- { return __real__ _M_value; }
-
- inline long double&
- complex<long double>::imag()
- { return __imag__ _M_value; }
-
- inline const long double&
- complex<long double>::imag() const
- { return __imag__ _M_value; }
-
- inline complex<long double>&
- complex<long double>::operator=(long double __r)
- {
- __real__ _M_value = __r;
- __imag__ _M_value = 0.0L;
- return *this;
- }
-
- inline complex<long double>&
- complex<long double>::operator+=(long double __r)
- {
- __real__ _M_value += __r;
- return *this;
- }
-
- inline complex<long double>&
- complex<long double>::operator-=(long double __r)
- {
- __real__ _M_value -= __r;
- return *this;
- }
-
- inline complex<long double>&
- complex<long double>::operator*=(long double __r)
- {
- _M_value *= __r;
- return *this;
- }
-
- inline complex<long double>&
- complex<long double>::operator/=(long double __r)
- {
- _M_value /= __r;
- return *this;
- }
-
- template<typename _Tp>
- inline complex<long double>&
- complex<long double>::operator=(const complex<_Tp>& __z)
- {
- __real__ _M_value = __z.real();
- __imag__ _M_value = __z.imag();
- return *this;
- }
-
- template<typename _Tp>
- inline complex<long double>&
- complex<long double>::operator+=(const complex<_Tp>& __z)
- {
- __real__ _M_value += __z.real();
- __imag__ _M_value += __z.imag();
- return *this;
- }
-
- template<typename _Tp>
- inline complex<long double>&
- complex<long double>::operator-=(const complex<_Tp>& __z)
- {
- __real__ _M_value -= __z.real();
- __imag__ _M_value -= __z.imag();
- return *this;
- }
-
- template<typename _Tp>
- inline complex<long double>&
- complex<long double>::operator*=(const complex<_Tp>& __z)
- {
- _ComplexT __t;
- __real__ __t = __z.real();
- __imag__ __t = __z.imag();
- _M_value *= __t;
- return *this;
- }
-
- template<typename _Tp>
- inline complex<long double>&
- complex<long double>::operator/=(const complex<_Tp>& __z)
- {
- _ComplexT __t;
- __real__ __t = __z.real();
- __imag__ __t = __z.imag();
- _M_value /= __t;
- return *this;
- }
-
// These bits have to be at the end of this file, so that the
// specializations have all been defined.
// ??? No, they have to be there because of compiler limitation at
@@ -1471,21 +1368,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
: _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()) { }
-
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.