[GiNaC-list] code: extended gcd

Ralf Stephan ralf at ark.in-berlin.de
Mon Oct 4 19:41:03 CEST 2004


> Is the root of the problem the missing documentation of cofactors in the
> tutorial or am I missing something fundamental?!

Actually, yes, both, sorry. This code:

  ex e1, e2;
  symbol x("x");
	cout << gcd(x-1, x*x*x, &e1, &e2, true) << "," << e1 << "," << e2 << endl;

gives 1,-1+x,x^3

where my function and Pari's bezout() gives

1,-1-x-x^2,1    (or a different order but you get the idea)

since -(x-1)(1+x+x^2) + x^3 = 1.


Best regards,
ralf




More information about the GiNaC-list mailing list