Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

563596 views
1
2
4 Gaussian Algorithms
3
4
5
4.1 A list of the available algorithms
6
7
As decribed earlier, the main functions of Gauss are EchelonMat (4.2-1) and
8
EchelonMatTransformation (4.2-2), ReduceMat (4.2-3) and
9
ReduceMatTransformation (4.2-4), KernelMat (4.2-5) and, additionally Rank
10
(4.2-6). These are all documented in the next section, but of course rely on
11
specific algorithms depending on the base ring of the matrix. These are not
12
fully documented but it should be very easy to find out how they work based
13
on the documentation of the main functions.
14
15
EchelonMat
16
Field: EchelonMatDestructive
17
Ring: HermiteMatDestructive
18
EchelonMatTransformation
19
Field: EchelonMatTransformationDestructive
20
Ring: HermiteMatTransformationDestructive
21
ReduceMat
22
Field: ReduceMatWithEchelonMat
23
Ring: ReduceMatWithHermiteMat
24
ReduceMatTransformation
25
Field: ReduceMatWithEchelonMatTransformation
26
Ring: ReduceMatWithHermiteMatTransformation
27
KernelMat
28
Field: KernelEchelonMatDestructive
29
Ring: KernelHermiteMatDestructive
30
Rank
31
Field (dense): Rank (GAP method)
32
Field (sparse): RankDestructive
33
GF(2) (sparse): RankOfIndicesListList
34
Ring: n.a.
35
36
37
4.2 Methods and Functions for Gaussian algorithms
38
39
4.2-1 EchelonMat
40
41
EchelonMat( mat )  method
42
Returns: a record that contains information about an echelonized form of
43
the matrix mat.
44
45
The components of this record are
46
47
`vectors'
48
49
the reduced row echelon / hermite form of the matrix mat without
50
zero rows.
51
52
`heads'
53
54
list that contains at position <i>, if nonzero, the number of the
55
row for that the pivot element is in column <i>.
56
57
computes the reduced row echelon form RREF of a dense or sparse matrix mat
58
over a field, or the hermite form of a sparse matrix mat over ℤ / < p^n >.
59
60
 Example 
61
gap> M := [[0,0,0,1,0],[0,1,1,1,1],[1,1,1,1,0]] * One( GF(2) );;
62
gap> Display(M);
63
 . . . 1 .
64
 . 1 1 1 1
65
 1 1 1 1 .
66
gap> EchelonMat(M);
67
rec( heads := [ 1, 2, 0, 3, 0 ],
68
 vectors := [ <an immutable GF2 vector of length 5>,
69
 <an immutable GF2 vector of length 5>,
70
 <an immutable GF2 vector of length 5> ] )
71
gap> Display( last.vectors );
72
 1 . . . 1
73
 . 1 1 . 1
74
 . . . 1 .
75
gap> SM := SparseMatrix( M );
76
<a 3 x 5 sparse matrix over GF(2)>
77
gap> EchelonMat( SM );
78
rec( heads := [ 1, 2, 0, 3, 0 ], vectors := <a 3 x 5 sparse matrix over GF(
79
 2)> )
80
gap> Display(last.vectors);
81
 1 . . . 1
82
 . 1 1 . 1
83
 . . . 1 .
84
gap> SM := SparseMatrix( [[7,4,5],[0,0,6],[0,4,4]] * One( Integers mod 8 ) );
85
<a 3 x 3 sparse matrix over (Integers mod 8)>
86
gap> Display( SM );
87
 7 4 5
88
 . . 6
89
 . 4 4
90
gap> EchelonMat( SM );
91
rec( heads := [ 1, 2, 3 ],
92
 vectors := <a 3 x 3 sparse matrix over (Integers mod 8)> )
93
gap> Display( last.vectors );
94
 1 . 1
95
 . 4 .
96
 . . 2 
97

98
99
4.2-2 EchelonMatTransformation
100
101
EchelonMatTransformation( mat )  method
102
Returns: a record that contains information about an echelonized form of
103
the matrix mat.
104
105
The components of this record are
106
107
`vectors'
108
109
the reduced row echelon / hermite form of the matrix mat without
110
zero rows.
111
112
`heads'
113
114
list that contains at position <i>, if nonzero, the number of the
115
row for that the pivot element is in column <i>.
116
117
`coeffs'
118
119
the transformation matrix needed to obtain the RREF from mat.
120
121
`relations'
122
123
the kernel of the matrix mat if RingOfDefinition(mat) is a field.
124
Otherwise these are only the obvious row relations of mat, there
125
might be more kernel vectors - --> KernelMat (4.2-5).
126
127
computes the reduced row echelon form RREF of a dense or sparse matrix mat
128
over a field, or the hermite form of a sparse matrix mat over ℤ / < p^n >.
129
In either case, the transformation matrix T is calculated as the row union
130
of `coeffs' and `relations'.
131
132
 Example 
