mpz_gcd_ext(NULL, ...)

Marc Glisse marc.glisse at
Fri Nov 25 13:11:31 UTC 2016

On Fri, 25 Nov 2016, Niels Möller wrote:

> Marc Glisse <marc.glisse at> writes:
>> a user was asking if we could support calling mpz_gcd_ext with a NULL
>> first argument (the gcd), since they are only interested in the
>> coefficients s and t and would like to save the unnecessary
>> allocation. I doubt it would save that much, but it seems trivial to
>> add a check if(g!=NULL) similar to the tests for s and t. Does it make
>> sense to you?
> Sounds reasonable to me.


> But then I'd also consider adding a return value, returning one if the 
> inputs were coprime (gcd == 1), otherwise zero. Would be useful for 
> mpz_invert.

Makes sense. If you want to do it...

> It won't save much for the computation, only the final copy. But it's
> also a gain to clarity if callers don't have to pass in dummy, unused,
> result arguments.


Marc Glisse

More information about the gmp-devel mailing list