File: matblock.tst

package info (click to toggle)
gap 4r4p12-2
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 29,584 kB
  • ctags: 7,113
  • sloc: ansic: 98,786; sh: 3,299; perl: 2,263; makefile: 498; asm: 63; awk: 6
file content (123 lines) | stat: -rw-r--r-- 3,881 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#############################################################################
##
#W  matblock.tst                GAP Library                     Thomas Breuer
##
#H  @(#)$Id: matblock.tst,v 1.7.4.4 2005/08/29 14:50:35 gap Exp $
##
#Y  Copyright (C)  1997,  Lehrstuhl D fuer Mathematik,  RWTH Aachen,  Germany
##
##  Exclude from testall.g: why?
##

gap> START_TEST("$Id: matblock.tst,v 1.7.4.4 2005/08/29 14:50:35 gap Exp $");

gap> m1 := BlockMatrix( [ [ 1, 1, [[1,1],[0,1]] ],
>                         [ 1, 3, [[1,0],[0,1]] ],
>                         [ 2, 2, [[0,1],[1,0]] ],
>                         [ 3, 4, [[1,0],[0,0]] ] ], 3, 4 );
<block matrix of dimensions (3*2)x(4*2)>
gap> m2 := BlockMatrix( [ [ 1, 3, [[1,0],[0,1]] ],
>                         [ 2, 1, [[1,0],[0,1]] ],
>                         [ 3, 2, [[1,0],[0,1]] ] ], 3, 3 );
<block matrix of dimensions (3*2)x(3*2)>
gap> m3 := AsBlockMatrix( m2, 2, 2 );
<block matrix of dimensions (2*3)x(2*3)>
gap> z  := BlockMatrix( [], 3, 3, 2, 2, 0 );
<block matrix of dimensions (3*2)x(3*2)>

gap> Length( m1 ); DimensionsMat( m1 );
6
[ 6, 8 ]
gap> Length( m2 ); DimensionsMat( m2 );
6
[ 6, 6 ]
gap> Length( m3 ); DimensionsMat( m3 );
6
[ 6, 6 ]
gap> Length( z );  DimensionsMat( z );
6
[ 6, 6 ]

gap> m1[3];
[ 0, 0, 0, 1, 0, 0, 0, 0 ]
gap> z[2];
[ 0, 0, 0, 0, 0, 0 ]

gap> m2 = m3;
true
gap> p1:= m2 * m1;
<block matrix of dimensions (3*2)x(4*2)>
gap> p2:= m3 * m1;
[ [ 0, 0, 0, 0, 0, 0, 1, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0 ],
  [ 1, 1, 0, 0, 1, 0, 0, 0 ], [ 0, 1, 0, 0, 0, 1, 0, 0 ],
  [ 0, 0, 0, 1, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0, 0, 0 ] ]
gap> p1 = p2;
true
gap> p3:= m1 * TransposedMat( m1 );
<block matrix of dimensions (3*2)x(3*2)>
gap> mm:= MatrixByBlockMatrix( m1 );
[ [ 1, 1, 0, 0, 1, 0, 0, 0 ], [ 0, 1, 0, 0, 0, 1, 0, 0 ],
  [ 0, 0, 0, 1, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0, 0, 0 ],
  [ 0, 0, 0, 0, 0, 0, 1, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0 ] ]
gap> mm * TransposedMat( mm ) = p3;
true
gap> p4:= TransposedMat( m1 ) * m2;
<block matrix of dimensions (4*2)x(3*2)>

gap> p3 = p4;
false
gap> z = AsBlockMatrix( z, 2, 2 );
true

gap> MatrixByBlockMatrix( m1 );
[ [ 1, 1, 0, 0, 1, 0, 0, 0 ], [ 0, 1, 0, 0, 0, 1, 0, 0 ],
  [ 0, 0, 0, 1, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0, 0, 0 ],
  [ 0, 0, 0, 0, 0, 0, 1, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0 ] ]
gap> MatrixByBlockM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 ]
gap> 3 * m1;
<block matrix of dimensions (3*2)x(4*2)>
gap> Print( m2 * 5, "\n" );
BlockMatrix( [ [ 1, 3, [ [ 5, 0 ], [ 0, 5 ] ] ], 
  [ 2, 1, [ [ 5, 0 ], [ 0, 5 ] ] ], [ 3, 2, [ [ 5, 0 ], [ 0, 5 ] ] ] ],3,3,2,
2,0 )

gap> o1:= One( m2 );
<block matrix of dimensions (3*2)x(3*2)>
gap> o2:= One( z );
<block matrix of dimensions (3*2)x(3*2)>
gap> o1 = o2;
true

gap> STOP_TEST( "matblock.tst", 3000000 );


#############################################################################
##
#E