Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] use of Interval_nt in Sqrt_extension

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] use of Interval_nt in Sqrt_extension


Chronological Thread 
  • From: Marc Mörig <>
  • To:
  • Subject: Re: [cgal-discuss] use of Interval_nt in Sqrt_extension
  • Date: Thu, 26 Jul 2012 09:35:58 +0200

On 07/26/2012 09:24 AM, Sebastien Loriot (GeometryFactory) wrote:
On 07/26/2012 09:09 AM, Marc Mörig wrote:
Dear CGAL maintainers,

in the file Sqrt_extension_type.h, there is the following code:

std::pair<double, double> compute_to_interval() const
{
if (! is_extended_)
return CGAL_NTS to_interval(a0_);
CGAL::Interval_nt<false>::Protector p;
const CGAL::Interval_nt<false>& a0_int = CGAL_NTS to_interval(a0_);
const CGAL::Interval_nt<false>& a1_int = CGAL_NTS to_interval(a1_);
const CGAL::Interval_nt<false>& root_int = CGAL_NTS to_interval(root_);
const CGAL::Interval_nt<false>& x_int =
a0_int + (a1_int * CGAL::sqrt(root_int));

std::pair<double, double> res(x_int.inf(), x_int.sup());
this->update_cached_value(res);
return res;
}


The Protector p sets a directed rounding mode for floating point
arithmetic, which is propagated to other code inside, e.g.
to_interval(a0_). In my case, this breaks code which assumes the default
rounding mode.

Are you sure the problems is coming from that part? The previous
rounding mode mode is restored when the protector is deleted.

Sebastien.


I am pretty sure. a0_ is of a custom number type I wrote myself. Hence the directed rounding mode is in effect when my code is called. The problem goes away if I move the Protector creation three lines downwards. This is ok, since no floating-point operations are performed in the interval assignment anyways.

Marc

--
Marc Mörig Email:

Institut für Simulation und Graphik Phone: +49 391 67-52858
Otto-von-Guericke Universität Magdeburg Office: G29-227



Archive powered by MHonArc 2.6.18.

Top of Page