Skip to content

Commit

Permalink
Avoid calling ImmutableVector(0, v)
Browse files Browse the repository at this point in the history
The code for algebraic extensions passed fam!.rchar to ImmutableVector;
but that value was 0 if the characteristic exceeded 256.
  • Loading branch information
fingolfin committed Sep 3, 2020
1 parent 32ea105 commit beb0d58
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions hpcgap/lib/vecmat.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,7 @@ end);
InstallMethod( ImmutableVector,"general,2",[IsObject,IsRowVector],0,
function(f,v)
local v2;
Assert(1, IsField(f) or IsPrimePowerInt(f));
if not IsInt(f) then f := Size(f); fi;
if f <= 256 then
v2 := CopyToVectorRep(v,f);
Expand All @@ -1716,6 +1717,7 @@ end);
InstallOtherMethod( ImmutableVector,"general,3",[IsObject,IsRowVector,IsBool],0,
function(f,v,change)
local v2;
Assert(1, IsField(f) or IsPrimePowerInt(f));
if not IsInt(f) then f := Size(f); fi;
if f <= 256 then
v2 := CopyToVectorRep(v,f);
Expand Down
2 changes: 1 addition & 1 deletion lib/algfld.gi
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ local fam,i,cof,red,rchar,impattr,deg,tmp;
else
rchar:=0;
fi;
fam!.rchar:=rchar;
fam!.rchar:=Size(f);

fam!.poly:=p;
fam!.polCoeffs:=CoefficientsOfUnivariatePolynomial(p);
Expand Down
2 changes: 2 additions & 0 deletions lib/vecmat.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1521,12 +1521,14 @@ end);
##
InstallMethod( ImmutableVector,"general,2",[IsObject,IsRowVector],0,
function(f,v)
Assert(1, IsField(f) or IsPrimePowerInt(f));
ConvertToVectorRepNC(v,f);
return Immutable(v);
end);

InstallOtherMethod( ImmutableVector,"general,3",[IsObject,IsRowVector,IsBool],0,
function(f,v,change)
Assert(1, IsField(f) or IsPrimePowerInt(f));
ConvertToVectorRepNC(v,f);
if change then
MakeImmutable(v);
Expand Down
9 changes: 8 additions & 1 deletion tst/teststandard/algext.tst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
##
## Test of algebraic extensions.
##
#@local t, f0, p1, f1, p2, f2, p3, f3, p4, f4, x, l, a, ll, b
#@local t, f0, p1, f1, p2, f2, p3, f3, p4, f4, x, l, a, ll, b, pol, K, xinv, c
gap> START_TEST("algext.tst");
gap> t := Runtime();;
gap> f0 := GF(3);;
Expand All @@ -25,5 +25,12 @@ gap> b := RootOfDefiningPolynomial(ll);;
gap> (a+b)^5-(a-b)^5;
20*alpha^2*beta^3+(10*alpha^2-10)*beta+!4

#
gap> pol := UnivariatePolynomial(GF(293), Z(293)^0 * ConwayPol(293,8));;
gap> K := AlgebraicExtension(GF(293), pol);;
gap> xinv := 1/PrimitiveElement(K);
Z(293)^145*a^7+Z(293)^274*a^3+Z(293)^120*a^2+Z(293)^134*a+Z(293)^179
gap> c := Random(K);;

#
gap> STOP_TEST("algext.tst",1);

0 comments on commit beb0d58

Please sign in to comment.