From 4e75aa3f61d63295321c46d96980862f27d00abf Mon Sep 17 00:00:00 2001 From: Sylvain Pion Date: Fri, 1 Sep 2000 16:43:23 +0000 Subject: [PATCH] - Added a #if 0'd out preliminary version of to_interval(). --- .../include/CGAL/Interval_arithmetic/IA_Fixed.h | 9 +++++++++ .../include/CGAL/Interval_arithmetic/IA_Gmpz.h | 14 +++++++++++++- .../CGAL/Interval_arithmetic/IA_Lazy_exact_nt.h | 10 ++++++++++ .../include/CGAL/Interval_arithmetic/IA_Quotient.h | 11 ++++++++++- .../CGAL/Interval_arithmetic/IA_leda_bigfloat.h | 12 ++++++++++++ .../CGAL/Interval_arithmetic/IA_leda_integer.h | 12 ++++++++++++ .../CGAL/Interval_arithmetic/IA_leda_rational.h | 14 ++++++++++++++ .../CGAL/Interval_arithmetic/IA_leda_real.h | 13 +++++++++++++ 8 files changed, 93 insertions(+), 2 deletions(-) diff --git a/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_Fixed.h b/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_Fixed.h index 36fae15872f..a892eab0879 100644 --- a/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_Fixed.h +++ b/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_Fixed.h @@ -27,6 +27,15 @@ CGAL_BEGIN_NAMESPACE // Fixed is in fact a float => trivial conversion. +#if 0 +inline +Interval_base +to_interval (const Fixed_precision_nt & z) +{ + return CGAL::to_double(z); +} +#endif + inline Interval_nt_advanced convert_from_to (const Interval_nt_advanced&, const Fixed_precision_nt & z) diff --git a/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_Gmpz.h b/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_Gmpz.h index aeffed7df72..61713c5f6c4 100644 --- a/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_Gmpz.h +++ b/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_Gmpz.h @@ -31,9 +31,21 @@ CGAL_BEGIN_NAMESPACE // We choose the lazy approach, which is good enough: we take the double // approximation, which is guaranted 1 bit error max (when rounding to // nearest), and return an interval around this value. -// It should be much faster to have a low level function especially designed +// It could be better to have a low level function especially designed // for that using rounding to infinity. +#if 0 +inline // better in libCGAL... +Interval_base +to_interval(const Gmpz & z) +{ + Protect_FPU_rounding<> P(CGAL_FE_TONEAREST); + Interval_nt_advanced approx (CGAL::to_double(z)); + FPU_set_cw(CGAL_FE_UPWARD); + return approx + Interval_base::Smallest; +} +#endif + inline Interval_nt_advanced convert_from_to (const Interval_nt_advanced&, const Gmpz & z) diff --git a/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_Lazy_exact_nt.h b/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_Lazy_exact_nt.h index 66cb9bcc2ce..c5bf5fa3d7e 100644 --- a/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_Lazy_exact_nt.h +++ b/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_Lazy_exact_nt.h @@ -25,6 +25,16 @@ CGAL_BEGIN_NAMESPACE +#if 0 +template +inline +Interval_base +to_interval (const Lazy_exact_nt & z) +{ + return z.approx(); +} +#endif + template inline Interval_nt_advanced diff --git a/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_Quotient.h b/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_Quotient.h index 55d9aa1866a..6f7dc2b67a6 100644 --- a/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_Quotient.h +++ b/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_Quotient.h @@ -28,8 +28,17 @@ CGAL_BEGIN_NAMESPACE // We don't know anything about the internal RT type, so there is a risk of // overflow, but we can't do better than the following trivial conversion. +#if 0 +template +Interval_base +to_interval (const Quotient & z) +{ + return Interval_nt<>(CGAL::to_interval(z.numerator())) / + Interval_nt<>(CGAL::to_interval(z.denominator())); +} +#endif + template -inline Interval_nt_advanced convert_from_to (const Interval_nt_advanced&, const Quotient & z) { diff --git a/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_leda_bigfloat.h b/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_leda_bigfloat.h index 3d4e5314bfc..a1866a31de9 100644 --- a/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_leda_bigfloat.h +++ b/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_leda_bigfloat.h @@ -29,6 +29,18 @@ CGAL_BEGIN_NAMESPACE // approximation, which is guaranted 1 bit error max(?), and return an // interval around this value (+/- ulp). +#if 0 +inline // hum... +Interval_base +to_interval (const leda_bigfloat & z) +{ + Protect_FPU_rounding<> P (CGAL_FE_TONEAREST); + Interval_nt_advanced approx (::to_double(z)); + FPU_set_cw(CGAL_FE_UPWARD); + return approx + Interval_base::Smallest; +} +#endif + inline Interval_nt_advanced convert_from_to (const Interval_nt_advanced&, const leda_bigfloat & z) diff --git a/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_leda_integer.h b/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_leda_integer.h index 660674d14cd..e3e1573ebc5 100644 --- a/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_leda_integer.h +++ b/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_leda_integer.h @@ -31,6 +31,18 @@ CGAL_BEGIN_NAMESPACE // LEDA integer's internal representation, which is not possible without // modifying LEDA. +#if 0 +inline // ? +Interval_base +to_interval (const leda_integer & z) +{ + Protect_FPU_rounding<> P (CGAL_FE_TONEAREST); + Interval_nt_advanced approx (z.to_double()); + FPU_set_cw(CGAL_FE_UPWARD); + return approx + Interval_base::Smallest; +} +#endif + inline Interval_nt_advanced convert_from_to (const Interval_nt_advanced&, const leda_integer & z) diff --git a/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_leda_rational.h b/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_leda_rational.h index 2f4a2812c1d..e97fb218172 100644 --- a/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_leda_rational.h +++ b/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_leda_rational.h @@ -29,6 +29,20 @@ CGAL_BEGIN_NAMESPACE // conversion. Since LEDA types (except real) don't give information on the // precision of to_double(), we can't do much... +#if 0 +inline // well, at that point... big fat function. +Interval_base +to_interval (const leda_rational & z) +{ + Protect_FPU_rounding<> P (CGAL_FE_TONEAREST); + Interval_nt_advanced approx (z.to_double()); + FPU_set_cw(CGAL_FE_UPWARD); + + return ( (approx + Interval_base::Smallest) + Interval_base::Smallest) + + Interval_base::Smallest; +} +#endif + inline Interval_nt_advanced convert_from_to (const Interval_nt_advanced&, const leda_rational & z) diff --git a/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_leda_real.h b/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_leda_real.h index 37c7241d0d9..118a2b53eff 100644 --- a/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_leda_real.h +++ b/Packages/Interval_arithmetic/include/CGAL/Interval_arithmetic/IA_leda_real.h @@ -25,6 +25,19 @@ CGAL_BEGIN_NAMESPACE +#if 0 +inline // hum... +Interval_base +to_interval (const leda_real & z) +{ + Protect_FPU_rounding<> P (CGAL_FE_TONEAREST); + double approx = z.to_double(); + double rel_error = z.get_double_error(); + FPU_set_cw(CGAL_FE_UPWARD); + return ( Interval_nt_advanced(-rel_error,rel_error) + 1 ) * approx; +} +#endif + inline Interval_nt_advanced convert_from_to (const Interval_nt_advanced&, const leda_real & z)