ReactOS 0.4.15-dev-7788-g1ad9096
_complex.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 1999
3 * Silicon Graphics Computer Systems, Inc.
4 *
5 * Copyright (c) 1999
6 * Boris Fomitchev
7 *
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
10 *
11 * Permission to use or copy this software for any purpose is hereby granted
12 * without fee, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
16 *
17 */
18#ifndef _STLP_INTERNAL_COMPLEX
19#define _STLP_INTERNAL_COMPLEX
20
21// This header declares the template class complex, as described in
22// in the draft C++ standard. Single-precision complex numbers
23// are complex<float>, double-precision are complex<double>, and
24// quad precision are complex<long double>.
25
26// Note that the template class complex is declared within namespace
27// std, as called for by the draft C++ standard.
28
29#ifndef _STLP_INTERNAL_CMATH
30# include <stl/_cmath.h>
31#endif
32
34
35template <class _Tp>
36struct complex {
37 typedef _Tp value_type;
39
40 // Constructors, destructor, assignment operator.
41 complex() : _M_re(0), _M_im(0) {}
42 complex(const value_type& __x)
43 : _M_re(__x), _M_im(0) {}
44 complex(const value_type& __x, const value_type& __y)
45 : _M_re(__x), _M_im(__y) {}
46 complex(const _Self& __z)
47 : _M_re(__z._M_re), _M_im(__z._M_im) {}
48
49 _Self& operator=(const _Self& __z) {
50 _M_re = __z._M_re;
51 _M_im = __z._M_im;
52 return *this;
53 }
54
55#if defined (_STLP_MEMBER_TEMPLATES) && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
56 template <class _Tp2>
57 explicit complex(const complex<_Tp2>& __z)
58 : _M_re(__z._M_re), _M_im(__z._M_im) {}
59
60 template <class _Tp2>
61 _Self& operator=(const complex<_Tp2>& __z) {
62 _M_re = __z._M_re;
63 _M_im = __z._M_im;
64 return *this;
65 }
66#endif /* _STLP_MEMBER_TEMPLATES */
67
68 // Element access.
69 value_type real() const { return _M_re; }
70 value_type imag() const { return _M_im; }
71
72 // Arithmetic op= operations involving one real argument.
73
74 _Self& operator= (const value_type& __x) {
75 _M_re = __x;
76 _M_im = 0;
77 return *this;
78 }
80 _M_re += __x;
81 return *this;
82 }
83 _Self& operator-= (const value_type& __x) {
84 _M_re -= __x;
85 return *this;
86 }
87 _Self& operator*= (const value_type& __x) {
88 _M_re *= __x;
89 _M_im *= __x;
90 return *this;
91 }
92 _Self& operator/= (const value_type& __x) {
93 _M_re /= __x;
94 _M_im /= __x;
95 return *this;
96 }
97
98 // Arithmetic op= operations involving two complex arguments.
99
100 static void _STLP_CALL _div(const value_type& __z1_r, const value_type& __z1_i,
101 const value_type& __z2_r, const value_type& __z2_i,
102 value_type& __res_r, value_type& __res_i);
103
104 static void _STLP_CALL _div(const value_type& __z1_r,
105 const value_type& __z2_r, const value_type& __z2_i,
106 value_type& __res_r, value_type& __res_i);
107
108#if defined (_STLP_MEMBER_TEMPLATES) // && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
109
110 template <class _Tp2> _Self& operator+= (const complex<_Tp2>& __z) {
111 _M_re += __z._M_re;
112 _M_im += __z._M_im;
113 return *this;
114 }
115
116 template <class _Tp2> _Self& operator-= (const complex<_Tp2>& __z) {
117 _M_re -= __z._M_re;
118 _M_im -= __z._M_im;
119 return *this;
120 }
121
122 template <class _Tp2> _Self& operator*= (const complex<_Tp2>& __z) {
123 value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
124 value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
125 _M_re = __r;
126 _M_im = __i;
127 return *this;
128 }
129
130 template <class _Tp2> _Self& operator/= (const complex<_Tp2>& __z) {
131 value_type __r;
132 value_type __i;
133 _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
134 _M_re = __r;
135 _M_im = __i;
136 return *this;
137 }
138#endif /* _STLP_MEMBER_TEMPLATES */
139
140 _Self& operator+= (const _Self& __z) {
141 _M_re += __z._M_re;
142 _M_im += __z._M_im;
143 return *this;
144 }
145
146 _Self& operator-= (const _Self& __z) {
147 _M_re -= __z._M_re;
148 _M_im -= __z._M_im;
149 return *this;
150 }
151
152 _Self& operator*= (const _Self& __z) {
153 value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
154 value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
155 _M_re = __r;
156 _M_im = __i;
157 return *this;
158 }
159
160 _Self& operator/= (const _Self& __z) {
161 value_type __r;
162 value_type __i;
163 _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
164 _M_re = __r;
165 _M_im = __i;
166 return *this;
167 }
168
169 // Data members.
172};
173
174// Explicit specializations for float, double, long double. The only
175// reason for these specializations is to enable automatic conversions
176// from complex<float> to complex<double>, and complex<double> to
177// complex<long double>.
178
181 typedef float value_type;
183 // Constructors, destructor, assignment operator.
184
185 complex(value_type __x = 0.0f, value_type __y = 0.0f)
186 : _M_re(__x), _M_im(__y) {}
187
188 complex(const complex<float>& __z) : _M_re(__z._M_re), _M_im(__z._M_im) {}
189
190 inline explicit complex(const complex<double>& __z);
191#ifndef _STLP_NO_LONG_DOUBLE
192 inline explicit complex(const complex<long double>& __z);
193#endif
194 // Element access.
195 value_type real() const { return _M_re; }
196 value_type imag() const { return _M_im; }
197
198 // Arithmetic op= operations involving one real argument.
199
200 _Self& operator= (value_type __x) {
201 _M_re = __x;
202 _M_im = 0.0f;
203 return *this;
204 }
206 _M_re += __x;
207 return *this;
208 }
209 _Self& operator-= (value_type __x) {
210 _M_re -= __x;
211 return *this;
212 }
213 _Self& operator*= (value_type __x) {
214 _M_re *= __x;
215 _M_im *= __x;
216 return *this;
217 }
218 _Self& operator/= (value_type __x) {
219 _M_re /= __x;
220 _M_im /= __x;
221 return *this;
222 }
223
224 // Arithmetic op= operations involving two complex arguments.
225
226 static void _STLP_CALL _div(const float& __z1_r, const float& __z1_i,
227 const float& __z2_r, const float& __z2_i,
228 float& __res_r, float& __res_i);
229
230 static void _STLP_CALL _div(const float& __z1_r,
231 const float& __z2_r, const float& __z2_i,
232 float& __res_r, float& __res_i);
233
234#if defined (_STLP_MEMBER_TEMPLATES)
235 template <class _Tp2>
236 complex<float>& operator=(const complex<_Tp2>& __z) {
237 _M_re = __z._M_re;
238 _M_im = __z._M_im;
239 return *this;
240 }
241
242 template <class _Tp2>
244 _M_re += __z._M_re;
245 _M_im += __z._M_im;
246 return *this;
247 }
248
249 template <class _Tp2>
250 complex<float>& operator-= (const complex<_Tp2>& __z) {
251 _M_re -= __z._M_re;
252 _M_im -= __z._M_im;
253 return *this;
254 }
255
256 template <class _Tp2>
257 complex<float>& operator*= (const complex<_Tp2>& __z) {
258 float __r = _M_re * __z._M_re - _M_im * __z._M_im;
259 float __i = _M_re * __z._M_im + _M_im * __z._M_re;
260 _M_re = __r;
261 _M_im = __i;
262 return *this;
263 }
264
265 template <class _Tp2>
266 complex<float>& operator/= (const complex<_Tp2>& __z) {
267 float __r;
268 float __i;
269 _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
270 _M_re = __r;
271 _M_im = __i;
272 return *this;
273 }
274
275#endif /* _STLP_MEMBER_TEMPLATES */
276
277 _Self& operator=(const _Self& __z) {
278 _M_re = __z._M_re;
279 _M_im = __z._M_im;
280 return *this;
281 }
282
283 _Self& operator+= (const _Self& __z) {
284 _M_re += __z._M_re;
285 _M_im += __z._M_im;
286 return *this;
287 }
288
289 _Self& operator-= (const _Self& __z) {
290 _M_re -= __z._M_re;
291 _M_im -= __z._M_im;
292 return *this;
293 }
294
295 _Self& operator*= (const _Self& __z) {
296 value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
297 value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
298 _M_re = __r;
299 _M_im = __i;
300 return *this;
301 }
302
303 _Self& operator/= (const _Self& __z) {
304 value_type __r;
305 value_type __i;
306 _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
307 _M_re = __r;
308 _M_im = __i;
309 return *this;
310 }
311
312 // Data members.
315};
316
319 typedef double value_type;
321
322 // Constructors, destructor, assignment operator.
323
324 complex(value_type __x = 0.0, value_type __y = 0.0)
325 : _M_re(__x), _M_im(__y) {}
326
328 : _M_re(__z._M_re), _M_im(__z._M_im) {}
329 inline complex(const complex<float>& __z);
330#if !defined (_STLP_NO_LONG_DOUBLE)
331 explicit inline complex(const complex<long double>& __z);
332#endif
333 // Element access.
334 value_type real() const { return _M_re; }
335 value_type imag() const { return _M_im; }
336
337 // Arithmetic op= operations involving one real argument.
338
339 _Self& operator= (value_type __x) {
340 _M_re = __x;
341 _M_im = 0.0;
342 return *this;
343 }
345 _M_re += __x;
346 return *this;
347 }
348 _Self& operator-= (value_type __x) {
349 _M_re -= __x;
350 return *this;
351 }
352 _Self& operator*= (value_type __x) {
353 _M_re *= __x;
354 _M_im *= __x;
355 return *this;
356 }
357 _Self& operator/= (value_type __x) {
358 _M_re /= __x;
359 _M_im /= __x;
360 return *this;
361 }
362
363 // Arithmetic op= operations involving two complex arguments.
364
365 static void _STLP_CALL _div(const double& __z1_r, const double& __z1_i,
366 const double& __z2_r, const double& __z2_i,
367 double& __res_r, double& __res_i);
368 static void _STLP_CALL _div(const double& __z1_r,
369 const double& __z2_r, const double& __z2_i,
370 double& __res_r, double& __res_i);
371
372#if defined (_STLP_MEMBER_TEMPLATES) && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
373 template <class _Tp2>
374 complex<double>& operator=(const complex<_Tp2>& __z) {
375 _M_re = __z._M_re;
376 _M_im = __z._M_im;
377 return *this;
378 }
379
380 template <class _Tp2>
382 _M_re += __z._M_re;
383 _M_im += __z._M_im;
384 return *this;
385 }
386
387 template <class _Tp2>
388 complex<double>& operator-= (const complex<_Tp2>& __z) {
389 _M_re -= __z._M_re;
390 _M_im -= __z._M_im;
391 return *this;
392 }
393
394 template <class _Tp2>
395 complex<double>& operator*= (const complex<_Tp2>& __z) {
396 double __r = _M_re * __z._M_re - _M_im * __z._M_im;
397 double __i = _M_re * __z._M_im + _M_im * __z._M_re;
398 _M_re = __r;
399 _M_im = __i;
400 return *this;
401 }
402
403 template <class _Tp2>
404 complex<double>& operator/= (const complex<_Tp2>& __z) {
405 double __r;
406 double __i;
407 _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
408 _M_re = __r;
409 _M_im = __i;
410 return *this;
411 }
412
413#endif /* _STLP_MEMBER_TEMPLATES */
414
415 _Self& operator=(const _Self& __z) {
416 _M_re = __z._M_re;
417 _M_im = __z._M_im;
418 return *this;
419 }
420
421 _Self& operator+= (const _Self& __z) {
422 _M_re += __z._M_re;
423 _M_im += __z._M_im;
424 return *this;
425 }
426
427 _Self& operator-= (const _Self& __z) {
428 _M_re -= __z._M_re;
429 _M_im -= __z._M_im;
430 return *this;
431 }
432
433 _Self& operator*= (const _Self& __z) {
434 value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
435 value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
436 _M_re = __r;
437 _M_im = __i;
438 return *this;
439 }
440
441 _Self& operator/= (const _Self& __z) {
442 value_type __r;
443 value_type __i;
444 _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
445 _M_re = __r;
446 _M_im = __i;
447 return *this;
448 }
449
450 // Data members.
453};
454
455#if !defined (_STLP_NO_LONG_DOUBLE)
456
459 typedef long double value_type;
461
462 // Constructors, destructor, assignment operator.
463 complex(value_type __x = 0.0l, value_type __y = 0.0l)
464 : _M_re(__x), _M_im(__y) {}
465
467 : _M_re(__z._M_re), _M_im(__z._M_im) {}
468 inline complex(const complex<float>& __z);
469 inline complex(const complex<double>& __z);
470
471 // Element access.
472 value_type real() const { return _M_re; }
473 value_type imag() const { return _M_im; }
474
475 // Arithmetic op= operations involving one real argument.
476
477 _Self& operator= (value_type __x) {
478 _M_re = __x;
479 _M_im = 0.0l;
480 return *this;
481 }
483 _M_re += __x;
484 return *this;
485 }
486 _Self& operator-= (value_type __x) {
487 _M_re -= __x;
488 return *this;
489 }
490 _Self& operator*= (value_type __x) {
491 _M_re *= __x;
492 _M_im *= __x;
493 return *this;
494 }
495 _Self& operator/= (value_type __x) {
496 _M_re /= __x;
497 _M_im /= __x;
498 return *this;
499 }
500
501 // Arithmetic op= operations involving two complex arguments.
502
503 static void _STLP_CALL _div(const long double& __z1_r, const long double& __z1_i,
504 const long double& __z2_r, const long double& __z2_i,
505 long double& __res_r, long double& __res_i);
506
507 static void _STLP_CALL _div(const long double& __z1_r,
508 const long double& __z2_r, const long double& __z2_i,
509 long double& __res_r, long double& __res_i);
510
511# if defined (_STLP_MEMBER_TEMPLATES) && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
512
513 template <class _Tp2>
514 complex<long double>& operator=(const complex<_Tp2>& __z) {
515 _M_re = __z._M_re;
516 _M_im = __z._M_im;
517 return *this;
518 }
519
520 template <class _Tp2>
522 _M_re += __z._M_re;
523 _M_im += __z._M_im;
524 return *this;
525 }
526
527 template <class _Tp2>
528 complex<long double>& operator-= (const complex<_Tp2>& __z) {
529 _M_re -= __z._M_re;
530 _M_im -= __z._M_im;
531 return *this;
532 }
533
534 template <class _Tp2>
535 complex<long double>& operator*= (const complex<_Tp2>& __z) {
536 long double __r = _M_re * __z._M_re - _M_im * __z._M_im;
537 long double __i = _M_re * __z._M_im + _M_im * __z._M_re;
538 _M_re = __r;
539 _M_im = __i;
540 return *this;
541 }
542
543 template <class _Tp2>
544 complex<long double>& operator/= (const complex<_Tp2>& __z) {
545 long double __r;
546 long double __i;
547 _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
548 _M_re = __r;
549 _M_im = __i;
550 return *this;
551 }
552
553# endif /* _STLP_MEMBER_TEMPLATES */
554
555 _Self& operator=(const _Self& __z) {
556 _M_re = __z._M_re;
557 _M_im = __z._M_im;
558 return *this;
559 }
560
561 _Self& operator+= (const _Self& __z) {
562 _M_re += __z._M_re;
563 _M_im += __z._M_im;
564 return *this;
565 }
566
567 _Self& operator-= (const _Self& __z) {
568 _M_re -= __z._M_re;
569 _M_im -= __z._M_im;
570 return *this;
571 }
572
573 _Self& operator*= (const _Self& __z) {
574 value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
575 value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
576 _M_re = __r;
577 _M_im = __i;
578 return *this;
579 }
580
581 _Self& operator/= (const _Self& __z) {
582 value_type __r;
583 value_type __i;
584 _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
585 _M_re = __r;
586 _M_im = __i;
587 return *this;
588 }
589
590 // Data members.
593};
594
595#endif /* _STLP_NO_LONG_DOUBLE */
596
597// Converting constructors from one of these three specialized types
598// to another.
599
601 : _M_re((float)__z._M_re), _M_im((float)__z._M_im) {}
603 : _M_re(__z._M_re), _M_im(__z._M_im) {}
604#ifndef _STLP_NO_LONG_DOUBLE
606 : _M_re((float)__z._M_re), _M_im((float)__z._M_im) {}
608 : _M_re((double)__z._M_re), _M_im((double)__z._M_im) {}
610 : _M_re(__z._M_re), _M_im(__z._M_im) {}
612 : _M_re(__z._M_re), _M_im(__z._M_im) {}
613#endif
614
615// Unary non-member arithmetic operators.
616
617template <class _Tp>
619{ return __z; }
620
621template <class _Tp>
623{ return complex<_Tp>(-__z._M_re, -__z._M_im); }
624
625// Non-member arithmetic operations involving one real argument.
626
627template <class _Tp>
628inline complex<_Tp> _STLP_CALL operator+(const _Tp& __x, const complex<_Tp>& __z)
629{ return complex<_Tp>(__x + __z._M_re, __z._M_im); }
630
631template <class _Tp>
632inline complex<_Tp> _STLP_CALL operator+(const complex<_Tp>& __z, const _Tp& __x)
633{ return complex<_Tp>(__z._M_re + __x, __z._M_im); }
634
635template <class _Tp>
636inline complex<_Tp> _STLP_CALL operator-(const _Tp& __x, const complex<_Tp>& __z)
637{ return complex<_Tp>(__x - __z._M_re, -__z._M_im); }
638
639template <class _Tp>
640inline complex<_Tp> _STLP_CALL operator-(const complex<_Tp>& __z, const _Tp& __x)
641{ return complex<_Tp>(__z._M_re - __x, __z._M_im); }
642
643template <class _Tp>
644inline complex<_Tp> _STLP_CALL operator*(const _Tp& __x, const complex<_Tp>& __z)
645{ return complex<_Tp>(__x * __z._M_re, __x * __z._M_im); }
646
647template <class _Tp>
648inline complex<_Tp> _STLP_CALL operator*(const complex<_Tp>& __z, const _Tp& __x)
649{ return complex<_Tp>(__z._M_re * __x, __z._M_im * __x); }
650
651template <class _Tp>
652inline complex<_Tp> _STLP_CALL operator/(const _Tp& __x, const complex<_Tp>& __z) {
653 complex<_Tp> __result;
655 __z._M_re, __z._M_im,
656 __result._M_re, __result._M_im);
657 return __result;
658}
659
660template <class _Tp>
661inline complex<_Tp> _STLP_CALL operator/(const complex<_Tp>& __z, const _Tp& __x)
662{ return complex<_Tp>(__z._M_re / __x, __z._M_im / __x); }
663
664// Non-member arithmetic operations involving two complex arguments
665
666template <class _Tp>
668operator+(const complex<_Tp>& __z1, const complex<_Tp>& __z2)
669{ return complex<_Tp>(__z1._M_re + __z2._M_re, __z1._M_im + __z2._M_im); }
670
671template <class _Tp>
673operator-(const complex<_Tp>& __z1, const complex<_Tp>& __z2)
674{ return complex<_Tp>(__z1._M_re - __z2._M_re, __z1._M_im - __z2._M_im); }
675
676template <class _Tp>
678operator*(const complex<_Tp>& __z1, const complex<_Tp>& __z2) {
679 return complex<_Tp>(__z1._M_re * __z2._M_re - __z1._M_im * __z2._M_im,
680 __z1._M_re * __z2._M_im + __z1._M_im * __z2._M_re);
681}
682
683template <class _Tp>
685operator/(const complex<_Tp>& __z1, const complex<_Tp>& __z2) {
686 complex<_Tp> __result;
687 complex<_Tp>::_div(__z1._M_re, __z1._M_im,
688 __z2._M_re, __z2._M_im,
689 __result._M_re, __result._M_im);
690 return __result;
691}
692
693// Comparison operators.
694
695template <class _Tp>
696inline bool _STLP_CALL operator==(const complex<_Tp>& __z1, const complex<_Tp>& __z2)
697{ return __z1._M_re == __z2._M_re && __z1._M_im == __z2._M_im; }
698
699template <class _Tp>
700inline bool _STLP_CALL operator==(const complex<_Tp>& __z, const _Tp& __x)
701{ return __z._M_re == __x && __z._M_im == 0; }
702
703template <class _Tp>
704inline bool _STLP_CALL operator==(const _Tp& __x, const complex<_Tp>& __z)
705{ return __x == __z._M_re && 0 == __z._M_im; }
706
707//04/27/04 dums: removal of this check, if it is restablish
708//please explain why the other operators are not macro guarded
709//#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
710
711template <class _Tp>
712inline bool _STLP_CALL operator!=(const complex<_Tp>& __z1, const complex<_Tp>& __z2)
713{ return __z1._M_re != __z2._M_re || __z1._M_im != __z2._M_im; }
714
715//#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
716
717template <class _Tp>
718inline bool _STLP_CALL operator!=(const complex<_Tp>& __z, const _Tp& __x)
719{ return __z._M_re != __x || __z._M_im != 0; }
720
721template <class _Tp>
722inline bool _STLP_CALL operator!=(const _Tp& __x, const complex<_Tp>& __z)
723{ return __x != __z._M_re || 0 != __z._M_im; }
724
725// Other basic arithmetic operations
726template <class _Tp>
727inline _Tp _STLP_CALL real(const complex<_Tp>& __z)
728{ return __z._M_re; }
729
730template <class _Tp>
731inline _Tp _STLP_CALL imag(const complex<_Tp>& __z)
732{ return __z._M_im; }
733
734template <class _Tp>
735_Tp _STLP_CALL abs(const complex<_Tp>& __z);
736
737template <class _Tp>
738_Tp _STLP_CALL arg(const complex<_Tp>& __z);
739
740template <class _Tp>
741inline _Tp _STLP_CALL norm(const complex<_Tp>& __z)
742{ return __z._M_re * __z._M_re + __z._M_im * __z._M_im; }
743
744template <class _Tp>
746{ return complex<_Tp>(__z._M_re, -__z._M_im); }
747
748template <class _Tp>
750{ return complex<_Tp>(__rho, 0); }
751
752template <class _Tp>
753complex<_Tp> _STLP_CALL polar(const _Tp& __rho, const _Tp& __phi);
754
764_STLP_DECLSPEC complex<float> _STLP_CALL polar(const float& __rho, const float& __phi);
766_STLP_DECLSPEC complex<double> _STLP_CALL polar(const double& __rho, const double& __phi);
767
768template <class _Tp>
770{ return _Tp(abs(complex<double>(double(__z.real()), double(__z.imag())))); }
771
772template <class _Tp>
774{ return _Tp(arg(complex<double>(double(__z.real()), double(__z.imag())))); }
775
776template <class _Tp>
777complex<_Tp> _STLP_CALL polar(const _Tp& __rho, const _Tp& __phi) {
778 complex<double> __tmp = polar(double(__rho), double(__phi));
779 return complex<_Tp>(_Tp(__tmp.real()), _Tp(__tmp.imag()));
780}
781
782#if !defined (_STLP_NO_LONG_DOUBLE)
788_STLP_DECLSPEC complex<long double> _STLP_CALL polar(const long double&, const long double&);
789#endif
790
791
792#if !defined (_STLP_USE_NO_IOSTREAMS)
793
795
796# ifndef _STLP_INTERNAL_IOSFWD
797# include <stl/_iosfwd.h>
798# endif
799
801
802// Complex output, in the form (re,im). We use a two-step process
803// involving stringstream so that we get the padding right.
804template <class _Tp, class _CharT, class _Traits>
807
808template <class _Tp, class _CharT, class _Traits>
811
812// Specializations for narrow characters; lets us avoid widen.
813
817
821
825
829
830# if !defined (_STLP_NO_LONG_DOUBLE)
834
838
839# endif
840
841# if defined (_STLP_USE_TEMPLATE_EXPORT) && ! defined (_STLP_NO_WCHAR_T)
842
851
852# if !defined (_STLP_NO_LONG_DOUBLE)
857# endif
858# endif
859#endif
860
861
862// Transcendental functions. These are defined only for float,
863// double, and long double. (Sqrt isn't transcendental, of course,
864// but it's included in this section anyway.)
865
867
871
876
880
884
886
890
895
899
903
904#if !defined (_STLP_NO_LONG_DOUBLE)
909
914 const complex<long double>&);
915
919
923#endif
924
926
927#ifndef _STLP_LINK_TIME_INSTANTIATION
928# include <stl/_complex.c>
929#endif
930
931#endif
932
933// Local Variables:
934// mode:C++
935// End:
#define _STLP_CALL
Definition: _bc.h:131
_STLP_DECLSPEC complex< float > _STLP_CALL pow(const complex< float > &, int)
Definition: complex.cpp:308
_STLP_DECLSPEC complex< float > _STLP_CALL sinh(const complex< float > &)
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
_STLP_DECLSPEC complex< float > _STLP_CALL tan(const complex< float > &)
complex< _Tp > _STLP_CALL operator/(const _Tp &__x, const complex< _Tp > &__z)
Definition: _complex.h:652
complex< _Tp > _STLP_CALL operator-(const complex< _Tp > &__z)
Definition: _complex.h:622
_Tp _STLP_CALL norm(const complex< _Tp > &__z)
Definition: _complex.h:741
_STLP_DECLSPEC complex< float > _STLP_CALL cosh(const complex< float > &)
bool _STLP_CALL operator==(const complex< _Tp > &__z1, const complex< _Tp > &__z2)
Definition: _complex.h:696
_Tp _STLP_CALL imag(const complex< _Tp > &__z)
Definition: _complex.h:731
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
complex< _Tp > _STLP_CALL polar(const _Tp &__rho)
Definition: _complex.h:749
_STLP_END_NAMESPACE _STLP_BEGIN_NAMESPACE basic_ostream< _CharT, _Traits > &_STLP_CALL operator<<(basic_ostream< _CharT, _Traits > &__os, const complex< _Tp > &__z)
Definition: _complex.c:92
_STLP_DECLSPEC complex< float > _STLP_CALL log10(const complex< float > &)
Definition: complex.cpp:230
bool _STLP_CALL operator!=(const complex< _Tp > &__z1, const complex< _Tp > &__z2)
Definition: _complex.h:712
basic_istream< _CharT, _Traits > &_STLP_CALL operator>>(basic_istream< _CharT, _Traits > &__is, complex< _Tp > &__z)
Definition: _complex.c:107
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
Definition: complex.cpp:188
_STLP_DECLSPEC complex< float > _STLP_CALL tanh(const complex< float > &)
complex< _Tp > _STLP_CALL operator+(const complex< _Tp > &__z)
Definition: _complex.h:618
complex< _Tp > _STLP_CALL operator*(const _Tp &__x, const complex< _Tp > &__z)
Definition: _complex.h:644
complex< _Tp > _STLP_CALL conj(const complex< _Tp > &__z)
Definition: _complex.h:745
rope< _CharT, _Alloc > & operator+=(rope< _CharT, _Alloc > &__left, const rope< _CharT, _Alloc > &__right)
Definition: _rope.h:2202
#define complex
Definition: complex.h:37
unsigned long
Definition: typeof.h:102
#define abs(i)
Definition: fconv.c:206
#define _STLP_TEMPLATE_NULL
Definition: features.h:652
#define _STLP_OPERATOR_TEMPLATE
Definition: features.h:658
#define _STLP_CLASS_DECLSPEC
Definition: features.h:983
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_EXPORT_TEMPLATE
Definition: features.h:955
#define _STLP_END_NAMESPACE
Definition: features.h:503
#define _STLP_DECLSPEC
Definition: features.h:982
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
static float(__cdecl *square_half_float)(float x
DWORD exp
Definition: msg.c:16058
#define real
#define log(outFile, fmt,...)
Definition: util.h:15
complex< double > _Self
Definition: _complex.h:320
complex(value_type __x=0.0, value_type __y=0.0)
Definition: _complex.h:324
double value_type
Definition: _complex.h:319
complex(const complex< double > &__z)
Definition: _complex.h:327
value_type _M_im
Definition: _complex.h:452
value_type imag() const
Definition: _complex.h:335
_Self & operator=(const _Self &__z)
Definition: _complex.h:415
value_type real() const
Definition: _complex.h:334
value_type _M_re
Definition: _complex.h:451
value_type real() const
Definition: _complex.h:195
complex(const complex< float > &__z)
Definition: _complex.h:188
complex< float > _Self
Definition: _complex.h:182
float value_type
Definition: _complex.h:181
value_type _M_im
Definition: _complex.h:314
value_type imag() const
Definition: _complex.h:196
complex(value_type __x=0.0f, value_type __y=0.0f)
Definition: _complex.h:185
_Self & operator=(const _Self &__z)
Definition: _complex.h:277
value_type _M_re
Definition: _complex.h:313
value_type real() const
Definition: _complex.h:472
complex(const complex< long double > &__z)
Definition: _complex.h:466
_Self & operator=(const _Self &__z)
Definition: _complex.h:555
static void _STLP_CALL _div(const long double &__z1_r, const long double &__z2_r, const long double &__z2_i, long double &__res_r, long double &__res_i)
value_type imag() const
Definition: _complex.h:473
complex(value_type __x=0.0l, value_type __y=0.0l)
Definition: _complex.h:463
complex(const complex< float > &__z)
static void _STLP_CALL _div(const long double &__z1_r, const long double &__z1_i, const long double &__z2_r, const long double &__z2_i, long double &__res_r, long double &__res_i)
complex(const complex< double > &__z)
long double value_type
Definition: _complex.h:459
complex< long double > _Self
Definition: _complex.h:460
complex< _Tp > _Self
Definition: _complex.h:38
complex(const _Self &__z)
Definition: _complex.h:46
complex()
Definition: _complex.h:41
_Self & operator=(const _Self &__z)
Definition: _complex.h:49
value_type real() const
Definition: _complex.h:69
complex(const value_type &__x)
Definition: _complex.h:42
_Tp value_type
Definition: _complex.h:37
value_type _M_im
Definition: _complex.h:171
complex(const value_type &__x, const value_type &__y)
Definition: _complex.h:44
value_type _M_re
Definition: _complex.h:170
static void _STLP_CALL _div(const value_type &__z1_r, const value_type &__z1_i, const value_type &__z2_r, const value_type &__z2_i, value_type &__res_r, value_type &__res_i)
Definition: _complex.c:44
value_type imag() const
Definition: _complex.h:70
void * arg
Definition: msvc.h:10