133
gap> M := [[1,0,1],[1,1,0],[1,0,1],[1,1,0],[1,1,1]] * One( GF(2) );;
134
gap> EchelonMatTransformation( M );
135
rec( 
136
 coeffs := [ <an immutable GF2 vector of length 5>,
137
 <an immutable GF2 vector of length 5>, 
138
 <an immutable GF2 vector of length 5> ], heads := [ 1, 2, 3 ], 
139
 relations := 
140
 [ <an immutable GF2 vector of length 5>,
141
 <an immutable GF2 vector of length 5> ], 
142
 vectors := [ <an immutable GF2 vector of length 3>,
143
 <an immutable GF2 vector of length 3>,
144
 <an immutable GF2 vector of length 3> ] )
145
gap> Display(last.vectors);
146
 1 . .
147
 . 1 .
148
 . . 1
149
gap> Display(last.coeffs);
150
 1 1 . . 1
151
 1 . . . 1
152
 . 1 . . 1
153
gap> Display(last.relations);
154
 1 . 1 . .
155
 . 1 . 1 .
156
gap> Display( Concatenation( last.coeffs, last.relations ) * M );
157
 1 . .
158
 . 1 .
159
 . . 1
160
 . . .
161
 . . .
162
gap> SM := SparseMatrix( M );
163
<a 5 x 3 sparse matrix over GF(2)>
164
gap> EchelonMatTransformation( SM );
165
rec( coeffs := <a 3 x 5 sparse matrix over GF(2)>, 
166
 heads := [ 1, 2, 3 ], 
167
 relations := <a 2 x 5 sparse matrix over GF(2)>, 
168
 vectors := <a 3 x 3 sparse matrix over GF(2)> )
169
gap> Display(last.vectors);
170
 1 . .
171
 . 1 .
172
 . . 1
173
gap> Display(last.coeffs);
174
 1 1 . . 1
175
 1 . . . 1
176
 . 1 . . 1
177
gap> Display(last.relations);
178
 1 . 1 . .
179
 . 1 . 1 .
180
gap> Display( UnionOfRows( last.coeffs, last.relations ) * SM );
181
 1 . .
182
 . 1 .
183
 . . 1
184
 . . .
185
 . . .
186

