C-XSC - A C++ Class Library for Extended Scientific Computing  2.5.4
l_complex.inl
1 /*
2 ** CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4)
3 **
4 ** Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik,
5 ** Universitaet Karlsruhe, Germany
6 ** (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie
7 ** Universitaet Wuppertal, Germany
8 **
9 ** This library is free software; you can redistribute it and/or
10 ** modify it under the terms of the GNU Library General Public
11 ** License as published by the Free Software Foundation; either
12 ** version 2 of the License, or (at your option) any later version.
13 **
14 ** This library is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ** Library General Public License for more details.
18 **
19 ** You should have received a copy of the GNU Library General Public
20 ** License along with this library; if not, write to the Free
21 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23 /* CVS $Id: l_complex.inl,v 1.16 2014/01/30 17:23:46 cxsc Exp $ */
24 
25 // -------------------------------------------------------------------------
26 // ------------------ File l_complex.inl ---------------------------------
27 namespace cxsc {
28 
29 // ---------------- l_complex +/- l_complex --------------------------------
30 
31 inline l_complex operator +(const l_complex &a, const l_complex &b) throw()
32 {
33  return l_complex(a.re + b.re, a.im + b.im);
34 }
35 
36 inline l_complex operator -(const l_complex &a, const l_complex &b) throw()
37 {
38  return l_complex(a.re - b.re, a.im - b.im);
39 }
40 
41 inline l_complex l_complex::operator +(const complex &op2) const throw()
42 {
43  return l_complex(this->re + Re(op2), this->im + Im(op2));
44 }
45 
46 inline l_complex operator + (const complex& c, const l_complex& lc) throw()
47 {
48  return lc + c;
49 }
50 
51 inline l_complex l_complex::operator + (const real& op2) const throw()
52 {
53  return l_complex(this->re + op2, this->im);
54 }
55 
56 inline l_complex operator +
57  (const real& r, const l_complex& lc) throw()
58 {
59  return lc + r;
60 }
61 
62 inline l_complex l_complex::operator + (const l_real& op2) const throw()
63 {
64  return l_complex(this->re + op2, this->im);
65 }
66 
67 inline l_complex operator +
68  (const l_real& r, const l_complex& lc) throw()
69 {
70  return lc + r;
71 }
72 
73 inline l_complex l_complex::operator - (const l_real& op2) const throw()
74 {
75  return l_complex(this->re - op2, this->im);
76 }
77 
78 inline l_complex operator -
79  (const l_real& r, const l_complex& lc) throw()
80 {
81  return -(lc - r);
82 }
83 
84 inline l_complex l_complex::operator -(const complex &op2) const throw()
85 {
86  return l_complex(this->re - Re(op2), this->im - Im(op2));
87 }
88 
89 inline l_complex operator - (const complex& c, const l_complex& lc) throw()
90 {
91  return -(lc-c);
92 }
93 
94 inline l_complex l_complex::operator - (const real& op2) const throw()
95 {
96  return l_complex(this->re - op2, this->im);
97 }
98 
99 inline l_complex operator -
100  (const real& r, const l_complex& lc) throw()
101 {
102  return -(lc-r);
103 }
104 
105 inline l_complex l_complex::operator * (const real& op2) const throw()
106 {
107  return l_complex(this->re * op2, this->im * op2);
108 }
109 
110 inline l_complex operator *
111  (const real& r, const l_complex& lc) throw()
112 {
113  return lc * r;
114 }
115 
116 inline l_complex l_complex::operator * (const l_real& op2) const throw()
117 {
118  return l_complex(this->re * op2, this->im * op2);
119 }
120 
121 inline l_complex operator *
122  (const l_real& r, const l_complex& lc) throw()
123 {
124  return lc * r;
125 }
126 
127 // ---------------- l_complex +(-)= l_complex|complex|real|l_real ------------
128 inline l_complex & operator += (l_complex &lc, const l_complex &lc1) throw()
129  {
130  lc = lc + lc1; return lc;
131  }
132 inline l_complex & operator -= (l_complex &lc, const l_complex &lc1) throw()
133  {
134  lc = lc - lc1; return lc;
135  }
136 inline l_complex & operator += (l_complex &lc, const complex &c) throw()
137  {
138  lc = lc + c; return lc;
139  }
140 inline l_complex & operator -= (l_complex &lc, const complex &c) throw()
141  {
142  lc = lc - c; return lc;
143  }
144 inline l_complex & operator += (l_complex &lc, const real &r) throw()
145  {
146  lc = lc + r; return lc;
147  }
148 inline l_complex & operator -= (l_complex &lc, const real &r) throw()
149  {
150  lc = lc - r; return lc;
151  }
152 inline l_complex & operator += (l_complex &lc, const l_real &lr) throw()
153  {
154  lc = lc + lr; return lc;
155  }
156 inline l_complex & operator -= (l_complex &lc, const l_real &lr) throw()
157  {
158  lc = lc - lr; return lc;
159  }
160 
161 // ---------------- l_complex *= l_complex|complex|real|l_real --------------
162 inline l_complex & operator *= (l_complex &lc, const l_complex &lc1) throw()
163  {
164  lc = lc * lc1; return lc;
165  }
166 inline l_complex & operator *= (l_complex &lc, const complex &c) throw()
167  {
168  lc = lc * c; return lc;
169  }
170 inline l_complex & operator *= (l_complex &lc, const real &r) throw()
171  {
172  lc = lc * r; return lc;
173  }
174 inline l_complex & operator *= (l_complex &lc, const l_real &lr) throw()
175  {
176  lc = lc * lr; return lc;
177  }
178 
179 inline l_complex operator / (const l_complex& a, const complex& b) throw()
180 {
181  return a / l_complex(b);
182 }
183 
184 inline l_complex operator / (const l_complex& a, const l_real& b) throw()
185 {
186  return l_complex(a.re/b, a.im/b);
187 }
188 
189 inline l_complex operator / (const l_complex& a, const real& b) throw()
190 {
191  return l_complex(a.re/b, a.im/b);
192 }
193 
194 inline l_complex operator / (const complex& a, const l_complex& b) throw()
195 {
196  return l_complex(a) / b;
197 }
198 
199 inline l_complex operator / (const real& a, const l_complex& b) throw()
200 {
201  return l_complex(a) / b;
202 }
203 
204 inline l_complex operator / (const l_real& a, const l_complex& b) throw()
205 {
206  return l_complex(a) / b;
207 }
208 
209 inline l_complex& operator /= (l_complex& a, const l_complex& b) throw()
210 { return a = a/b; }
211 
212 inline l_complex& operator /= (l_complex& a, const complex& b) throw()
213 { return a = a/b; }
214 
215 inline l_complex& operator /= (l_complex& a, const real& b) throw()
216 { return a = a/b; }
217 
218 inline l_complex& operator /= (l_complex& a, const l_real& b) throw()
219 { return a = a/b; }
220 
221 
222 // ---------------- Compare Operators ---------------------------------------
223 inline bool operator! (const l_complex & a) throw() { return !a.re && !a.im; }
224 inline bool operator== (const l_complex & a, const l_complex & b) throw()
225  { return a.re==b.re && a.im==b.im; }
226 inline bool operator!= (const l_complex & a, const l_complex & b) throw()
227  { return a.re!=b.re || a.im!=b.im; }
228 inline bool operator== (const l_complex & a, const complex & b) throw()
229  { return a.re==Re(b) && a.im==Im(b); }
230 inline bool operator== (const complex & a, const l_complex & b) throw()
231  { return Re(a)==b.re && Im(a)==b.im; }
232 inline bool operator!= (const l_complex & a, const complex & b) throw()
233  { return a.re!=Re(b) || a.im!=Im(b); }
234 inline bool operator!= (const complex & a, const l_complex & b) throw()
235  { return Re(a)!=b.re || Im(a)!=b.im; }
236 inline bool operator== (const l_complex & a, const real & b) throw()
237  { return a.re==b && !a.im; }
238 inline bool operator== (const real & a, const l_complex & b) throw()
239  { return a==b.re && !b.im; }
240 inline bool operator!= (const l_complex & a, const real & b) throw()
241  { return a.re!=b || !!a.im; }
242 inline bool operator!= (const real & a, const l_complex & b) throw()
243  { return a!=b.re || !!b.im; }
244 inline bool operator== (const l_complex & a, const l_real & b) throw()
245  { return a.re==b && !a.im; }
246 inline bool operator== (const l_real & a, const l_complex & b) throw()
247  { return a==b.re && !b.im; }
248 inline bool operator!= (const l_complex & a, const l_real & b) throw()
249  { return a.re!=b || !!a.im; }
250 inline bool operator!= (const l_real & a, const l_complex & b) throw()
251  { return a!=b.re || !!b.im; }
252 inline bool operator== (const l_complex & a, const dotprecision & b) throw()
253  { return a.re==b && !a.im; }
254 inline bool operator== (const dotprecision & a, const l_complex & b) throw()
255  { return b.re==a && !b.im; }
256 inline bool operator!= (const l_complex & a, const dotprecision & b) throw()
257  { return a.re!=b || !!a.im; }
258 inline bool operator!= (const dotprecision & a, const l_complex & b) throw()
259  { return b.re!=a || !!b.im; }
260 
261 inline bool operator ==(const l_complex &c, const cdotprecision &a)
262 throw() { return(c.re==Re(_l_complex(a)) && c.im==Im(_l_complex(a))); }
263 inline bool operator !=(const l_complex &c, const cdotprecision &a)
264 throw() { return(c.re!=Re(_l_complex(a)) || c.im!=Im(_l_complex(a))); }
265 inline bool operator ==(const cdotprecision &a, const l_complex &c)
266 throw() { return(c.re==Re(_l_complex(a)) && c.im==Im(_l_complex(a))); }
267 inline bool operator !=(const cdotprecision &a, const l_complex &c)
268 throw() { return(c.re!=Re(_l_complex(a)) || c.im!=Im(_l_complex(a))); }
269 
270 inline l_complex conj(const l_complex& a) throw()
271 { return l_complex(a.re,-a.im); }
272 
273 } // End of namespace cxsc
274 
275 
276 
277 
278 
279 
280 
281 
cxsc::l_complex::operator+
friend l_complex operator+(const l_complex &)
Implementation of standard algebraic positive sign operation.
Definition: l_complex.cpp:36
cxsc::operator*=
cimatrix & operator*=(cimatrix &m, const cinterval &c)
Implementation of multiplication and allocation operation.
Definition: cimatrix.inl:1605
cxsc::l_complex::operator-
friend l_complex operator-(const l_complex &)
Implementation of standard algebraic negative sign operation.
Definition: l_complex.cpp:31
cxsc::l_complex
The Multiple-Precision Data Type l_complex.
Definition: l_complex.hpp:46
cxsc::dotprecision
The Data Type dotprecision.
Definition: dot.hpp:112
cxsc::operator/=
cimatrix & operator/=(cimatrix &m, const cinterval &c)
Implementation of division and allocation operation.
Definition: cimatrix.inl:1623
cxsc::l_complex::operator*
friend l_complex operator*(const l_complex &a, const l_complex &b)
Implementation of standard algebraic multiplication operation.
Definition: l_complex.cpp:86
cxsc
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition: cdot.cpp:29
cxsc::operator+=
cdotprecision & operator+=(cdotprecision &cd, const l_complex &lc)
Implementation of standard algebraic addition and allocation operation.
Definition: cdot.inl:251
cxsc::l_real
The Multiple-Precision Data Type l_real.
Definition: l_real.hpp:78
cxsc::cdotprecision
The Data Type cdotprecision.
Definition: cdot.hpp:61
cxsc::operator/
civector operator/(const cimatrix_subv &rv, const cinterval &s)
Implementation of division operation.
Definition: cimatrix.inl:730
cxsc::complex
The Scalar Type complex.
Definition: complex.hpp:50
cxsc::real
The Scalar Type real.
Definition: real.hpp:114