Skip to content

Commit 228a998

Browse files
committed
add some assertions
1 parent 4943105 commit 228a998

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/matobjminimal.gi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ InstallMethod( NewMatrix,
2828
if Length(list_in[rowindex]) <> nrcols then
2929
Error( "NewMatrix: Each row must have nrcols entries." );
3030
fi;
31-
for colindex in [1..nrcols] do
31+
for colindex in [1..nrcols] do
32+
Assert(2, list_in[rowindex][colindex] in basedomain);
3233
list[(rowindex-1)*nrcols + colindex] := list_in[rowindex][colindex];
3334
od;
3435
od;
@@ -71,12 +72,17 @@ InstallMethod( NumberColumns, "for a minimal example matrix rep",
7172
InstallMethod( MatElm, "for an minimal example matrix rep and two positions",
7273
[ IsMinimalExampleMatrixRep, IsPosInt, IsPosInt ],
7374
function( mat, row, col )
75+
Assert(2, 1 <= row and row <= mat![MINREP_NRPOS]);
76+
Assert(2, 1 <= col and col <= mat![MINREP_NCPOS]);
7477
return mat![MINREP_ELSPOS][(row-1)*mat![MINREP_NCPOS]+col];
7578
end );
7679

7780
InstallMethod( SetMatElm, "for an minimal example matrix rep, two positions, and an object",
7881
[ IsMinimalExampleMatrixRep and IsMutable, IsPosInt, IsPosInt, IsObject ],
7982
function( mat, row, col, obj )
83+
Assert(2, 1 <= row and row <= mat![MINREP_NRPOS]);
84+
Assert(2, 1 <= col and col <= mat![MINREP_NCPOS]);
85+
Assert(2, obj in mat![MINREP_BDPOS]);
8086
mat![MINREP_ELSPOS][(row-1)*mat![MINREP_NCPOS]+col] := obj;
8187
end );
8288

0 commit comments

Comments
 (0)