C-XSC - A C++ Class Library for Extended Scientific Computing
2.5.4
|
00001 /* 00002 ** CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4) 00003 ** 00004 ** Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik, 00005 ** Universitaet Karlsruhe, Germany 00006 ** (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie 00007 ** Universitaet Wuppertal, Germany 00008 ** 00009 ** This library is free software; you can redistribute it and/or 00010 ** modify it under the terms of the GNU Library General Public 00011 ** License as published by the Free Software Foundation; either 00012 ** version 2 of the License, or (at your option) any later version. 00013 ** 00014 ** This library is distributed in the hope that it will be useful, 00015 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 ** Library General Public License for more details. 00018 ** 00019 ** You should have received a copy of the GNU Library General Public 00020 ** License along with this library; if not, write to the Free 00021 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 */ 00023 /* CVS $Id: l_complex.inl,v 1.16 2014/01/30 17:23:46 cxsc Exp $ */ 00024 00025 // ------------------------------------------------------------------------- 00026 // ------------------ File l_complex.inl --------------------------------- 00027 namespace cxsc { 00028 00029 // ---------------- l_complex +/- l_complex -------------------------------- 00030 00031 inline l_complex operator +(const l_complex &a, const l_complex &b) throw() 00032 { 00033 return l_complex(a.re + b.re, a.im + b.im); 00034 } 00035 00036 inline l_complex operator -(const l_complex &a, const l_complex &b) throw() 00037 { 00038 return l_complex(a.re - b.re, a.im - b.im); 00039 } 00040 00041 inline l_complex l_complex::operator +(const complex &op2) const throw() 00042 { 00043 return l_complex(this->re + Re(op2), this->im + Im(op2)); 00044 } 00045 00046 inline l_complex operator + (const complex& c, const l_complex& lc) throw() 00047 { 00048 return lc + c; 00049 } 00050 00051 inline l_complex l_complex::operator + (const real& op2) const throw() 00052 { 00053 return l_complex(this->re + op2, this->im); 00054 } 00055 00056 inline l_complex operator + 00057 (const real& r, const l_complex& lc) throw() 00058 { 00059 return lc + r; 00060 } 00061 00062 inline l_complex l_complex::operator + (const l_real& op2) const throw() 00063 { 00064 return l_complex(this->re + op2, this->im); 00065 } 00066 00067 inline l_complex operator + 00068 (const l_real& r, const l_complex& lc) throw() 00069 { 00070 return lc + r; 00071 } 00072 00073 inline l_complex l_complex::operator - (const l_real& op2) const throw() 00074 { 00075 return l_complex(this->re - op2, this->im); 00076 } 00077 00078 inline l_complex operator - 00079 (const l_real& r, const l_complex& lc) throw() 00080 { 00081 return -(lc - r); 00082 } 00083 00084 inline l_complex l_complex::operator -(const complex &op2) const throw() 00085 { 00086 return l_complex(this->re - Re(op2), this->im - Im(op2)); 00087 } 00088 00089 inline l_complex operator - (const complex& c, const l_complex& lc) throw() 00090 { 00091 return -(lc-c); 00092 } 00093 00094 inline l_complex l_complex::operator - (const real& op2) const throw() 00095 { 00096 return l_complex(this->re - op2, this->im); 00097 } 00098 00099 inline l_complex operator - 00100 (const real& r, const l_complex& lc) throw() 00101 { 00102 return -(lc-r); 00103 } 00104 00105 inline l_complex l_complex::operator * (const real& op2) const throw() 00106 { 00107 return l_complex(this->re * op2, this->im * op2); 00108 } 00109 00110 inline l_complex operator * 00111 (const real& r, const l_complex& lc) throw() 00112 { 00113 return lc * r; 00114 } 00115 00116 inline l_complex l_complex::operator * (const l_real& op2) const throw() 00117 { 00118 return l_complex(this->re * op2, this->im * op2); 00119 } 00120 00121 inline l_complex operator * 00122 (const l_real& r, const l_complex& lc) throw() 00123 { 00124 return lc * r; 00125 } 00126 00127 // ---------------- l_complex +(-)= l_complex|complex|real|l_real ------------ 00128 inline l_complex & operator += (l_complex &lc, const l_complex &lc1) throw() 00129 { 00130 lc = lc + lc1; return lc; 00131 } 00132 inline l_complex & operator -= (l_complex &lc, const l_complex &lc1) throw() 00133 { 00134 lc = lc - lc1; return lc; 00135 } 00136 inline l_complex & operator += (l_complex &lc, const complex &c) throw() 00137 { 00138 lc = lc + c; return lc; 00139 } 00140 inline l_complex & operator -= (l_complex &lc, const complex &c) throw() 00141 { 00142 lc = lc - c; return lc; 00143 } 00144 inline l_complex & operator += (l_complex &lc, const real &r) throw() 00145 { 00146 lc = lc + r; return lc; 00147 } 00148 inline l_complex & operator -= (l_complex &lc, const real &r) throw() 00149 { 00150 lc = lc - r; return lc; 00151 } 00152 inline l_complex & operator += (l_complex &lc, const l_real &lr) throw() 00153 { 00154 lc = lc + lr; return lc; 00155 } 00156 inline l_complex & operator -= (l_complex &lc, const l_real &lr) throw() 00157 { 00158 lc = lc - lr; return lc; 00159 } 00160 00161 // ---------------- l_complex *= l_complex|complex|real|l_real -------------- 00162 inline l_complex & operator *= (l_complex &lc, const l_complex &lc1) throw() 00163 { 00164 lc = lc * lc1; return lc; 00165 } 00166 inline l_complex & operator *= (l_complex &lc, const complex &c) throw() 00167 { 00168 lc = lc * c; return lc; 00169 } 00170 inline l_complex & operator *= (l_complex &lc, const real &r) throw() 00171 { 00172 lc = lc * r; return lc; 00173 } 00174 inline l_complex & operator *= (l_complex &lc, const l_real &lr) throw() 00175 { 00176 lc = lc * lr; return lc; 00177 } 00178 00179 inline l_complex operator / (const l_complex& a, const complex& b) throw() 00180 { 00181 return a / l_complex(b); 00182 } 00183 00184 inline l_complex operator / (const l_complex& a, const l_real& b) throw() 00185 { 00186 return l_complex(a.re/b, a.im/b); 00187 } 00188 00189 inline l_complex operator / (const l_complex& a, const real& b) throw() 00190 { 00191 return l_complex(a.re/b, a.im/b); 00192 } 00193 00194 inline l_complex operator / (const complex& a, const l_complex& b) throw() 00195 { 00196 return l_complex(a) / b; 00197 } 00198 00199 inline l_complex operator / (const real& a, const l_complex& b) throw() 00200 { 00201 return l_complex(a) / b; 00202 } 00203 00204 inline l_complex operator / (const l_real& a, const l_complex& b) throw() 00205 { 00206 return l_complex(a) / b; 00207 } 00208 00209 inline l_complex& operator /= (l_complex& a, const l_complex& b) throw() 00210 { return a = a/b; } 00211 00212 inline l_complex& operator /= (l_complex& a, const complex& b) throw() 00213 { return a = a/b; } 00214 00215 inline l_complex& operator /= (l_complex& a, const real& b) throw() 00216 { return a = a/b; } 00217 00218 inline l_complex& operator /= (l_complex& a, const l_real& b) throw() 00219 { return a = a/b; } 00220 00221 00222 // ---------------- Compare Operators --------------------------------------- 00223 inline bool operator! (const l_complex & a) throw() { return !a.re && !a.im; } 00224 inline bool operator== (const l_complex & a, const l_complex & b) throw() 00225 { return a.re==b.re && a.im==b.im; } 00226 inline bool operator!= (const l_complex & a, const l_complex & b) throw() 00227 { return a.re!=b.re || a.im!=b.im; } 00228 inline bool operator== (const l_complex & a, const complex & b) throw() 00229 { return a.re==Re(b) && a.im==Im(b); } 00230 inline bool operator== (const complex & a, const l_complex & b) throw() 00231 { return Re(a)==b.re && Im(a)==b.im; } 00232 inline bool operator!= (const l_complex & a, const complex & b) throw() 00233 { return a.re!=Re(b) || a.im!=Im(b); } 00234 inline bool operator!= (const complex & a, const l_complex & b) throw() 00235 { return Re(a)!=b.re || Im(a)!=b.im; } 00236 inline bool operator== (const l_complex & a, const real & b) throw() 00237 { return a.re==b && !a.im; } 00238 inline bool operator== (const real & a, const l_complex & b) throw() 00239 { return a==b.re && !b.im; } 00240 inline bool operator!= (const l_complex & a, const real & b) throw() 00241 { return a.re!=b || !!a.im; } 00242 inline bool operator!= (const real & a, const l_complex & b) throw() 00243 { return a!=b.re || !!b.im; } 00244 inline bool operator== (const l_complex & a, const l_real & b) throw() 00245 { return a.re==b && !a.im; } 00246 inline bool operator== (const l_real & a, const l_complex & b) throw() 00247 { return a==b.re && !b.im; } 00248 inline bool operator!= (const l_complex & a, const l_real & b) throw() 00249 { return a.re!=b || !!a.im; } 00250 inline bool operator!= (const l_real & a, const l_complex & b) throw() 00251 { return a!=b.re || !!b.im; } 00252 inline bool operator== (const l_complex & a, const dotprecision & b) throw() 00253 { return a.re==b && !a.im; } 00254 inline bool operator== (const dotprecision & a, const l_complex & b) throw() 00255 { return b.re==a && !b.im; } 00256 inline bool operator!= (const l_complex & a, const dotprecision & b) throw() 00257 { return a.re!=b || !!a.im; } 00258 inline bool operator!= (const dotprecision & a, const l_complex & b) throw() 00259 { return b.re!=a || !!b.im; } 00260 00261 inline bool operator ==(const l_complex &c, const cdotprecision &a) 00262 throw() { return(c.re==Re(_l_complex(a)) && c.im==Im(_l_complex(a))); } 00263 inline bool operator !=(const l_complex &c, const cdotprecision &a) 00264 throw() { return(c.re!=Re(_l_complex(a)) || c.im!=Im(_l_complex(a))); } 00265 inline bool operator ==(const cdotprecision &a, const l_complex &c) 00266 throw() { return(c.re==Re(_l_complex(a)) && c.im==Im(_l_complex(a))); } 00267 inline bool operator !=(const cdotprecision &a, const l_complex &c) 00268 throw() { return(c.re!=Re(_l_complex(a)) || c.im!=Im(_l_complex(a))); } 00269 00270 inline l_complex conj(const l_complex& a) throw() 00271 { return l_complex(a.re,-a.im); } 00272 00273 } // End of namespace cxsc 00274 00275 00276 00277 00278 00279 00280 00281