marc.glisse at inria.fr
Sat Jun 5 19:29:43 CEST 2010
On Sat, 5 Jun 2010, Torbjorn Granlund wrote:
> Marc Glisse <marc.glisse at inria.fr> writes:
> There are many places where the required size could be computed more
> It is not clear how to make it more tightly in the case of
> mpz_cdiv_q_2exp, though, without adding more logic.
That's exactly what I said. You can compute a better bound, but computing
that bound is more complicated (for this function, the mpn_add_1 can only
require an extra limb if the shift is by a multiple of the limb size, and
this test should be enough to never allocate more than 1 extra limb).
> What other places do you have in mind?
Last time I posted something related, your answer was:
"*If* it is a good idea, the same trick applies to dozens of other places
(no, I don't have anything particular in mind)
By the way, the GMP manual already documents the memory requirements of
several mpz functions in mpz_array_init. I am not sure it would hurt that
much to document very conservative bounds (as opposed to tight bounds on
the current behavior), although that's yet more work...
More information about the gmp-devel