Skip to content

Commit

Permalink
Fix NewZero{Matrix,Vector} of length 0
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Apr 15, 2021
1 parent 0b64ce6 commit 3611770
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions hpcgap/lib/vec8bit.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ InstallMethod( NewZeroVector, "for Is8BitVectorRep, GF(q), and an int",
Error("Is8BitVectorRep only supports base fields with 3 to 256 elements");
fi;
v := ListWithIdenticalEntries(i,Zero(f));
ConvertToVectorRep(v,Size(f));
CONV_VEC8BIT(v,Size(f));
return v;
end );

Expand Down Expand Up @@ -1185,7 +1185,7 @@ InstallMethod( NewZeroMatrix, "for Is8BitMatrixRep, GF(q), and two ints",
for i in [2..rows] do
m[i] := ShallowCopy(m[1]);
od;
ConvertToMatrixRep(m,Size(f));
ConvertToMatrixRepNC(m,Size(f));
return m;
end );

Expand Down
4 changes: 2 additions & 2 deletions lib/vec8bit.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ InstallMethod( NewZeroVector, "for Is8BitVectorRep, GF(q), and an int",
Error("Is8BitVectorRep only supports base fields with 3 to 256 elements");
fi;
v := ListWithIdenticalEntries(i,Zero(f));
ConvertToVectorRep(v,Size(f));
CONV_VEC8BIT(v,Size(f));
return v;
end );

Expand Down Expand Up @@ -1142,7 +1142,7 @@ InstallMethod( NewZeroMatrix, "for Is8BitMatrixRep, GF(q), and two ints",
for i in [2..rows] do
m[i] := ShallowCopy(m[1]);
od;
ConvertToMatrixRep(m,Size(f));
ConvertToMatrixRepNC(m,Size(f));
return m;
end );

Expand Down
8 changes: 4 additions & 4 deletions tst/testinstall/MatrixObj/ZeroMatrix.tst
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ Error, IsGF2MatrixRep only supported over GF(2)
gap> TestZeroMatrix(Is8BitMatrixRep, GF(3), 2, 3);
[ [ 0*Z(3), 0*Z(3), 0*Z(3) ], [ 0*Z(3), 0*Z(3), 0*Z(3) ] ]
gap> TestZeroMatrix(Is8BitMatrixRep, GF(3), 2, 0);
Error, Assertion failure
< mutable compressed matrix 2x0 over GF(3) >
gap> TestZeroMatrix(Is8BitMatrixRep, GF(3), 0, 3);
Error, Is8BitMatrixRep with zero rows not yet supported

#
gap> TestZeroMatrix(Is8BitMatrixRep, GF(251), 2, 3);
[ [ 0*Z(251), 0*Z(251), 0*Z(251) ], [ 0*Z(251), 0*Z(251), 0*Z(251) ] ]
gap> TestZeroMatrix(Is8BitMatrixRep, GF(251), 2, 0);
Error, Assertion failure
< mutable compressed matrix 2x0 over GF(251) >
gap> TestZeroMatrix(Is8BitMatrixRep, GF(251), 0, 3);
Error, Is8BitMatrixRep with zero rows not yet supported

Expand Down Expand Up @@ -114,15 +114,15 @@ gap> ZeroMatrix(GF(3), 2, 3);
gap> ZeroMatrix(GF(3), 0, 3);
Error, Is8BitMatrixRep with zero rows not yet supported
gap> ZeroMatrix(GF(3), 2, 0);
[ [ ], [ ] ]
< mutable compressed matrix 2x0 over GF(3) >

#
gap> ZeroMatrix(GF(4), 2, 3);
[ [ 0*Z(2), 0*Z(2), 0*Z(2) ], [ 0*Z(2), 0*Z(2), 0*Z(2) ] ]
gap> ZeroMatrix(GF(4), 0, 3);
Error, Is8BitMatrixRep with zero rows not yet supported
gap> ZeroMatrix(GF(4), 2, 0);
[ [ ], [ ] ]
< mutable compressed matrix 2x0 over GF(4) >

#
gap> STOP_TEST("ZeroMatrix.tst");
8 changes: 4 additions & 4 deletions tst/testinstall/MatrixObj/ZeroVector.tst
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ Error, IsGF2VectorRep only supported over GF(2)
gap> TestZeroVector(Is8BitVectorRep, GF(3), 3);
Error, Assertion failure
gap> TestZeroVector(Is8BitVectorRep, GF(3), 0);
Error, Assertion failure
Error, Z: <q> must be a positive prime power (not the integer 1)

#
gap> TestZeroVector(Is8BitVectorRep, GF(251), 3);
Error, Assertion failure
gap> TestZeroVector(Is8BitVectorRep, GF(251), 0);
Error, Assertion failure
Error, Z: <q> must be a positive prime power (not the integer 1)

# test error handling
gap> TestZeroVector(Is8BitVectorRep, GF(3), -1);
Expand Down Expand Up @@ -100,15 +100,15 @@ Error, ZeroVector: length must be non-negative
gap> ZeroVector(GF(3), 2);
[ 0*Z(3), 0*Z(3) ]
gap> ZeroVector(GF(3), 0);
[ ]
< mutable compressed vector length 0 over GF(3) >
gap> ZeroVector(GF(3), -1);
Error, ZeroVector: length must be non-negative

#
gap> ZeroVector(GF(4), 2);
[ 0*Z(2), 0*Z(2) ]
gap> ZeroVector(GF(4), 0);
[ ]
< mutable compressed vector length 0 over GF(4) >
gap> ZeroVector(GF(4), -1);
Error, ZeroVector: length must be non-negative

Expand Down

0 comments on commit 3611770

Please sign in to comment.