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 ---------------------------------
27namespace cxsc {
28
29// ---------------- l_complex +/- l_complex --------------------------------
30
31inline l_complex operator +(const l_complex &a, const l_complex &b) noexcept
32{
33 return l_complex(a.re + b.re, a.im + b.im);
34}
35
36inline l_complex operator -(const l_complex &a, const l_complex &b) noexcept
37{
38 return l_complex(a.re - b.re, a.im - b.im);
39}
40
41inline l_complex l_complex::operator +(const complex &op2) const noexcept
42{
43 return l_complex(this->re + Re(op2), this->im + Im(op2));
44}
45
46inline l_complex operator + (const complex& c, const l_complex& lc) noexcept
47{
48 return lc + c;
49}
50
51inline l_complex l_complex::operator + (const real& op2) const noexcept
52{
53 return l_complex(this->re + op2, this->im);
54}
55
56inline l_complex operator +
57 (const real& r, const l_complex& lc) noexcept
58{
59 return lc + r;
60}
61
62inline l_complex l_complex::operator + (const l_real& op2) const noexcept
63{
64 return l_complex(this->re + op2, this->im);
65}
66
67inline l_complex operator +
68 (const l_real& r, const l_complex& lc) noexcept
69{
70 return lc + r;
71}
72
73inline l_complex l_complex::operator - (const l_real& op2) const noexcept
74{
75 return l_complex(this->re - op2, this->im);
76}
77
78inline l_complex operator -
79 (const l_real& r, const l_complex& lc) noexcept
80{
81 return -(lc - r);
82}
83
84inline l_complex l_complex::operator -(const complex &op2) const noexcept
85{
86 return l_complex(this->re - Re(op2), this->im - Im(op2));
87}
88
89inline l_complex operator - (const complex& c, const l_complex& lc) noexcept
90{
91 return -(lc-c);
92}
93
94inline l_complex l_complex::operator - (const real& op2) const noexcept
95{
96 return l_complex(this->re - op2, this->im);
97}
98
99inline l_complex operator -
100 (const real& r, const l_complex& lc) noexcept
101{
102 return -(lc-r);
103}
104
105inline l_complex l_complex::operator * (const real& op2) const noexcept
106{
107 return l_complex(this->re * op2, this->im * op2);
108}
109
110inline l_complex operator *
111 (const real& r, const l_complex& lc) noexcept
112{
113 return lc * r;
114}
115
116inline l_complex l_complex::operator * (const l_real& op2) const noexcept
117{
118 return l_complex(this->re * op2, this->im * op2);
119}
120
121inline l_complex operator *
122 (const l_real& r, const l_complex& lc) noexcept
123{
124 return lc * r;
125}
126
127// ---------------- l_complex +(-)= l_complex|complex|real|l_real ------------
128inline l_complex & operator += (l_complex &lc, const l_complex &lc1) noexcept
129 {
130 lc = lc + lc1; return lc;
131 }
132inline l_complex & operator -= (l_complex &lc, const l_complex &lc1) noexcept
133 {
134 lc = lc - lc1; return lc;
135 }
136inline l_complex & operator += (l_complex &lc, const complex &c) noexcept
137 {
138 lc = lc + c; return lc;
139 }
140inline l_complex & operator -= (l_complex &lc, const complex &c) noexcept
141 {
142 lc = lc - c; return lc;
143 }
144inline l_complex & operator += (l_complex &lc, const real &r) noexcept
145 {
146 lc = lc + r; return lc;
147 }
148inline l_complex & operator -= (l_complex &lc, const real &r) noexcept
149 {
150 lc = lc - r; return lc;
151 }
152inline l_complex & operator += (l_complex &lc, const l_real &lr) noexcept
153 {
154 lc = lc + lr; return lc;
155 }
156inline l_complex & operator -= (l_complex &lc, const l_real &lr) noexcept
157 {
158 lc = lc - lr; return lc;
159 }
160
161// ---------------- l_complex *= l_complex|complex|real|l_real --------------
162inline l_complex & operator *= (l_complex &lc, const l_complex &lc1) noexcept
163 {
164 lc = lc * lc1; return lc;
165 }
166inline l_complex & operator *= (l_complex &lc, const complex &c) noexcept
167 {
168 lc = lc * c; return lc;
169 }
170inline l_complex & operator *= (l_complex &lc, const real &r) noexcept
171 {
172 lc = lc * r; return lc;
173 }
174inline l_complex & operator *= (l_complex &lc, const l_real &lr) noexcept
175 {
176 lc = lc * lr; return lc;
177 }
178
179inline l_complex operator / (const l_complex& a, const complex& b) noexcept
180{
181 return a / l_complex(b);
182}
183
184inline l_complex operator / (const l_complex& a, const l_real& b) noexcept
185{
186 return l_complex(a.re/b, a.im/b);
187}
188
189inline l_complex operator / (const l_complex& a, const real& b) noexcept
190{
191 return l_complex(a.re/b, a.im/b);
192}
193
194inline l_complex operator / (const complex& a, const l_complex& b) noexcept
195{
196 return l_complex(a) / b;
197}
198
199inline l_complex operator / (const real& a, const l_complex& b) noexcept
200{
201 return l_complex(a) / b;
202}
203
204inline l_complex operator / (const l_real& a, const l_complex& b) noexcept
205{
206 return l_complex(a) / b;
207}
208
209inline l_complex& operator /= (l_complex& a, const l_complex& b) noexcept
210{ return a = a/b; }
211
212inline l_complex& operator /= (l_complex& a, const complex& b) noexcept
213{ return a = a/b; }
214
215inline l_complex& operator /= (l_complex& a, const real& b) noexcept
216{ return a = a/b; }
217
218inline l_complex& operator /= (l_complex& a, const l_real& b) noexcept
219{ return a = a/b; }
220
221
222// ---------------- Compare Operators ---------------------------------------
223inline bool operator! (const l_complex & a) noexcept { return !a.re && !a.im; }
224inline bool operator== (const l_complex & a, const l_complex & b) noexcept
225 { return a.re==b.re && a.im==b.im; }
226inline bool operator!= (const l_complex & a, const l_complex & b) noexcept
227 { return a.re!=b.re || a.im!=b.im; }
228inline bool operator== (const l_complex & a, const complex & b) noexcept
229 { return a.re==Re(b) && a.im==Im(b); }
230inline bool operator== (const complex & a, const l_complex & b) noexcept
231 { return Re(a)==b.re && Im(a)==b.im; }
232inline bool operator!= (const l_complex & a, const complex & b) noexcept
233 { return a.re!=Re(b) || a.im!=Im(b); }
234inline bool operator!= (const complex & a, const l_complex & b) noexcept
235 { return Re(a)!=b.re || Im(a)!=b.im; }
236inline bool operator== (const l_complex & a, const real & b) noexcept
237 { return a.re==b && !a.im; }
238inline bool operator== (const real & a, const l_complex & b) noexcept
239 { return a==b.re && !b.im; }
240inline bool operator!= (const l_complex & a, const real & b) noexcept
241 { return a.re!=b || !!a.im; }
242inline bool operator!= (const real & a, const l_complex & b) noexcept
243 { return a!=b.re || !!b.im; }
244inline bool operator== (const l_complex & a, const l_real & b) noexcept
245 { return a.re==b && !a.im; }
246inline bool operator== (const l_real & a, const l_complex & b) noexcept
247 { return a==b.re && !b.im; }
248inline bool operator!= (const l_complex & a, const l_real & b) noexcept
249 { return a.re!=b || !!a.im; }
250inline bool operator!= (const l_real & a, const l_complex & b) noexcept
251 { return a!=b.re || !!b.im; }
252inline bool operator== (const l_complex & a, const dotprecision & b) noexcept
253 { return a.re==b && !a.im; }
254inline bool operator== (const dotprecision & a, const l_complex & b) noexcept
255 { return b.re==a && !b.im; }
256inline bool operator!= (const l_complex & a, const dotprecision & b) noexcept
257 { return a.re!=b || !!a.im; }
258inline bool operator!= (const dotprecision & a, const l_complex & b) noexcept
259 { return b.re!=a || !!b.im; }
260
261inline bool operator ==(const l_complex &c, const cdotprecision &a)
262noexcept { return(c.re==Re(_l_complex(a)) && c.im==Im(_l_complex(a))); }
263inline bool operator !=(const l_complex &c, const cdotprecision &a)
264noexcept { return(c.re!=Re(_l_complex(a)) || c.im!=Im(_l_complex(a))); }
265inline bool operator ==(const cdotprecision &a, const l_complex &c)
266noexcept { return(c.re==Re(_l_complex(a)) && c.im==Im(_l_complex(a))); }
267inline bool operator !=(const cdotprecision &a, const l_complex &c)
268noexcept { return(c.re!=Re(_l_complex(a)) || c.im!=Im(_l_complex(a))); }
269
270inline l_complex conj(const l_complex& a) noexcept
271{ return l_complex(a.re,-a.im); }
272
273} // End of namespace cxsc
274
275
276
277
278
279
280
281
The Data Type cdotprecision.
Definition cdot.hpp:61
The Scalar Type complex.
Definition complex.hpp:50
The Data Type dotprecision.
Definition dot.hpp:112
The Multiple-Precision Data Type l_complex.
Definition l_complex.hpp:46
friend l_complex operator*(const l_complex &a, const l_complex &b) noexcept
Implementation of standard algebraic multiplication operation.
Definition l_complex.cpp:86
friend l_complex operator-(const l_complex &)
Implementation of standard algebraic negative sign operation.
Definition l_complex.cpp:31
friend l_complex operator+(const l_complex &)
Implementation of standard algebraic positive sign operation.
Definition l_complex.cpp:36
The Multiple-Precision Data Type l_real.
Definition l_real.hpp:78
The Scalar Type real.
Definition real.hpp:114
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition cdot.cpp:29
cdotprecision & operator+=(cdotprecision &cd, const l_complex &lc) noexcept
Implementation of standard algebraic addition and allocation operation.
Definition cdot.inl:251
civector operator/(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of division operation.
Definition cimatrix.inl:730
cimatrix & operator*=(cimatrix &m, const cinterval &c) noexcept
Implementation of multiplication and allocation operation.
cimatrix & operator/=(cimatrix &m, const cinterval &c) noexcept
Implementation of division and allocation operation.