1 // xcomplex internal header
2 #pragma once
3 #ifndef _XCOMPLEX_
4 #define _XCOMPLEX_
5 #ifndef RC_INVOKED
6
7         // TEMPLATE FUNCTION operator+
8 _TMPLT(_Ty) inline
9     _CMPLX(_Ty) __CLRCALL_OR_CDECL operator+(const _CMPLX(_Ty)& _Left,
10         const _CMPLX(_Ty)& _Right)
11     {    // add complex to complex
12     _CMPLX(_Ty) _Tmp(_Left);
13     return (_Tmp += _Right);
14     }
15
16 _TMPLT(_Ty) inline
17     _CMPLX(_Ty) __CLRCALL_OR_CDECL operator+(const _CMPLX(_Ty)& _Left,
18         const _Ty& _Right)
19     {    // add real to complex
20     _CMPLX(_Ty) _Tmp(_Left);
21     _Tmp.real(_Tmp.real() + _Right);
22     return (_Tmp);
23     }
24
25 _TMPLT(_Ty) inline
26     _CMPLX(_Ty) __CLRCALL_OR_CDECL operator+(const _Ty& _Left,
27         const _CMPLX(_Ty)& _Right)
28     {    // add complex to real
29     _CMPLX(_Ty) _Tmp(_Left);
30     return (_Tmp += _Right);
31     }
32
33         // TEMPLATE FUNCTION operator-
34 _TMPLT(_Ty) inline
35     _CMPLX(_Ty) __CLRCALL_OR_CDECL operator-(const _CMPLX(_Ty)& _Left,
36         const _CMPLX(_Ty)& _Right)
37     {    // subtract complex from complex
38     _CMPLX(_Ty) _Tmp(_Left);
39     return (_Tmp -= _Right);
40     }
41
42 _TMPLT(_Ty) inline
43     _CMPLX(_Ty) __CLRCALL_OR_CDECL operator-(const _CMPLX(_Ty)& _Left,
44         const _Ty& _Right)
45     {    // subtract real from complex
46     _CMPLX(_Ty) _Tmp(_Left);
47     _Tmp.real(_Tmp.real() - _Right);
48     return (_Tmp);
49     }
50
51 _TMPLT(_Ty) inline
52     _CMPLX(_Ty) __CLRCALL_OR_CDECL operator-(const _Ty& _Left,
53         const _CMPLX(_Ty)& _Right)
54     {    // subtract complex from real
55     _CMPLX(_Ty) _Tmp(_Left);
Lines 56 ... 426 are skipped.
427         -_CTR(_Ty)::_Sinh(imag(_Left),
428             _CTR(_Ty)::sin(real(_Left)))));
429     }
430
431         // TEMPLATE FUNCTION log10
432 _TMPLT(_Ty) inline
433     _CMPLX(_Ty) __CLRCALL_OR_CDECL log10(const _CMPLX(_Ty)& _Left)
434     {    // return log10(complex)
435     return (log(_Left) * (_Ty)0.43429448190325182765112891891660508L);
436     }
437
438         // TEMPLATE FUNCTION norm
439 _TMPLT(_Ty) inline
440     _Ty __CLRCALL_OR_CDECL norm(const _CMPLX(_Ty)& _Left)
441     {    // return squared magnitude
442     return (real(_Left) * real(_Left) + imag(_Left) * imag(_Left));
443     }
444
445         // TEMPLATE FUNCTION polar
446 _TMPLT(_Ty) inline
447     _CMPLX(_Ty) __CLRCALL_OR_CDECL polar(const _Ty& _Rho, const _Ty& _Theta)
448     {    // return _Rho * exp(i * _Theta) as complex
449     return (_CMPLX(_Ty)(_Rho * _CTR(_Ty)::cos(_Theta),
450         _Rho * _CTR(_Ty)::sin(_Theta)));
451     }
452
453 _TMPLT(_Ty) inline
454     _CMPLX(_Ty) __CLRCALL_OR_CDECL polar(const _Ty& _Rho)
455     {    // return _Rho * exp(i * 0) as complex
456     return (_CMPLX(_Ty)(_Rho, (_Ty)0));
457     }
458
459         // TEMPLATE FUNCTION sin
460 _TMPLT(_Ty) inline
461     _CMPLX(_Ty) __CLRCALL_OR_CDECL sin(const _CMPLX(_Ty)& _Left)
462     {    // return sin(complex)
463     return (_CMPLX(_Ty)(
464         _CTR(_Ty)::_Cosh(imag(_Left), _CTR(_Ty)::sin(real(_Left))),
465         _CTR(_Ty)::_Sinh(imag(_Left), _CTR(_Ty)::cos(real(_Left)))));
466     }
467
468     // TEMPLATE FUNCTION tan
469 _TMPLT(_Ty) inline
470     _CMPLX(_Ty) __CLRCALL_OR_CDECL tan(const _CMPLX(_Ty)& _Left)
471     {    // return tan(complex)
472     _CMPLX(_Ty) _Zv(tanh(_CMPLX(_Ty)(-imag(_Left), real(_Left))));
473     return (_CMPLX(_Ty)(imag(_Zv), -real(_Zv)));
474     }
475
476  #if defined(_DLL_CPPLIB) && !defined(_M_CEE_PURE)
477 template _CRTIMP2_PURE float
478     __CLRCALL_OR_CDECL imag(const complex<float>&);
479 template _CRTIMP2_PURE float
480     __CLRCALL_OR_CDECL real(const complex<float>&);
481 template _CRTIMP2_PURE float
482     __CLRCALL_OR_CDECL _Fabs(const complex<float>&, int *);
483 template _CRTIMP2_PURE complex<float>
484     __CLRCALL_OR_CDECL operator+(const complex<float>&, const complex<float>&);
485 template _CRTIMP2_PURE complex<float>
486     __CLRCALL_OR_CDECL operator+(const complex<float>&, const float&);
487 template _CRTIMP2_PURE complex<float>
488     __CLRCALL_OR_CDECL operator+(const float&, const complex<float>&);
489 template _CRTIMP2_PURE complex<float>
490     __CLRCALL_OR_CDECL operator-(const complex<float>&, const complex<float>&);
491 template _CRTIMP2_PURE complex<float>
492     __CLRCALL_OR_CDECL operator-(const complex<float>&, const float&);
493 template _CRTIMP2_PURE complex<float>
494     __CLRCALL_OR_CDECL operator-(const float&, const complex<float>&);
495 template _CRTIMP2_PURE complex<float>
496     __CLRCALL_OR_CDECL operator*(const complex<float>&, const complex<float>&);
497 template _CRTIMP2_PURE complex<float>
498     __CLRCALL_OR_CDECL operator*(const complex<float>&, const float&);
499 template _CRTIMP2_PURE complex<float>
500     __CLRCALL_OR_CDECL operator*(const float&, const complex<float>&);
501 template _CRTIMP2_PURE complex<float>
502     __CLRCALL_OR_CDECL operator/(const complex<float>&, const complex<float>&);
503 template _CRTIMP2_PURE complex<float>
504     __CLRCALL_OR_CDECL operator/(const complex<float>&, const float&);
505 template _CRTIMP2_PURE complex<float>
506     __CLRCALL_OR_CDECL operator/(const float&, const complex<float>&);
507 template _CRTIMP2_PURE complex<float>
508     __CLRCALL_OR_CDECL operator+(const complex<float>&);
509 template _CRTIMP2_PURE complex<float>
510     __CLRCALL_OR_CDECL operator-(const complex<float>&);
511 template _CRTIMP2_PURE bool
512     __CLRCALL_OR_CDECL operator==(const complex<float>&, const complex<float>&);
513 template _CRTIMP2_PURE bool
514     __CLRCALL_OR_CDECL operator==(const complex<float>&, const float&);
515 template _CRTIMP2_PURE bool
516     __CLRCALL_OR_CDECL operator==(const float&, const complex<float>&);
517 template _CRTIMP2_PURE bool
518     __CLRCALL_OR_CDECL operator!=(const complex<float>&, const complex<float>&);
519 template _CRTIMP2_PURE bool
520     __CLRCALL_OR_CDECL operator!=(const complex<float>&, const float&);
521 template _CRTIMP2_PURE bool
522     __CLRCALL_OR_CDECL operator!=(const float&, const complex<float>&);
523 template _CRTIMP2_PURE float
524     __CLRCALL_OR_CDECL abs(const complex<float>&);
525 template _CRTIMP2_PURE float
526     __CLRCALL_OR_CDECL arg(const complex<float>&);
527 template _CRTIMP2_PURE complex<float>
528     __CLRCALL_OR_CDECL conj(const complex<float>&);
529 template _CRTIMP2_PURE complex<float>
530     __CLRCALL_OR_CDECL cos(const complex<float>&);
531 template _CRTIMP2_PURE complex<float>
532     __CLRCALL_OR_CDECL cosh(const complex<float>&);
533 template _CRTIMP2_PURE complex<float>
534     __CLRCALL_OR_CDECL exp(const complex<float>&);
535 template _CRTIMP2_PURE complex<float>
536     __CLRCALL_OR_CDECL log(const complex<float>&);
537 template _CRTIMP2_PURE complex<float>
538     __CLRCALL_OR_CDECL log10(const complex<float>&);
539 template _CRTIMP2_PURE float
540     __CLRCALL_OR_CDECL norm(const complex<float>&);
541 template _CRTIMP2_PURE complex<float>
542     __CLRCALL_OR_CDECL polar(const float&, const float&);
543 template _CRTIMP2_PURE complex<float>
544     __CLRCALL_OR_CDECL polar(const float&);
545 template _CRTIMP2_PURE complex<float>
546     __CLRCALL_OR_CDECL pow(const complex<float>&, const float&);
547 template _CRTIMP2_PURE complex<float>
548     __CLRCALL_OR_CDECL pow(const complex<float>&, int);
549 template _CRTIMP2_PURE complex<float>
550     __CLRCALL_OR_CDECL pow(const float&, const complex<float>&);
551 template _CRTIMP2_PURE complex<float>
552     __CLRCALL_OR_CDECL pow(const complex<float>&, const complex<float>&);
553 template _CRTIMP2_PURE complex<float>
554     __CLRCALL_OR_CDECL sin(const complex<float>&);
555 template _CRTIMP2_PURE complex<float>
556     __CLRCALL_OR_CDECL sinh(const complex<float>&);
557 template _CRTIMP2_PURE complex<float>
558     __CLRCALL_OR_CDECL sqrt(const complex<float>&);
559 template _CRTIMP2_PURE complex<float>
560     __CLRCALL_OR_CDECL tanh(const complex<float>&);
561 template _CRTIMP2_PURE complex<float>
562     __CLRCALL_OR_CDECL tan(const complex<float>&);
563
564 template _CRTIMP2_PURE double
565     __CLRCALL_OR_CDECL imag(const complex<double>&);
566 template _CRTIMP2_PURE double
567     __CLRCALL_OR_CDECL real(const complex<double>&);
568 template _CRTIMP2_PURE double
569     __CLRCALL_OR_CDECL _Fabs(const complex<double>&, int *);
570 template _CRTIMP2_PURE complex<double>
571     __CLRCALL_OR_CDECL operator+(const complex<double>&, const complex<double>&);
572 template _CRTIMP2_PURE complex<double>
573     __CLRCALL_OR_CDECL operator+(const complex<double>&, const double&);
574 template _CRTIMP2_PURE complex<double>
575     __CLRCALL_OR_CDECL operator+(const double&, const complex<double>&);
576 template _CRTIMP2_PURE complex<double>
577     __CLRCALL_OR_CDECL operator-(const complex<double>&, const complex<double>&);
578 template _CRTIMP2_PURE complex<double>
579     __CLRCALL_OR_CDECL operator-(const complex<double>&, const double&);
580 template _CRTIMP2_PURE complex<double>
581     __CLRCALL_OR_CDECL operator-(const double&, const complex<double>&);
582 template _CRTIMP2_PURE complex<double>
583     __CLRCALL_OR_CDECL operator*(const complex<double>&, const complex<double>&);
584 template _CRTIMP2_PURE complex<double>
585     __CLRCALL_OR_CDECL operator*(const complex<double>&, const double&);
586 template _CRTIMP2_PURE complex<double>
587     __CLRCALL_OR_CDECL operator*(const double&, const complex<double>&);
588 template _CRTIMP2_PURE complex<double>
589     __CLRCALL_OR_CDECL operator/(const complex<double>&, const complex<double>&);
590 template _CRTIMP2_PURE complex<double>
591     __CLRCALL_OR_CDECL operator/(const complex<double>&, const double&);
592 template _CRTIMP2_PURE complex<double>
593     __CLRCALL_OR_CDECL operator/(const double&, const complex<double>&);
594 template _CRTIMP2_PURE complex<double>
595     __CLRCALL_OR_CDECL operator+(const complex<double>&);
596 template _CRTIMP2_PURE complex<double>
597     __CLRCALL_OR_CDECL operator-(const complex<double>&);
598 template _CRTIMP2_PURE bool
599     __CLRCALL_OR_CDECL operator==(const complex<double>&, const complex<double>&);
600 template _CRTIMP2_PURE bool
601     __CLRCALL_OR_CDECL operator==(const complex<double>&, const double&);
602 template _CRTIMP2_PURE bool
603     __CLRCALL_OR_CDECL operator==(const double&, const complex<double>&);
604 template _CRTIMP2_PURE bool
605     __CLRCALL_OR_CDECL operator!=(const complex<double>&, const complex<double>&);
606 template _CRTIMP2_PURE bool
607     __CLRCALL_OR_CDECL operator!=(const complex<double>&, const double&);
608 template _CRTIMP2_PURE bool
609     __CLRCALL_OR_CDECL operator!=(const double&, const complex<double>&);
610 template _CRTIMP2_PURE double
611     __CLRCALL_OR_CDECL abs(const complex<double>&);
612 template _CRTIMP2_PURE double
613     __CLRCALL_OR_CDECL arg(const complex<double>&);
614 template _CRTIMP2_PURE complex<double>
615     __CLRCALL_OR_CDECL conj(const complex<double>&);
616 template _CRTIMP2_PURE complex<double>
617     __CLRCALL_OR_CDECL cos(const complex<double>&);
618 template _CRTIMP2_PURE complex<double>
619     __CLRCALL_OR_CDECL cosh(const complex<double>&);
620 template _CRTIMP2_PURE complex<double>
621     __CLRCALL_OR_CDECL exp(const complex<double>&);
622 template _CRTIMP2_PURE complex<double>
623     __CLRCALL_OR_CDECL log(const complex<double>&);
624 template _CRTIMP2_PURE complex<double>
625     __CLRCALL_OR_CDECL log10(const complex<double>&);
626 template _CRTIMP2_PURE double
627     __CLRCALL_OR_CDECL norm(const complex<double>&);
628 template _CRTIMP2_PURE complex<double>
629     __CLRCALL_OR_CDECL polar(const double&, const double&);
630 template _CRTIMP2_PURE complex<double>
631     __CLRCALL_OR_CDECL polar(const double&);
632 template _CRTIMP2_PURE complex<double>
633     __CLRCALL_OR_CDECL pow(const complex<double>&, const double&);
634 template _CRTIMP2_PURE complex<double>
635     __CLRCALL_OR_CDECL pow(const complex<double>&, int);
636 template _CRTIMP2_PURE complex<double>
637     __CLRCALL_OR_CDECL pow(const double&,    const complex<double>&);
638 template _CRTIMP2_PURE complex<double>
639     __CLRCALL_OR_CDECL pow(const complex<double>&, const complex<double>&);
640 template _CRTIMP2_PURE complex<double>
641     __CLRCALL_OR_CDECL sin(const complex<double>&);
642 template _CRTIMP2_PURE complex<double>
643     __CLRCALL_OR_CDECL sinh(const complex<double>&);
644 template _CRTIMP2_PURE complex<double>
645     __CLRCALL_OR_CDECL sqrt(const complex<double>&);
646 template _CRTIMP2_PURE complex<double>
647     __CLRCALL_OR_CDECL tanh(const complex<double>&);
648 template _CRTIMP2_PURE complex<double>
649     __CLRCALL_OR_CDECL tan(const complex<double>&);
650
651 template _CRTIMP2_PURE long double
652     __CLRCALL_OR_CDECL imag(const complex<long double>&);
653 template _CRTIMP2_PURE long double
654     __CLRCALL_OR_CDECL real(const complex<long double>&);
655 template _CRTIMP2_PURE long double
656     __CLRCALL_OR_CDECL _Fabs(const complex<long double>&, int *);
657 template _CRTIMP2_PURE complex<long double>
658     __CLRCALL_OR_CDECL operator+(const complex<long double>&,
659         const complex<long double>&);
660 template _CRTIMP2_PURE complex<long double>
661     __CLRCALL_OR_CDECL operator+(const complex<long double>&, const long double&);
662 template _CRTIMP2_PURE complex<long double>
663     __CLRCALL_OR_CDECL operator+(const long double&, const complex<long double>&);
664 template _CRTIMP2_PURE complex<long double>
665     __CLRCALL_OR_CDECL operator-(const complex<long double>&,
666         const complex<long double>&);
667 template _CRTIMP2_PURE complex<long double>
668     __CLRCALL_OR_CDECL operator-(const complex<long double>&, const long double&);
669 template _CRTIMP2_PURE complex<long double>
670     __CLRCALL_OR_CDECL operator-(const long double&, const complex<long double>&);
671 template _CRTIMP2_PURE complex<long double>
672     __CLRCALL_OR_CDECL operator*(const complex<long double>&,
673         const complex<long double>&);
674 template _CRTIMP2_PURE complex<long double>
675     __CLRCALL_OR_CDECL operator*(const complex<long double>&, const long double&);
676 template _CRTIMP2_PURE complex<long double>
677     __CLRCALL_OR_CDECL operator*(const long double&, const complex<long double>&);
678 template _CRTIMP2_PURE complex<long double>
679     __CLRCALL_OR_CDECL operator/(const complex<long double>&,
680         const complex<long double>&);
681 template _CRTIMP2_PURE complex<long double>
682     __CLRCALL_OR_CDECL operator/(const complex<long double>&, const long double&);
683 template _CRTIMP2_PURE complex<long double>
684     __CLRCALL_OR_CDECL operator/(const long double&, const complex<long double>&);
685 template _CRTIMP2_PURE complex<long double>
686     __CLRCALL_OR_CDECL operator+(const complex<long double>&);
687 template _CRTIMP2_PURE complex<long double>
688     __CLRCALL_OR_CDECL operator-(const complex<long double>&);
689 template _CRTIMP2_PURE bool
690     __CLRCALL_OR_CDECL operator==(const complex<long double>&,
691         const complex<long double>&);
692 template _CRTIMP2_PURE bool
693     __CLRCALL_OR_CDECL operator==(const complex<long double>&, const long double&);
694 template _CRTIMP2_PURE bool
695     __CLRCALL_OR_CDECL operator==(const long double&, const complex<long double>&);
696 template _CRTIMP2_PURE bool
697     __CLRCALL_OR_CDECL operator!=(const complex<long double>&,
698         const complex<long double>&);
699 template _CRTIMP2_PURE bool
700     __CLRCALL_OR_CDECL operator!=(const complex<long double>&, const long double&);
701 template _CRTIMP2_PURE bool
702     __CLRCALL_OR_CDECL operator!=(const long double&, const complex<long double>&);
703 template _CRTIMP2_PURE long double
704     __CLRCALL_OR_CDECL abs(const complex<long double>&);
705 template _CRTIMP2_PURE long double
706     __CLRCALL_OR_CDECL arg(const complex<long double>&);
707 template _CRTIMP2_PURE complex<long double>
708     __CLRCALL_OR_CDECL conj(const complex<long double>&);
709 template _CRTIMP2_PURE complex<long double>
710     __CLRCALL_OR_CDECL cos(const complex<long double>&);
711 template _CRTIMP2_PURE complex<long double>
712     __CLRCALL_OR_CDECL cosh(const complex<long double>&);
713 template _CRTIMP2_PURE complex<long double>
714     __CLRCALL_OR_CDECL exp(const complex<long double>&);
715 template _CRTIMP2_PURE complex<long double>
716     __CLRCALL_OR_CDECL log(const complex<long double>&);
717 template _CRTIMP2_PURE complex<long double>
718     __CLRCALL_OR_CDECL log10(const complex<long double>&);
719 template _CRTIMP2_PURE long double
720     __CLRCALL_OR_CDECL norm(const complex<long double>&);
721 template _CRTIMP2_PURE complex<long double>
722     __CLRCALL_OR_CDECL polar(const long double&, const long double&);
723 template _CRTIMP2_PURE complex<long double>
724     __CLRCALL_OR_CDECL polar(const long double&);
725 template _CRTIMP2_PURE complex<long double>
726     __CLRCALL_OR_CDECL pow(const complex<long double>&, const long double&);
727 template _CRTIMP2_PURE complex<long double>
728     __CLRCALL_OR_CDECL pow(const complex<long double>&, int);
729 template _CRTIMP2_PURE complex<long double>
730     __CLRCALL_OR_CDECL pow(const long double&, const complex<long double>&);
731 template _CRTIMP2_PURE complex<long double>
732     __CLRCALL_OR_CDECL pow(const complex<long double>&, const complex<long double>&);
733 template _CRTIMP2_PURE complex<long double>
734     __CLRCALL_OR_CDECL sin(const complex<long double>&);
735 template _CRTIMP2_PURE complex<long double>
736     __CLRCALL_OR_CDECL sinh(const complex<long double>&);
737 template _CRTIMP2_PURE complex<long double>
738     __CLRCALL_OR_CDECL sqrt(const complex<long double>&);
739 template _CRTIMP2_PURE complex<long double>
740     __CLRCALL_OR_CDECL tanh(const complex<long double>&);
741 template _CRTIMP2_PURE complex<long double>
742     __CLRCALL_OR_CDECL tan(const complex<long double>&);
743
744  #endif
745
746 #undef _XCOMPLEX_    /* SIC: may be included multiple times */
747 #endif /* RC_INVOKED */
748 #endif /* _XCOMPLEX_ */
749
750 /*
751  * Copyright (c) 1992-2006 by P.J. Plauger.  ALL RIGHTS RESERVED.
752  * Consult your license regarding permissions and restrictions.
753  V5.02:0009 */
754