00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 namespace cxsc {
00028
00029
00030 inline complex & complex::operator= (const real & r) throw()
00031 {
00032 re=r;im=0;
00033 return *this;
00034 }
00035
00036
00037 inline complex operator -(const complex &a) throw ()
00038 {
00039 return complex(-a.re,-a.im);
00040 }
00041
00042 inline complex operator +(const complex &a) throw ()
00043 {
00044 return a;
00045 }
00046
00047 inline complex operator +(const complex &a,const complex &b) throw()
00048 {
00049 return complex(a.re+b.re,a.im+b.im);
00050 }
00051
00052 inline complex operator -(const complex &a,const complex &b) throw()
00053 {
00054 return complex(a.re-b.re,a.im-b.im);
00055 }
00056
00057 inline complex & operator +=(complex &a, const complex &b) throw() { return a=a+b; }
00058 inline complex & operator -=(complex &a, const complex &b) throw() { return a=a-b; }
00059 inline complex & operator *=(complex &a, const complex &b) throw() { return a=a*b; }
00060 inline complex & operator /=(complex &a, const complex &b) throw() { return a=a/b; }
00061
00062 inline complex operator +(const complex & a,const real & b) throw()
00063 {
00064 return complex(a.re+b,a.im);
00065 }
00066
00067 inline complex operator +(const real & a,const complex & b) throw()
00068 {
00069 return complex(a+b.re,b.im);
00070 }
00071
00072 inline complex operator -(const complex & a,const real & b) throw()
00073 {
00074 return complex(a.re-b,a.im);
00075 }
00076
00077 inline complex operator -(const real & a,const complex & b) throw()
00078 {
00079 return complex(a-b.re,-b.im);
00080 }
00081
00082 inline complex operator *(const complex & a,const real & b) throw()
00083 {
00084
00085 return complex(a.re*b,a.im*b);
00086 }
00087
00088 inline complex operator *(const real & a,const complex & b) throw()
00089 {
00090
00091 return complex(a*b.re, a*b.im);
00092 }
00093
00094 inline complex operator /(const complex & a,const real & b) throw()
00095 {
00096
00097 return complex(a.re/b, a.im/b);
00098 }
00099
00100 inline complex operator /(const real & a,const complex & b) throw()
00101 {
00102 return _complex(a)/b;
00103 }
00104
00105 inline complex & operator +=(complex & a, const real & b) throw() { return a=a+b; }
00106 inline complex & operator -=(complex & a, const real & b) throw() { return a=a-b; }
00107 inline complex & operator *=(complex & a, const real & b) throw() { return a=a*b; }
00108 inline complex & operator /=(complex & a, const real & b) throw() { return a=a/b; }
00109
00110
00111 inline bool operator! (const complex & a) throw() { return !a.re && !a.im; }
00112 inline bool operator== (const complex & a, const complex & b) throw() { return a.re==b.re && a.im==b.im; }
00113 inline bool operator!= (const complex & a, const complex & b) throw() { return a.re!=b.re || a.im!=b.im; }
00114 inline bool operator== (const complex & a, const real & b) throw() { return !a.im && a.re==b; }
00115 inline bool operator== (const real & a, const complex & b) throw() { return !b.im && a==b.re; }
00116 inline bool operator!= (const complex & a, const real & b) throw() { return !!a.im || a.re!=b; }
00117 inline bool operator!= (const real & a, const complex & b) throw() { return !!b.im || a!=b.re; }
00118
00119
00120
00121 inline complex conj(const complex & a) throw() { return complex(a.re,-a.im); }
00122
00123
00124
00125
00126
00127
00128
00129 inline complex addd(const complex& a, const complex& b) throw()
00130 { return complex(addd(a.re,b.re), addd(a.im,b.im)); }
00131
00132 inline complex addu(const complex& a, const complex& b) throw()
00133 { return complex(addu(a.re,b.re), addu(a.im,b.im)); }
00134
00135 inline complex addd(const complex& a, const real& b) throw()
00136 { return complex(addd(a.re,b), a.im); }
00137
00138 inline complex addu(const complex& a, const real& b) throw()
00139 { return complex(addu(a.re,b), a.im); }
00140
00141 inline complex addd(const real& a, const complex& b) throw()
00142 { return complex(addd(a,b.re), b.im); }
00143
00144 inline complex addu(const real& a, const complex& b) throw()
00145 { return complex(addu(a,b.re), b.im); }
00146
00147
00148 inline complex subd(const complex& a, const complex& b) throw()
00149 { return complex(subd(a.re,b.re), subd(a.im,b.im)); }
00150
00151 inline complex subu(const complex& a, const complex& b) throw()
00152 { return complex(subu(a.re,b.re), subu(a.im,b.im)); }
00153
00154 inline complex subd(const complex& a, const real& b) throw()
00155 { return complex(subd(a.re,b), a.im); }
00156
00157 inline complex subu(const complex& a, const real& b) throw()
00158 { return complex(subu(a.re,b), a.im); }
00159
00160 inline complex subd(const real& a, const complex& b) throw()
00161 { return complex(subd(a,b.re), -b.im); }
00162
00163 inline complex subu(const real& a, const complex& b) throw()
00164 { return complex(subu(a,b.re), -b.im); }
00165
00166
00167
00168 inline complex muld(const complex &a, const real &b) throw()
00169 { return complex( muld(a.re,b), muld(a.im,b) ); }
00170
00171 inline complex mulu(const complex &a, const real &b) throw()
00172 { return complex( mulu(a.re,b), mulu(a.im,b) ); }
00173
00174 inline complex muld(const real &a, const complex &b) throw()
00175 { return complex( muld(a,b.re), muld(a,b.im) ); }
00176
00177 inline complex mulu(const real &a, const complex &b) throw()
00178 { return complex( mulu(a,b.re), mulu(a,b.im) ); }
00179
00180
00181
00182 inline complex divd(const complex &a, const real &b) throw()
00183 { return complex( divd(a.re,b), divd(a.im,b) ); }
00184
00185 inline complex divu(const complex &a, const real &b) throw()
00186 { return complex( divu(a.re,b), divu(a.im,b) ); }
00187
00188 inline complex divd(const real &a, const complex &b) throw()
00189 { return divd(_complex(a),b); }
00190
00191 inline complex divu(const real &a, const complex &b) throw()
00192 { return divu(_complex(a),b); }
00193 }
00194