[GiNaC-list] code: extended gcd

Ralf Stephan ralf at ark.in-berlin.de
Mon Nov 8 12:41:04 CET 2004


Hello,
In case you did not understand my last message on this, here again:

You wrote 
> On Sun, 3 Oct 2004, Ralf Stephan wrote:
> > ex xgcd (const ex& a, const ex& b, ex& u, ex& v, const symbol& s)
> 
> What's the point in having this twice?  In normal.cpp:1275 we have:
> 
> /** Compute GCD (Greatest Common Divisor) of multivariate polynomials a(X)
>  *  and b(X) in Z[X].
>  *  @param ca pointer to expression that will receive the cofactor of a, or NULL
>  *  @param cb pointer to expression that will receive the cofactor of b, or NULL

To declare something as cofactor does not mean it is. What the function
returns does NOT satisfy the usual cofactor equation

         gcd(a,b) = ca*a + cb*b.

Vide my earlier example, or a = (x-1)(x+1), b = (x-1)^3 which should
give ca = (3-x)/4 and cb = 1/4. But it gives ca = (1-x)^2, cb = 1+x.

Of course, if your gcd() WOULD return the cofactors, normal() would be
broken, as it depends on the odd behaviour which I have no explanation
for.

It would be likewise helpful for me if you just tell your intention
to look into this or not, so I can either go on or try to fix your code.
Certainly, you are more familiar with the code.


Best,
ralf




More information about the GiNaC-list mailing list