Skip to content

Commit

Permalink
MatrixObj: some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Jul 13, 2018
1 parent c26305a commit be5fda4
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
74 changes: 74 additions & 0 deletions tst/testinstall/MatrixObj/IdentityMatrix.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
gap> START_TEST("IdentityMatrix.tst");

#
gap> m:=IdentityMatrix( GF(2), 5 ); Display(m);
<a 5x5 matrix over GF2>
1 . . . .
. 1 . . .
. . 1 . .
. . . 1 .
. . . . 1
gap> m:=IdentityMatrix( GF(3), 5 ); Display(m);
[ [ Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],
[ 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3) ],
[ 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3) ],
[ 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3) ],
[ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0 ] ]
1 . . . .
. 1 . . .
. . 1 . .
. . . 1 .
. . . . 1
gap> m:=IdentityMatrix( GF(4), 5 ); Display(m);
[ [ Z(2)^0, 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2) ],
[ 0*Z(2), Z(2)^0, 0*Z(2), 0*Z(2), 0*Z(2) ],
[ 0*Z(2), 0*Z(2), Z(2)^0, 0*Z(2), 0*Z(2) ],
[ 0*Z(2), 0*Z(2), 0*Z(2), Z(2)^0, 0*Z(2) ],
[ 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), Z(2)^0 ] ]
1 . . . .
. 1 . . .
. . 1 . .
. . . 1 .
. . . . 1
gap> m:=IdentityMatrix( Integers, 5 ); Display(m);
<5x5-matrix over Integers>
<5x5-matrix over Integers:
[[ 1, 0, 0, 0, 0 ]
[ 0, 1, 0, 0, 0 ]
[ 0, 0, 1, 0, 0 ]
[ 0, 0, 0, 1, 0 ]
[ 0, 0, 0, 0, 1 ]
]>
gap> m:=IdentityMatrix( Integers mod 4, 5 ); Display(m);
<5x5-matrix over (Integers mod 4)>
<5x5-matrix over (Integers mod 4):
[[ ZmodnZObj( 1, 4 ), ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ),
ZmodnZObj( 0, 4 ) ]
[ ZmodnZObj( 0, 4 ), ZmodnZObj( 1, 4 ), ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ),
ZmodnZObj( 0, 4 ) ]
[ ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ), ZmodnZObj( 1, 4 ), ZmodnZObj( 0, 4 ),
ZmodnZObj( 0, 4 ) ]
[ ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ), ZmodnZObj( 1, 4 ),
ZmodnZObj( 0, 4 ) ]
[ ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ),
ZmodnZObj( 1, 4 ) ]
]>

#
gap> m:=IdentityMatrix( Integers, 0 ); Display(m);
<0x0-matrix over Integers>
<0x0-matrix over Integers:
]>

# some error checking
gap> m:=IdentityMatrix( GF(2), -1 );
Error, <n> must be a non-negative integer (not a integer)
gap> m:=IdentityMatrix( GF(3), -1 );
Error, <n> must be a non-negative integer (not a integer)
gap> m:=IdentityMatrix( GF(4), -1 );
Error, <n> must be a non-negative integer (not a integer)
gap> m:=IdentityMatrix( Integers mod 4, -1 );
Error, <n> must be a non-negative integer (not a integer)

#
gap> STOP_TEST("IdentityMatrix.tst");
43 changes: 43 additions & 0 deletions tst/testinstall/MatrixObj/Matrix.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
gap> START_TEST("Matrix.tst");

#
gap> m := Matrix( [[1,2],[3,4]] );
<2x2-matrix over Rationals>
gap> Display(m);
<2x2-matrix over Rationals:
[[ 1, 2 ]
[ 3, 4 ]
]>

#
gap> m := Matrix( [[1,2],[3,4]] * Z(2) );
<a 2x2 matrix over GF2>
gap> Display(m);
1 .
1 .

#
gap> m := Matrix( IsGF2MatrixRep, GF(2), [[1,2],[3,4]] * Z(2) );
<a 2x2 matrix over GF2>
gap> Display(m);
1 .
1 .

#
gap> m := Matrix( Is8BitMatrixRep, GF(4), [[1,2],[3,4]] * Z(2) );
[ [ Z(2)^0, 0*Z(2) ], [ Z(2)^0, 0*Z(2) ] ]
gap> Display(m);
1 .
1 .

#
gap> m := Matrix( IsPlistMatrixRep, GF(2), [[1,2],[3,4]] * Z(2) );
<2x2-matrix over GF(2)>
gap> Display(m);
<2x2-matrix over GF(2):
[[ Z(2)^0, 0*Z(2) ]
[ Z(2)^0, 0*Z(2) ]
]>

#
gap> STOP_TEST("Matrix.tst");

0 comments on commit be5fda4

Please sign in to comment.