25#include "l_complex.hpp"
26#include "l_interval.hpp"
143static const int maxexpo = 1020;
145void skale_down_exp(
int ex1,
int ex2,
int D,
int& d1,
int& d2)
165 { c = ex1; ex1 = ex2; ex2 = c; change =
true; }
170 Diff = ex2 - c; D1 = Diff/2;
171 d1 = D + D1; d2 = D - d1;
175 { c = d1; d1 = d2; d2 = c; }
180void skale_up_exp1(
int ex1,
int ex2,
int& fillin,
int& d1,
int& d2)
194 fillin = maxexpo - (ex1+ex2);
198 { c = ex1; ex1 = ex2; ex2 = c; change =
true; }
200 pot2 = maxexpo - ex2;
202 if (fillin <= pot2) d2 = fillin;
203 else { d2 = pot2; d1 = fillin - pot2; }
205 { c = d1; d1 = d2; d2 = c; }
209void skale_up_exp2(
int ex1,
int ex2,
int fillin,
int& d1,
int& d2)
226 { c = ex1; ex1 = ex2; ex2 = c; change =
true; }
230 if (fillin <= pot2) d2 = fillin;
231 else { d2 = pot2; d1 = fillin - pot2; }
233 { c = d1; d1 = d2; d2 = c; }
241 l_real a1(a), b1(b), c1(c), d1(d);
243 a1 += 0.0; b1 += 0.0; c1 += 0.0; d1 += 0.0;
244 int ex_a1( expo(a1[1]) ), ex_b1( expo(b1[1]) ),
245 ex_c1( expo(c1[1]) ), ex_d1( expo(d1[1]) ), m,p,D1,D2;
246 l_interval a_i(a1),b_i(b1),c_i(c1),d_i(d1),li;
248 ex = expo(0.0); res = 0.0;
250 if ( ex_a1 == ex || ex_b1 == ex )
251 if ( ex_c1 == ex || ex_d1 == ex ) ;
258 skale_down_exp(ex_c1, ex_d1, p, D1, D2);
262 accumulate(Akku,c_i,d_i);
268 skale_up_exp1(ex_c1, ex_d1, p, D1, D2);
272 accumulate(Akku,c_i,d_i);
278 if ( ex_c1 == ex || ex_d1 == ex )
284 skale_down_exp(ex_a1, ex_b1, p, D1, D2);
288 accumulate(Akku,a_i,b_i);
294 skale_up_exp1(ex_a1, ex_b1, p, D1, D2);
298 accumulate(Akku,a_i,b_i);
305 if ( (ex_c1+ex_d1) > (ex_a1+ex_b1) )
307 li = a_i; a_i = c_i; c_i = li;
308 li = b_i; b_i = d_i; d_i = li;
309 m = ex_a1; ex_a1 = ex_c1; ex_c1 = m;
310 m = ex_b1; ex_b1 = ex_d1; ex_d1 = m;
317 skale_down_exp(ex_a1,ex_b1,p,D1,D2);
320 skale_down_exp(ex_c1,ex_d1,p,D1,D2);
324 accumulate(Akku,a_i,b_i);
325 accumulate(Akku,c_i,d_i);
331 skale_up_exp1(ex_a1, ex_b1, p, D1, D2);
334 skale_up_exp2(ex_c1, ex_d1, p, D1, D2);
338 accumulate(Akku,a_i,b_i);
339 accumulate(Akku,c_i,d_i);
351 c1 += 0.0; d1 += 0.0;
352 int ex_c1( expo(c1[1]) ), ex_d1( expo(d1[1]) ), m;
356 ex = expo(0.0); res = 0.0;
364 accumulate(Akku,d_i,d_i);
373 accumulate(Akku,c_i,c_i);
381 li = c_i; c_i = d_i; d_i = li;
382 m = ex_c1; ex_c1 = ex_d1; ex_d1 = m;
387 accumulate(Akku,c_i,c_i);
388 accumulate(Akku,d_i,d_i);
410 std::cerr <<
"quotient1(const l_interval& z, const l_interval& n, int round, int ex_z, int ex_n): Division by zero" << std::endl;
414 if ( zero_(z) ) { q1=0;
return q1; };
416 ex_diff = ex_z - ex_n;
418 Times2pown(res,ex_diff);
440 product(Re(b),Im(b),ex2,n);
441 product(Re(a),Re(b),Im(a),Im(b),ex1,z);
442 SetRe(tmp, quotient(z,n,round,ex1,ex2));
443 product(Im(a),Re(b),-Re(a),Im(b),ex1,z);
444 SetIm(tmp, quotient(z,n,round,ex1,ex2));
450 return _c_division(a,b,RND_NEXT);
455 return _c_division(a,b,RND_DOWN);
460 return _c_division(a,b,RND_UP);
492 const real& r)
noexcept
499 const l_real& lr)
noexcept
524 { a.im=b;
return a; }
527 { a.re=b;
return a; }
The Data Type cdotprecision.
complex & operator=(const real &r) noexcept
Implementation of standard assigning operator.
complex(void) noexcept
Constructor of class complex.
friend real & Re(complex &a)
Returns the real part of the complex value.
friend real & Im(complex &a)
Returns the imaginary part of the complex value.
The Data Type dotprecision.
The Data Type idotprecision.
The Multiple-Precision Data Type l_complex.
friend l_complex divn(const l_complex &, const l_complex &)
Division of two real values and rounding to the nearest value.
friend l_real & Im(l_complex &a)
Returns the imaginary part of the complex value.
friend l_complex & SetIm(l_complex &a, const l_real &b)
Sets the imaginary part of a complex value.
friend l_real abs2(const l_complex &a) noexcept
The absolute value of a l_complex value.
friend l_complex & SetRe(l_complex &a, const l_real &b)
Sets the real part of a complex value.
friend l_real & Re(l_complex &a)
Returns the real part of the complex value.
friend l_complex operator-(const l_complex &)
Implementation of standard algebraic negative sign operation.
friend int StagPrec(const l_complex &) noexcept
Returns the precision of the long datatype value.
l_complex(void) noexcept
Constructor of class l_complex.
friend void accumulate(cdotprecision &, const l_complex &, const l_complex &) noexcept
The accurate scalar product of the last two arguments added to the value of the first argument.
friend l_complex operator+(const l_complex &)
Implementation of standard algebraic positive sign operation.
The Multiple-Precision Data Type l_interval.
The Multiple-Precision Data Type l_real.
The namespace cxsc, providing all functionality of the class library C-XSC.
civector operator/(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of division operation.
ivector abs(const cimatrix_subv &mv) noexcept
Returns the absolute value of the matrix.
void times2pown(cinterval &x, int n) noexcept
Fast multiplication of reference parameter [z] with .
cvector mid(const cimatrix_subv &mv) noexcept
Returns the middle of the matrix.
civector operator*(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of multiplication operation.
interval sqrtx2y2(const interval &x, const interval &y) noexcept
Calculates .
cdotprecision _cdotprecision(const l_complex &)