Lazy mpz allocation
marc.glisse at inria.fr
Wed May 4 12:16:36 UTC 2016
On Wed, 4 May 2016, Niels Möller wrote:
> tg at gmplib.org (Torbjörn Granlund) writes:
>> I forgot about that we need to have an explicit denominator.
>> We could surely point that to some static read-only data, but that would
>> of course incur a cost when "re-allocating".
> I'm not familiar with mpq internals, but I guess it might be possible to
> get away with leaving the denominator as zero on initialization.
> Then one would need to follow the convention that if numerator is zero,
> then the denominator is ignored. Or (but I guess that's more cumbersome)
> adapt the convention that zero denominator means "this is an integer",
> and treated as one.
The fact that an mpq is made of 2 mpz that can be accessed directly is
part of the interface. I think following your suggestion would mean
More information about the gmp-devel