187
188
4.2-3 ReduceMat
189
190
ReduceMat( A, B )  method
191
Returns: a record with a single component `reduced_matrix' := M. M is
192
created by reducing A with B, where B must be in Echelon/Hermite
193
form. M will have the same dimensions as A.
194
195
 Example 
196
gap> M := [[0,0,0,1,0],[0,1,1,1,1],[1,1,1,1,0]] * One( GF(2) );;
197
gap> Display(M);
198
 . . . 1 .
199
 . 1 1 1 1
200
 1 1 1 1 .
201
gap> N := [[1,1,0,0,0],[0,0,1,0,1]] * One( GF(2) );;
202
gap> Display(N);
203
 1 1 . . .
204
 . . 1 . 1
205
gap> ReduceMat(M,N);
206
rec(
207
 reduced_matrix := [ <a GF2 vector of length 5>, <a GF2 vector of length 5>,
208
 <a GF2 vector of length 5> ] )
209
gap> Display(last.reduced_matrix);
210
 . . . 1 .
211
 . 1 . 1 .
212
 . . . 1 1
213
gap> SM := SparseMatrix(M); SN := SparseMatrix(N);
214
<a 3 x 5 sparse matrix over GF(2)>
215
<a 2 x 5 sparse matrix over GF(2)>
216
gap> ReduceMat(SM,SN);
217
rec( reduced_matrix := <a 3 x 5 sparse matrix over GF(2)> )
218
gap> Display(last.reduced_matrix);
219
 . . . 1 .
220
 . 1 . 1 .
221
 . . . 1 1
222

223
224
4.2-4 ReduceMatTransformation
225
226
ReduceMatTransformation( A, B )  method
227
Returns: a record with a component `reduced_matrix' := M. M is created by
228
reducing A with B, where B must be in Echelon/Hermite form. M will
229
have the same dimensions as A. In addition to the (identical)
230
output as ReduceMat this record also includes the component
231
`transformation', which stores the row operations that were needed
232
to reduce A with B. This differs from "normal" transformation
233
matrices because only rows of B had to be moved. Therefore, the
234
transformation matrix solves M = A + T * B.
235
236
 Example 
237
gap> M := [[0,0,0,1,0],[0,1,1,1,1],[1,1,1,1,0]] * One( GF(2) );;
238
gap> Display(M);
239
 . . . 1 .
240
 . 1 1 1 1
241
 1 1 1 1 .
242
gap> N := [[1,1,0,0,0],[0,0,1,0,1]] * One( GF(2) );;
243
gap> Display(N);
244
 1 1 . . .
245
 . . 1 . 1
246
gap> ReduceMatTransformation(M,N);
247
rec( 
248
 reduced_matrix := 
249
 [ <a GF2 vector of length 5>, <a GF2 vector of length 5>, 
250
 <a GF2 vector of length 5> ], 
251
 transformation := [ <a GF2 vector of length 2>,
252
 <a GF2 vector of length 2>, <a GF2 vector of length 2> ] )
253
gap> Display(last.reduced_matrix);
254
 . . . 1 .
255
 . 1 . 1 .
256
 . . . 1 1
257
gap> Display(last.transformation);
258
 . .
259
 . 1
260
 1 1
261
gap> Display( M + last.transformation * N );
262
 . . . 1 .
263
 . 1 . 1 .
264
 . . . 1 1 
265
gap> SM := SparseMatrix(M); SN := SparseMatrix(N);
266
<a 3 x 5 sparse matrix over GF(2)>
267
<a 2 x 5 sparse matrix over GF(2)>
268
gap> ReduceMatTransformation(SM,SN);
269
rec( reduced_matrix := <a 3 x 5 sparse matrix over GF(2)>,
270
 transformation := <a 3 x 2 sparse matrix over GF(2)> )
271
gap> Display(last.reduced_matrix);
272
 . . . 1 .
273
 . 1 . 1 .
274
 . . . 1 1
275
gap> Display(last.transformation);
276
 . .
277
 . 1
278
 1 1
279
gap> Display( SM + last.transformation * SN );
280
 . . . 1 .
281
 . 1 . 1 .
282
 . . . 1 1
283

284
285
4.2-5 KernelMat
286
287
KernelMat( M )  function
288
Returns: a record with a single component `relations'.
289
290
If M is a matrix over a field this is the same output as
291
EchelonMatTransformation (4.2-2) provides in the `relations' component, but
292
with less memory and CPU usage. If the base ring of M is a non-field, the
293
Kernel might have additional generators, which are added to the output.
294
295
 Example 
296
gap> M := [[2,1],[0,2]];
297
[ [ 2, 1 ], [ 0, 2 ] ]
298
gap> SM := SparseMatrix( M * One( GF(3) ) );
299
<a 2 x 2 sparse matrix over GF(3)>
300
gap> KernelMat(SM);
301
rec( relations := <a 0 x 2 sparse matrix over GF(3)> )
302
gap> SN := SparseMatrix( M * One( Integers mod 4 ) );
303
<a 2 x 2 sparse matrix over (Integers mod 4)>
304
gap> KernelMat(SN);
305
rec( relations := <a 1 x 2 sparse matrix over (Integers mod 4)> )
306
gap> Display(last.relations);
307
 2 1
308

309
310
4.2-6 Rank
311
312
Rank( sm[, boundary] )  method
313
Returns: the rank of the sparse matrix sm. Only works for fields.
314
315
Computes the rank of a sparse matrix. If the optional argument boundary is
316
provided, some algorithms take into account the fact that Rank(sm) <=
317
boundary, thus possibly terminating earlier.
318
319
 Example 
320
gap> M := SparseDiagMat( ListWithIdenticalEntries( 10,
321
>  SparseMatrix( [[1,1],[1,1]] * One( GF(5) ) ) ) );
322
<a 20 x 20 sparse matrix over GF(5)>
323
gap> Display(M);
324
 1 1 . . . . . . . . . . . . . . . . . .
325
 1 1 . . . . . . . . . . . . . . . . . .
326
 . . 1 1 . . . . . . . . . . . . . . . .
327
 . . 1 1 . . . . . . . . . . . . . . . .
328
 . . . . 1 1 . . . . . . . . . . . . . .
329
 . . . . 1 1 . . . . . . . . . . . . . .
330
 . . . . . . 1 1 . . . . . . . . . . . .
331
 . . . . . . 1 1 . . . . . . . . . . . .
332
 . . . . . . . . 1 1 . . . . . . . . . .
333
 . . . . . . . . 1 1 . . . . . . . . . .
334
 . . . . . . . . . . 1 1 . . . . . . . .
335
 . . . . . . . . . . 1 1 . . . . . . . .
336
 . . . . . . . . . . . . 1 1 . . . . . .
337
 . . . . . . . . . . . . 1 1 . . . . . .
338
 . . . . . . . . . . . . . . 1 1 . . . .
339
 . . . . . . . . . . . . . . 1 1 . . . .
340
 . . . . . . . . . . . . . . . . 1 1 . .
341
 . . . . . . . . . . . . . . . . 1 1 . .
342
 . . . . . . . . . . . . . . . . . . 1 1
343
 . . . . . . . . . . . . . . . . . . 1 1
344
gap> Rank(M);
345
10
346

347
348
349