Skip to content

Commit be5fda4

Browse files
committed
MatrixObj: some more tests
1 parent c26305a commit be5fda4

2 files changed

Lines changed: 117 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
gap> START_TEST("IdentityMatrix.tst");
2+
3+
#
4+
gap> m:=IdentityMatrix( GF(2), 5 ); Display(m);
5+
<a 5x5 matrix over GF2>
6+
1 . . . .
7+
. 1 . . .
8+
. . 1 . .
9+
. . . 1 .
10+
. . . . 1
11+
gap> m:=IdentityMatrix( GF(3), 5 ); Display(m);
12+
[ [ Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],
13+
[ 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3) ],
14+
[ 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3) ],
15+
[ 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3) ],
16+
[ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0 ] ]
17+
1 . . . .
18+
. 1 . . .
19+
. . 1 . .
20+
. . . 1 .
21+
. . . . 1
22+
gap> m:=IdentityMatrix( GF(4), 5 ); Display(m);
23+
[ [ Z(2)^0, 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2) ],
24+
[ 0*Z(2), Z(2)^0, 0*Z(2), 0*Z(2), 0*Z(2) ],
25+
[ 0*Z(2), 0*Z(2), Z(2)^0, 0*Z(2), 0*Z(2) ],
26+
[ 0*Z(2), 0*Z(2), 0*Z(2), Z(2)^0, 0*Z(2) ],
27+
[ 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), Z(2)^0 ] ]
28+
1 . . . .
29+
. 1 . . .
30+
. . 1 . .
31+
. . . 1 .
32+
. . . . 1
33+
gap> m:=IdentityMatrix( Integers, 5 ); Display(m);
34+
<5x5-matrix over Integers>
35+
<5x5-matrix over Integers:
36+
[[ 1, 0, 0, 0, 0 ]
37+
[ 0, 1, 0, 0, 0 ]
38+
[ 0, 0, 1, 0, 0 ]
39+
[ 0, 0, 0, 1, 0 ]
40+
[ 0, 0, 0, 0, 1 ]
41+
]>
42+
gap> m:=IdentityMatrix( Integers mod 4, 5 ); Display(m);
43+
<5x5-matrix over (Integers mod 4)>
44+
<5x5-matrix over (Integers mod 4):
45+
[[ ZmodnZObj( 1, 4 ), ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ),
46+
ZmodnZObj( 0, 4 ) ]
47+
[ ZmodnZObj( 0, 4 ), ZmodnZObj( 1, 4 ), ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ),
48+
ZmodnZObj( 0, 4 ) ]
49+
[ ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ), ZmodnZObj( 1, 4 ), ZmodnZObj( 0, 4 ),
50+
ZmodnZObj( 0, 4 ) ]
51+
[ ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ), ZmodnZObj( 1, 4 ),
52+
ZmodnZObj( 0, 4 ) ]
53+
[ ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ), ZmodnZObj( 0, 4 ),
54+
ZmodnZObj( 1, 4 ) ]
55+
]>
56+
57+
#
58+
gap> m:=IdentityMatrix( Integers, 0 ); Display(m);
59+
<0x0-matrix over Integers>
60+
<0x0-matrix over Integers:
61+
]>
62+
63+
# some error checking
64+
gap> m:=IdentityMatrix( GF(2), -1 );
65+
Error, <n> must be a non-negative integer (not a integer)
66+
gap> m:=IdentityMatrix( GF(3), -1 );
67+
Error, <n> must be a non-negative integer (not a integer)
68+
gap> m:=IdentityMatrix( GF(4), -1 );
69+
Error, <n> must be a non-negative integer (not a integer)
70+
gap> m:=IdentityMatrix( Integers mod 4, -1 );
71+
Error, <n> must be a non-negative integer (not a integer)
72+
73+
#
74+
gap> STOP_TEST("IdentityMatrix.tst");
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
gap> START_TEST("Matrix.tst");
2+
3+
#
4+
gap> m := Matrix( [[1,2],[3,4]] );
5+
<2x2-matrix over Rationals>
6+
gap> Display(m);
7+
<2x2-matrix over Rationals:
8+
[[ 1, 2 ]
9+
[ 3, 4 ]
10+
]>
11+
12+
#
13+
gap> m := Matrix( [[1,2],[3,4]] * Z(2) );
14+
<a 2x2 matrix over GF2>
15+
gap> Display(m);
16+
1 .
17+
1 .
18+
19+
#
20+
gap> m := Matrix( IsGF2MatrixRep, GF(2), [[1,2],[3,4]] * Z(2) );
21+
<a 2x2 matrix over GF2>
22+
gap> Display(m);
23+
1 .
24+
1 .
25+
26+
#
27+
gap> m := Matrix( Is8BitMatrixRep, GF(4), [[1,2],[3,4]] * Z(2) );
28+
[ [ Z(2)^0, 0*Z(2) ], [ Z(2)^0, 0*Z(2) ] ]
29+
gap> Display(m);
30+
1 .
31+
1 .
32+
33+
#
34+
gap> m := Matrix( IsPlistMatrixRep, GF(2), [[1,2],[3,4]] * Z(2) );
35+
<2x2-matrix over GF(2)>
36+
gap> Display(m);
37+
<2x2-matrix over GF(2):
38+
[[ Z(2)^0, 0*Z(2) ]
39+
[ Z(2)^0, 0*Z(2) ]
40+
]>
41+
42+
#
43+
gap> STOP_TEST("Matrix.tst");

0 commit comments

Comments
 (0)