Typo in the manual, and clarification for mpn_gcd

Niels Möller nisse at lysator.liu.se
Sun Jan 1 22:18:26 UTC 2017


Max Horn <max at quendi.de> writes:

> mpn/generic/gcd.c:1:/* mpn/gcd.c: mpn_gcd for gcd of two odd integers.
> mpn/generic/gcd.c:283:  /* Due to the calling convention for mpn_gcd, at most one can be
>
> However, the documentation for mpn_gcd does not actually state this
> requirement, see
> <https://gmplib.org/manual/Low_002dlevel-Functions.html#index-mpn_005fgcd>.
>
> It would be very nice if this could be clarified in the documentation.

I agree this is appear a bit confused. The gcd implementation on GMP
used to be a variant of bianry gcd, requiring odd inputs. In the current
implementation, most of the code doesn't depend on operands being odd,
but gcd_2 (and the logic where it is called) seems to still do.

Not sure if we should update the code or the documentation.

> (2) I tried using mpn_gcd in some code (sadly, in that code I can only
> use the mpn_ functions, as memory allocations are a no-go)

Note that many mpn_ functions, including mpn_gcd, do allocate memory.
But for small operands, they usually allocate needed storage on the
stack.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.


More information about the gmp-bugs mailing list