Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Scaling of gcd of polynomials to be standard #3227

Merged
merged 1 commit into from
Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions hpcgap/lib/polyrat.gi
Original file line number Diff line number Diff line change
Expand Up @@ -775,13 +775,17 @@ local brci,gcd,fam,fc,gc;
if gcd=fail then
# fall back to the original version:
gcd:=RPIGcd(f,g);
if Length(gcd)>0 and not IsOne(gcd[1]) then gcd:=gcd/gcd[1];fi;
if Length(gcd)>0 and not IsOne(gcd[Length(gcd)]) then
gcd:=gcd/gcd[Length(gcd)];
fi;
return gcd;

fi;
fc:=Minimum(fc[2],gc[2]);
fc:=fc+RemoveOuterCoeffs(gcd,fam!.zeroCoefficient);
if Length(gcd)>0 and not IsOne(gcd[1]) then gcd:=gcd/gcd[1];fi;
if Length(gcd)>0 and not IsOne(gcd[Length(gcd)]) then
gcd:=gcd/gcd[Length(gcd)];
fi;
return LaurentPolynomialByExtRepNC(fam,gcd,fc,brci);
end);

Expand Down Expand Up @@ -1859,7 +1863,7 @@ local fc,ind, v, g, q, s, r, x,shift;
Append(s,List([1..v],f->x));
Sort(s);

if not IsBound(opt.stopdegs) and Sum(s,DegreeOfLaurentPolynomial)<>DegreeOfLaurentPolynomial(f)+v then
if not (IsBound(opt.stopdegs) or IsBound(opt.onlydegs)) and Sum(s,DegreeOfLaurentPolynomial)<>DegreeOfLaurentPolynomial(f)+v then
Error("degree discrepancy!");
fi;

Expand Down
8 changes: 6 additions & 2 deletions lib/polyrat.gi
Original file line number Diff line number Diff line change
Expand Up @@ -764,13 +764,17 @@ local brci,gcd,fam,fc,gc;
if gcd=fail then
# fall back to the original version:
gcd:=RPIGcd(f,g);
if Length(gcd)>0 and not IsOne(gcd[1]) then gcd:=gcd/gcd[1];fi;
if Length(gcd)>0 and not IsOne(gcd[Length(gcd)]) then
gcd:=gcd/gcd[Length(gcd)];
fi;
return gcd;

fi;
fc:=Minimum(fc[2],gc[2]);
fc:=fc+RemoveOuterCoeffs(gcd,fam!.zeroCoefficient);
if Length(gcd)>0 and not IsOne(gcd[1]) then gcd:=gcd/gcd[1];fi;
if Length(gcd)>0 and not IsOne(gcd[Length(gcd)]) then
gcd:=gcd/gcd[Length(gcd)];
fi;
return LaurentPolynomialByExtRepNC(fam,gcd,fc,brci);
end);

Expand Down
4 changes: 4 additions & 0 deletions tst/testinstall/ratfun.tst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ gap> (t^24-1)/(t^16-1);
gap> (t^24-1)/(t^-16-1);
(t^32+t^24+t^16)/(-t^8-1)

#
gap> Gcd(t-2,t^2-2*t);
t-2

#
# multivariate
#
Expand Down