mini-gmp and mpq
Torbjörn Granlund
tg at gmplib.org
Wed May 2 13:05:28 UTC 2018
Bradley Lucier <lucier at math.purdue.edu> writes:
On 04/30/2018 04:06 AM, Marco Bodrato wrote:
> Ciao,
>
> Il Lun, 30 Aprile 2018 4:10 am, Bradley Lucier ha scritto:
>>> On Apr 29, 2018, at 9:02 PM, Marco Bodrato <bodrato at mail.dm.unipi.it>
>>>> Il Dom, 29 Aprile 2018 8:24 pm, Bradley Lucier ha scritto:
>
>> Looks good. The important case is when a=b, but I just realized that the
>> test can be refined to when the denominator of a is the denominator of b.
>
> Interesting observation. But, do you think it's worth replacing
> if (a != b)
> with
> if (mpz_cmp (mpq_denref (a), mpq_denref (b)))
> ?
No.
I am not so sure. I have no idea how often the denominators will be
equal out there, but I'd expect that mpz_cmp would terminate in time
O(1) on average when they are not.
--
Torbjörn
Please encrypt, key id 0xC8601622
More information about the gmp-devel
mailing list