mirror of https://github.com/CGAL/cgal
- Added [expensive] post conditions to check the interval is really containing
the initial value. It might be removed one day because it's slow.
This commit is contained in:
parent
73a110c6ad
commit
6bc091291e
|
|
@ -38,8 +38,16 @@ inline CGAL_Interval_nt_advanced CGAL_convert_to (const CGAL_Gmpz &z)
|
|||
CGAL_FPU_set_rounding_to_nearest();
|
||||
double approx = CGAL_to_double(z);
|
||||
CGAL_FPU_set_rounding_to_infinity();
|
||||
return CGAL_Interval_nt_advanced (approx) +
|
||||
CGAL_Interval_nt_advanced::smallest;
|
||||
const CGAL_Interval_nt_advanced result =
|
||||
CGAL_Interval_nt_advanced (approx) +
|
||||
CGAL_Interval_nt_advanced::smallest;
|
||||
#ifndef CGAL_NO_POSTCONDITIONS
|
||||
CGAL_FPU_set_rounding_to_nearest();
|
||||
CGAL_assertion( CGAL_Gmpz(result.lower_bound()) <= z &&
|
||||
CGAL_Gmpz(result.upper_bound()) >= z);
|
||||
CGAL_FPU_set_rounding_to_infinity();
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // CGAL_IA_GMPZ_H
|
||||
|
|
|
|||
|
|
@ -36,8 +36,16 @@ inline CGAL_Interval_nt_advanced CGAL_convert_to (const leda_bigfloat &z)
|
|||
CGAL_FPU_set_rounding_to_nearest();
|
||||
double approx = CGAL_to_double(z);
|
||||
CGAL_FPU_set_rounding_to_infinity();
|
||||
return CGAL_Interval_nt_advanced (approx) +
|
||||
CGAL_Interval_nt_advanced::smallest;
|
||||
const CGAL_Interval_nt_advanced result =
|
||||
CGAL_Interval_nt_advanced (approx) +
|
||||
CGAL_Interval_nt_advanced::smallest;
|
||||
#ifndef CGAL_NO_POSTCONDITIONS
|
||||
CGAL_FPU_set_rounding_to_nearest();
|
||||
CGAL_assertion( leda_bigfloat(result.lower_bound()) <= z &&
|
||||
leda_bigfloat(result.upper_bound()) >= z);
|
||||
CGAL_FPU_set_rounding_to_infinity();
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // CGAL_IA_LEDA_BIGFLOAT_H
|
||||
|
|
|
|||
|
|
@ -38,8 +38,16 @@ inline CGAL_Interval_nt_advanced CGAL_convert_to (const leda_integer &z)
|
|||
CGAL_FPU_set_rounding_to_nearest();
|
||||
double approx = CGAL_to_double(z);
|
||||
CGAL_FPU_set_rounding_to_infinity();
|
||||
return CGAL_Interval_nt_advanced (approx) +
|
||||
CGAL_Interval_nt_advanced::smallest;
|
||||
const CGAL_Interval_nt_advanced result =
|
||||
CGAL_Interval_nt_advanced (approx) +
|
||||
CGAL_Interval_nt_advanced::smallest;
|
||||
#ifndef CGAL_NO_POSTCONDITIONS
|
||||
CGAL_FPU_set_rounding_to_nearest();
|
||||
CGAL_assertion( leda_integer(result.lower_bound()) <= z &&
|
||||
leda_integer(result.upper_bound()) >= z);
|
||||
CGAL_FPU_set_rounding_to_infinity();
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // CGAL_IA_LEDA_INTEGER_H
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef CGAL_IA_LEDA_RATIONAL_H
|
||||
#define CGAL_IA_LEDA_RATIONAL_H
|
||||
|
||||
// For this one, I hope that adding 2 ulps will be enough for an exact
|
||||
// For this one, I hope that adding 3 ulps will be enough for an exact
|
||||
// conversion. Since LEDA types (except real) don't give information on the
|
||||
// precision of to_double(), we can't do much...
|
||||
|
||||
|
|
@ -37,12 +37,21 @@ inline CGAL_Interval_nt_advanced CGAL_convert_to (const leda_rational &z)
|
|||
double approx = CGAL_to_double(z);
|
||||
CGAL_FPU_set_rounding_to_infinity();
|
||||
|
||||
return (CGAL_Interval_nt_advanced (approx)
|
||||
const CGAL_Interval_nt_advanced result =
|
||||
((CGAL_Interval_nt_advanced (approx)
|
||||
+ CGAL_Interval_nt_advanced::smallest)
|
||||
+ CGAL_Interval_nt_advanced::smallest)
|
||||
+ CGAL_Interval_nt_advanced::smallest;
|
||||
// The following is bad because overflow is highly probable with rationals.
|
||||
// return CGAL_convert_to<CGAL_Interval_nt_advanced>(z.numerator())
|
||||
// / CGAL_convert_to<CGAL_Interval_nt_advanced>(z.denominator());
|
||||
#ifndef CGAL_NO_POSTCONDITIONS
|
||||
CGAL_FPU_set_rounding_to_nearest();
|
||||
CGAL_assertion( leda_rational(result.lower_bound()) <= z &&
|
||||
leda_rational(result.upper_bound()) >= z );
|
||||
CGAL_FPU_set_rounding_to_infinity();
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // CGAL_IA_LEDA_RATIONAL_H
|
||||
|
|
|
|||
|
|
@ -33,8 +33,16 @@ inline CGAL_Interval_nt_advanced CGAL_convert_to (const leda_real &z)
|
|||
const double approx = CGAL_to_double(z);
|
||||
const double rel_error = z.get_double_error();
|
||||
CGAL_FPU_set_rounding_to_infinity();
|
||||
return ( CGAL_Interval_nt_advanced(-rel_error,rel_error) + 1 )
|
||||
* CGAL_Interval_nt_advanced(approx);
|
||||
const CGAL_Interval_nt_advanced result =
|
||||
( CGAL_Interval_nt_advanced(-rel_error,rel_error) + 1 )
|
||||
* CGAL_Interval_nt_advanced(approx);
|
||||
#ifndef CGAL_NO_POSTCONDITIONS
|
||||
CGAL_FPU_set_rounding_to_nearest();
|
||||
CGAL_assertion( leda_real(result.lower_bound()) <= z &&
|
||||
leda_real(result.upper_bound()) >= z );
|
||||
CGAL_FPU_set_rounding_to_infinity();
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // CGAL_IA_LEDA_REAL_H
|
||||
|
|
|
|||
Loading…
Reference in New Issue