C-XSC - A C++ Class Library for Extended Scientific Computing 2.5.4
cinterval.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
24/* CVS $Id: cinterval.inl,v 1.20 2014/01/30 17:23:44 cxsc Exp $ */
25
26namespace cxsc {
27
28// Inlined functions for cinterval.
29
30// ---- implicit constructors ------------------------------
31
32inline cinterval::cinterval(const interval & a,const interval & b) noexcept
33 : re(a), im(b)
34{
35}
36
37inline cinterval::cinterval(const complex & a,const complex & b)
38 : re(Re(a),Re(b)),
39 im(Im(a),Im(b))
40{
41 if(Inf(re)>Sup(re) || Inf(im)>Sup(im))
42 cxscthrow(ERROR_CINTERVAL_EMPTY_INTERVAL("cinterval::cinterval(const complex & a,const complex & b)"));
43}
44
45// ---- explicit constructors ------------------------------
46
47inline cinterval::cinterval(const real & a) noexcept : re(a,a), im(0,0) {}
48inline cinterval::cinterval(const interval & a) noexcept : re(a), im(0,0) {}
49inline cinterval::cinterval(const complex & a) noexcept : re(Re(a),Re(a)),im(Im(a),Im(a)) {}
50
51// ---- assignments -----------------------------------------
52
53inline cinterval & cinterval::operator =(const real & a) noexcept
54{
55 re=a,im=0.0;
56 return *this;
57}
58
59inline cinterval & cinterval::operator =(const interval & a) noexcept
60{
61 re=a,im=0.0;
62 return *this;
63}
64
65inline cinterval & cinterval::operator =(const complex & a) noexcept
66{
67 re=Re(a),im=Im(a);
68 return *this;
69}
70
71inline cinterval & cinterval::operator =(const cinterval & a) noexcept
72{
73 re=a.re;
74 im=a.im;
75 return *this;
76}
77
78inline cinterval & cinterval::operator =(const dotprecision & a) noexcept
79{
80 return *this=cinterval(a);
81}
82
83inline cinterval & cinterval::operator =(const idotprecision & a) noexcept
84{
85 return *this=cinterval(a);
86}
87
88inline cinterval & cinterval::operator =(const cdotprecision & a) noexcept
89{
90 return *this=cinterval(a);
91}
92
94{
95 return *this=cinterval(a);
96}
97
98// ---- compatiblility typecasts ----------------------------
99
105inline cinterval _cinterval(const real & a) noexcept
106{
107 return cinterval(interval(a,a), interval(0.0,0.0));
108}
109
115inline cinterval _cinterval(const complex & a) noexcept
116{
117 return cinterval(a,a);
118}
119
125inline cinterval _cinterval(const interval & a) noexcept
126{
127 return cinterval(a,_interval(0.0,0.0));
128}
129
135inline cinterval _cinterval(const dotprecision & a) noexcept { return cinterval(a); }
136
142inline cinterval _cinterval(const cdotprecision & a) noexcept { return cinterval(a); }
143
149inline cinterval _cinterval(const idotprecision & a) noexcept { return cinterval(a); }
150
156inline cinterval _cinterval(const cidotprecision & a) noexcept { return cinterval(a); }
157
163inline cinterval _cinterval(const complex & a,const complex & b) noexcept
164{
165 return cinterval(interval(Re(a),Re(b)),interval(Im(a),Im(b)));
166}
167
173inline cinterval _cinterval(const real & a,const complex & b) noexcept
174{
175 return cinterval(complex(a),b);
176}
177
183inline cinterval _cinterval(const complex & a,const real & b) noexcept
184{
185 return cinterval(a,complex(b));
186}
187
193inline cinterval _cinterval(const interval & a,const interval & b) noexcept
194{
195 return cinterval(a,b);
196}
197
203inline cinterval _cinterval(const real & a,const interval & b) noexcept
204{
205 return cinterval(interval(a),b);
206}
207
213inline cinterval _cinterval(const interval & a,const real & b) noexcept
214{
215 return cinterval(a,interval(b));
216}
217
223inline cinterval _unchecked_cinterval(const complex & a,const complex & b) noexcept
224{
225 cinterval tmp;
226 UncheckedSetInf(tmp,a);
227 UncheckedSetSup(tmp,b);
228 return tmp;
229}
230
236inline cinterval _unchecked_cinterval(const real & a,const complex & b) noexcept
237{
238 cinterval tmp;
239 UncheckedSetInf(tmp,_complex(a));
240 UncheckedSetSup(tmp,b);
241 return tmp;
242}
243
249inline cinterval _unchecked_cinterval(const complex & a,const real & b) noexcept
250{
251 cinterval tmp;
252 UncheckedSetInf(tmp,a);
253 UncheckedSetSup(tmp,_complex(b));
254 return tmp;
255}
256
257// ---- Std.Operators ---------------------------------------
258
259inline cinterval operator -(const cinterval & a) noexcept
260{
261 return cinterval(-a.re,-a.im);
262}
263
264inline cinterval operator +(const cinterval & a) noexcept
265{
266 return a;
267}
268
269inline cinterval operator +(const cinterval & a,const cinterval & b) noexcept
270{
271 return cinterval(a.re+b.re,a.im+b.im);
272}
273
274inline cinterval operator -(const cinterval & a,const cinterval & b) noexcept
275{
276 return cinterval(a.re-b.re,a.im-b.im);
277}
278
279inline cinterval operator &(const cinterval & a,const cinterval & b)
280{
281 cinterval tmp = a;
282 SetInf(tmp.re, max(Inf(a.re), Inf(b.re)));
283 SetInf(tmp.im, max(Inf(a.im), Inf(b.im)));
284 SetSup(tmp.re, min(Sup(a.re), Sup(b.re)));
285 SetSup(tmp.im, min(Sup(a.im), Sup(b.im)));
286 if (Inf(tmp.re) > Sup(tmp.re) || Inf(tmp.im) > Sup(tmp.im))
287 cxscthrow(ERROR_CINTERVAL_EMPTY_INTERVAL("inline cinterval operator &(const cinterval & a,const cinterval & b)"));
288 return tmp;
289}
290
291inline cinterval operator |(const cinterval & a,const cinterval & b) noexcept
292{
293 cinterval tmp = a;
294 SetInf(tmp.re, min(Inf(a.re), Inf(b.re)));
295 SetInf(tmp.im, min(Inf(a.im), Inf(b.im)));
296 SetSup(tmp.re, max(Sup(a.re), Sup(b.re)));
297 SetSup(tmp.im, max(Sup(a.im), Sup(b.im)));
298 return tmp;
299}
300
301inline cinterval & operator +=(cinterval & a, const cinterval & b) noexcept { return a=a+b; }
302inline cinterval & operator -=(cinterval & a, const cinterval & b) noexcept { return a=a-b; }
303inline cinterval & operator *=(cinterval & a, const cinterval & b) noexcept { return a=a*b; }
304inline cinterval & operator /=(cinterval & a, const cinterval & b) noexcept { return a=a/b; }
305inline cinterval & operator |=(cinterval & a, const cinterval & b) noexcept { return a=a|b; }
306inline cinterval & operator &=(cinterval & a, const cinterval & b) { return a=a&b; }
307
308// CI-R
309
310inline cinterval operator +(const cinterval & a,const real & b) noexcept { return a+_cinterval(b); }
311inline cinterval operator +(const real & a,const cinterval & b) noexcept { return _cinterval(a)+b; }
312inline cinterval operator -(const cinterval & a,const real & b) noexcept { return a-_cinterval(b); }
313inline cinterval operator -(const real & a,const cinterval & b) noexcept { return _cinterval(a)-b; }
314inline cinterval operator *(const cinterval & a,const real & b) noexcept { return a*_cinterval(b); }
315inline cinterval operator *(const real & a,const cinterval & b) noexcept
316{ // return _cinterval(a)*b;
317 return cinterval(b.re*a, b.im*a); // Blomquist 07.11.02;
318}
319inline cinterval operator /(const cinterval & a,const real & b) noexcept
320{ // return a/_cinterval(b);
321 return cinterval(a.re/b, a.im/b); // Blomquist 07.11.02;
322}
323inline cinterval operator /(const real & a,const cinterval & b) noexcept { return _cinterval(a)/b; }
324inline cinterval operator |(const cinterval & a,const real & b) noexcept { return a|_cinterval(b); }
325inline cinterval operator |(const real & a,const cinterval & b) noexcept { return _cinterval(a)|b; }
326inline cinterval operator &(const cinterval & a,const real & b) noexcept { return a&_cinterval(b); }
327inline cinterval operator &(const real & a,const cinterval & b) noexcept { return _cinterval(a)&b; }
328
329inline cinterval & operator +=(cinterval & a, const real & b) noexcept { return a=a+_cinterval(b); }
330inline cinterval & operator -=(cinterval & a, const real & b) noexcept { return a=a-_cinterval(b); }
331inline cinterval & operator *=(cinterval & a, const real & b) noexcept
332{ // return a=a*_cinterval(b);
333 return a = a * b; // Blomquist 07.11.02;
334}
335inline cinterval & operator /=(cinterval & a, const real & b) noexcept
336{ // return a=a/_cinterval(b);
337 return a = a / b; // Blomquist 07.11.02;
338}
339inline cinterval & operator |=(cinterval & a, const real & b) noexcept { return a=a|_cinterval(b); }
340inline cinterval & operator &=(cinterval & a, const real & b) noexcept { return a=a&_cinterval(b); }
341
342// CI-C
343
344inline cinterval operator +(const cinterval & a,const complex & b) noexcept { return a+_cinterval(b); }
345inline cinterval operator +(const complex & a,const cinterval & b) noexcept { return _cinterval(a)+b; }
346inline cinterval operator -(const cinterval & a,const complex & b) noexcept { return a-_cinterval(b); }
347inline cinterval operator -(const complex & a,const cinterval & b) noexcept { return _cinterval(a)-b; }
348inline cinterval operator *(const cinterval & a,const complex & b) noexcept { return a*_cinterval(b); }
349inline cinterval operator *(const complex & a,const cinterval & b) noexcept { return _cinterval(a)*b; }
350inline cinterval operator /(const cinterval & a,const complex & b) noexcept { return a/_cinterval(b); }
351inline cinterval operator /(const complex & a,const cinterval & b) noexcept { return _cinterval(a)/b; }
352inline cinterval operator |(const cinterval & a,const complex & b) noexcept { return a|_cinterval(b); }
353inline cinterval operator |(const complex & a,const cinterval & b) noexcept { return _cinterval(a)|b; }
354inline cinterval operator &(const cinterval & a,const complex & b) noexcept { return a&_cinterval(b); }
355inline cinterval operator &(const complex & a,const cinterval & b) noexcept { return _cinterval(a)&b; }
356
357inline cinterval & operator +=(cinterval & a, const complex & b) noexcept { return a=a+_cinterval(b); }
358inline cinterval & operator -=(cinterval & a, const complex & b) noexcept { return a=a-_cinterval(b); }
359inline cinterval & operator *=(cinterval & a, const complex & b) noexcept { return a=a*_cinterval(b); }
360inline cinterval & operator /=(cinterval & a, const complex & b) noexcept { return a=a/_cinterval(b); }
361inline cinterval & operator |=(cinterval & a, const complex & b) noexcept { return a=a|_cinterval(b); }
362inline cinterval & operator &=(cinterval & a, const complex & b) noexcept { return a=a&_cinterval(b); }
363
364// CI-I
365
366inline cinterval operator +(const cinterval & a,const interval & b) noexcept { return a+_cinterval(b); }
367inline cinterval operator +(const interval & a,const cinterval & b) noexcept { return _cinterval(a)+b; }
368inline cinterval operator -(const cinterval & a,const interval & b) noexcept { return a-_cinterval(b); }
369inline cinterval operator -(const interval & a,const cinterval & b) noexcept { return _cinterval(a)-b; }
370inline cinterval operator *(const cinterval & a,const interval & b) noexcept
371{ // return a*_cinterval(b);
372 return cinterval(a.re*b,a.im*b); // Blomquist, 07.11.02;
373}
374inline cinterval operator *(const interval & a,const cinterval & b) noexcept
375{ // return _cinterval(a)*b;
376 return cinterval(b.re*a,b.im*a);
377}
378inline cinterval operator /(const cinterval & a,const interval & b) noexcept
379{ // return a/_cinterval(b);
380 return cinterval(a.re/b,a.im/b);
381}
382inline cinterval operator /(const interval & a,const cinterval & b) noexcept { return _cinterval(a)/b; }
383inline cinterval operator |(const cinterval & a,const interval & b) noexcept { return a|_cinterval(b); }
384inline cinterval operator |(const interval & a,const cinterval & b) noexcept { return _cinterval(a)|b; }
385inline cinterval operator &(const cinterval & a,const interval & b) noexcept { return a&_cinterval(b); }
386inline cinterval operator &(const interval & a,const cinterval & b) noexcept { return _cinterval(a)&b; }
387
388inline cinterval & operator +=(cinterval & a, const interval & b) noexcept { return a=a+_cinterval(b); }
389inline cinterval & operator -=(cinterval & a, const interval & b) noexcept { return a=a-_cinterval(b); }
390inline cinterval & operator *=(cinterval & a, const interval & b) noexcept { return a=a*_cinterval(b); }
391inline cinterval & operator /=(cinterval & a, const interval & b) noexcept { return a=a/_cinterval(b); }
392inline cinterval & operator |=(cinterval & a, const interval & b) noexcept { return a=a|_cinterval(b); }
393inline cinterval & operator &=(cinterval & a, const interval & b) noexcept { return a=a&_cinterval(b); }
394
395// C-R
396
397inline cinterval operator |(const complex & a,const real & b) noexcept { return _cinterval(a)|_cinterval(b); }
398inline cinterval operator |(const real & a,const complex & b) noexcept { return _cinterval(a)|_cinterval(b); }
399
400// C-I
401
402inline cinterval operator +(const complex & a,const interval & b) noexcept { return _cinterval(a)+_cinterval(b); }
403inline cinterval operator +(const interval & a,const complex & b) noexcept { return _cinterval(a)+_cinterval(b); }
404inline cinterval operator -(const complex & a,const interval & b) noexcept { return _cinterval(a)-_cinterval(b); }
405inline cinterval operator -(const interval & a,const complex & b) noexcept { return _cinterval(a)-_cinterval(b); }
406inline cinterval operator *(const complex & a,const interval & b) noexcept
407{ // return _cinterval(a)*_cinterval(b);
408 return _cinterval(a)*b; // Blomquist, 07.11.02;
409}
410inline cinterval operator *(const interval & a,const complex & b) noexcept
411{ // return _cinterval(a)*_cinterval(b);
412 return _cinterval(b) * a; // Blomquist, 07.11.02;
413}
414inline cinterval operator /(const complex & a,const interval & b) noexcept
415{ // return _cinterval(a)/_cinterval(b);
416 return _cinterval(a) / b; // Blomquist, 07.11.02;
417}
418inline cinterval operator /(const interval & a,const complex & b) noexcept { return _cinterval(a)/_cinterval(b); }
419inline cinterval operator |(const complex & a,const interval & b) noexcept { return _cinterval(a)|_cinterval(b); }
420inline cinterval operator |(const interval & a,const complex & b) noexcept { return _cinterval(a)|_cinterval(b); }
421inline cinterval operator &(const complex & a,const interval & b) noexcept { return _cinterval(a)&_cinterval(b); }
422inline cinterval operator &(const interval & a,const complex & b) noexcept { return _cinterval(a)&_cinterval(b); }
423
424// C-C
425
426inline cinterval operator |(const complex & a,const complex & b) noexcept { return _cinterval(a)|_cinterval(b); }
427
428// ---- Comp.Operat. ---------------------------------------
429inline bool operator! (const cinterval & a) noexcept
430{
431 return !a.re && !a.im;
432}
433
434inline bool operator== (const cinterval & a, const cinterval & b) noexcept
435{
436 return a.re==b.re && a.im==b.im;
437}
438
439inline bool operator!= (const cinterval & a, const cinterval & b) noexcept
440{
441 return a.re!=b.re || a.im!=b.im;
442}
443
444// CI-R
445
446inline bool operator== (const cinterval & a, const real & b) noexcept { return a==_cinterval(b); }
447inline bool operator== (const real & a, const cinterval & b) noexcept { return _cinterval(a)==b; }
448inline bool operator!= (const cinterval & a, const real & b) noexcept { return a!=_cinterval(b); }
449inline bool operator!= (const real & a, const cinterval & b) noexcept { return _cinterval(a)!=b; }
450
451// CI-C
452
453inline bool operator== (const cinterval & a, const complex & b) noexcept { return a==_cinterval(b); }
454inline bool operator== (const complex & a, const cinterval & b) noexcept { return _cinterval(a)==b; }
455inline bool operator!= (const cinterval & a, const complex & b) noexcept { return a!=_cinterval(b); }
456inline bool operator!= (const complex & a, const cinterval & b) noexcept { return _cinterval(a)!=b; }
457
458// CI-I
459
460inline bool operator== (const cinterval & a, const interval & b) noexcept { return a==_cinterval(b); }
461inline bool operator== (const interval & a, const cinterval & b) noexcept { return _cinterval(a)==b; }
462inline bool operator!= (const cinterval & a, const interval & b) noexcept { return a!=_cinterval(b); }
463inline bool operator!= (const interval & a, const cinterval & b) noexcept { return _cinterval(a)!=b; }
464
465// ---- Set Operators ----
466inline bool operator <(const cinterval & a,const cinterval & b) noexcept
467{
468 if (Inf(a.re) <= Inf(b.re) || Sup(a.re) >= Sup(b.re))
469 return false;
470 if (Inf(a.im) <= Inf(b.im) || Sup(a.im) >= Sup(b.im))
471 return false;
472
473 return true;
474}
475
476inline bool operator >(const cinterval & a,const cinterval & b) noexcept { return b<a; }
477
478inline bool operator <=(const cinterval & a,const cinterval & b) noexcept
479{
480 if (Inf(a.re) < Inf(b.re) || Sup(a.re) > Sup(b.re))
481 return false;
482 if (Inf(a.im) < Inf(b.im) || Sup(a.im) > Sup(b.im))
483 return false;
484
485 return true;
486}
487
488inline bool operator >=(const cinterval & a,const cinterval & b) noexcept { return b<=a; }
489
490// CI-R
491
492inline bool operator <(const real & a,const cinterval & b) noexcept { return _cinterval(a)<b; }
493inline bool operator >(const real & a,const cinterval & b) noexcept { return _cinterval(a)>b; }
494inline bool operator <=(const real & a,const cinterval & b) noexcept { return _cinterval(a)<=b; }
495inline bool operator >=(const real & a,const cinterval & b) noexcept { return _cinterval(a)>=b; }
496
497inline bool operator <(const cinterval & a,const real & b) noexcept { return a<_cinterval(b); }
498inline bool operator >(const cinterval & a,const real & b) noexcept { return a>_cinterval(b); }
499inline bool operator <=(const cinterval & a,const real & b) noexcept { return a<=_cinterval(b); }
500inline bool operator >=(const cinterval & a,const real & b) noexcept { return a>=_cinterval(b); }
501
502// CI-C
503
504inline bool operator <(const complex & a,const cinterval & b) noexcept { return _cinterval(a)<b; }
505inline bool operator >(const complex & a,const cinterval & b) noexcept { return _cinterval(a)>b; }
506inline bool operator <=(const complex & a,const cinterval & b) noexcept { return _cinterval(a)<=b; }
507inline bool operator >=(const complex & a,const cinterval & b) noexcept { return _cinterval(a)>=b; }
508
509inline bool operator <(const cinterval & a,const complex & b) noexcept { return a<_cinterval(b); }
510inline bool operator >(const cinterval & a,const complex & b) noexcept { return a>_cinterval(b); }
511inline bool operator <=(const cinterval & a,const complex & b) noexcept { return a<=_cinterval(b); }
512inline bool operator >=(const cinterval & a,const complex & b) noexcept { return a>=_cinterval(b); }
513
514// CI-C
515
516inline bool operator <(const interval & a,const cinterval & b) noexcept { return _cinterval(a)<b; }
517inline bool operator >(const interval & a,const cinterval & b) noexcept { return _cinterval(a)>b; }
518inline bool operator <=(const interval & a,const cinterval & b) noexcept { return _cinterval(a)<=b; }
519inline bool operator >=(const interval & a,const cinterval & b) noexcept { return _cinterval(a)>=b; }
520
521inline bool operator <(const cinterval & a,const interval & b) noexcept { return a<_cinterval(b); }
522inline bool operator >(const cinterval & a,const interval & b) noexcept { return a>_cinterval(b); }
523inline bool operator <=(const cinterval & a,const interval & b) noexcept { return a<=_cinterval(b); }
524inline bool operator >=(const cinterval & a,const interval & b) noexcept { return a>=_cinterval(b); }
525
526// ---- Others -------------------------------------------
527inline complex Inf(const cinterval & a) noexcept { return _complex(Inf(a.re),Inf(a.im)); }
528inline complex Sup(const cinterval & a) noexcept { return _complex(Sup(a.re),Sup(a.im)); }
529
530inline cinterval & SetInf(cinterval & a,const complex & b)
531{
532 Inf(a.re)=Re(b);
533 Inf(a.im)=Im(b);
534
535 if (Inf(a.re) > Sup(a.re) || Inf(a.im) > Sup(a.im))
536 cxscthrow(ERROR_CINTERVAL_EMPTY_INTERVAL("inline cinterval & SetInf(cinterval & a,const complex & b)"));
537
538 return a;
539}
540
541inline cinterval & SetSup(cinterval & a,const complex & b)
542{
543 Sup(a.re)=Re(b);
544 Sup(a.im)=Im(b);
545
546 if (Inf(a.re) > Sup(a.re) || Inf(a.im) > Sup(a.im))
547 cxscthrow(ERROR_CINTERVAL_EMPTY_INTERVAL("inline cinterval & SetSup(cinterval & a,const complex & b)"));
548
549 return a;
550}
551
552inline cinterval & SetInf(cinterval & a,const real & b)
553{
554 Inf(a.re)=b;
555 Inf(a.im)=0.0;
556
557 if (Inf(a.re) > Sup(a.re) || Inf(a.im) > Sup(a.im))
558 cxscthrow(ERROR_CINTERVAL_EMPTY_INTERVAL("inline cinterval & SetInf(cinterval & a,const real & b)"));
559
560 return a;
561}
562
563inline cinterval & SetSup(cinterval & a,const real & b)
564{
565 Sup(a.re)=b;
566 Sup(a.im)=0.0;
567
568 if (Inf(a.re) > Sup(a.re) || Inf(a.im) > Sup(a.im))
569 cxscthrow(ERROR_CINTERVAL_EMPTY_INTERVAL("inline cinterval & SetSup(cinterval & a,const real & b)"));
570
571 return a;
572}
573
574inline cinterval & UncheckedSetInf(cinterval & a,const complex & b) noexcept
575{
576 Inf(a.re)=Re(b);
577 Inf(a.im)=Im(b);
578 return a;
579}
580
581inline cinterval & UncheckedSetInf(cinterval & a,const real & b) noexcept
582{
583 Inf(a.re)=b;
584 Inf(a.im)=0.0;
585 return a;
586}
587
588inline cinterval & UncheckedSetSup(cinterval & a,const complex & b) noexcept
589{
590 Sup(a.re)=Re(b);
591 Sup(a.im)=Im(b);
592 return a;
593}
594
595inline cinterval & UncheckedSetSup(cinterval & a,const real & b) noexcept
596{
597 Sup(a.re)=b;
598 Sup(a.im)=0.0;
599 return a;
600}
601
602inline interval & Re(cinterval & a) noexcept { return a.re; }
603inline interval Re(const cinterval & a) noexcept { return a.re; }
604inline interval & Im(cinterval & a) noexcept { return a.im; }
605inline interval Im(const cinterval & a) noexcept { return a.im; }
606
607inline cinterval & SetRe(cinterval & a,const interval & b) { a.re=b; return a; }
608inline cinterval & SetIm(cinterval & a,const interval & b) { a.im=b; return a; }
609inline cinterval & SetRe(cinterval & a,const real & b) { a.re=b; return a; }
610inline cinterval & SetIm(cinterval & a,const real & b) { a.im=b; return a; }
611
612inline real InfRe(const cinterval &a) noexcept { return Inf(a.re); }
613inline real InfIm(const cinterval &a) noexcept { return Inf(a.im); }
614inline real SupRe(const cinterval &a) noexcept { return Sup(a.re); }
615inline real SupIm(const cinterval &a) noexcept { return Sup(a.im); }
616
617inline real & InfRe(cinterval &a) noexcept { return Inf(a.re); }
618inline real & InfIm(cinterval &a) noexcept { return Inf(a.im); }
619inline real & SupRe(cinterval &a) noexcept { return Sup(a.re); }
620inline real & SupIm(cinterval &a) noexcept { return Sup(a.im); }
621
622
623
624
625
626
627
628
629
630
631inline cinterval conj(const cinterval & a) noexcept { return cinterval(a.re,-a.im); }
632
633inline complex mid(const cinterval &a) noexcept { return complex(mid(a.re),mid(a.im)); }
634inline complex diam(const cinterval &a) noexcept{ return complex(diam(a.re),diam(a.im)); }
635
636cinterval mult_operator(const cinterval & a,const cinterval & b) noexcept;
637cinterval div_operator(const cinterval & a,const cinterval & b);
638
639inline cinterval operator *(const cinterval & a,const cinterval & b) noexcept
640{
641#ifdef CXSC_FAST_COMPLEX_OPERATIONS
642 return cinterval(Re(a)*Re(b)-Im(a)*Im(b), Re(a)*Im(b)+Im(a)*Re(b));
643#else
644 return mult_operator(a,b);
645#endif
646}
647
648inline cinterval operator / (const cinterval & a, const cinterval & b)
649{
650 if (0.0 <= Re(b) && 0.0 <= Im(b) ) {
651 cxscthrow(DIV_BY_ZERO("cinterval operator / (const cinterval&, const cinterval&)"));
652 return a; // dummy result
653 }
654#ifdef CXSC_FAST_COMPLEX_OPERATIONS
655 return a * (1.0 / b);
656#else
657 return div_operator(a,b);
658#endif
659}
660
661
662} // namespace cxsc
663
The Data Type cdotprecision.
Definition cdot.hpp:61
The Data Type cidotprecision.
Definition cidot.hpp:58
The Scalar Type cinterval.
Definition cinterval.hpp:55
friend complex Sup(const cinterval &) noexcept
Returns the supremum of a complex interval.
cinterval(void) noexcept
Constructor of class cinterval.
Definition cinterval.hpp:64
friend complex Inf(const cinterval &) noexcept
Returns the infimum of a complex interval.
cinterval & operator=(const real &) noexcept
Implementation of standard assigning operator.
Definition cinterval.inl:53
The Scalar Type complex.
Definition complex.hpp:50
The Data Type dotprecision.
Definition dot.hpp:112
The Data Type idotprecision.
Definition idot.hpp:48
The Scalar Type interval.
Definition interval.hpp:55
The Scalar Type real.
Definition real.hpp:114
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition cdot.cpp:29
complex _complex(const real &a) noexcept
Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
Definition complex.hpp:366
cinterval _unchecked_cinterval(const complex &a, const complex &b) noexcept
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
cvector diam(const cimatrix_subv &mv) noexcept
Returns the diameter of the matrix.
Definition cimatrix.inl:738
cimatrix & operator*=(cimatrix &m, const cinterval &c) noexcept
Implementation of multiplication and allocation operation.
cvector mid(const cimatrix_subv &mv) noexcept
Returns the middle of the matrix.
Definition cimatrix.inl:739
civector operator*(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of multiplication operation.
Definition cimatrix.inl:731
cinterval _cinterval(const real &a) noexcept
cimatrix & operator/=(cimatrix &m, const cinterval &c) noexcept
Implementation of division and allocation operation.