Annotation of researchv8dc/cmd/cfront/libC/complex/complex.h, revision 1.1

1.1     ! root        1: 
        !             2: #include <stream.h>
        !             3: #include <errno.h>
        !             4: 
        !             5: overload cos;
        !             6: overload cosh;
        !             7: overload exp;
        !             8: overload log;
        !             9: overload pow;
        !            10: overload sin;
        !            11: overload sinh;
        !            12: overload sqrt;
        !            13: overload abs;
        !            14: 
        !            15: #include <math.h>
        !            16: inline double abs(double d) { return fabs(d); }
        !            17: 
        !            18: class complex {
        !            19:        double  re, im;
        !            20: public:
        !            21:        complex(double r = 0, double i = 0)     { re=r; im=i; }
        !            22:                
        !            23:        friend  double  real(complex&);
        !            24:        friend  double  imag(complex&);
        !            25: 
        !            26:        friend  double  abs(complex);
        !            27:        friend  double  norm(complex);
        !            28:        friend  double  arg(complex);
        !            29:        friend  complex conj(complex);
        !            30:        friend  complex cos(complex);
        !            31:        friend  complex cosh(complex);
        !            32:        friend  complex exp(complex);
        !            33:        friend  complex log(complex);
        !            34:        friend  complex pow(double, complex);
        !            35:        friend  complex pow(complex, int);
        !            36:        friend  complex pow(complex, double);
        !            37:        friend  complex pow(complex, complex);
        !            38:        friend  complex polar(double, double = 0);
        !            39:        friend  complex sin(complex);
        !            40:        friend  complex sinh(complex);
        !            41:        friend  complex sqrt(complex);
        !            42: 
        !            43:        friend  complex operator+(complex, complex);
        !            44:        friend  complex operator-(complex);
        !            45:        friend  complex operator-(complex, complex);
        !            46:        friend  complex operator*(complex, complex);
        !            47:        friend  complex operator/(complex, complex);
        !            48:        friend  int     operator==(complex, complex);
        !            49:        friend  int     operator!=(complex, complex);
        !            50:        
        !            51:        void operator+=(complex);
        !            52:        void operator-=(complex);
        !            53:        void operator*=(complex);
        !            54:        void operator/=(complex);
        !            55: };
        !            56: 
        !            57: ostream& operator<<(ostream&, complex);
        !            58: istream& operator>>(istream&, complex&);
        !            59: 
        !            60: void complex_error(int,double);
        !            61: extern int errno;
        !            62: 
        !            63: inline double real(complex& a)
        !            64: {
        !            65:        return a.re;
        !            66: }
        !            67: 
        !            68: inline double imag(complex& a)
        !            69: {
        !            70:        return a.im;
        !            71: }
        !            72: 
        !            73: inline complex operator+(complex a1, complex a2) 
        !            74: {
        !            75:        return complex(a1.re+a2.re, a1.im+a2.im);
        !            76: }
        !            77: 
        !            78: inline complex operator-(complex a1,complex a2) 
        !            79: {
        !            80:        return complex(a1.re-a2.re, a1.im-a2.im);
        !            81: }
        !            82: 
        !            83: inline complex operator-(complex a) 
        !            84: {
        !            85:        return complex(-a.re, -a.im);
        !            86: }
        !            87: 
        !            88: inline complex conj(complex a) 
        !            89: {
        !            90:        return complex(a.re, -a.im);
        !            91: }
        !            92: 
        !            93: inline int operator==(complex a, complex b) 
        !            94: {
        !            95:        return (a.re==b.re && a.im==b.im);
        !            96: }
        !            97: 
        !            98: inline int operator!=(complex a, complex b)
        !            99: {
        !           100:        return (a.re!=b.re || a.im!=b.im);
        !           101: }
        !           102: 
        !           103: inline void complex.operator+=(complex a)
        !           104: {
        !           105:        re += a.re;
        !           106:        im += a.im;
        !           107: }
        !           108: 
        !           109: inline void complex.operator-=(complex a)
        !           110: {
        !           111:        re -= a.re;
        !           112:        im -= a.im;
        !           113: }
        !           114: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.