_mp_alloc vs ALLOC

Torbjorn Granlund tg at gmplib.org
Mon Jun 4 20:38:20 CEST 2012

nisse at lysator.liu.se (Niels Möller) writes:

  The old_size argument should be removed also from the free function, not
  just realloc.

  Add return value to mpz_sqrt, for consistency with mpz_root (assuming
  such a flag can be returned very cheaply, which I think it can).

  And in the category of changes which I'm afraid we don't all agree on:
  Let the mpn_mul* functions return the high limb, but not store it.
  Motivation: Avoid having to allocate space for it in the case that the
  top limb is known zero (happens, e.g., in the toom code). My gut feeling
  is that it can also simplify allocation for some divide-and-conquer
  algorithms, but I don't have any clear example handy. Maybe one could
  also argue for consistency with mpn_addmul_1 and similar functions,
  e.g., for the C mpn_mul_basecase, it would be nice if the final call to
  mpn_addmul_1 (or _2 or _N) could be compiled as a tail call.
Last time you suggested this, I think I asked you to explain how to do
with the multitude of multiply functions, which might need to store the
full n-limb value in a new large temp area, then copy its low n-1 limbs
to the target area.


More information about the gmp-devel mailing list