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;
80void l_real::_clear(
int p)
noexcept
83 for (
int i=p; i<=prec; i++)
88void l_real::_akku_out(
const dotprecision& d)
noexcept
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));
107void l_real::_akku_out_up(
const dotprecision& d)
noexcept
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));
130void l_real::_akku_out_down(
const dotprecision& d)
noexcept
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];
183l_real::~l_real() noexcept
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);
279 real* tmp =
new real[lr.prec];
283 memcpy(tmp,lr.data,
sizeof(real)*prec);
295 data=
new real[prec=stagprec];
327 dotprecision dot(0.0);
342 dotprecision dot(0.0);
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));
490 dotprecision dot(0.0);
500 dotprecision dot(0.0);
511 dotprecision dot(0.0);
522 dotprecision dot1(0.0);
523 dotprecision dot2(0.0);
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);
556 dotprecision dot1(0.0);
557 dotprecision dot2(0.0);
565 dotprecision dot1(0.0);
566 dotprecision dot2(0.0);
574 dotprecision dot(0.0);
580bool operator< (
const l_real& lr1,
const l_real& lr2)
noexcept {
return !(lr2<=lr1); }
581bool operator> (
const l_real& lr1,
const l_real& lr2)
noexcept {
return !(lr1<=lr2); }
661real & real::operator = (
const l_real& a)
noexcept
673 dotprecision dot(0.0);
686 dotprecision dot(0.0);
695 if (x.prec == stagprec)
697 else if (x.prec > stagprec)
699 dotprecision dot(0.0);
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));
The Data Type dotprecision.
dotprecision(void) noexcept
Constructor of class dotprecision.
dotprecision & operator=(const dotprecision &) noexcept
Implementation of standard assigning operator.
The Data Type idotprecision.
idotprecision()
Constructor of class idotprecision.
The Scalar Type interval.
interval & operator=(const real &a)
Implementation of standard assigning operator.
interval()
Constructor of class interval.
The Multiple-Precision Data Type l_interval.
The Multiple-Precision Data Type l_real.
friend std::istream & operator>>(std::istream &, l_real &) noexcept
Implementation of standard input method.
friend l_real & operator-=(l_real &, const l_real &) noexcept
Implementation of standard algebraic subtraction and allocation operation.
l_real & operator=(const l_real &) noexcept
Implementation of standard assigning operator.
friend bool operator!=(const l_real &, const l_real &) noexcept
Implementation of standard negated equality operation.
real & operator[](int) const noexcept
Access to the single components used to store the long data type value.
friend l_real adjust(const l_real &) noexcept
Sets the precision of a specific long datatype value.
l_real(void) noexcept
Constructor of class l_real.
friend bool operator!(const l_real &lr) noexcept
Implementation of standard negation operation.
friend bool operator>=(const l_real &, const l_real &) noexcept
Implementation of standard greater-or-equal-than operation.
friend l_real Sup(const l_interval &) noexcept
Returns the supremum of an l_interval.
friend l_real Inf(const l_interval &) noexcept
Returns the infimum of an l_interval.
friend int sign(const l_real &) noexcept
The sign of a l_real value.
friend bool operator>(const l_real &, const l_real &) noexcept
Implementation of standard greater-than operation.
friend real _l_real(const l_rvector &) noexcept
Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
friend l_real operator+(const l_real &lr1) noexcept
Implementation of standard algebraic positive sign operation.
friend bool operator==(const l_real &, const l_real &) noexcept
Implementation of standard equality operation.
friend void accumulate(dotprecision &, const real &, const l_real &) noexcept
The accurate scalar product of the last two arguments added to the value of the first argument.
friend int StagPrec(const l_real &) noexcept
Returns the precision of the long datatype value.
friend bool operator<(const l_real &, const l_real &) noexcept
Implementation of standard less-than operation.
friend bool operator<=(const l_real &, const l_real &) noexcept
Implementation of standard less-or-equal-than operation.
friend std::ostream & operator<<(std::ostream &, const l_real &) noexcept
Implementation of standard output method.
friend l_real operator-(const l_real &lr1) noexcept
Implementation of standard algebraic negative sign operation.
real(void) noexcept
Constructor of class real.
The namespace cxsc, providing all functionality of the class library C-XSC.
cdotprecision & operator+=(cdotprecision &cd, const l_complex &lc) noexcept
Implementation of standard algebraic addition and allocation operation.
l_real rnd_up(const dotprecision &a)
Rounds the argument up to the next l_real value.
civector operator/(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of division operation.
int expo_gr(const l_interval &x)
l_real rnd_down(const dotprecision &a)
Rounds the argument down to the next l_real value.
cimatrix & operator*=(cimatrix &m, const cinterval &c) noexcept
Implementation of multiplication and allocation operation.
ivector abs(const cimatrix_subv &mv) noexcept
Returns the absolute value of the matrix.
civector operator*(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of multiplication operation.
int expo_sm(const l_interval &x)
dotprecision _dotprecision(const real &d) noexcept
cimatrix & operator/=(cimatrix &m, const cinterval &c) noexcept
Implementation of division and allocation operation.