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