18 mfunname(
"DoubleAc::DoubleAc(double f, double ffmin, double ffmax)");
27 mfunname(
"DoubleAc::DoubleAc(double f, double relative_prec)");
32 da = f * (1.0 + relative_prec);
33 di = f / (1.0 + relative_prec);
35 di = f * (1.0 + relative_prec);
36 da = f / (1.0 + relative_prec);
41 mfunnamep(
"DoubleAc& DoubleAc::operator*=(const DoubleAc& f)");
42#ifdef DEBUG_OPERATOR_MULT_PRINT
44 mcout <<
"d=" << d <<
'\n';
45 mcout <<
"di=" << di <<
'\n';
46 mcout <<
"da=" << da <<
'\n';
47 mcout <<
"f.d=" << f.d <<
'\n';
48 mcout <<
"f.di=" << f.di <<
'\n';
49 mcout <<
"f.da=" << f.da <<
'\n';
52 if (std::isnan(di) == 1) di = -DBL_MAX;
53 if (std::isnan(da) == 1) da = DBL_MAX;
54 if (std::isnan(f.di) == 1) f.di = -DBL_MAX;
55 if (std::isnan(f.da) == 1) f.da = DBL_MAX;
57 if (_isnan(di) == 1) di = -DBL_MAX;
58 if (_isnan(da) == 1) da = DBL_MAX;
59 if (_isnan(f.di) == 1) f.di = -DBL_MAX;
60 if (_isnan(f.da) == 1) f.da = DBL_MAX;
62#ifdef POSSIBLE_FAILURE_ISNAN
63 if (!(di < d) && !(di >= d)) di = -DBL_MAX;
64 if (!(da < d) && !(da >= d)) da = DBL_MAX;
65 if (!(f.di < f.d) && !(f.di >= f.d)) f.di = -DBL_MAX;
66 if (!(f.da < f.d) && !(f.da >= f.d)) f.da = DBL_MAX;
68#ifdef DEBUG_OPERATOR_MULT
76#ifdef DEBUG_OPERATOR_MULT_PRINT
83#ifdef DEBUG_OPERATOR_MULT_PRINT
88 double ti = da * f.di;
91#ifdef DEBUG_OPERATOR_MULT_PRINT
100#ifdef DEBUG_OPERATOR_MULT_PRINT
103 }
else if (f.da >= 0) {
104 double ti =
find_min(di * f.da, da * f.di);
105 da =
find_max(di * f.di, da * f.da);
107#ifdef DEBUG_OPERATOR_MULT_PRINT
111 double ti = da * f.di;
114#ifdef DEBUG_OPERATOR_MULT_PRINT
123#ifdef DEBUG_OPERATOR_MULT_PRINT
126 }
else if (f.da >= 0) {
127 double ti = di * f.da;
130#ifdef DEBUG_OPERATOR_MULT_PRINT
134 double ti = da * f.da;
137#ifdef DEBUG_OPERATOR_MULT_PRINT
145#ifdef CHECK_CORRECTNESS_AT_MULT
150 mcerr <<
"d < di at the end of computations\n";
151 mcerr <<
"This number:\n";
153 mcerr <<
"Argument:\n";
155 if (d > di)
mcerr <<
"if(d > di) is also positive\n";
156 if (d == di)
mcerr <<
"if(d == di) is also positive\n";
158#ifdef DEBUG_OPERATOR_MULT
160 mcerr <<
"old value:\n";
169 mcerr <<
"d > di at the end of computations\n";
170 mcerr <<
"This number:\n";
172 mcerr <<
"Argument:\n";
174 if (d < da)
mcerr <<
"if(d < da) is also positive\n";
175 if (d == da)
mcerr <<
"if(d == da) is also positive\n";
177#ifdef DEBUG_OPERATOR_MULT
179 mcerr <<
"old value:\n";
190 mfunnamep(
"DoubleAc& DoubleAc::operator/=(const DoubleAc& f)");
194 if (std::isnan(di) == 1) di = -DBL_MAX;
195 if (std::isnan(da) == 1) da = DBL_MAX;
196 if (std::isnan(f.di) == 1) f.di = -DBL_MAX;
197 if (std::isnan(f.da) == 1) f.da = DBL_MAX;
199 if (_isnan(di) == 1) di = -DBL_MAX;
200 if (_isnan(da) == 1) da = DBL_MAX;
201 if (_isnan(f.di) == 1) f.di = -DBL_MAX;
202 if (_isnan(f.da) == 1) f.da = DBL_MAX;
204#ifdef POSSIBLE_FAILURE_ISNAN
205 if (!(di < d) && !(di >= d)) di = -DBL_MAX;
206 if (!(da < d) && !(da >= d)) da = DBL_MAX;
207 if (!(f.di < f.d) && !(f.di >= f.d)) f.di = -DBL_MAX;
208 if (!(f.da < f.d) && !(f.da >= f.d)) f.da = DBL_MAX;
212 if (f.di < 0 && f.da > 0) {
215 }
else if (di >= 0) {
219 }
else if (f.di == 0) {
227 double ti = da / f.da;
233 }
else if (da >= 0) {
237 }
else if (f.di == 0) {
245 double ti = da / f.da;
255 }
else if (f.di == 0) {
261 mcerr <<
"f.da == 0\n";
262 mcerr <<
"This means that f.d == 0 which should been already "
264 mcerr <<
"If the program reaches this point, this means that\n"
265 <<
"f.d is not between f.di and f.da, which is prohibited\n";
276 double ti = da / f.di;
282#ifdef CHECK_CORRECTNESS_AT_MULT
285 mcerr <<
"d < di at the end of computations\n";
286 mcerr <<
"This number:\n";
288 mcerr <<
"Argument:\n";
297 mcerr <<
"d > di at the end of computations\n";
298 mcerr <<
"This number:\n";
300 mcerr <<
"Argument:\n";
315 mcerr <<
"error in DoubleAc sqrt(const DoubleAc& f): f.get() < 0, f.get()="
337 if (p == 1)
return f;
340 double d = std::pow(f.
get(), p);
357 double d = std::pow(f.
get(), -p);
377 double d = std::exp(f.
get());
385 double d = std::sin(f.
get());
432 double d = std::cos(f.
get());
470 mcerr <<
"ERROR in inline DoubleAc asin(const DoubleAc& f):\n"
471 <<
"fabs(f.get()) > 1: f.get()=" << f.
get() <<
'\n';
474 double d = std::asin(f.
get());
477 di = std::asin(-1.0);
490 mcerr <<
"ERROR in inline DoubleAc acos(const DoubleAc& f):\n"
491 <<
"fabs(f.get()) > 1: f.get()=" << f.
get() <<
'\n';
494 double d = std::acos(f.
get());
497 da = std::acos(-1.0);
513 file << d <<
" [ " << di <<
" , " << da <<
" ] ";
516 int t = file.precision(2);
517 file <<
" [" << std::setw(8) << d - di <<
"," << std::setw(8) << da - d
521 file << d <<
" [ " << di <<
" , " << da <<
" ] \n";
524 int t = file.precision(2);
525 file <<
" [" << std::setw(8) << d - di <<
"," << std::setw(8) << da - d
529 int t = file.precision(16);
530 file <<
"DoubleAc: d=" << std::setw(20) << d <<
" di=" << std::setw(20)
531 << di <<
" da=" << std::setw(20) << da <<
'\n';
537 mcerr <<
"ERROR in inline DoubleAc pow(const DoubleAc& f, const DoubleAc& "
539 mcerr <<
"not implemented yet\n";
DoubleAc cos(const DoubleAc &f)
DoubleAc asin(const DoubleAc &f)
DoubleAc pow(const DoubleAc &f, double p)
DoubleAc sqrt(const DoubleAc &f)
DoubleAc square(const DoubleAc &f)
DoubleAc sin(const DoubleAc &f)
std::ostream & operator<<(std::ostream &file, const DoubleAc &f)
DoubleAc acos(const DoubleAc &f)
DoubleAc exp(const DoubleAc &f)
DoubleAc fabs(const DoubleAc &f)
DoubleAc find_min(const DoubleAc &a, const DoubleAc &b)
DoubleAc find_max(const DoubleAc &a, const DoubleAc &b)
#define check_econd11(a, signb, stream)
#define check_econd12a(a, sign, b, add, stream)
#define mfunnamep(string)
DoubleAc & operator/=(DoubleAc f)
void print(std::ostream &file, int l=1) const
DoubleAc & operator*=(DoubleAc f)
double get_right_limit(void) const
double left_limit(void) const
double right_limit(void) const
double get_left_limit(void) const
long left_round(double f)
#define Iprintn(file, name)