ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

_complex.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1999
00003  * Silicon Graphics Computer Systems, Inc.
00004  *
00005  * Copyright (c) 1999
00006  * Boris Fomitchev
00007  *
00008  * This material is provided "as is", with absolutely no warranty expressed
00009  * or implied. Any use is at your own risk.
00010  *
00011  * Permission to use or copy this software for any purpose is hereby granted
00012  * without fee, provided the above notices are retained on all copies.
00013  * Permission to modify the code and to distribute modified code is granted,
00014  * provided the above notices are retained, and a notice that the code was
00015  * modified is included with the above copyright notice.
00016  *
00017  */
00018 #ifndef _STLP_INTERNAL_COMPLEX
00019 #define _STLP_INTERNAL_COMPLEX
00020 
00021 // This header declares the template class complex, as described in
00022 // in the draft C++ standard.  Single-precision complex numbers
00023 // are complex<float>, double-precision are complex<double>, and
00024 // quad precision are complex<long double>.
00025 
00026 // Note that the template class complex is declared within namespace
00027 // std, as called for by the draft C++ standard.
00028 
00029 #ifndef _STLP_INTERNAL_CMATH
00030 #  include <stl/_cmath.h>
00031 #endif
00032 
00033 _STLP_BEGIN_NAMESPACE
00034 
00035 template <class _Tp>
00036 struct complex {
00037   typedef _Tp value_type;
00038   typedef complex<_Tp> _Self;
00039 
00040   // Constructors, destructor, assignment operator.
00041   complex() : _M_re(0), _M_im(0) {}
00042   complex(const value_type& __x)
00043     : _M_re(__x), _M_im(0) {}
00044   complex(const value_type& __x, const value_type& __y)
00045     : _M_re(__x), _M_im(__y) {}
00046   complex(const _Self& __z)
00047     : _M_re(__z._M_re), _M_im(__z._M_im) {}
00048 
00049   _Self& operator=(const _Self& __z) {
00050     _M_re = __z._M_re;
00051     _M_im = __z._M_im;
00052     return *this;
00053   }
00054 
00055 #if defined (_STLP_MEMBER_TEMPLATES) && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
00056   template <class _Tp2>
00057   explicit complex(const complex<_Tp2>& __z)
00058     : _M_re(__z._M_re), _M_im(__z._M_im) {}
00059 
00060   template <class _Tp2>
00061   _Self& operator=(const complex<_Tp2>& __z) {
00062     _M_re = __z._M_re;
00063     _M_im = __z._M_im;
00064     return *this;
00065   }
00066 #endif /* _STLP_MEMBER_TEMPLATES */
00067 
00068   // Element access.
00069   value_type real() const { return _M_re; }
00070   value_type imag() const { return _M_im; }
00071 
00072   // Arithmetic op= operations involving one real argument.
00073 
00074   _Self& operator= (const value_type& __x) {
00075     _M_re = __x;
00076     _M_im = 0;
00077     return *this;
00078   }
00079   _Self& operator+= (const value_type& __x) {
00080     _M_re += __x;
00081     return *this;
00082   }
00083   _Self& operator-= (const value_type& __x) {
00084     _M_re -= __x;
00085     return *this;
00086   }
00087   _Self& operator*= (const value_type& __x) {
00088     _M_re *= __x;
00089     _M_im *= __x;
00090     return *this;
00091   }
00092   _Self& operator/= (const value_type& __x) {
00093     _M_re /= __x;
00094     _M_im /= __x;
00095     return *this;
00096   }
00097 
00098   // Arithmetic op= operations involving two complex arguments.
00099 
00100   static void  _STLP_CALL _div(const value_type& __z1_r, const value_type& __z1_i,
00101                                const value_type& __z2_r, const value_type& __z2_i,
00102                                value_type& __res_r, value_type& __res_i);
00103 
00104   static void _STLP_CALL _div(const value_type& __z1_r,
00105                               const value_type& __z2_r, const value_type& __z2_i,
00106                               value_type& __res_r, value_type& __res_i);
00107 
00108 #if defined (_STLP_MEMBER_TEMPLATES) // && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
00109 
00110   template <class _Tp2> _Self& operator+= (const complex<_Tp2>& __z) {
00111     _M_re += __z._M_re;
00112     _M_im += __z._M_im;
00113     return *this;
00114   }
00115 
00116   template <class _Tp2> _Self& operator-= (const complex<_Tp2>& __z) {
00117     _M_re -= __z._M_re;
00118     _M_im -= __z._M_im;
00119     return *this;
00120   }
00121 
00122   template <class _Tp2> _Self& operator*= (const complex<_Tp2>& __z) {
00123     value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
00124     value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
00125     _M_re = __r;
00126     _M_im = __i;
00127     return *this;
00128   }
00129 
00130   template <class _Tp2> _Self& operator/= (const complex<_Tp2>& __z) {
00131     value_type __r;
00132     value_type __i;
00133     _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
00134     _M_re = __r;
00135     _M_im = __i;
00136     return *this;
00137   }
00138 #endif /* _STLP_MEMBER_TEMPLATES */
00139 
00140   _Self& operator+= (const _Self& __z) {
00141     _M_re += __z._M_re;
00142     _M_im += __z._M_im;
00143     return *this;
00144   }
00145 
00146   _Self& operator-= (const _Self& __z) {
00147     _M_re -= __z._M_re;
00148     _M_im -= __z._M_im;
00149     return *this;
00150   }
00151 
00152   _Self& operator*= (const _Self& __z) {
00153     value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
00154     value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
00155     _M_re = __r;
00156     _M_im = __i;
00157     return *this;
00158   }
00159 
00160   _Self& operator/= (const _Self& __z) {
00161     value_type __r;
00162     value_type __i;
00163     _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
00164     _M_re = __r;
00165     _M_im = __i;
00166     return *this;
00167   }
00168 
00169   // Data members.
00170   value_type _M_re;
00171   value_type _M_im;
00172 };
00173 
00174 // Explicit specializations for float, double, long double.  The only
00175 // reason for these specializations is to enable automatic conversions
00176 // from complex<float> to complex<double>, and complex<double> to
00177 // complex<long double>.
00178 
00179 _STLP_TEMPLATE_NULL
00180 struct _STLP_CLASS_DECLSPEC complex<float> {
00181   typedef float value_type;
00182   typedef complex<float> _Self;
00183   // Constructors, destructor, assignment operator.
00184 
00185   complex(value_type __x = 0.0f, value_type __y = 0.0f)
00186     : _M_re(__x), _M_im(__y) {}
00187 
00188   complex(const complex<float>& __z)    : _M_re(__z._M_re), _M_im(__z._M_im) {}
00189 
00190   inline explicit complex(const complex<double>& __z);
00191 #ifndef _STLP_NO_LONG_DOUBLE
00192   inline explicit complex(const complex<long double>& __z);
00193 #endif
00194   // Element access.
00195   value_type real() const { return _M_re; }
00196   value_type imag() const { return _M_im; }
00197 
00198   // Arithmetic op= operations involving one real argument.
00199 
00200   _Self& operator= (value_type __x) {
00201     _M_re = __x;
00202     _M_im = 0.0f;
00203     return *this;
00204   }
00205   _Self& operator+= (value_type __x) {
00206     _M_re += __x;
00207     return *this;
00208   }
00209   _Self& operator-= (value_type __x) {
00210     _M_re -= __x;
00211     return *this;
00212   }
00213   _Self& operator*= (value_type __x) {
00214     _M_re *= __x;
00215     _M_im *= __x;
00216     return *this;
00217   }
00218   _Self& operator/= (value_type __x) {
00219     _M_re /= __x;
00220     _M_im /= __x;
00221     return *this;
00222   }
00223 
00224   // Arithmetic op= operations involving two complex arguments.
00225 
00226   static void _STLP_CALL _div(const float& __z1_r, const float& __z1_i,
00227                               const float& __z2_r, const float& __z2_i,
00228                               float& __res_r, float& __res_i);
00229 
00230   static void _STLP_CALL _div(const float& __z1_r,
00231                               const float& __z2_r, const float& __z2_i,
00232                               float& __res_r, float& __res_i);
00233 
00234 #if defined (_STLP_MEMBER_TEMPLATES)
00235   template <class _Tp2>
00236   complex<float>& operator=(const complex<_Tp2>& __z) {
00237     _M_re = __z._M_re;
00238     _M_im = __z._M_im;
00239     return *this;
00240   }
00241 
00242   template <class _Tp2>
00243   complex<float>& operator+= (const complex<_Tp2>& __z) {
00244     _M_re += __z._M_re;
00245     _M_im += __z._M_im;
00246     return *this;
00247   }
00248 
00249   template <class _Tp2>
00250   complex<float>& operator-= (const complex<_Tp2>& __z) {
00251     _M_re -= __z._M_re;
00252     _M_im -= __z._M_im;
00253     return *this;
00254   }
00255 
00256   template <class _Tp2>
00257   complex<float>& operator*= (const complex<_Tp2>& __z) {
00258     float __r = _M_re * __z._M_re - _M_im * __z._M_im;
00259     float __i = _M_re * __z._M_im + _M_im * __z._M_re;
00260     _M_re = __r;
00261     _M_im = __i;
00262     return *this;
00263   }
00264 
00265   template <class _Tp2>
00266   complex<float>& operator/= (const complex<_Tp2>& __z) {
00267     float __r;
00268     float __i;
00269     _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
00270     _M_re = __r;
00271     _M_im = __i;
00272     return *this;
00273   }
00274 
00275 #endif /* _STLP_MEMBER_TEMPLATES */
00276 
00277   _Self& operator=(const _Self& __z) {
00278     _M_re = __z._M_re;
00279     _M_im = __z._M_im;
00280     return *this;
00281   }
00282 
00283   _Self& operator+= (const _Self& __z) {
00284     _M_re += __z._M_re;
00285     _M_im += __z._M_im;
00286     return *this;
00287   }
00288 
00289   _Self& operator-= (const _Self& __z) {
00290     _M_re -= __z._M_re;
00291     _M_im -= __z._M_im;
00292     return *this;
00293   }
00294 
00295   _Self& operator*= (const _Self& __z) {
00296     value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
00297     value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
00298     _M_re = __r;
00299     _M_im = __i;
00300     return *this;
00301   }
00302 
00303   _Self& operator/= (const _Self& __z) {
00304     value_type __r;
00305     value_type __i;
00306     _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
00307     _M_re = __r;
00308     _M_im = __i;
00309     return *this;
00310   }
00311 
00312   // Data members.
00313   value_type _M_re;
00314   value_type _M_im;
00315 };
00316 
00317 _STLP_TEMPLATE_NULL
00318 struct _STLP_CLASS_DECLSPEC complex<double> {
00319   typedef double value_type;
00320   typedef complex<double> _Self;
00321 
00322   // Constructors, destructor, assignment operator.
00323 
00324   complex(value_type __x = 0.0, value_type __y = 0.0)
00325     : _M_re(__x), _M_im(__y) {}
00326 
00327   complex(const complex<double>& __z)
00328     : _M_re(__z._M_re), _M_im(__z._M_im) {}
00329   inline complex(const complex<float>& __z);
00330 #if !defined (_STLP_NO_LONG_DOUBLE)
00331   explicit inline complex(const complex<long double>& __z);
00332 #endif
00333   // Element access.
00334   value_type real() const { return _M_re; }
00335   value_type imag() const { return _M_im; }
00336 
00337   // Arithmetic op= operations involving one real argument.
00338 
00339   _Self& operator= (value_type __x) {
00340     _M_re = __x;
00341     _M_im = 0.0;
00342     return *this;
00343   }
00344   _Self& operator+= (value_type __x) {
00345     _M_re += __x;
00346     return *this;
00347   }
00348   _Self& operator-= (value_type __x) {
00349     _M_re -= __x;
00350     return *this;
00351   }
00352   _Self& operator*= (value_type __x) {
00353     _M_re *= __x;
00354     _M_im *= __x;
00355     return *this;
00356   }
00357   _Self& operator/= (value_type __x) {
00358     _M_re /= __x;
00359     _M_im /= __x;
00360     return *this;
00361   }
00362 
00363   // Arithmetic op= operations involving two complex arguments.
00364 
00365   static void _STLP_CALL _div(const double& __z1_r, const double& __z1_i,
00366                               const double& __z2_r, const double& __z2_i,
00367                               double& __res_r, double& __res_i);
00368   static void _STLP_CALL _div(const double& __z1_r,
00369                               const double& __z2_r, const double& __z2_i,
00370                               double& __res_r, double& __res_i);
00371 
00372 #if defined (_STLP_MEMBER_TEMPLATES) && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
00373   template <class _Tp2>
00374   complex<double>& operator=(const complex<_Tp2>& __z) {
00375     _M_re = __z._M_re;
00376     _M_im = __z._M_im;
00377     return *this;
00378   }
00379 
00380   template <class _Tp2>
00381   complex<double>& operator+= (const complex<_Tp2>& __z) {
00382     _M_re += __z._M_re;
00383     _M_im += __z._M_im;
00384     return *this;
00385   }
00386 
00387   template <class _Tp2>
00388   complex<double>& operator-= (const complex<_Tp2>& __z) {
00389     _M_re -= __z._M_re;
00390     _M_im -= __z._M_im;
00391     return *this;
00392   }
00393 
00394   template <class _Tp2>
00395   complex<double>& operator*= (const complex<_Tp2>& __z) {
00396     double __r = _M_re * __z._M_re - _M_im * __z._M_im;
00397     double __i = _M_re * __z._M_im + _M_im * __z._M_re;
00398     _M_re = __r;
00399     _M_im = __i;
00400     return *this;
00401   }
00402 
00403   template <class _Tp2>
00404   complex<double>& operator/= (const complex<_Tp2>& __z) {
00405     double __r;
00406     double __i;
00407     _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
00408     _M_re = __r;
00409     _M_im = __i;
00410     return *this;
00411   }
00412 
00413 #endif /* _STLP_MEMBER_TEMPLATES */
00414 
00415   _Self& operator=(const _Self& __z) {
00416     _M_re = __z._M_re;
00417     _M_im = __z._M_im;
00418     return *this;
00419   }
00420 
00421   _Self& operator+= (const _Self& __z) {
00422     _M_re += __z._M_re;
00423     _M_im += __z._M_im;
00424     return *this;
00425   }
00426 
00427   _Self& operator-= (const _Self& __z) {
00428     _M_re -= __z._M_re;
00429     _M_im -= __z._M_im;
00430     return *this;
00431   }
00432 
00433   _Self& operator*= (const _Self& __z) {
00434     value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
00435     value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
00436     _M_re = __r;
00437     _M_im = __i;
00438     return *this;
00439   }
00440 
00441   _Self& operator/= (const _Self& __z) {
00442     value_type __r;
00443     value_type __i;
00444     _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
00445     _M_re = __r;
00446     _M_im = __i;
00447     return *this;
00448   }
00449 
00450   // Data members.
00451   value_type _M_re;
00452   value_type _M_im;
00453 };
00454 
00455 #if !defined (_STLP_NO_LONG_DOUBLE)
00456 
00457 _STLP_TEMPLATE_NULL
00458 struct _STLP_CLASS_DECLSPEC complex<long double> {
00459   typedef long double value_type;
00460   typedef complex<long double> _Self;
00461 
00462   // Constructors, destructor, assignment operator.
00463   complex(value_type __x = 0.0l, value_type __y = 0.0l)
00464     : _M_re(__x), _M_im(__y) {}
00465 
00466   complex(const complex<long double>& __z)
00467     : _M_re(__z._M_re), _M_im(__z._M_im) {}
00468   inline complex(const complex<float>& __z);
00469   inline complex(const complex<double>& __z);
00470 
00471   // Element access.
00472   value_type real() const { return _M_re; }
00473   value_type imag() const { return _M_im; }
00474 
00475   // Arithmetic op= operations involving one real argument.
00476 
00477   _Self& operator= (value_type __x) {
00478     _M_re = __x;
00479     _M_im = 0.0l;
00480     return *this;
00481   }
00482   _Self& operator+= (value_type __x) {
00483     _M_re += __x;
00484     return *this;
00485   }
00486   _Self& operator-= (value_type __x) {
00487     _M_re -= __x;
00488     return *this;
00489   }
00490   _Self& operator*= (value_type __x) {
00491     _M_re *= __x;
00492     _M_im *= __x;
00493     return *this;
00494   }
00495   _Self& operator/= (value_type __x) {
00496     _M_re /= __x;
00497     _M_im /= __x;
00498     return *this;
00499   }
00500 
00501   // Arithmetic op= operations involving two complex arguments.
00502 
00503   static void _STLP_CALL _div(const long double& __z1_r, const long double& __z1_i,
00504                               const long double& __z2_r, const long double& __z2_i,
00505                               long double& __res_r, long double& __res_i);
00506 
00507   static void _STLP_CALL _div(const long double& __z1_r,
00508                               const long double& __z2_r, const long double& __z2_i,
00509                               long double& __res_r, long double& __res_i);
00510 
00511 #  if defined (_STLP_MEMBER_TEMPLATES) && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
00512 
00513   template <class _Tp2>
00514   complex<long double>& operator=(const complex<_Tp2>& __z) {
00515     _M_re = __z._M_re;
00516     _M_im = __z._M_im;
00517     return *this;
00518   }
00519 
00520   template <class _Tp2>
00521   complex<long double>& operator+= (const complex<_Tp2>& __z) {
00522     _M_re += __z._M_re;
00523     _M_im += __z._M_im;
00524     return *this;
00525   }
00526 
00527   template <class _Tp2>
00528   complex<long double>& operator-= (const complex<_Tp2>& __z) {
00529     _M_re -= __z._M_re;
00530     _M_im -= __z._M_im;
00531     return *this;
00532   }
00533 
00534   template <class _Tp2>
00535   complex<long double>& operator*= (const complex<_Tp2>& __z) {
00536     long double __r = _M_re * __z._M_re - _M_im * __z._M_im;
00537     long double __i = _M_re * __z._M_im + _M_im * __z._M_re;
00538     _M_re = __r;
00539     _M_im = __i;
00540     return *this;
00541   }
00542 
00543   template <class _Tp2>
00544   complex<long double>& operator/= (const complex<_Tp2>& __z) {
00545     long double __r;
00546     long double __i;
00547     _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
00548     _M_re = __r;
00549     _M_im = __i;
00550     return *this;
00551   }
00552 
00553 #  endif /* _STLP_MEMBER_TEMPLATES */
00554 
00555   _Self& operator=(const _Self& __z) {
00556     _M_re = __z._M_re;
00557     _M_im = __z._M_im;
00558     return *this;
00559   }
00560 
00561   _Self& operator+= (const _Self& __z) {
00562     _M_re += __z._M_re;
00563     _M_im += __z._M_im;
00564     return *this;
00565   }
00566 
00567   _Self& operator-= (const _Self& __z) {
00568     _M_re -= __z._M_re;
00569     _M_im -= __z._M_im;
00570     return *this;
00571   }
00572 
00573   _Self& operator*= (const _Self& __z) {
00574     value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
00575     value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
00576     _M_re = __r;
00577     _M_im = __i;
00578     return *this;
00579   }
00580 
00581   _Self& operator/= (const _Self& __z) {
00582     value_type __r;
00583     value_type __i;
00584     _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
00585     _M_re = __r;
00586     _M_im = __i;
00587     return *this;
00588   }
00589 
00590   // Data members.
00591   value_type _M_re;
00592   value_type _M_im;
00593 };
00594 
00595 #endif /* _STLP_NO_LONG_DOUBLE */
00596 
00597 // Converting constructors from one of these three specialized types
00598 // to another.
00599 
00600 inline complex<float>::complex(const complex<double>& __z)
00601   : _M_re((float)__z._M_re), _M_im((float)__z._M_im) {}
00602 inline complex<double>::complex(const complex<float>& __z)
00603   : _M_re(__z._M_re), _M_im(__z._M_im) {}
00604 #ifndef _STLP_NO_LONG_DOUBLE
00605 inline complex<float>::complex(const complex<long double>& __z)
00606   : _M_re((float)__z._M_re), _M_im((float)__z._M_im) {}
00607 inline complex<double>::complex(const complex<long double>& __z)
00608   : _M_re((double)__z._M_re), _M_im((double)__z._M_im) {}
00609 inline complex<long double>::complex(const complex<float>& __z)
00610   : _M_re(__z._M_re), _M_im(__z._M_im) {}
00611 inline complex<long double>::complex(const complex<double>& __z)
00612   : _M_re(__z._M_re), _M_im(__z._M_im) {}
00613 #endif
00614 
00615 // Unary non-member arithmetic operators.
00616 
00617 template <class _Tp>
00618 inline complex<_Tp> _STLP_CALL operator+(const complex<_Tp>& __z)
00619 { return __z; }
00620 
00621 template <class _Tp>
00622 inline complex<_Tp> _STLP_CALL  operator-(const complex<_Tp>& __z)
00623 { return complex<_Tp>(-__z._M_re, -__z._M_im); }
00624 
00625 // Non-member arithmetic operations involving one real argument.
00626 
00627 template <class _Tp>
00628 inline complex<_Tp> _STLP_CALL operator+(const _Tp& __x, const complex<_Tp>& __z)
00629 { return complex<_Tp>(__x + __z._M_re, __z._M_im); }
00630 
00631 template <class _Tp>
00632 inline complex<_Tp> _STLP_CALL operator+(const complex<_Tp>& __z, const _Tp& __x)
00633 { return complex<_Tp>(__z._M_re + __x, __z._M_im); }
00634 
00635 template <class _Tp>
00636 inline complex<_Tp> _STLP_CALL operator-(const _Tp& __x, const complex<_Tp>& __z)
00637 { return complex<_Tp>(__x - __z._M_re, -__z._M_im); }
00638 
00639 template <class _Tp>
00640 inline complex<_Tp> _STLP_CALL operator-(const complex<_Tp>& __z, const _Tp& __x)
00641 { return complex<_Tp>(__z._M_re - __x, __z._M_im); }
00642 
00643 template <class _Tp>
00644 inline complex<_Tp> _STLP_CALL operator*(const _Tp& __x, const complex<_Tp>& __z)
00645 { return complex<_Tp>(__x * __z._M_re, __x * __z._M_im); }
00646 
00647 template <class _Tp>
00648 inline complex<_Tp> _STLP_CALL operator*(const complex<_Tp>& __z, const _Tp& __x)
00649 { return complex<_Tp>(__z._M_re * __x, __z._M_im * __x); }
00650 
00651 template <class _Tp>
00652 inline complex<_Tp> _STLP_CALL operator/(const _Tp& __x, const complex<_Tp>& __z) {
00653   complex<_Tp> __result;
00654   complex<_Tp>::_div(__x,
00655                      __z._M_re, __z._M_im,
00656                      __result._M_re, __result._M_im);
00657   return __result;
00658 }
00659 
00660 template <class _Tp>
00661 inline complex<_Tp> _STLP_CALL operator/(const complex<_Tp>& __z, const _Tp& __x)
00662 { return complex<_Tp>(__z._M_re / __x, __z._M_im / __x); }
00663 
00664 // Non-member arithmetic operations involving two complex arguments
00665 
00666 template <class _Tp>
00667 inline complex<_Tp> _STLP_CALL
00668 operator+(const complex<_Tp>& __z1, const complex<_Tp>& __z2)
00669 { return complex<_Tp>(__z1._M_re + __z2._M_re, __z1._M_im + __z2._M_im); }
00670 
00671 template <class _Tp>
00672 inline complex<_Tp> _STLP_CALL
00673 operator-(const complex<_Tp>& __z1, const complex<_Tp>& __z2)
00674 { return complex<_Tp>(__z1._M_re - __z2._M_re, __z1._M_im - __z2._M_im); }
00675 
00676 template <class _Tp>
00677 inline complex<_Tp> _STLP_CALL
00678 operator*(const complex<_Tp>& __z1, const complex<_Tp>& __z2) {
00679   return complex<_Tp>(__z1._M_re * __z2._M_re - __z1._M_im * __z2._M_im,
00680                       __z1._M_re * __z2._M_im + __z1._M_im * __z2._M_re);
00681 }
00682 
00683 template <class _Tp>
00684 inline complex<_Tp> _STLP_CALL
00685 operator/(const complex<_Tp>& __z1, const complex<_Tp>& __z2) {
00686   complex<_Tp> __result;
00687   complex<_Tp>::_div(__z1._M_re, __z1._M_im,
00688                      __z2._M_re, __z2._M_im,
00689                      __result._M_re, __result._M_im);
00690   return __result;
00691 }
00692 
00693 // Comparison operators.
00694 
00695 template <class _Tp>
00696 inline bool _STLP_CALL operator==(const complex<_Tp>& __z1, const complex<_Tp>& __z2)
00697 { return __z1._M_re == __z2._M_re && __z1._M_im == __z2._M_im; }
00698 
00699 template <class _Tp>
00700 inline bool _STLP_CALL operator==(const complex<_Tp>& __z, const _Tp& __x)
00701 { return __z._M_re == __x && __z._M_im == 0; }
00702 
00703 template <class _Tp>
00704 inline bool _STLP_CALL operator==(const _Tp& __x, const complex<_Tp>& __z)
00705 { return __x == __z._M_re && 0 == __z._M_im; }
00706 
00707 //04/27/04 dums: removal of this check, if it is restablish
00708 //please explain why the other operators are not macro guarded
00709 //#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
00710 
00711 template <class _Tp>
00712 inline bool _STLP_CALL operator!=(const complex<_Tp>& __z1, const complex<_Tp>& __z2)
00713 { return __z1._M_re != __z2._M_re || __z1._M_im != __z2._M_im; }
00714 
00715 //#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
00716 
00717 template <class _Tp>
00718 inline bool _STLP_CALL operator!=(const complex<_Tp>& __z, const _Tp& __x)
00719 { return __z._M_re != __x || __z._M_im != 0; }
00720 
00721 template <class _Tp>
00722 inline bool _STLP_CALL operator!=(const _Tp& __x, const complex<_Tp>& __z)
00723 { return __x != __z._M_re || 0 != __z._M_im; }
00724 
00725 // Other basic arithmetic operations
00726 template <class _Tp>
00727 inline _Tp _STLP_CALL real(const complex<_Tp>& __z)
00728 { return __z._M_re; }
00729 
00730 template <class _Tp>
00731 inline _Tp _STLP_CALL imag(const complex<_Tp>& __z)
00732 { return __z._M_im; }
00733 
00734 template <class _Tp>
00735 _Tp _STLP_CALL abs(const complex<_Tp>& __z);
00736 
00737 template <class _Tp>
00738 _Tp _STLP_CALL arg(const complex<_Tp>& __z);
00739 
00740 template <class _Tp>
00741 inline _Tp _STLP_CALL norm(const complex<_Tp>& __z)
00742 { return __z._M_re * __z._M_re + __z._M_im * __z._M_im; }
00743 
00744 template <class _Tp>
00745 inline complex<_Tp> _STLP_CALL conj(const complex<_Tp>& __z)
00746 { return complex<_Tp>(__z._M_re, -__z._M_im); }
00747 
00748 template <class _Tp>
00749 complex<_Tp> _STLP_CALL polar(const _Tp& __rho)
00750 { return complex<_Tp>(__rho, 0); }
00751 
00752 template <class _Tp>
00753 complex<_Tp> _STLP_CALL polar(const _Tp& __rho, const _Tp& __phi);
00754 
00755 _STLP_TEMPLATE_NULL
00756 _STLP_DECLSPEC float _STLP_CALL abs(const complex<float>&);
00757 _STLP_TEMPLATE_NULL
00758 _STLP_DECLSPEC double _STLP_CALL abs(const complex<double>&);
00759 _STLP_TEMPLATE_NULL
00760 _STLP_DECLSPEC float _STLP_CALL arg(const complex<float>&);
00761 _STLP_TEMPLATE_NULL
00762 _STLP_DECLSPEC double _STLP_CALL arg(const complex<double>&);
00763 _STLP_TEMPLATE_NULL
00764 _STLP_DECLSPEC complex<float> _STLP_CALL polar(const float& __rho, const float& __phi);
00765 _STLP_TEMPLATE_NULL
00766 _STLP_DECLSPEC complex<double> _STLP_CALL polar(const double& __rho, const double& __phi);
00767 
00768 template <class _Tp>
00769 _Tp _STLP_CALL abs(const complex<_Tp>& __z)
00770 { return _Tp(abs(complex<double>(double(__z.real()), double(__z.imag())))); }
00771 
00772 template <class _Tp>
00773 _Tp _STLP_CALL arg(const complex<_Tp>& __z)
00774 { return _Tp(arg(complex<double>(double(__z.real()), double(__z.imag())))); }
00775 
00776 template <class _Tp>
00777 complex<_Tp> _STLP_CALL polar(const _Tp& __rho, const _Tp& __phi) {
00778   complex<double> __tmp = polar(double(__rho), double(__phi));
00779   return complex<_Tp>(_Tp(__tmp.real()), _Tp(__tmp.imag()));
00780 }
00781 
00782 #if !defined (_STLP_NO_LONG_DOUBLE)
00783 _STLP_TEMPLATE_NULL
00784 _STLP_DECLSPEC long double _STLP_CALL arg(const complex<long double>&);
00785 _STLP_TEMPLATE_NULL
00786 _STLP_DECLSPEC long double _STLP_CALL abs(const complex<long double>&);
00787 _STLP_TEMPLATE_NULL
00788 _STLP_DECLSPEC complex<long double> _STLP_CALL polar(const long double&, const long double&);
00789 #endif
00790 
00791 
00792 #if !defined (_STLP_USE_NO_IOSTREAMS)
00793 
00794 _STLP_END_NAMESPACE
00795 
00796 #  ifndef _STLP_INTERNAL_IOSFWD
00797 #    include <stl/_iosfwd.h>
00798 #  endif
00799 
00800 _STLP_BEGIN_NAMESPACE
00801 
00802 // Complex output, in the form (re,im).  We use a two-step process
00803 // involving stringstream so that we get the padding right.
00804 template <class _Tp, class _CharT, class _Traits>
00805 basic_ostream<_CharT, _Traits>&  _STLP_CALL
00806 operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __z);
00807 
00808 template <class _Tp, class _CharT, class _Traits>
00809 basic_istream<_CharT, _Traits>& _STLP_CALL
00810 operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __z);
00811 
00812 // Specializations for narrow characters; lets us avoid widen.
00813 
00814 _STLP_OPERATOR_TEMPLATE
00815 _STLP_DECLSPEC basic_istream<char, char_traits<char> >& _STLP_CALL
00816 operator>>(basic_istream<char, char_traits<char> >& __is, complex<float>& __z);
00817 
00818 _STLP_OPERATOR_TEMPLATE
00819 _STLP_DECLSPEC basic_istream<char, char_traits<char> >& _STLP_CALL
00820 operator>>(basic_istream<char, char_traits<char> >& __is, complex<double>& __z);
00821 
00822 _STLP_OPERATOR_TEMPLATE
00823 _STLP_DECLSPEC basic_ostream<char, char_traits<char> >& _STLP_CALL
00824 operator<<(basic_ostream<char, char_traits<char> >& __is, const complex<float>& __z);
00825 
00826 _STLP_OPERATOR_TEMPLATE
00827 _STLP_DECLSPEC basic_ostream<char, char_traits<char> >& _STLP_CALL
00828 operator<<(basic_ostream<char, char_traits<char> >& __is, const complex<double>& __z);
00829 
00830 #  if !defined (_STLP_NO_LONG_DOUBLE)
00831 _STLP_OPERATOR_TEMPLATE
00832 _STLP_DECLSPEC basic_istream<char, char_traits<char> >& _STLP_CALL
00833 operator>>(basic_istream<char, char_traits<char> >& __is, complex<long double>& __z);
00834 
00835 _STLP_OPERATOR_TEMPLATE
00836 _STLP_DECLSPEC basic_ostream<char, char_traits<char> >& _STLP_CALL
00837 operator<<(basic_ostream<char, char_traits<char> >& __is, const complex<long double>& __z);
00838 
00839 #  endif
00840 
00841 #  if defined (_STLP_USE_TEMPLATE_EXPORT) && ! defined (_STLP_NO_WCHAR_T)
00842 
00843 _STLP_EXPORT_TEMPLATE basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
00844 operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<double>&);
00845 _STLP_EXPORT_TEMPLATE basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
00846 operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<double>&);
00847 _STLP_EXPORT_TEMPLATE basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
00848 operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<float>&);
00849 _STLP_EXPORT_TEMPLATE basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
00850 operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<float>&);
00851 
00852 #    if !defined (_STLP_NO_LONG_DOUBLE)
00853 _STLP_EXPORT_TEMPLATE basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
00854 operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<long double>&);
00855 _STLP_EXPORT_TEMPLATE basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
00856 operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<long double>&);
00857 #    endif
00858 #  endif
00859 #endif
00860 
00861 
00862 // Transcendental functions.  These are defined only for float,
00863 //  double, and long double.  (Sqrt isn't transcendental, of course,
00864 //  but it's included in this section anyway.)
00865 
00866 _STLP_DECLSPEC complex<float> _STLP_CALL sqrt(const complex<float>&);
00867 
00868 _STLP_DECLSPEC complex<float> _STLP_CALL exp(const complex<float>&);
00869 _STLP_DECLSPEC complex<float> _STLP_CALL  log(const complex<float>&);
00870 _STLP_DECLSPEC complex<float> _STLP_CALL log10(const complex<float>&);
00871 
00872 _STLP_DECLSPEC complex<float> _STLP_CALL pow(const complex<float>&, int);
00873 _STLP_DECLSPEC complex<float> _STLP_CALL pow(const complex<float>&, const float&);
00874 _STLP_DECLSPEC complex<float> _STLP_CALL pow(const float&, const complex<float>&);
00875 _STLP_DECLSPEC complex<float> _STLP_CALL pow(const complex<float>&, const complex<float>&);
00876 
00877 _STLP_DECLSPEC complex<float> _STLP_CALL sin(const complex<float>&);
00878 _STLP_DECLSPEC complex<float> _STLP_CALL cos(const complex<float>&);
00879 _STLP_DECLSPEC complex<float> _STLP_CALL tan(const complex<float>&);
00880 
00881 _STLP_DECLSPEC complex<float> _STLP_CALL sinh(const complex<float>&);
00882 _STLP_DECLSPEC complex<float> _STLP_CALL cosh(const complex<float>&);
00883 _STLP_DECLSPEC complex<float> _STLP_CALL tanh(const complex<float>&);
00884 
00885 _STLP_DECLSPEC complex<double> _STLP_CALL sqrt(const complex<double>&);
00886 
00887 _STLP_DECLSPEC complex<double> _STLP_CALL exp(const complex<double>&);
00888 _STLP_DECLSPEC complex<double> _STLP_CALL log(const complex<double>&);
00889 _STLP_DECLSPEC complex<double> _STLP_CALL log10(const complex<double>&);
00890 
00891 _STLP_DECLSPEC complex<double> _STLP_CALL pow(const complex<double>&, int);
00892 _STLP_DECLSPEC complex<double> _STLP_CALL pow(const complex<double>&, const double&);
00893 _STLP_DECLSPEC complex<double> _STLP_CALL pow(const double&, const complex<double>&);
00894 _STLP_DECLSPEC complex<double> _STLP_CALL pow(const complex<double>&, const complex<double>&);
00895 
00896 _STLP_DECLSPEC complex<double> _STLP_CALL sin(const complex<double>&);
00897 _STLP_DECLSPEC complex<double> _STLP_CALL cos(const complex<double>&);
00898 _STLP_DECLSPEC complex<double> _STLP_CALL tan(const complex<double>&);
00899 
00900 _STLP_DECLSPEC complex<double> _STLP_CALL sinh(const complex<double>&);
00901 _STLP_DECLSPEC complex<double> _STLP_CALL cosh(const complex<double>&);
00902 _STLP_DECLSPEC complex<double> _STLP_CALL tanh(const complex<double>&);
00903 
00904 #if !defined (_STLP_NO_LONG_DOUBLE)
00905 _STLP_DECLSPEC complex<long double> _STLP_CALL sqrt(const complex<long double>&);
00906 _STLP_DECLSPEC complex<long double> _STLP_CALL exp(const complex<long double>&);
00907 _STLP_DECLSPEC complex<long double> _STLP_CALL log(const complex<long double>&);
00908 _STLP_DECLSPEC complex<long double> _STLP_CALL log10(const complex<long double>&);
00909 
00910 _STLP_DECLSPEC complex<long double> _STLP_CALL pow(const complex<long double>&, int);
00911 _STLP_DECLSPEC complex<long double> _STLP_CALL pow(const complex<long double>&, const long double&);
00912 _STLP_DECLSPEC complex<long double> _STLP_CALL pow(const long double&, const complex<long double>&);
00913 _STLP_DECLSPEC complex<long double> _STLP_CALL pow(const complex<long double>&,
00914                                                    const complex<long double>&);
00915 
00916 _STLP_DECLSPEC complex<long double> _STLP_CALL sin(const complex<long double>&);
00917 _STLP_DECLSPEC complex<long double> _STLP_CALL cos(const complex<long double>&);
00918 _STLP_DECLSPEC complex<long double> _STLP_CALL tan(const complex<long double>&);
00919 
00920 _STLP_DECLSPEC complex<long double> _STLP_CALL sinh(const complex<long double>&);
00921 _STLP_DECLSPEC complex<long double> _STLP_CALL cosh(const complex<long double>&);
00922 _STLP_DECLSPEC complex<long double> _STLP_CALL tanh(const complex<long double>&);
00923 #endif
00924 
00925 _STLP_END_NAMESPACE
00926 
00927 #ifndef _STLP_LINK_TIME_INSTANTIATION
00928 #  include <stl/_complex.c>
00929 #endif
00930 
00931 #endif
00932 
00933 // Local Variables:
00934 // mode:C++
00935 // End:

Generated on Sat May 26 2012 04:27:31 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.