31 #include "interval.hpp" 32 #include "l_interval.hpp" 36 #ifdef CXSC_USE_TLS_PREC 39 __declspec(thread) int stagprec = 2;
41 __thread
int stagprec = 2;
80 void l_real::_clear(
int p)
throw()
83 for (
int i=p; i<=prec; i++)
94 this->elem(1) = rnd(dot);
99 dot -= this->elem(i-1);
100 this->elem(i) = rnd(dot);
102 weiter = this->elem(i-1) != 0;
103 }
while (weiter && (i <= prec));
107 void l_real::_akku_out_up(
const dotprecision& d)
throw()
115 this->elem(1) = (prec==1)? rnd(dot,RND_UP) : rnd(dot);
120 dot -= this->elem(i-1);
121 weiter = (sign(dot) != 0);
123 this->elem(i) = (i==prec)?
124 rnd(dot,RND_UP) : rnd(dot);
126 }
while (weiter && (i <= prec));
130 void l_real::_akku_out_down(
const dotprecision& d)
throw()
138 this->elem(1) = (prec==1)? rnd(dot,RND_DOWN) : rnd(dot);
143 dot -= this->elem(i-1);
144 weiter = (sign(dot) != 0);
146 this->elem(i) = (i==prec)?
147 rnd(dot,RND_DOWN) : rnd(dot);
149 }
while (weiter && (i <= prec));
156 for (
int i=1; i<=prec; i++)
158 if (this->elem(i) != 0) d += this->elem(i);
165 for (
int i=1; i<=prec; i++)
167 if (this->elem(i) != 0) d -= this->elem(i);
176 data=
new real[stagprec];
183 l_real::~l_real()
throw()
189 : data(
new real[lr.prec])
194 memcpy(data,lr.data,
sizeof(
real)*prec);
207 : prec(1), data(
new real[1])
237 memset(akku,0,BUFFERSIZE);
243 memset(akku,0,BUFFERSIZE);
283 memcpy(tmp,lr.data,
sizeof(
real)*prec);
295 data=
new real[prec=stagprec];
362 for (
int i=1; i<=lr.prec; i++)
369 for (
int i=1; i<=lr.prec; i++)
377 for (i=1; i<=lr1.prec; i++)
378 for (j=1; j<=lr2.prec; j++)
397 lr._akku_out_down(a);
429 { lr = lr-_l_real(r);
return lr; }
432 { lr = lr+_l_real(r);
return lr; }
435 { lr = lr*_l_real(r);
return lr; }
438 { lr = lr/_l_real(r);
return lr; }
478 for (
int i=1; i<=lr1.prec; i++)
479 lr2.elem(i) = -(lr1.elem(i));
526 a = rnd(dot1, RND_DOWN);
527 b = rnd(dot2, RND_UP);
530 cxscthrow(DIV_BY_ZERO(
"l_real operator/(const l_real&, const l_real&)"));
534 for (
int i=2; i<=stagprec; i++)
538 for (
int j=1; j<=lr2.prec; j++)
539 if (!!lr3.elem(i-1) && !!lr2.elem(j) )
540 accumulate(dot1, lr3.elem(i-1), -lr2.elem(j));
541 a = rnd(dot1, RND_DOWN);
661 real & real::operator = (
const l_real& a)
throw()
695 if (x.prec == stagprec)
697 else if (x.prec > stagprec)
705 for (i = 0; i <= stagprec-x.prec-1; i++)
707 for (i = stagprec-x.prec; i <= stagprec-1; i++)
708 y.data[i] = x.data[i-(stagprec-x.prec)];
731 while (y.elem(k)==0 && k>1) k--;
732 return expo(y.elem(k));
750 while (y.elem(k)==0 && k<p) k++;
751 return expo(y.elem(k));
dotprecision _dotprecision(const real &d)
The Multiple-Precision Data Type l_interval.
int expo_sm(const l_interval &x)
cimatrix & operator/=(cimatrix &m, const cinterval &c)
Implementation of division and allocation operation.
The Data Type idotprecision.
The Multiple-Precision Data Type l_real.
The Data Type dotprecision.
friend dotprecision & Sup(idotprecision &a)
Returns the supremum of a dotprecison interval.
The namespace cxsc, providing all functionality of the class library C-XSC.
civector operator*(const cimatrix_subv &rv, const cinterval &s)
Implementation of multiplication operation.
real & operator[](int) const
Access to the single components used to store the long data type value.
The Scalar Type interval.
friend std::istream & operator>>(std::istream &s, idotprecision &a)
Implementation of standard input method.
friend bool operator>=(const idotprecision &, const idotprecision &)
Implementation of standard greater-or-equal-than operation.
l_real & operator=(const l_real &)
Implementation of standard assigning operator.
friend bool operator>(const idotprecision &, const idotprecision &)
Implementation of standard greater-than operation.
friend idotprecision & operator|=(idotprecision &, const idotprecision &)
Allocates the convex hull of the arguments to the first argument.
l_real rnd_up(const dotprecision &a)
Rounds the argument up to the next l_real value.
friend std::ostream & operator<<(std::ostream &s, const idotprecision &a)
Implementation of standard output method.
friend idotprecision operator&(const idotprecision &, const idotprecision &)
Returns the intersection of the arguments.
friend idotprecision operator-(const idotprecision &)
Implementation of standard algebraic negative sign operation.
friend bool operator==(const idotprecision &, const idotprecision &)
Implementation of standard equality operation.
dotprecision & operator=(const dotprecision &)
Implementation of standard assigning operator.
friend idotprecision & operator+=(idotprecision &, const idotprecision &)
Implementation of standard algebraic addition and allocation operation.
friend idotprecision abs(const idotprecision &a)
Returns the absolute value of a dotprecision interval.
friend void accumulate(idotprecision &, const interval &, const interval &)
The accurate scalar product of the last two arguments added to the value of the first argument...
friend bool operator!(const idotprecision &)
Implementation of standard negation operation.
dotprecision(void)
Constructor of class dotprecision.
interval()
Constructor of class interval.
friend idotprecision & operator&=(idotprecision &, const idotprecision &)
Allocates the intersection of the arguments to the first argument.
interval & operator=(const real &a)
Implementation of standard assigning operator.
friend idotprecision operator|(const idotprecision &, const idotprecision &)
Returns the convex hull of the arguments.
l_real(void)
Constructor of class l_real.
real(void)
Constructor of class real.
friend idotprecision & operator-=(idotprecision &, const idotprecision &)
Implementation of standard algebraic subtraction and allocation operation.
friend bool operator<=(const idotprecision &, const idotprecision &)
Implementation of standard less-or-equal-than operation.
idotprecision()
Constructor of class idotprecision.
int expo_gr(const l_interval &x)
l_real rnd_down(const dotprecision &a)
Rounds the argument down to the next l_real value.
civector operator/(const cimatrix_subv &rv, const cinterval &s)
Implementation of division operation.
cimatrix & operator*=(cimatrix &m, const cinterval &c)
Implementation of multiplication and allocation operation.
friend idotprecision operator+(const idotprecision &)
Implementation of standard algebraic positive sign operation.
friend bool operator!=(const idotprecision &, const idotprecision &)
Implementation of standard negated equality operation.
friend dotprecision & Inf(idotprecision &a)
Returns the infimum of a dotprecison interval.
friend bool operator<(const idotprecision &, const idotprecision &)
Implementation of standard less-than operation.