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