1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/tools/stlport/stl/_complex.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,947 @@
1.4 +/*
1.5 + * Copyright (c) 1999
1.6 + * Silicon Graphics Computer Systems, Inc.
1.7 + *
1.8 + * Copyright (c) 1999
1.9 + * Boris Fomitchev
1.10 + *
1.11 + * This material is provided "as is", with absolutely no warranty expressed
1.12 + * or implied. Any use is at your own risk.
1.13 + *
1.14 + * Permission to use or copy this software for any purpose is hereby granted
1.15 + * without fee, provided the above notices are retained on all copies.
1.16 + * Permission to modify the code and to distribute modified code is granted,
1.17 + * provided the above notices are retained, and a notice that the code was
1.18 + * modified is included with the above copyright notice.
1.19 + *
1.20 + */
1.21 +#ifndef _STLP_INTERNAL_COMPLEX
1.22 +#define _STLP_INTERNAL_COMPLEX
1.23 +
1.24 +// This header declares the template class complex, as described in
1.25 +// in the draft C++ standard. Single-precision complex numbers
1.26 +// are complex<float>, double-precision are complex<double>, and
1.27 +// quad precision are complex<long double>.
1.28 +
1.29 +// Note that the template class complex is declared within namespace
1.30 +// std, as called for by the draft C++ standard.
1.31 +
1.32 +#ifndef _STLP_INTERNAL_CMATH
1.33 +# include <stl/_cmath.h>
1.34 +#endif
1.35 +
1.36 +_STLP_BEGIN_NAMESPACE
1.37 +
1.38 +#if !defined (_STLP_NO_COMPLEX_SPECIALIZATIONS) //*TY 02/25/2000 - added for MPW compiler workaround
1.39 +
1.40 +template <class _Tp> struct complex;
1.41 +
1.42 +_STLP_TEMPLATE_NULL struct _STLP_CLASS_DECLSPEC complex<float>;
1.43 +_STLP_TEMPLATE_NULL struct _STLP_CLASS_DECLSPEC complex<double>;
1.44 +# if !defined (_STLP_NO_LONG_DOUBLE)
1.45 +_STLP_TEMPLATE_NULL struct _STLP_CLASS_DECLSPEC complex<long double>;
1.46 +# endif
1.47 +#endif /* _STLP_NO_COMPLEX_SPECIALIZATIONS */
1.48 +
1.49 +template <class _Tp>
1.50 +struct complex {
1.51 + typedef _Tp value_type;
1.52 + typedef complex<_Tp> _Self;
1.53 +
1.54 + // Constructors, destructor, assignment operator.
1.55 + complex() : _M_re(0), _M_im(0) {}
1.56 + complex(const value_type& __x)
1.57 + : _M_re(__x), _M_im(0) {}
1.58 + complex(const value_type& __x, const value_type& __y)
1.59 + : _M_re(__x), _M_im(__y) {}
1.60 + complex(const _Self& __z)
1.61 + : _M_re(__z._M_re), _M_im(__z._M_im) {}
1.62 +
1.63 + _Self& operator=(const _Self& __z) {
1.64 + _M_re = __z._M_re;
1.65 + _M_im = __z._M_im;
1.66 + return *this;
1.67 + }
1.68 +
1.69 +#if defined (_STLP_MEMBER_TEMPLATES) && (defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) || defined(_STLP_NO_COMPLEX_SPECIALIZATIONS))
1.70 + template <class _Tp2>
1.71 + explicit complex(const complex<_Tp2>& __z)
1.72 + : _M_re(__z._M_re), _M_im(__z._M_im) {}
1.73 +
1.74 + template <class _Tp2>
1.75 + _Self& operator=(const complex<_Tp2>& __z) {
1.76 + _M_re = __z._M_re;
1.77 + _M_im = __z._M_im;
1.78 + return *this;
1.79 + }
1.80 +#endif /* _STLP_MEMBER_TEMPLATES */
1.81 +
1.82 + // Element access.
1.83 + value_type real() const { return _M_re; }
1.84 + value_type imag() const { return _M_im; }
1.85 +
1.86 + // Arithmetic op= operations involving one real argument.
1.87 +
1.88 + _Self& operator= (const value_type& __x) {
1.89 + _M_re = __x;
1.90 + _M_im = 0;
1.91 + return *this;
1.92 + }
1.93 + _Self& operator+= (const value_type& __x) {
1.94 + _M_re += __x;
1.95 + return *this;
1.96 + }
1.97 + _Self& operator-= (const value_type& __x) {
1.98 + _M_re -= __x;
1.99 + return *this;
1.100 + }
1.101 + _Self& operator*= (const value_type& __x) {
1.102 + _M_re *= __x;
1.103 + _M_im *= __x;
1.104 + return *this;
1.105 + }
1.106 + _Self& operator/= (const value_type& __x) {
1.107 + _M_re /= __x;
1.108 + _M_im /= __x;
1.109 + return *this;
1.110 + }
1.111 +
1.112 + // Arithmetic op= operations involving two complex arguments.
1.113 +
1.114 + static void _STLP_CALL _div(const value_type& __z1_r, const value_type& __z1_i,
1.115 + const value_type& __z2_r, const value_type& __z2_i,
1.116 + value_type& __res_r, value_type& __res_i);
1.117 +
1.118 + static void _STLP_CALL _div(const value_type& __z1_r,
1.119 + const value_type& __z2_r, const value_type& __z2_i,
1.120 + value_type& __res_r, value_type& __res_i);
1.121 +
1.122 +#if defined (_STLP_MEMBER_TEMPLATES) // && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
1.123 +
1.124 + template <class _Tp2> _Self& operator+= (const complex<_Tp2>& __z) {
1.125 + _M_re += __z._M_re;
1.126 + _M_im += __z._M_im;
1.127 + return *this;
1.128 + }
1.129 +
1.130 + template <class _Tp2> _Self& operator-= (const complex<_Tp2>& __z) {
1.131 + _M_re -= __z._M_re;
1.132 + _M_im -= __z._M_im;
1.133 + return *this;
1.134 + }
1.135 +
1.136 + template <class _Tp2> _Self& operator*= (const complex<_Tp2>& __z) {
1.137 + value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
1.138 + value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
1.139 + _M_re = __r;
1.140 + _M_im = __i;
1.141 + return *this;
1.142 + }
1.143 +
1.144 + template <class _Tp2> _Self& operator/= (const complex<_Tp2>& __z) {
1.145 + value_type __r;
1.146 + value_type __i;
1.147 + _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
1.148 + _M_re = __r;
1.149 + _M_im = __i;
1.150 + return *this;
1.151 + }
1.152 +#endif /* _STLP_MEMBER_TEMPLATES */
1.153 +
1.154 + _Self& operator+= (const _Self& __z) {
1.155 + _M_re += __z._M_re;
1.156 + _M_im += __z._M_im;
1.157 + return *this;
1.158 + }
1.159 +
1.160 + _Self& operator-= (const _Self& __z) {
1.161 + _M_re -= __z._M_re;
1.162 + _M_im -= __z._M_im;
1.163 + return *this;
1.164 + }
1.165 +
1.166 + _Self& operator*= (const _Self& __z) {
1.167 + value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
1.168 + value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
1.169 + _M_re = __r;
1.170 + _M_im = __i;
1.171 + return *this;
1.172 + }
1.173 +
1.174 + _Self& operator/= (const _Self& __z) {
1.175 + value_type __r;
1.176 + value_type __i;
1.177 + _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
1.178 + _M_re = __r;
1.179 + _M_im = __i;
1.180 + return *this;
1.181 + }
1.182 +
1.183 + // Data members.
1.184 + value_type _M_re;
1.185 + value_type _M_im;
1.186 +};
1.187 +
1.188 +#if !defined (_STLP_NO_COMPLEX_SPECIALIZATIONS) //*TY 02/25/2000 - added for MPW compiler workaround
1.189 +// Explicit specializations for float, double, long double. The only
1.190 +// reason for these specializations is to enable automatic conversions
1.191 +// from complex<float> to complex<double>, and complex<double> to
1.192 +// complex<long double>.
1.193 +
1.194 +_STLP_TEMPLATE_NULL
1.195 +struct _STLP_CLASS_DECLSPEC complex<float> {
1.196 + typedef float value_type;
1.197 + typedef complex<float> _Self;
1.198 + // Constructors, destructor, assignment operator.
1.199 +
1.200 + complex(value_type __x = 0.0f, value_type __y = 0.0f)
1.201 + : _M_re(__x), _M_im(__y) {}
1.202 +
1.203 + complex(const complex<float>& __z) : _M_re(__z._M_re), _M_im(__z._M_im) {}
1.204 +
1.205 + inline explicit complex(const complex<double>& __z);
1.206 +# ifndef _STLP_NO_LONG_DOUBLE
1.207 + inline explicit complex(const complex<long double>& __z);
1.208 +# endif
1.209 + // Element access.
1.210 + value_type real() const { return _M_re; }
1.211 + value_type imag() const { return _M_im; }
1.212 +
1.213 + // Arithmetic op= operations involving one real argument.
1.214 +
1.215 + _Self& operator= (value_type __x) {
1.216 + _M_re = __x;
1.217 + _M_im = 0.0f;
1.218 + return *this;
1.219 + }
1.220 + _Self& operator+= (value_type __x) {
1.221 + _M_re += __x;
1.222 + return *this;
1.223 + }
1.224 + _Self& operator-= (value_type __x) {
1.225 + _M_re -= __x;
1.226 + return *this;
1.227 + }
1.228 + _Self& operator*= (value_type __x) {
1.229 + _M_re *= __x;
1.230 + _M_im *= __x;
1.231 + return *this;
1.232 + }
1.233 + _Self& operator/= (value_type __x) {
1.234 + _M_re /= __x;
1.235 + _M_im /= __x;
1.236 + return *this;
1.237 + }
1.238 +
1.239 + // Arithmetic op= operations involving two complex arguments.
1.240 +
1.241 + static void _STLP_CALL _div(const float& __z1_r, const float& __z1_i,
1.242 + const float& __z2_r, const float& __z2_i,
1.243 + float& __res_r, float& __res_i);
1.244 +
1.245 + static void _STLP_CALL _div(const float& __z1_r,
1.246 + const float& __z2_r, const float& __z2_i,
1.247 + float& __res_r, float& __res_i);
1.248 +
1.249 +# if defined (_STLP_MEMBER_TEMPLATES)
1.250 + template <class _Tp2>
1.251 + complex<float>& operator=(const complex<_Tp2>& __z) {
1.252 + _M_re = __z._M_re;
1.253 + _M_im = __z._M_im;
1.254 + return *this;
1.255 + }
1.256 +
1.257 + template <class _Tp2>
1.258 + complex<float>& operator+= (const complex<_Tp2>& __z) {
1.259 + _M_re += __z._M_re;
1.260 + _M_im += __z._M_im;
1.261 + return *this;
1.262 + }
1.263 +
1.264 + template <class _Tp2>
1.265 + complex<float>& operator-= (const complex<_Tp2>& __z) {
1.266 + _M_re -= __z._M_re;
1.267 + _M_im -= __z._M_im;
1.268 + return *this;
1.269 + }
1.270 +
1.271 + template <class _Tp2>
1.272 + complex<float>& operator*= (const complex<_Tp2>& __z) {
1.273 + float __r = _M_re * __z._M_re - _M_im * __z._M_im;
1.274 + float __i = _M_re * __z._M_im + _M_im * __z._M_re;
1.275 + _M_re = __r;
1.276 + _M_im = __i;
1.277 + return *this;
1.278 + }
1.279 +
1.280 + template <class _Tp2>
1.281 + complex<float>& operator/= (const complex<_Tp2>& __z) {
1.282 + float __r;
1.283 + float __i;
1.284 + _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
1.285 + _M_re = __r;
1.286 + _M_im = __i;
1.287 + return *this;
1.288 + }
1.289 +
1.290 +# endif /* _STLP_MEMBER_TEMPLATES */
1.291 +
1.292 + _Self& operator=(const _Self& __z) {
1.293 + _M_re = __z._M_re;
1.294 + _M_im = __z._M_im;
1.295 + return *this;
1.296 + }
1.297 +
1.298 + _Self& operator+= (const _Self& __z) {
1.299 + _M_re += __z._M_re;
1.300 + _M_im += __z._M_im;
1.301 + return *this;
1.302 + }
1.303 +
1.304 + _Self& operator-= (const _Self& __z) {
1.305 + _M_re -= __z._M_re;
1.306 + _M_im -= __z._M_im;
1.307 + return *this;
1.308 + }
1.309 +
1.310 + _Self& operator*= (const _Self& __z) {
1.311 + value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
1.312 + value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
1.313 + _M_re = __r;
1.314 + _M_im = __i;
1.315 + return *this;
1.316 + }
1.317 +
1.318 + _Self& operator/= (const _Self& __z) {
1.319 + value_type __r;
1.320 + value_type __i;
1.321 + _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
1.322 + _M_re = __r;
1.323 + _M_im = __i;
1.324 + return *this;
1.325 + }
1.326 +
1.327 + // Data members.
1.328 + value_type _M_re;
1.329 + value_type _M_im;
1.330 +};
1.331 +
1.332 +_STLP_TEMPLATE_NULL
1.333 +struct _STLP_CLASS_DECLSPEC complex<double> {
1.334 + typedef double value_type;
1.335 + typedef complex<double> _Self;
1.336 +
1.337 + // Constructors, destructor, assignment operator.
1.338 +
1.339 + complex(value_type __x = 0.0, value_type __y = 0.0)
1.340 + : _M_re(__x), _M_im(__y) {}
1.341 +
1.342 + complex(const complex<double>& __z)
1.343 + : _M_re(__z._M_re), _M_im(__z._M_im) {}
1.344 + inline complex(const complex<float>& __z);
1.345 +# if !defined (_STLP_NO_LONG_DOUBLE)
1.346 + explicit inline complex(const complex<long double>& __z);
1.347 +# endif
1.348 + // Element access.
1.349 + value_type real() const { return _M_re; }
1.350 + value_type imag() const { return _M_im; }
1.351 +
1.352 + // Arithmetic op= operations involving one real argument.
1.353 +
1.354 + _Self& operator= (value_type __x) {
1.355 + _M_re = __x;
1.356 + _M_im = 0.0;
1.357 + return *this;
1.358 + }
1.359 + _Self& operator+= (value_type __x) {
1.360 + _M_re += __x;
1.361 + return *this;
1.362 + }
1.363 + _Self& operator-= (value_type __x) {
1.364 + _M_re -= __x;
1.365 + return *this;
1.366 + }
1.367 + _Self& operator*= (value_type __x) {
1.368 + _M_re *= __x;
1.369 + _M_im *= __x;
1.370 + return *this;
1.371 + }
1.372 + _Self& operator/= (value_type __x) {
1.373 + _M_re /= __x;
1.374 + _M_im /= __x;
1.375 + return *this;
1.376 + }
1.377 +
1.378 + // Arithmetic op= operations involving two complex arguments.
1.379 +
1.380 + static void _STLP_CALL _div(const double& __z1_r, const double& __z1_i,
1.381 + const double& __z2_r, const double& __z2_i,
1.382 + double& __res_r, double& __res_i);
1.383 + static void _STLP_CALL _div(const double& __z1_r,
1.384 + const double& __z2_r, const double& __z2_i,
1.385 + double& __res_r, double& __res_i);
1.386 +
1.387 +# if defined (_STLP_MEMBER_TEMPLATES) && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
1.388 + template <class _Tp2>
1.389 + complex<double>& operator=(const complex<_Tp2>& __z) {
1.390 + _M_re = __z._M_re;
1.391 + _M_im = __z._M_im;
1.392 + return *this;
1.393 + }
1.394 +
1.395 + template <class _Tp2>
1.396 + complex<double>& operator+= (const complex<_Tp2>& __z) {
1.397 + _M_re += __z._M_re;
1.398 + _M_im += __z._M_im;
1.399 + return *this;
1.400 + }
1.401 +
1.402 + template <class _Tp2>
1.403 + complex<double>& operator-= (const complex<_Tp2>& __z) {
1.404 + _M_re -= __z._M_re;
1.405 + _M_im -= __z._M_im;
1.406 + return *this;
1.407 + }
1.408 +
1.409 + template <class _Tp2>
1.410 + complex<double>& operator*= (const complex<_Tp2>& __z) {
1.411 + double __r = _M_re * __z._M_re - _M_im * __z._M_im;
1.412 + double __i = _M_re * __z._M_im + _M_im * __z._M_re;
1.413 + _M_re = __r;
1.414 + _M_im = __i;
1.415 + return *this;
1.416 + }
1.417 +
1.418 + template <class _Tp2>
1.419 + complex<double>& operator/= (const complex<_Tp2>& __z) {
1.420 + double __r;
1.421 + double __i;
1.422 + _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
1.423 + _M_re = __r;
1.424 + _M_im = __i;
1.425 + return *this;
1.426 + }
1.427 +
1.428 +# endif /* _STLP_MEMBER_TEMPLATES */
1.429 +
1.430 + _Self& operator=(const _Self& __z) {
1.431 + _M_re = __z._M_re;
1.432 + _M_im = __z._M_im;
1.433 + return *this;
1.434 + }
1.435 +
1.436 + _Self& operator+= (const _Self& __z) {
1.437 + _M_re += __z._M_re;
1.438 + _M_im += __z._M_im;
1.439 + return *this;
1.440 + }
1.441 +
1.442 + _Self& operator-= (const _Self& __z) {
1.443 + _M_re -= __z._M_re;
1.444 + _M_im -= __z._M_im;
1.445 + return *this;
1.446 + }
1.447 +
1.448 + _Self& operator*= (const _Self& __z) {
1.449 + value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
1.450 + value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
1.451 + _M_re = __r;
1.452 + _M_im = __i;
1.453 + return *this;
1.454 + }
1.455 +
1.456 + _Self& operator/= (const _Self& __z) {
1.457 + value_type __r;
1.458 + value_type __i;
1.459 + _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
1.460 + _M_re = __r;
1.461 + _M_im = __i;
1.462 + return *this;
1.463 + }
1.464 +
1.465 + // Data members.
1.466 + value_type _M_re;
1.467 + value_type _M_im;
1.468 +};
1.469 +
1.470 +# if !defined (_STLP_NO_LONG_DOUBLE)
1.471 +
1.472 +_STLP_TEMPLATE_NULL
1.473 +struct _STLP_CLASS_DECLSPEC complex<long double> {
1.474 + typedef long double value_type;
1.475 + typedef complex<long double> _Self;
1.476 +
1.477 + // Constructors, destructor, assignment operator.
1.478 + complex(value_type __x = 0.0l, value_type __y = 0.0l)
1.479 + : _M_re(__x), _M_im(__y) {}
1.480 +
1.481 + complex(const complex<long double>& __z)
1.482 + : _M_re(__z._M_re), _M_im(__z._M_im) {}
1.483 + inline complex(const complex<float>& __z);
1.484 + inline complex(const complex<double>& __z);
1.485 +
1.486 + // Element access.
1.487 + value_type real() const { return _M_re; }
1.488 + value_type imag() const { return _M_im; }
1.489 +
1.490 + // Arithmetic op= operations involving one real argument.
1.491 +
1.492 + _Self& operator= (value_type __x) {
1.493 + _M_re = __x;
1.494 + _M_im = 0.0l;
1.495 + return *this;
1.496 + }
1.497 + _Self& operator+= (value_type __x) {
1.498 + _M_re += __x;
1.499 + return *this;
1.500 + }
1.501 + _Self& operator-= (value_type __x) {
1.502 + _M_re -= __x;
1.503 + return *this;
1.504 + }
1.505 + _Self& operator*= (value_type __x) {
1.506 + _M_re *= __x;
1.507 + _M_im *= __x;
1.508 + return *this;
1.509 + }
1.510 + _Self& operator/= (value_type __x) {
1.511 + _M_re /= __x;
1.512 + _M_im /= __x;
1.513 + return *this;
1.514 + }
1.515 +
1.516 + // Arithmetic op= operations involving two complex arguments.
1.517 +
1.518 + static void _STLP_CALL _div(const long double& __z1_r, const long double& __z1_i,
1.519 + const long double& __z2_r, const long double& __z2_i,
1.520 + long double& __res_r, long double& __res_i);
1.521 +
1.522 + static void _STLP_CALL _div(const long double& __z1_r,
1.523 + const long double& __z2_r, const long double& __z2_i,
1.524 + long double& __res_r, long double& __res_i);
1.525 +
1.526 +# if defined (_STLP_MEMBER_TEMPLATES) && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
1.527 +
1.528 + template <class _Tp2>
1.529 + complex<long double>& operator=(const complex<_Tp2>& __z) {
1.530 + _M_re = __z._M_re;
1.531 + _M_im = __z._M_im;
1.532 + return *this;
1.533 + }
1.534 +
1.535 + template <class _Tp2>
1.536 + complex<long double>& operator+= (const complex<_Tp2>& __z) {
1.537 + _M_re += __z._M_re;
1.538 + _M_im += __z._M_im;
1.539 + return *this;
1.540 + }
1.541 +
1.542 + template <class _Tp2>
1.543 + complex<long double>& operator-= (const complex<_Tp2>& __z) {
1.544 + _M_re -= __z._M_re;
1.545 + _M_im -= __z._M_im;
1.546 + return *this;
1.547 + }
1.548 +
1.549 + template <class _Tp2>
1.550 + complex<long double>& operator*= (const complex<_Tp2>& __z) {
1.551 + long double __r = _M_re * __z._M_re - _M_im * __z._M_im;
1.552 + long double __i = _M_re * __z._M_im + _M_im * __z._M_re;
1.553 + _M_re = __r;
1.554 + _M_im = __i;
1.555 + return *this;
1.556 + }
1.557 +
1.558 + template <class _Tp2>
1.559 + complex<long double>& operator/= (const complex<_Tp2>& __z) {
1.560 + long double __r;
1.561 + long double __i;
1.562 + _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
1.563 + _M_re = __r;
1.564 + _M_im = __i;
1.565 + return *this;
1.566 + }
1.567 +
1.568 +# endif /* _STLP_MEMBER_TEMPLATES */
1.569 +
1.570 + _Self& operator=(const _Self& __z) {
1.571 + _M_re = __z._M_re;
1.572 + _M_im = __z._M_im;
1.573 + return *this;
1.574 + }
1.575 +
1.576 + _Self& operator+= (const _Self& __z) {
1.577 + _M_re += __z._M_re;
1.578 + _M_im += __z._M_im;
1.579 + return *this;
1.580 + }
1.581 +
1.582 + _Self& operator-= (const _Self& __z) {
1.583 + _M_re -= __z._M_re;
1.584 + _M_im -= __z._M_im;
1.585 + return *this;
1.586 + }
1.587 +
1.588 + _Self& operator*= (const _Self& __z) {
1.589 + value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
1.590 + value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
1.591 + _M_re = __r;
1.592 + _M_im = __i;
1.593 + return *this;
1.594 + }
1.595 +
1.596 + _Self& operator/= (const _Self& __z) {
1.597 + value_type __r;
1.598 + value_type __i;
1.599 + _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
1.600 + _M_re = __r;
1.601 + _M_im = __i;
1.602 + return *this;
1.603 + }
1.604 +
1.605 + // Data members.
1.606 + value_type _M_re;
1.607 + value_type _M_im;
1.608 +};
1.609 +
1.610 +# endif /* _STLP_NO_LONG_DOUBLE */
1.611 +
1.612 +// Converting constructors from one of these three specialized types
1.613 +// to another.
1.614 +
1.615 +inline complex<float>::complex(const complex<double>& __z)
1.616 + : _M_re((float)__z._M_re), _M_im((float)__z._M_im) {}
1.617 +inline complex<double>::complex(const complex<float>& __z)
1.618 + : _M_re(__z._M_re), _M_im(__z._M_im) {}
1.619 +# ifndef _STLP_NO_LONG_DOUBLE
1.620 +inline complex<float>::complex(const complex<long double>& __z)
1.621 + : _M_re((float)__z._M_re), _M_im((float)__z._M_im) {}
1.622 +inline complex<double>::complex(const complex<long double>& __z)
1.623 + : _M_re((double)__z._M_re), _M_im((double)__z._M_im) {}
1.624 +inline complex<long double>::complex(const complex<float>& __z)
1.625 + : _M_re(__z._M_re), _M_im(__z._M_im) {}
1.626 +inline complex<long double>::complex(const complex<double>& __z)
1.627 + : _M_re(__z._M_re), _M_im(__z._M_im) {}
1.628 +# endif
1.629 +
1.630 +#endif /* SPECIALIZATIONS */
1.631 +
1.632 +// Unary non-member arithmetic operators.
1.633 +
1.634 +template <class _Tp>
1.635 +inline complex<_Tp> _STLP_CALL operator+(const complex<_Tp>& __z)
1.636 +{ return __z; }
1.637 +
1.638 +template <class _Tp>
1.639 +inline complex<_Tp> _STLP_CALL operator-(const complex<_Tp>& __z)
1.640 +{ return complex<_Tp>(-__z._M_re, -__z._M_im); }
1.641 +
1.642 +// Non-member arithmetic operations involving one real argument.
1.643 +
1.644 +template <class _Tp>
1.645 +inline complex<_Tp> _STLP_CALL operator+(const _Tp& __x, const complex<_Tp>& __z)
1.646 +{ return complex<_Tp>(__x + __z._M_re, __z._M_im); }
1.647 +
1.648 +template <class _Tp>
1.649 +inline complex<_Tp> _STLP_CALL operator+(const complex<_Tp>& __z, const _Tp& __x)
1.650 +{ return complex<_Tp>(__z._M_re + __x, __z._M_im); }
1.651 +
1.652 +template <class _Tp>
1.653 +inline complex<_Tp> _STLP_CALL operator-(const _Tp& __x, const complex<_Tp>& __z)
1.654 +{ return complex<_Tp>(__x - __z._M_re, -__z._M_im); }
1.655 +
1.656 +template <class _Tp>
1.657 +inline complex<_Tp> _STLP_CALL operator-(const complex<_Tp>& __z, const _Tp& __x)
1.658 +{ return complex<_Tp>(__z._M_re - __x, __z._M_im); }
1.659 +
1.660 +template <class _Tp>
1.661 +inline complex<_Tp> _STLP_CALL operator*(const _Tp& __x, const complex<_Tp>& __z)
1.662 +{ return complex<_Tp>(__x * __z._M_re, __x * __z._M_im); }
1.663 +
1.664 +template <class _Tp>
1.665 +inline complex<_Tp> _STLP_CALL operator*(const complex<_Tp>& __z, const _Tp& __x)
1.666 +{ return complex<_Tp>(__z._M_re * __x, __z._M_im * __x); }
1.667 +
1.668 +template <class _Tp>
1.669 +inline complex<_Tp> _STLP_CALL operator/(const _Tp& __x, const complex<_Tp>& __z) {
1.670 + complex<_Tp> __result;
1.671 + complex<_Tp>::_div(__x,
1.672 + __z._M_re, __z._M_im,
1.673 + __result._M_re, __result._M_im);
1.674 + return __result;
1.675 +}
1.676 +
1.677 +template <class _Tp>
1.678 +inline complex<_Tp> _STLP_CALL operator/(const complex<_Tp>& __z, const _Tp& __x)
1.679 +{ return complex<_Tp>(__z._M_re / __x, __z._M_im / __x); }
1.680 +
1.681 +// Non-member arithmetic operations involving two complex arguments
1.682 +
1.683 +template <class _Tp>
1.684 +inline complex<_Tp> _STLP_CALL
1.685 +operator+(const complex<_Tp>& __z1, const complex<_Tp>& __z2)
1.686 +{ return complex<_Tp>(__z1._M_re + __z2._M_re, __z1._M_im + __z2._M_im); }
1.687 +
1.688 +template <class _Tp>
1.689 +inline complex<_Tp> _STLP_CALL
1.690 +operator-(const complex<_Tp>& __z1, const complex<_Tp>& __z2)
1.691 +{ return complex<_Tp>(__z1._M_re - __z2._M_re, __z1._M_im - __z2._M_im); }
1.692 +
1.693 +template <class _Tp>
1.694 +inline complex<_Tp> _STLP_CALL
1.695 +operator*(const complex<_Tp>& __z1, const complex<_Tp>& __z2) {
1.696 + return complex<_Tp>(__z1._M_re * __z2._M_re - __z1._M_im * __z2._M_im,
1.697 + __z1._M_re * __z2._M_im + __z1._M_im * __z2._M_re);
1.698 +}
1.699 +
1.700 +template <class _Tp>
1.701 +inline complex<_Tp> _STLP_CALL
1.702 +operator/(const complex<_Tp>& __z1, const complex<_Tp>& __z2) {
1.703 + complex<_Tp> __result;
1.704 + complex<_Tp>::_div(__z1._M_re, __z1._M_im,
1.705 + __z2._M_re, __z2._M_im,
1.706 + __result._M_re, __result._M_im);
1.707 + return __result;
1.708 +}
1.709 +
1.710 +// Comparison operators.
1.711 +
1.712 +template <class _Tp>
1.713 +inline bool _STLP_CALL operator==(const complex<_Tp>& __z1, const complex<_Tp>& __z2)
1.714 +{ return __z1._M_re == __z2._M_re && __z1._M_im == __z2._M_im; }
1.715 +
1.716 +template <class _Tp>
1.717 +inline bool _STLP_CALL operator==(const complex<_Tp>& __z, const _Tp& __x)
1.718 +{ return __z._M_re == __x && __z._M_im == 0; }
1.719 +
1.720 +template <class _Tp>
1.721 +inline bool _STLP_CALL operator==(const _Tp& __x, const complex<_Tp>& __z)
1.722 +{ return __x == __z._M_re && 0 == __z._M_im; }
1.723 +
1.724 +//04/27/04 dums: removal of this check, if it is restablish
1.725 +//please explain why the other operators are not macro guarded
1.726 +//#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
1.727 +
1.728 +template <class _Tp>
1.729 +inline bool _STLP_CALL operator!=(const complex<_Tp>& __z1, const complex<_Tp>& __z2)
1.730 +{ return __z1._M_re != __z2._M_re || __z1._M_im != __z2._M_im; }
1.731 +
1.732 +//#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
1.733 +
1.734 +template <class _Tp>
1.735 +inline bool _STLP_CALL operator!=(const complex<_Tp>& __z, const _Tp& __x)
1.736 +{ return __z._M_re != __x || __z._M_im != 0; }
1.737 +
1.738 +template <class _Tp>
1.739 +inline bool _STLP_CALL operator!=(const _Tp& __x, const complex<_Tp>& __z)
1.740 +{ return __x != __z._M_re || 0 != __z._M_im; }
1.741 +
1.742 +// Other basic arithmetic operations
1.743 +template <class _Tp>
1.744 +inline _Tp _STLP_CALL real(const complex<_Tp>& __z)
1.745 +{ return __z._M_re; }
1.746 +
1.747 +template <class _Tp>
1.748 +inline _Tp _STLP_CALL imag(const complex<_Tp>& __z)
1.749 +{ return __z._M_im; }
1.750 +
1.751 +template <class _Tp>
1.752 +_Tp _STLP_CALL abs(const complex<_Tp>& __z);
1.753 +
1.754 +template <class _Tp>
1.755 +_Tp _STLP_CALL arg(const complex<_Tp>& __z);
1.756 +
1.757 +template <class _Tp>
1.758 +inline _Tp _STLP_CALL norm(const complex<_Tp>& __z)
1.759 +{ return __z._M_re * __z._M_re + __z._M_im * __z._M_im; }
1.760 +
1.761 +template <class _Tp>
1.762 +inline complex<_Tp> _STLP_CALL conj(const complex<_Tp>& __z)
1.763 +{ return complex<_Tp>(__z._M_re, -__z._M_im); }
1.764 +
1.765 +template <class _Tp>
1.766 +complex<_Tp> _STLP_CALL polar(const _Tp& __rho)
1.767 +{ return complex<_Tp>(__rho, 0); }
1.768 +
1.769 +template <class _Tp>
1.770 +complex<_Tp> _STLP_CALL polar(const _Tp& __rho, const _Tp& __phi);
1.771 +
1.772 +_STLP_TEMPLATE_NULL
1.773 +_STLP_DECLSPEC float _STLP_CALL abs(const complex<float>&);
1.774 +_STLP_TEMPLATE_NULL
1.775 +_STLP_DECLSPEC double _STLP_CALL abs(const complex<double>&);
1.776 +_STLP_TEMPLATE_NULL
1.777 +_STLP_DECLSPEC float _STLP_CALL arg(const complex<float>&);
1.778 +_STLP_TEMPLATE_NULL
1.779 +_STLP_DECLSPEC double _STLP_CALL arg(const complex<double>&);
1.780 +_STLP_TEMPLATE_NULL
1.781 +_STLP_DECLSPEC complex<float> _STLP_CALL polar(const float& __rho, const float& __phi);
1.782 +_STLP_TEMPLATE_NULL
1.783 +_STLP_DECLSPEC complex<double> _STLP_CALL polar(const double& __rho, const double& __phi);
1.784 +
1.785 +template <class _Tp>
1.786 +_Tp _STLP_CALL abs(const complex<_Tp>& __z)
1.787 +{ return _Tp(abs(complex<double>(double(__z.real()), double(__z.imag())))); }
1.788 +
1.789 +template <class _Tp>
1.790 +_Tp _STLP_CALL arg(const complex<_Tp>& __z)
1.791 +{ return _Tp(arg(complex<double>(double(__z.real()), double(__z.imag())))); }
1.792 +
1.793 +template <class _Tp>
1.794 +complex<_Tp> _STLP_CALL polar(const _Tp& __rho, const _Tp& __phi) {
1.795 + complex<double> __tmp = polar(double(__rho), double(__phi));
1.796 + return complex<_Tp>(_Tp(__tmp.real()), _Tp(__tmp.imag()));
1.797 +}
1.798 +
1.799 +#if !defined (_STLP_NO_LONG_DOUBLE)
1.800 +_STLP_TEMPLATE_NULL
1.801 +_STLP_DECLSPEC long double _STLP_CALL arg(const complex<long double>&);
1.802 +_STLP_TEMPLATE_NULL
1.803 +_STLP_DECLSPEC long double _STLP_CALL abs(const complex<long double>&);
1.804 +_STLP_TEMPLATE_NULL
1.805 +_STLP_DECLSPEC complex<long double> _STLP_CALL polar(const long double&, const long double&);
1.806 +#endif
1.807 +
1.808 +
1.809 +#if !defined (_STLP_USE_NO_IOSTREAMS)
1.810 +
1.811 +_STLP_END_NAMESPACE
1.812 +
1.813 +# include <iosfwd>
1.814 +
1.815 +_STLP_BEGIN_NAMESPACE
1.816 +
1.817 +// Complex output, in the form (re,im). We use a two-step process
1.818 +// involving stringstream so that we get the padding right.
1.819 +template <class _Tp, class _CharT, class _Traits>
1.820 +basic_ostream<_CharT, _Traits>& _STLP_CALL
1.821 +operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __z);
1.822 +
1.823 +template <class _Tp, class _CharT, class _Traits>
1.824 +basic_istream<_CharT, _Traits>& _STLP_CALL
1.825 +operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __z);
1.826 +
1.827 +// Specializations for narrow characters; lets us avoid widen.
1.828 +
1.829 +_STLP_OPERATOR_TEMPLATE
1.830 +_STLP_DECLSPEC basic_istream<char, char_traits<char> >& _STLP_CALL
1.831 +operator>>(basic_istream<char, char_traits<char> >& __is, complex<float>& __z);
1.832 +
1.833 +_STLP_OPERATOR_TEMPLATE
1.834 +_STLP_DECLSPEC basic_istream<char, char_traits<char> >& _STLP_CALL
1.835 +operator>>(basic_istream<char, char_traits<char> >& __is, complex<double>& __z);
1.836 +
1.837 +_STLP_OPERATOR_TEMPLATE
1.838 +_STLP_DECLSPEC basic_ostream<char, char_traits<char> >& _STLP_CALL
1.839 +operator<<(basic_ostream<char, char_traits<char> >& __is, const complex<float>& __z);
1.840 +
1.841 +_STLP_OPERATOR_TEMPLATE
1.842 +_STLP_DECLSPEC basic_ostream<char, char_traits<char> >& _STLP_CALL
1.843 +operator<<(basic_ostream<char, char_traits<char> >& __is, const complex<double>& __z);
1.844 +
1.845 +# if !defined (_STLP_NO_LONG_DOUBLE)
1.846 +_STLP_OPERATOR_TEMPLATE
1.847 +_STLP_DECLSPEC basic_istream<char, char_traits<char> >& _STLP_CALL
1.848 +operator>>(basic_istream<char, char_traits<char> >& __is, complex<long double>& __z);
1.849 +
1.850 +_STLP_OPERATOR_TEMPLATE
1.851 +_STLP_DECLSPEC basic_ostream<char, char_traits<char> >& _STLP_CALL
1.852 +operator<<(basic_ostream<char, char_traits<char> >& __is, const complex<long double>& __z);
1.853 +
1.854 +# endif
1.855 +
1.856 +# if defined (_STLP_USE_TEMPLATE_EXPORT) && ! defined (_STLP_NO_WCHAR_T)
1.857 +
1.858 +_STLP_EXPORT_TEMPLATE basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
1.859 +operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<double>&);
1.860 +_STLP_EXPORT_TEMPLATE basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
1.861 +operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<double>&);
1.862 +_STLP_EXPORT_TEMPLATE basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
1.863 +operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<float>&);
1.864 +_STLP_EXPORT_TEMPLATE basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
1.865 +operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<float>&);
1.866 +
1.867 +# if !defined (_STLP_NO_LONG_DOUBLE)
1.868 +_STLP_EXPORT_TEMPLATE basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
1.869 +operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<long double>&);
1.870 +_STLP_EXPORT_TEMPLATE basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
1.871 +operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<long double>&);
1.872 +# endif
1.873 +# endif
1.874 +#endif
1.875 +
1.876 +
1.877 +// Transcendental functions. These are defined only for float,
1.878 +// double, and long double. (Sqrt isn't transcendental, of course,
1.879 +// but it's included in this section anyway.)
1.880 +
1.881 +_STLP_DECLSPEC complex<float> _STLP_CALL sqrt(const complex<float>&);
1.882 +
1.883 +_STLP_DECLSPEC complex<float> _STLP_CALL exp(const complex<float>&);
1.884 +_STLP_DECLSPEC complex<float> _STLP_CALL log(const complex<float>&);
1.885 +_STLP_DECLSPEC complex<float> _STLP_CALL log10(const complex<float>&);
1.886 +
1.887 +_STLP_DECLSPEC complex<float> _STLP_CALL pow(const complex<float>&, int);
1.888 +_STLP_DECLSPEC complex<float> _STLP_CALL pow(const complex<float>&, const float&);
1.889 +_STLP_DECLSPEC complex<float> _STLP_CALL pow(const float&, const complex<float>&);
1.890 +_STLP_DECLSPEC complex<float> _STLP_CALL pow(const complex<float>&, const complex<float>&);
1.891 +
1.892 +_STLP_DECLSPEC complex<float> _STLP_CALL sin(const complex<float>&);
1.893 +_STLP_DECLSPEC complex<float> _STLP_CALL cos(const complex<float>&);
1.894 +_STLP_DECLSPEC complex<float> _STLP_CALL tan(const complex<float>&);
1.895 +
1.896 +_STLP_DECLSPEC complex<float> _STLP_CALL sinh(const complex<float>&);
1.897 +_STLP_DECLSPEC complex<float> _STLP_CALL cosh(const complex<float>&);
1.898 +_STLP_DECLSPEC complex<float> _STLP_CALL tanh(const complex<float>&);
1.899 +
1.900 +_STLP_DECLSPEC complex<double> _STLP_CALL sqrt(const complex<double>&);
1.901 +
1.902 +_STLP_DECLSPEC complex<double> _STLP_CALL exp(const complex<double>&);
1.903 +_STLP_DECLSPEC complex<double> _STLP_CALL log(const complex<double>&);
1.904 +_STLP_DECLSPEC complex<double> _STLP_CALL log10(const complex<double>&);
1.905 +
1.906 +_STLP_DECLSPEC complex<double> _STLP_CALL pow(const complex<double>&, int);
1.907 +_STLP_DECLSPEC complex<double> _STLP_CALL pow(const complex<double>&, const double&);
1.908 +_STLP_DECLSPEC complex<double> _STLP_CALL pow(const double&, const complex<double>&);
1.909 +_STLP_DECLSPEC complex<double> _STLP_CALL pow(const complex<double>&, const complex<double>&);
1.910 +
1.911 +_STLP_DECLSPEC complex<double> _STLP_CALL sin(const complex<double>&);
1.912 +_STLP_DECLSPEC complex<double> _STLP_CALL cos(const complex<double>&);
1.913 +_STLP_DECLSPEC complex<double> _STLP_CALL tan(const complex<double>&);
1.914 +
1.915 +_STLP_DECLSPEC complex<double> _STLP_CALL sinh(const complex<double>&);
1.916 +_STLP_DECLSPEC complex<double> _STLP_CALL cosh(const complex<double>&);
1.917 +_STLP_DECLSPEC complex<double> _STLP_CALL tanh(const complex<double>&);
1.918 +
1.919 +#if !defined (_STLP_NO_LONG_DOUBLE)
1.920 +_STLP_DECLSPEC complex<long double> _STLP_CALL sqrt(const complex<long double>&);
1.921 +_STLP_DECLSPEC complex<long double> _STLP_CALL exp(const complex<long double>&);
1.922 +_STLP_DECLSPEC complex<long double> _STLP_CALL log(const complex<long double>&);
1.923 +_STLP_DECLSPEC complex<long double> _STLP_CALL log10(const complex<long double>&);
1.924 +
1.925 +_STLP_DECLSPEC complex<long double> _STLP_CALL pow(const complex<long double>&, int);
1.926 +_STLP_DECLSPEC complex<long double> _STLP_CALL pow(const complex<long double>&, const long double&);
1.927 +_STLP_DECLSPEC complex<long double> _STLP_CALL pow(const long double&, const complex<long double>&);
1.928 +_STLP_DECLSPEC complex<long double> _STLP_CALL pow(const complex<long double>&,
1.929 + const complex<long double>&);
1.930 +
1.931 +_STLP_DECLSPEC complex<long double> _STLP_CALL sin(const complex<long double>&);
1.932 +_STLP_DECLSPEC complex<long double> _STLP_CALL cos(const complex<long double>&);
1.933 +_STLP_DECLSPEC complex<long double> _STLP_CALL tan(const complex<long double>&);
1.934 +
1.935 +_STLP_DECLSPEC complex<long double> _STLP_CALL sinh(const complex<long double>&);
1.936 +_STLP_DECLSPEC complex<long double> _STLP_CALL cosh(const complex<long double>&);
1.937 +_STLP_DECLSPEC complex<long double> _STLP_CALL tanh(const complex<long double>&);
1.938 +#endif
1.939 +
1.940 +_STLP_END_NAMESPACE
1.941 +
1.942 +#ifndef _STLP_LINK_TIME_INSTANTIATION
1.943 +# include <stl/_complex.c>
1.944 +#endif
1.945 +
1.946 +#endif
1.947 +
1.948 +// Local Variables:
1.949 +// mode:C++
1.950 +// End: