Ciao Niels,
17 feb 2024, 21:26 da ni...@lysator.liu.se:
> marco.bodr...@tutanota.com writes:
>
>> Maybe we should also add the test:
>>
>> /* Require that s==0 iff g==abs(b) */
>> if (!mpz_sgn (s) ^ !mpz_cmpabs (g, b))
>> goto fail;
>>
>
> Good point, that's better than only checking th
marco.bodr...@tutanota.com writes:
> Maybe we should also add the test:
>
> /* Require that s==0 iff g==abs(b) */
> if (!mpz_sgn (s) ^ !mpz_cmpabs (g, b))
> goto fail;
Good point, that's better than only checking the special case |a| ==
|b|. (But maybe more readable with != instead of ^
Ciao,
17 feb 2024, 19:15 da :
> Ciao Niels,
>
> 17 feb 2024, 17:53 da ni...@lysator.liu.se:
>
>> Niels Möller writes:
>> The documented conditions say that gmp should return the same cofactors
>>
>
> The documentation also says "If abs(a) = abs(b), then s = 0, t = sgn(b)."
>
Maybe we should also
marco.bodr...@tutanota.com writes:
> And if I correctly patched and tested your proposed code. with equal numbers
> I get t=0, instead of s=0.
Thanks for testing, I have to look into that case, then.
> Shat about simply changing the test from > to >= ?
>
> /* Arrange so that |s| < |u| / 2g *
Ciao Niels,
17 feb 2024, 17:53 da ni...@lysator.liu.se:
> Niels Möller writes:
> The documented conditions say that gmp should return the same cofactors
>
The documentation also says "If abs(a) = abs(b), then s = 0, t = sgn(b)."
>
> canonicalization logic at the end wasn't right. Appending a
Niels Möller writes:
> Guido Vranken writes:
>
>> Computing extended gcd using mpz_gcdext where a = 1, b = 2:
>>
>> libgmp: g: 1, s: 1, t: 0
>> mini-gmp: g: 1, s: -1, t: 1
>> This violates the docs: "s = sgn(a) if abs(b) = 2", e.g. s must be 1
>>
>> Computing extended gcd using mpz_gcdext where
Guido Vranken writes:
> Computing extended gcd using mpz_gcdext where a = 1, b = 2:
>
> libgmp: g: 1, s: 1, t: 0
> mini-gmp: g: 1, s: -1, t: 1
> This violates the docs: "s = sgn(a) if abs(b) = 2", e.g. s must be 1
>
> Computing extended gcd using mpz_gcdext where a = 6, b = 4:
> libgmp: g: 2, s:
Computing extended gcd using mpz_gcdext where a = 1, b = 2:
libgmp: g: 1, s: 1, t: 0
mini-gmp: g: 1, s: -1, t: 1
This violates the docs: "s = sgn(a) if abs(b) = 2", e.g. s must be 1
Computing extended gcd using mpz_gcdext where a = 6, b = 4:
libgmp: g: 2, s: 1, t: -1
mini-libgmp: g: 2, s: -1, t: