19 mfunname(
"DoubleAc::DoubleAc(double f, double ffmin, double ffmax)");
28 mfunname(
"DoubleAc::DoubleAc(double f, double relative_prec)");
33 da = f * (1.0 + relative_prec);
34 di = f / (1.0 + relative_prec);
36 di = f * (1.0 + relative_prec);
37 da = f / (1.0 + relative_prec);
42 mfunnamep(
"DoubleAc& DoubleAc::operator*=(const DoubleAc& f)");
43#ifdef DEBUG_OPERATOR_MULT_PRINT
45 mcout <<
"d=" << d <<
'\n';
46 mcout <<
"di=" << di <<
'\n';
47 mcout <<
"da=" << da <<
'\n';
48 mcout <<
"f.d=" << f.d <<
'\n';
49 mcout <<
"f.di=" << f.di <<
'\n';
50 mcout <<
"f.da=" << f.da <<
'\n';
53 if (std::isnan(di) == 1) di = -DBL_MAX;
54 if (std::isnan(da) == 1) da = DBL_MAX;
55 if (std::isnan(f.di) == 1) f.di = -DBL_MAX;
56 if (std::isnan(f.da) == 1) f.da = DBL_MAX;
58 if (_isnan(di) == 1) di = -DBL_MAX;
59 if (_isnan(da) == 1) da = DBL_MAX;
60 if (_isnan(f.di) == 1) f.di = -DBL_MAX;
61 if (_isnan(f.da) == 1) f.da = DBL_MAX;
63#ifdef POSSIBLE_FAILURE_ISNAN
64 if (!(di < d) && !(di >= d)) di = -DBL_MAX;
65 if (!(da < d) && !(da >= d)) da = DBL_MAX;
66 if (!(f.di < f.d) && !(f.di >= f.d)) f.di = -DBL_MAX;
67 if (!(f.da < f.d) && !(f.da >= f.d)) f.da = DBL_MAX;
69#ifdef DEBUG_OPERATOR_MULT
77#ifdef DEBUG_OPERATOR_MULT_PRINT
84#ifdef DEBUG_OPERATOR_MULT_PRINT
89 double ti = da * f.di;
92#ifdef DEBUG_OPERATOR_MULT_PRINT
101#ifdef DEBUG_OPERATOR_MULT_PRINT
104 }
else if (f.da >= 0) {
105 double ti = std::min(di * f.da, da * f.di);
106 da = std::max(di * f.di, da * f.da);
108#ifdef DEBUG_OPERATOR_MULT_PRINT
112 double ti = da * f.di;
115#ifdef DEBUG_OPERATOR_MULT_PRINT
124#ifdef DEBUG_OPERATOR_MULT_PRINT
127 }
else if (f.da >= 0) {
128 double ti = di * f.da;
131#ifdef DEBUG_OPERATOR_MULT_PRINT
135 double ti = da * f.da;
138#ifdef DEBUG_OPERATOR_MULT_PRINT
146#ifdef CHECK_CORRECTNESS_AT_MULT
151 mcerr <<
"d < di at the end of computations\n";
152 mcerr <<
"This number:\n";
154 mcerr <<
"Argument:\n";
156 if (d > di)
mcerr <<
"if(d > di) is also positive\n";
157 if (d == di)
mcerr <<
"if(d == di) is also positive\n";
159#ifdef DEBUG_OPERATOR_MULT
161 mcerr <<
"old value:\n";
170 mcerr <<
"d > di at the end of computations\n";
171 mcerr <<
"This number:\n";
173 mcerr <<
"Argument:\n";
175 if (d < da)
mcerr <<
"if(d < da) is also positive\n";
176 if (d == da)
mcerr <<
"if(d == da) is also positive\n";
178#ifdef DEBUG_OPERATOR_MULT
180 mcerr <<
"old value:\n";
191 mfunnamep(
"DoubleAc& DoubleAc::operator/=(const DoubleAc& f)");
195 if (std::isnan(di) == 1) di = -DBL_MAX;
196 if (std::isnan(da) == 1) da = DBL_MAX;
197 if (std::isnan(f.di) == 1) f.di = -DBL_MAX;
198 if (std::isnan(f.da) == 1) f.da = DBL_MAX;
200 if (_isnan(di) == 1) di = -DBL_MAX;
201 if (_isnan(da) == 1) da = DBL_MAX;
202 if (_isnan(f.di) == 1) f.di = -DBL_MAX;
203 if (_isnan(f.da) == 1) f.da = DBL_MAX;
205#ifdef POSSIBLE_FAILURE_ISNAN
206 if (!(di < d) && !(di >= d)) di = -DBL_MAX;
207 if (!(da < d) && !(da >= d)) da = DBL_MAX;
208 if (!(f.di < f.d) && !(f.di >= f.d)) f.di = -DBL_MAX;
209 if (!(f.da < f.d) && !(f.da >= f.d)) f.da = DBL_MAX;
213 if (f.di < 0 && f.da > 0) {
216 }
else if (di >= 0) {
220 }
else if (f.di == 0) {
228 double ti = da / f.da;
234 }
else if (da >= 0) {
238 }
else if (f.di == 0) {
246 double ti = da / f.da;
256 }
else if (f.di == 0) {
262 mcerr <<
"f.da == 0\n";
263 mcerr <<
"This means that f.d == 0 which should been already "
265 mcerr <<
"If the program reaches this point, this means that\n"
266 <<
"f.d is not between f.di and f.da, which is prohibited\n";
277 double ti = da / f.di;
283#ifdef CHECK_CORRECTNESS_AT_MULT
286 mcerr <<
"d < di at the end of computations\n";
287 mcerr <<
"This number:\n";
289 mcerr <<
"Argument:\n";
298 mcerr <<
"d > di at the end of computations\n";
299 mcerr <<
"This number:\n";
301 mcerr <<
"Argument:\n";
316 mcerr <<
"error in DoubleAc sqrt(const DoubleAc& f): f.get() < 0, f.get()="
338 if (p == 1)
return f;
341 double d = std::pow(f.
get(), p);
350 return DoubleAc(d, 0.0, std::max(di, da));
358 double d = std::pow(f.
get(), -p);
367 return 1.0 /
DoubleAc(d, 0.0, std::max(di, da));
378 double d = std::exp(f.
get());
386 double d = std::sin(f.
get());
402 da = std::max(di, da);
408 di = std::min(di, da);
417 di = std::min(di, da);
423 da = std::max(di, da);
433 double d = std::cos(f.
get());
443 da = std::max(di, da);
449 di = std::min(di, da);
458 di = std::min(di, da);
464 da = std::max(di, da);
472 mcerr <<
"ERROR in inline DoubleAc asin(const DoubleAc& f):\n"
473 <<
"fabs(f.get()) > 1: f.get()=" << f.
get() <<
'\n';
476 double d = std::asin(f.
get());
479 di = std::asin(-1.0);
492 mcerr <<
"ERROR in inline DoubleAc acos(const DoubleAc& f):\n"
493 <<
"fabs(f.get()) > 1: f.get()=" << f.
get() <<
'\n';
496 double d = std::acos(f.
get());
499 da = std::acos(-1.0);
515 file << d <<
" [ " << di <<
" , " << da <<
" ] ";
518 int t = file.precision(2);
519 file <<
" [" << std::setw(8) << d - di <<
"," << std::setw(8) << da - d
523 file << d <<
" [ " << di <<
" , " << da <<
" ] \n";
526 int t = file.precision(2);
527 file <<
" [" << std::setw(8) << d - di <<
"," << std::setw(8) << da - d
531 int t = file.precision(16);
532 file <<
"DoubleAc: d=" << std::setw(20) << d <<
" di=" << std::setw(20)
533 << di <<
" da=" << std::setw(20) << da <<
'\n';
539 mcerr <<
"ERROR in inline DoubleAc pow(const DoubleAc& f, const DoubleAc& "
541 mcerr <<
"not implemented yet\n";
#define check_econd11(a, signb, stream)
#define check_econd12a(a, sign, b, add, stream)
#define mfunnamep(string)
double get_right_limit(void) const
DoubleAc & operator/=(DoubleAc f)
void print(std::ostream &file, int l=1) const
double get_left_limit(void) const
double left_limit(void) const
double right_limit(void) const
DoubleAc & operator*=(DoubleAc f)
DoubleAc cos(const DoubleAc &f)
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
DoubleAc pow(const DoubleAc &f, double p)
long left_round(double f)
DoubleAc exp(const DoubleAc &f)
DoubleAc square(const DoubleAc &f)
DoubleAc acos(const DoubleAc &f)
DoubleAc fabs(const DoubleAc &f)
DoubleAc sin(const DoubleAc &f)
DoubleAc asin(const DoubleAc &f)
DoubleAc sqrt(const DoubleAc &f)
#define Iprintn(file, name)