- 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:
Sylvain Pion 1998-12-17 17:46:11 +00:00
parent 73a110c6ad
commit 6bc091291e
5 changed files with 51 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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