documentation on internals not up to date

Marc Glisse marc.glisse at inria.fr
Fri Apr 27 12:46:35 UTC 2018


On Fri, 27 Apr 2018, Niels Möller wrote:

> Marc Glisse <marc.glisse at inria.fr> writes:
>
>> There would be a significant advantage to mpq if we could have a
>> non-allocated 1 for the denominator. But indeed, with the current code
>> where only some mpz functions would work, it seems safer to document
>> that none work.
>
> We could do that internally, even if we don't advertise it for other gmp
> users.

We document that users can use the denominator of a mpq_t as a regular 
mpz_t and apply pretty much any mpz_t operation to it. So it seems hard to 
handle just that case internally.

> Then mpq_init wouldn't do any allocation, right?

Right.

> We could have a single mpq object representing 0/1 with _mp_alloc == 0 
> for both parts, and initialize with struct assignment or memcpy.
>
> We would just ensure that mpz realloc keeps supporting thuis case.

-- 
Marc Glisse


More information about the gmp-devel mailing list