[Aldor-l] gcd
Ralf Hemmecke
ralf at hemmecke.de
Wed Jan 30 07:27:53 EST 2008
Dear Marc,
I guess, you or one of your students should know more about this code from
svn cat
https://aquarium.aldor.csd.uwo.ca/svn/trunk/aldor/lib/algebra/src/multpoly/multpolycat/alg_defgcd.as
See end of mail. Could you say a few words about the intend of this
content function with 2 parameters? Why wouldn't "content(b)" instead of
"content(b,vc)" be enough?
Anyway this content function is computing
gcd(cpv,content(cu,vcu))$%;
at the end of the for loop and *never* using that computation. Besides
from leading to segfaults that code also wastes computation time.
Maybe you know a quick fix of that buggy piece of code.
Thank you
Ralf
content(p: P, v: V): P == {
local u := univ(p,v);
-- content(u)$D;
local cpv: P := 0;
for cu in coefficients(u) repeat {
ground? cu => cpv := gcd(cpv,cu)$%;
vcu := mainVariable(cu);
vcu < v => cpv := gcd(cpv,cu)$%;
gcd(cpv,content(cu,vcu))$%;
}
return cpv;
}
gcd(a: P, b: P): P == {
a = 0 => b;
b = 0 => a;
ground? a or ground? b => {
gm:P:=gcd(content(a)$P, content(b)$P)::P;
unitCanonical gm;}
(a:=unitCanonical(a)) =(b:=unitCanonical(b)) => a;
va :V:= mainVariable(a);
vb :V:= mainVariable(b);
va < vb => {
-- MB 11/2004: THIS CODE IS BUGGY, WILL BOMB IF b is UNIVARIATE
-- SINCE THERE IS NO "NEXT VARIABLE"
vc := nextVariable(b,va);
gm :P:= gcd(a,content(b,vc))$%;
unitCanonical gm;}
va > vb => {
-- MB 11/2004: THIS CODE IS BUGGY, WILL BOMB IF a is UNIVARIATE
-- SINCE THERE IS NO "NEXT VARIABLE"
vc := nextVariable(a,vb);
gm :P:= gcd(b,content(a,vc))$%;
unitCanonical gm; }
assert(va = vb);
g :D:= gcd(univ(a,va),univ(b,vb))$D;
tmp:=multivariate(D)(g,va);
unitCanonical tmp;}
More information about the Aldor-l
mailing list