mini-gmp and mpq

Marc Glisse marc.glisse at inria.fr
Mon Feb 19 15:24:41 UTC 2018


On Mon, 19 Feb 2018, Marco Bodrato wrote:

> Il Mer, 14 Febbraio 2018 8:07 pm, Andreas Fabri ha scritto:
>> In the CGAL project ( != Daniele Panozzos project) we combine
>> double interval arithmetic with mpq when interval arithmetic
>> fails (say a comparison of two overlapping intervals)
>> in order to be fast and correct, and we would need:
>
> Are you speaking about GMP or mini-gmp?

Both. CGAL currently uses GMP, but if mini-gmp had what CGAL needs, this 
would be a tempting alternative, especially for windows.

> mini-gmp does not support mpq yet.
>
>> 1) the construction of a mpq from a double
>
> In GMP we already have mpq_set_d, doesn't it fit your needs?

It does, I read it as a wishlist for the new mini-mpq. Your earlier 
message seemed to imply that mini-mpq would not have mpq_set_d.

>> 2) the conversion of a mpq to its closest double
>
> mpq_get_d currently gives a double, but rounded towards zero...

Except when it uses the broken generic code :-(

>> 3) the conversion of a mpq to a tight double interval.
>
> ... that with the °next° double gives, more or less, what you want, don't it?

Except that being tight has a non-negligible impact on performance. Since 
many of those rationals were originally converted from double, we can 
often get singleton intervals, which have a fast path. Currently, we use 
mpfr to convert rationals to a double interval (and essentially nothing 
else...).

-- 
Marc Glisse


More information about the gmp-discuss mailing list