C-XSC - A C++ Class Library for Extended Scientific Computing  2.5.4
l_interval.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: l_interval.inl,v 1.22 2014/01/30 17:23:46 cxsc Exp $ */
25 
26 namespace cxsc {
27 
28 inline void l_interval::_allo(int nprec)
29 #if (CXSC_INDEX_CHECK)
30  throw(ERROR_LINTERVAL_WRONG_STAGPREC)
31 #else
32  throw()
33 #endif
34 {
35  prec=nprec;
36 #if (CXSC_INDEX_CHECK)
37  if(nprec<=0)
38  cxscthrow(ERROR_LINTERVAL_WRONG_STAGPREC("void l_interval::_allo(int nprec)"));
39 #endif
40  data=new real[(prec)+1];
41 }
42 
43 // ---- Konstruktoren ----
44 
46 #if (CXSC_INDEX_CHECK)
47  throw(ERROR_LINTERVAL_WRONG_STAGPREC)
48 #else
49  throw()
50 #endif
51 {
52  _allo(stagprec);
53 }
54 
56 #if (CXSC_INDEX_CHECK)
57  throw(ERROR_LINTERVAL_WRONG_STAGPREC)
58 #else
59  throw()
60 #endif
61 {
62  int i;
63  _allo(a.prec);
64  for(i=0;i<=prec;i++)
65  data[i]=a.data[i];
66 }
67 
68 inline l_interval::l_interval(const real &a, const real &b)
69 #if (CXSC_INDEX_CHECK)
70  throw(ERROR_LINTERVAL_WRONG_STAGPREC,ERROR_LINTERVAL_EMPTY_INTERVAL)
71 #else
72  throw(ERROR_LINTERVAL_EMPTY_INTERVAL)
73 #endif
74 {
75  _allo(1);
76  if(a>b)
77  cxscthrow(ERROR_LINTERVAL_EMPTY_INTERVAL("inline l_interval::l_interval(const real &a, const real &b)"));
78  elem(1)=a,elem(2)=b;
79 
80 }
81 
82 l_interval::l_interval(const real &a) throw()
83 {
84  try { _allo(1); }
85  catch(const ERROR_LINTERVAL_WRONG_STAGPREC &) {} // won't occur!
86  elem(1)=a,elem(2)=a;
87 }
88 
89 inline l_interval & l_interval::operator= (const real & a) throw()
90 {
91  return (*this)=_l_interval(a);
92 }
93 
94 inline l_interval & l_interval::operator= (const l_real & a) throw()
95 {
96  return (*this)=_l_interval(a);
97 }
98 
99 inline l_interval & l_interval::operator= (const interval & a) throw()
100 {
101  return (*this)=_l_interval(a);
102 }
103 
104 inline l_interval::~l_interval() throw()
105 {
106  delete [] data;
107 }
108 // ---- Typwandlungen ----
109 
111 {
112  try { _allo(1); }
113  catch(const ERROR_LINTERVAL_WRONG_STAGPREC &) {} // won't occur!
114  elem(1)=Inf(a),elem(2)=Sup(a);
115 }
116 
117 l_interval::l_interval(const l_real & a) throw()
118 {
119  try { _allo(StagPrec(a)); }
120  catch(const ERROR_LINTERVAL_WRONG_STAGPREC &) {} // shouldn't occur!
121  int i;
122  for(i=1;i<=prec;i++)
123  elem(i)=a[i];
124  elem(prec+1)=a[prec];
125 }
126 
127 inline interval _interval(const real & a, const l_real & b) throw() // Sollte in l_real!!!
128 {
129  return _interval(_l_interval(_l_real(a),b));
130 }
131 
132 inline interval _interval(const l_real & a, const real & b) throw() // Sollte in l_real!!!
133 {
134  return _interval(_l_interval(a,_l_real(b)));
135 }
136 
137 inline interval _interval(const l_real & a) throw() // l_real!
138 {
139  return _interval(_l_interval(a,a));
140 }
141 
142 inline interval _unchecked_interval(const l_real & a, const l_real & b) throw() // l_real!
143 {
144  return _unchecked_interval(_real(a),_real(b));
145 }
146 
147 // ---- Standardfunkt ---- (arithmetische Operatoren)
148 
149 inline l_interval operator+(const l_interval &a) throw() { return a; }
150 
151 // LI-LI
152 inline l_interval operator|(const l_interval & li1, const l_interval & li2) throw(ERROR_LINTERVAL_IN_EXACT_CH_OR_IS)
153 {
154  // liefert ConvexHull zweier Intervalle; Einschluss von aussen!
155  l_interval li3, li4; // innen, aussen
156 
157  ConvexHull(li1, li2, li3, li4);
158 
159  if (li3!=li4)
160  {
161  cxscthrow(ERROR_LINTERVAL_IN_EXACT_CH_OR_IS("inline l_interval operator|(const l_interval & li1, const l_interval & li2)"));
162  }
163  return li4;
164 }
165 
166 inline l_interval operator&(const l_interval & li1, const l_interval & li2) throw(ERROR_LINTERVAL_EMPTY_INTERVAL, ERROR_LINTERVAL_IN_EXACT_CH_OR_IS)
167 {
168  // liefert Intersection zweier Intervalle; Einschluss von aussen!
169  l_interval li3, li4; // innen, aussen
170 
171  try
172  {
173  Intersection(li1, li2, li3, li4);
174  }
175  catch(const EMPTY_INTERVAL &)
176  {
177  cxscthrow(ERROR_LINTERVAL_EMPTY_INTERVAL("inline l_interval operator&(const l_interval & li1, const l_interval & li2)"));
178  }
179 
180  if (li3!=li4)
181  {
182  cxscthrow(ERROR_LINTERVAL_IN_EXACT_CH_OR_IS("inline l_interval operator&(const l_interval & li1, const l_interval & li2)"));
183  }
184  return li4;
185 }
186 
187 inline l_interval & operator +=(l_interval &a,const l_interval &b) throw() { return a=a+b; }
188 inline l_interval & operator -=(l_interval &a,const l_interval &b) throw() { return a=a-b; }
189 inline l_interval & operator *=(l_interval &a,const l_interval &b) throw() { return a=a*b; }
190 inline l_interval & operator /=(l_interval &a,const l_interval &b) throw() { return a=a/b; }
191 inline l_interval & operator |=(l_interval &a,const l_interval &b) throw() { return a=a|b; }
192 inline l_interval & operator &=(l_interval &a,const l_interval &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a=a&b; }
193 
194 // LI-LR
195 inline l_interval operator +(const l_interval &a,const l_real &b) throw() { return a+_l_interval(b); }
196 inline l_interval operator +(const l_real &a,const l_interval &b) throw() { return _l_interval(a)+b; }
197 inline l_interval operator -(const l_interval &a,const l_real &b) throw() { return a-_l_interval(b); }
198 inline l_interval operator -(const l_real &a,const l_interval &b) throw() { return _l_interval(a)-b; }
199 inline l_interval operator *(const l_interval &a,const l_real &b) throw() { return a*_l_interval(b); }
200 inline l_interval operator *(const l_real &a,const l_interval &b) throw() { return _l_interval(a)*b; }
201 inline l_interval operator /(const l_interval &a,const l_real &b) throw() { return a/_l_interval(b); }
202 inline l_interval operator /(const l_real &a,const l_interval &b) throw() { return _l_interval(a)/b; }
203 inline l_interval operator |(const l_real &a,const l_interval &b) throw() { return _l_interval(a)|b; }
204 inline l_interval operator |(const l_interval &a,const l_real &b) throw() { return a|_l_interval(b); }
205 inline l_interval operator |(const l_real &a,const l_real &b) throw() { return _l_interval(a)|_l_interval(b); } // WARNING! For exact upper and lower bounds use the constructor!
206 inline l_interval operator &(const l_real &a,const l_interval &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return _l_interval(a)&b; }
207 inline l_interval operator &(const l_interval &a,const l_real &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a&_l_interval(b); }
208 
209 inline l_interval & operator +=(l_interval &a,const l_real &b) throw() { return a=a+_l_interval(b); }
210 inline l_interval & operator -=(l_interval &a,const l_real &b) throw() { return a=a-_l_interval(b); }
211 inline l_interval & operator *=(l_interval &a,const l_real &b) throw() { return a=a*_l_interval(b); }
212 inline l_interval & operator /=(l_interval &a,const l_real &b) throw() { return a=a/_l_interval(b); }
213 inline l_interval & operator |=(l_interval &a,const l_real &b) throw() { return a=a|_l_interval(b); }
214 inline l_interval & operator &=(l_interval &a,const l_real &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a=a&_l_interval(b); }
215 
216 // LI-I
217 inline l_interval operator +(const l_interval &a,const interval &b) throw() { return a+_l_interval(b); }
218 inline l_interval operator +(const interval &a,const l_interval &b) throw() { return _l_interval(a)+b; }
219 inline l_interval operator -(const l_interval &a,const interval &b) throw() { return a-_l_interval(b); }
220 inline l_interval operator -(const interval &a,const l_interval &b) throw() { return _l_interval(a)-b; }
221 inline l_interval operator *(const l_interval &a,const interval &b) throw() { return a*_l_interval(b); }
222 inline l_interval operator *(const interval &a,const l_interval &b) throw() { return _l_interval(a)*b; }
223 inline l_interval operator /(const l_interval &a,const interval &b) throw() { return a/_l_interval(b); }
224 inline l_interval operator /(const interval &a,const l_interval &b) throw() { return _l_interval(a)/b; }
225 inline l_interval operator |(const interval &a,const l_interval &b) throw() { return _l_interval(a)|b; }
226 inline l_interval operator |(const l_interval &a,const interval &b) throw() { return a|_l_interval(b); }
227 inline l_interval operator &(const interval &a,const l_interval &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return _l_interval(a)&b; }
228 inline l_interval operator &(const l_interval &a,const interval &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a&_l_interval(b); }
229 
230 inline l_interval & operator +=(l_interval &a,const interval &b) throw() { return a=a+_l_interval(b); }
231 inline l_interval & operator -=(l_interval &a,const interval &b) throw() { return a=a-_l_interval(b); }
232 inline l_interval & operator *=(l_interval &a,const interval &b) throw() { return a=a*_l_interval(b); }
233 inline l_interval & operator /=(l_interval &a,const interval &b) throw() { return a=a/_l_interval(b); }
234 inline l_interval & operator |=(l_interval &a,const interval &b) throw() { return a=a|_l_interval(b); }
235 inline l_interval & operator &=(l_interval &a,const interval &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a=a&_l_interval(b); }
236 
237 // LI-R
238 inline l_interval operator +(const l_interval &a,const real &b) throw() { return a+_l_interval(b); }
239 inline l_interval operator +(const real &a,const l_interval &b) throw() { return _l_interval(a)+b; }
240 inline l_interval operator -(const l_interval &a,const real &b) throw() { return a-_l_interval(b); }
241 inline l_interval operator -(const real &a,const l_interval &b) throw() { return _l_interval(a)-b; }
242 inline l_interval operator *(const l_interval &a,const real &b) throw() { return a*_l_interval(b); }
243 inline l_interval operator *(const real &a,const l_interval &b) throw() { return _l_interval(a)*b; }
244 inline l_interval operator /(const l_interval &a,const real &b) throw() { return a/_l_interval(b); }
245 inline l_interval operator /(const real &a,const l_interval &b) throw() { return _l_interval(a)/b; }
246 inline l_interval operator |(const real &a,const l_interval &b) throw() { return _l_interval(a)|b; }
247 inline l_interval operator |(const l_interval &a,const real &b) throw() { return a|_l_interval(b); }
248 inline l_interval operator &(const real &a,const l_interval &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return _l_interval(a)&b; }
249 inline l_interval operator &(const l_interval &a,const real &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a&_l_interval(b); }
250 
251 inline l_interval & operator +=(l_interval &a,const real &b) throw() { return a=a+_l_interval(b); }
252 inline l_interval & operator -=(l_interval &a,const real &b) throw() { return a=a-_l_interval(b); }
253 inline l_interval & operator *=(l_interval &a,const real &b) throw() { return a=a*_l_interval(b); }
254 inline l_interval & operator /=(l_interval &a,const real &b) throw() { return a=a/_l_interval(b); }
255 inline l_interval & operator |=(l_interval &a,const real &b) throw() { return a=a|_l_interval(b); }
256 inline l_interval & operator &=(l_interval &a,const real &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a=a&_l_interval(b); }
257 
258 // LI-ID
259 inline idotprecision operator +(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)+b; }
260 inline idotprecision operator +(const idotprecision &a,const l_interval &b) throw() { return a+_idotprecision(b); }
261 inline idotprecision operator -(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)-b; }
262 inline idotprecision operator -(const idotprecision &a,const l_interval &b) throw() { return a-_idotprecision(b); }
263 inline idotprecision operator |(const idotprecision &a,const l_interval &b) throw() { return a|_idotprecision(b); }
264 inline idotprecision operator |(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)|b; }
265 inline idotprecision operator &(const idotprecision &a,const l_interval &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a&_idotprecision(b); }
266 inline idotprecision operator &(const l_interval &a,const idotprecision &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return _idotprecision(a)&b; }
267 
268 inline idotprecision & operator +=(idotprecision &a,const l_interval &b) throw() { return a+=_idotprecision(b); }
269 inline idotprecision & operator -=(idotprecision &a,const l_interval &b) throw() { return a-=_idotprecision(b); }
270 inline idotprecision & operator |=(idotprecision &a,const l_interval &b) throw() { return a|=_idotprecision(b); }
271 inline idotprecision & operator &=(idotprecision &a,const l_interval &b) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL) { return a&=idotprecision(b); }
272 
273 // LR-R
274 inline l_interval operator |(const real &a,const l_real &b) throw() { return l_real(a)|b; }
275 inline l_interval operator |(const l_real &a,const real &b) throw() { return a|l_real(b); }
276 
277 // LR-D
278 inline idotprecision operator |(const dotprecision &a,const l_real &b) throw() { return a|dotprecision(b); }
279 inline idotprecision operator |(const l_real &a,const dotprecision &b) throw() { return dotprecision(a)|b; }
280 
281 // LR-I
282 inline l_interval operator +(const l_real &a,const interval &b) throw() { return a+_l_interval(b); }
283 inline l_interval operator +(const interval &a,const l_real &b) throw() { return _l_interval(a)+b; }
284 inline l_interval operator -(const l_real &a,const interval &b) throw() { return a-_l_interval(b); }
285 inline l_interval operator -(const interval &a,const l_real &b) throw() { return _l_interval(a)-b; }
286 inline l_interval operator *(const l_real &a,const interval &b) throw() { return a*_l_interval(b); }
287 inline l_interval operator *(const interval &a,const l_real &b) throw() { return _l_interval(a)*b; }
288 inline l_interval operator /(const l_real &a,const interval &b) throw() { return a/_l_interval(b); }
289 inline l_interval operator /(const interval &a,const l_real &b) throw() { return _l_interval(a)/b; }
290 inline l_interval operator |(const interval &a,const l_real &b) throw() { return _l_interval(a)|b; }
291 inline l_interval operator |(const l_real &a,const interval &b) throw() { return a|_l_interval(b); }
292 inline l_interval operator &(const interval &a,const l_real &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return _l_interval(a)&b; }
293 inline l_interval operator &(const l_real &a,const interval &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a&_l_interval(b); }
294 
295 // ---- Vergleichsop. ----
296 inline bool operator !=(const l_interval &a,const l_interval &b) throw() { return !(a==b); }
297 
298 inline bool operator ==(const l_real &a,const l_interval &b) throw() { return _l_interval(a)==b; }
299 inline bool operator !=(const l_real &a,const l_interval &b) throw() { return _l_interval(a)!=b; }
300 inline bool operator ==(const l_interval &a,const l_real &b) throw() { return a==_l_interval(b); }
301 inline bool operator !=(const l_interval &a,const l_real &b) throw() { return a!=_l_interval(b); }
302 
303 inline bool operator ==(const interval &a,const l_interval &b) throw() { return _l_interval(a)==b; }
304 inline bool operator !=(const interval &a,const l_interval &b) throw() { return _l_interval(a)!=b; }
305 inline bool operator ==(const l_interval &a,const interval &b) throw() { return a==_l_interval(b); }
306 inline bool operator !=(const l_interval &a,const interval &b) throw() { return a!=_l_interval(b); }
307 
308 inline bool operator ==(const real &a,const l_interval &b) throw() { return _l_interval(a)==b; }
309 inline bool operator !=(const real &a,const l_interval &b) throw() { return _l_interval(a)!=b; }
310 inline bool operator ==(const l_interval &a,const real &b) throw() { return a==_l_interval(b); }
311 inline bool operator !=(const l_interval &a,const real &b) throw() { return a!=_l_interval(b); }
312 
313 inline bool operator ==(const idotprecision &a,const l_interval &b) throw() { return a==_idotprecision(b); }
314 inline bool operator !=(const idotprecision &a,const l_interval &b) throw() { return a!=_idotprecision(b); }
315 inline bool operator ==(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)==b; }
316 inline bool operator !=(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)!=b; }
317 
318 inline bool operator ==(const dotprecision &a,const l_interval &b) throw() { return a==_idotprecision(b); }
319 inline bool operator !=(const dotprecision &a,const l_interval &b) throw() { return a!=_idotprecision(b); }
320 inline bool operator ==(const l_interval &a,const dotprecision &b) throw() { return _idotprecision(a)==b; }
321 inline bool operator !=(const l_interval &a,const dotprecision &b) throw() { return _idotprecision(a)!=b; }
322 
323 // ---- Mengenvergle. ----
324 inline bool operator <(const l_real &a,const l_interval &b) throw() { return _l_interval(a)<b; }
325 inline bool operator >(const l_real &a,const l_interval &b) throw() { return _l_interval(a)>b; }
326 inline bool operator <=(const l_real &a,const l_interval &b) throw() { return _l_interval(a)<=b; }
327 inline bool operator >=(const l_real &a,const l_interval &b) throw() { return _l_interval(a)>=b; }
328 inline bool operator <(const l_interval &a,const l_real &b) throw() { return a<_l_interval(b); }
329 inline bool operator >(const l_interval &a,const l_real &b) throw() { return a>_l_interval(b); }
330 inline bool operator <=(const l_interval &a,const l_real &b) throw() { return a<=_l_interval(b); }
331 inline bool operator >=(const l_interval &a,const l_real &b) throw() { return a>=_l_interval(b); }
332 
333 inline bool operator <(const interval &a,const l_interval &b) throw() { return _l_interval(a)<b; }
334 inline bool operator >(const interval &a,const l_interval &b) throw() { return _l_interval(a)>b; }
335 inline bool operator <=(const interval &a,const l_interval &b) throw() { return _l_interval(a)<=b; }
336 inline bool operator >=(const interval &a,const l_interval &b) throw() { return _l_interval(a)>=b; }
337 inline bool operator <(const l_interval &a,const interval &b) throw() { return a<_l_interval(b); }
338 inline bool operator >(const l_interval &a,const interval &b) throw() { return a>_l_interval(b); }
339 inline bool operator <=(const l_interval &a,const interval &b) throw() { return a<=_l_interval(b); }
340 inline bool operator >=(const l_interval &a,const interval &b) throw() { return a>=_l_interval(b); }
341 
342 inline bool operator <(const real &a,const l_interval &b) throw() { return _l_interval(a)<b; }
343 inline bool operator >(const real &a,const l_interval &b) throw() { return _l_interval(a)>b; }
344 inline bool operator <=(const real &a,const l_interval &b) throw() { return _l_interval(a)<=b; }
345 inline bool operator >=(const real &a,const l_interval &b) throw() { return _l_interval(a)>=b; }
346 inline bool operator <(const l_interval &a,const real &b) throw() { return a<_l_interval(b); }
347 inline bool operator >(const l_interval &a,const real &b) throw() { return a>_l_interval(b); }
348 inline bool operator <=(const l_interval &a,const real &b) throw() { return a<=_l_interval(b); }
349 inline bool operator >=(const l_interval &a,const real &b) throw() { return a>=_l_interval(b); }
350 
351 inline bool operator <(const idotprecision &a,const l_interval &b) throw() { return a<_idotprecision(b); }
352 inline bool operator >(const idotprecision &a,const l_interval &b) throw() { return a>_idotprecision(b); }
353 inline bool operator <=(const idotprecision &a,const l_interval &b) throw() { return a<=_idotprecision(b); }
354 inline bool operator >=(const idotprecision &a,const l_interval &b) throw() { return a>=_idotprecision(b); }
355 inline bool operator <(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)<b; }
356 inline bool operator >(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)>b; }
357 inline bool operator <=(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)<=b; }
358 inline bool operator >=(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)>=b; }
359 
360 inline bool operator <(const dotprecision &a,const l_interval &b) throw() { return a<_idotprecision(b); }
361 inline bool operator >(const dotprecision &a,const l_interval &b) throw() { return a>_idotprecision(b); }
362 inline bool operator <=(const dotprecision &a,const l_interval &b) throw() { return a<=_idotprecision(b); }
363 inline bool operator >=(const dotprecision &a,const l_interval &b) throw() { return a>=_idotprecision(b); }
364 inline bool operator <(const l_interval &a,const dotprecision &b) throw() { return _idotprecision(a)<b; }
365 inline bool operator >(const l_interval &a,const dotprecision &b) throw() { return _idotprecision(a)>b; }
366 inline bool operator <=(const l_interval &a,const dotprecision &b) throw() { return _idotprecision(a)<=b; }
367 inline bool operator >=(const l_interval &a,const dotprecision &b) throw() { return _idotprecision(a)>=b; }
368 
369 // ---- Funktionen ----
370 
371 static const int LI_Min_Exp_ = -1074,
372  LI_maxexpo1 = 1023;
373 
374 //inline l_interval_Inf Inf (l_interval & a) throw() { return l_interval_Inf(a); }
375 //inline l_interval_Sup Sup (l_interval & a) throw() { return l_interval_Sup(a); }
376 inline l_real Inf (const l_interval &li) throw()
377 {
378  // l_real in der Praezision des Intervals
379  int save_stagprec=stagprec;
380  stagprec=li.prec;
381  l_real lr; // l_real in der Praez. des l_intervals angele
382 
383  for (int i=1; i<=stagprec; i++)
384  lr.elem(i)=li.elem(i); // vgl. Darstellung der l_intervals
385 
386  stagprec=save_stagprec;
387 
388  return lr;
389 }
390 inline l_real Sup (const l_interval &li) throw()
391 {
392  // l_real in der Praezision des Intervals
393  int save_stagprec=stagprec;
394  stagprec=li.prec;
395  l_real lr; // l_real in der Praez. des l_intervals angele
396 
397  for (int i=1; i<stagprec; i++)
398  lr.elem(i)=li.elem(i); // vgl. Darstellung der l_intervals
399 
400  lr.elem(stagprec)=li.elem(stagprec+1);
401 
402  stagprec=save_stagprec;
403 
404  return lr;
405 }
406 
407 inline int StagPrec(const l_interval &a) throw() { return a.prec; }
408 
409 inline l_interval & SetInf (l_interval & a, const l_real & b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a=_l_interval(b,Sup((const l_interval)a)); }
410 inline l_interval & SetSup (l_interval & a, const l_real & b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a=_l_interval(Inf((const l_interval)a),b); }
411 inline l_interval & SetInf (l_interval & a, const real & b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return SetInf(a,_l_real(b)); }
412 inline l_interval & SetSup (l_interval & a, const real & b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return SetSup(a,_l_real(b)); }
413 
414 inline l_interval adjust(const l_interval & x) throw()
415 {
416  l_interval y;
417 
418  if (x.prec == stagprec)
419  y = x;
420  else if (x.prec > stagprec)
421  {
422  y = x + 0.0;
423  }
424  else
425  { // x.prec < stagprec
426  int i;
427  for (i = 0; i <= stagprec-x.prec-1; i++)
428  y.data[i] = 0.0;
429  for (i = stagprec-x.prec; i <= stagprec; i++)
430  y.data[i] = x.data[i-(stagprec-x.prec)];
431  }
432  return y;
433 }
434 
435 inline l_interval & UncheckedSetInf (l_interval & a, const l_real & b) throw() { return a=_unchecked_l_interval(b,Sup(a)); }
436 inline l_interval & UncheckedSetSup (l_interval & a, const l_real & b) throw() { return a=_unchecked_l_interval(Inf(a),b); }
437 inline l_interval & UncheckedSetInf (l_interval & a, const real & b) throw() { return UncheckedSetInf(a,_l_real(b)); }
438 inline l_interval & UncheckedSetSup (l_interval & a, const real & b) throw() { return UncheckedSetSup(a,_l_real(b)); }
439 
440 inline l_interval abs (const l_interval & li1) throw()
441 {
442  l_interval li2;
443  l_real i = Inf(li1), s = Sup(li1);
444  l_real inf = abs(i), sup = abs(s);
445 
446  if (i>s)
447  li2 = li1;
448  else if (!li1)
449  li2 = l_interval(0.0, (inf > sup) ? inf : sup);
450  else if (inf > sup)
451  li2 = l_interval(sup, inf);
452  else
453  li2 = l_interval(inf, sup);
454 
455  return li2;
456 }
457 
458 inline l_real diam (const l_interval & li) throw()
459 {
460  return _l_real(diam(_interval(li.elem(li.prec),li.elem(li.prec+1))));
461 }
462 
463 inline void accumulate(idotprecision & a, const real & b, const l_interval & c) throw() { accumulate(a,_l_interval(b),c); }
464 inline void accumulate(idotprecision & a, const l_interval & b, const real & c) throw() { accumulate(a,b,_l_interval(c)); }
465 inline void accumulate(idotprecision & a, const interval & b, const l_real & c) throw() { accumulate(a,_l_interval(b),_l_interval(c)); }
466 inline void accumulate(idotprecision & a, const l_real & b, const interval & c) throw() { accumulate(a,_l_interval(b),_l_interval(c)); }
467 inline void accumulate(idotprecision & a, const l_interval & b, const l_real & c) throw() { accumulate(a,b,_l_interval(c)); }
468 inline void accumulate(idotprecision & a, const l_real & b, const l_interval & c) throw() { accumulate(a,_l_interval(b),c); }
469 inline void accumulate(idotprecision & a, const l_interval & b, const interval & c) throw() { accumulate(a,b,_l_interval(c)); }
470 inline void accumulate(idotprecision & a, const interval & b, const l_interval & c) throw() { accumulate(a,_l_interval(b),c); }
471 
472 
474 #if (CXSC_INDEX_CHECK)
475  throw(ERROR_LINTERVAL_ELEMENT_NOT_IN_LONG)
476 #else
477  throw()
478 #endif
479 {
480 #if (CXSC_INDEX_CHECK)
481  if(a<1 || a>prec+1)
482  cxscthrow(ERROR_LINTERVAL_ELEMENT_NOT_IN_LONG("inline real & l_interval::operator[](int a)"));
483 #endif
484  return data[a-1];
485 }
486 
487 inline void l_interval::_clear(int p) throw()
488 {
489  int i;
490  // fuellt l_interval ab Stelle p bis zum Ende mit Null.
491  // funktioniert immer, da for-Schleife abweisend!
492  for (i=p; i<=prec+1; i++)
493  this->elem(i)=0.0;
494 }
495 
496 inline bool point_intv(const l_interval &a ) // bool delivers: a is a point interval;
497 {
498  int k(a.prec);
499  return a.elem(k+1) == a.elem(k);
500 }
501 
502 inline bool zero_(const l_interval& li) throw()
503 { // returns only true if all li.elem(i) == 0; Blomquist, 27.11.02;
504  int i=1, p=StagPrec(li)+1;
505  bool tmp = true;
506  do
507  {
508  if (sign(li.elem(i))!=0) tmp = false;
509  i++;
510  } while(tmp && i <= p );
511  return tmp;
512 }
513 
514 
515 
522  inline int expo_gr(const l_interval& x)
523  // Calculating expo(x[k]) of the greatest |x[k]|.
524  {
525  int k(1),p(x.prec),ex1,ex2;
526  l_interval y(x);
527  while (y.elem(k)==0 && k<p) k++;
528  ex1 = expo(y.elem(k));
529  ex2 = expo(y.elem(k+1));
530  if (ex2>ex1) ex1 = ex2; // ex1: Maximum;
531  return ex1;
532  }
539  inline int expo_sm(const l_interval& x)
540  // Calculating expo(x[k]) of the smallest |x[k]|<>0.
541  {
542  int k(x.prec+1),ex1,ex2;
543  l_interval y(x);
544 
545  while (y.elem(k)==0 && k>2) k--;
546  ex1 = expo(y.elem(k));
547  ex2 = expo(y.elem(k-1));
548  if (ex2<ex1)
549  {
550  k = ex1; ex1 = ex2; ex2 = k;
551  } // ex1: Minimum;
552  if (ex1<-100000) ex1 = ex2;
553  return ex1;
554  }
555 
556 
557 } // namespace cxsc
558 
cxsc::l_interval::operator[]
real & operator[](int)
Access to the single components used to store the long data type value.
Definition: l_interval.inl:473
cxsc::operator*=
cimatrix & operator*=(cimatrix &m, const cinterval &c)
Implementation of multiplication and allocation operation.
Definition: cimatrix.inl:1605
cxsc::interval
The Scalar Type interval.
Definition: interval.hpp:55
cxsc::expo_gr
int expo_gr(const l_interval &x)
Definition: l_interval.inl:522
cxsc::diam
cvector diam(const cimatrix_subv &mv)
Returns the diameter of the matrix.
Definition: cimatrix.inl:738
cxsc::_l_interval
l_interval _l_interval(const real &a)
Definition: l_interval.hpp:879
cxsc::_idotprecision
idotprecision _idotprecision(const real &a)
Definition: idot.inl:51
cxsc::idotprecision
The Data Type idotprecision.
Definition: idot.hpp:48
cxsc::abs
ivector abs(const cimatrix_subv &mv)
Returns the absolute value of the matrix.
Definition: cimatrix.inl:737
cxsc::operator*
civector operator*(const cimatrix_subv &rv, const cinterval &s)
Implementation of multiplication operation.
Definition: cimatrix.inl:731
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_interval
The Multiple-Precision Data Type l_interval.
Definition: l_interval.hpp:72
cxsc::expo_sm
int expo_sm(const l_interval &x)
Definition: l_interval.inl:539
cxsc::l_interval::operator=
l_interval & operator=(const real &a)
Implementation of standard assigning operator.
Definition: l_interval.inl:89
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::operator/
civector operator/(const cimatrix_subv &rv, const cinterval &s)
Implementation of division operation.
Definition: cimatrix.inl:730
cxsc::_unchecked_interval
interval _unchecked_interval(const real &a, const real &b)
Definition: interval.inl:66
cxsc::l_interval::l_interval
l_interval()
Constructor of class l_interval.
Definition: l_interval.inl:45
cxsc::real
The Scalar Type real.
Definition: real.hpp:114