File: matobj.xml

package info (click to toggle)
gap 4.15.1-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 110,212 kB
  • sloc: ansic: 97,261; xml: 48,343; cpp: 13,946; sh: 4,900; perl: 1,650; javascript: 255; makefile: 252; ruby: 9
file content (379 lines) | stat: -rw-r--r-- 12,668 bytes parent folder | download | duplicates (2)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<!--   matobj.xml               GAP documentation        Max Neunhoeffer  -->
<!--                                                                      -->
<!--   Copyright (C) 2011 The GAP Group                                   -->
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<Chapter Label="Vector and Matrix Objects">
<Heading>Vector and Matrix Objects</Heading>

This chapter describes an interface to vector and matrix objects
which are not represented by plain lists (of plain lists),
cf. Chapters <Ref Chap="Row Vectors"/> and <Ref Chap="Matrices"/>.


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Concepts and Rules for Vector and Matrix Objects">
<Heading>Concepts and Rules for Vector and Matrix Objects</Heading>

<#Include Label="MatObj_Overview">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Categories of Vector and Matrix Objects">
<Heading>Categories of Vector and Matrix Objects</Heading>

Currently the following categories of vector and matrix objects
are supported in &GAP;.
More can be added as soon as there is need for them.
<!-- For example, flat matrices? -->

<#Include Label="IsVectorObj">
<#Include Label="IsMatrixObj">
<#Include Label="IsMatrixOrMatrixObj">
<#Include Label="IsRowListMatrix">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Defining Attributes of Vector and Matrix Objects">
<Heading>Defining Attributes of Vector and Matrix Objects</Heading>

<#Include Label="BaseDomain">
<#Include Label="ConstructingFilter">
<#Include Label="CompatibleVectorFilter">
<#Include Label="Length_IsVectorObj">
<#Include Label="NumberRowsNumberColumns">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Constructing Vector and Matrix Objects">
<Heading>Constructing Vector and Matrix Objects</Heading>

<#Include Label="NewVector">
<#Include Label="Vector">
<#Include Label="VectorObj_ZeroVector">
<#Include Label="NewMatrix">
<#Include Label="MatObj_Matrix">
<#Include Label="MatObj_ZeroMatrix">
<#Include Label="MatObj_IdentityMatrix">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Operations for Base Domains of Vector and Matrix Objects">
<Heading>Operations for Base Domains of Vector and Matrix Objects</Heading>

<#Include Label="OneOfBaseDomain">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Operations for Vector and Matrix Objects">
<Heading>Operations for Vector and Matrix Objects</Heading>

<#Include Label="MatrixObjCompare">
<#Include Label="Unpack">
<#Include Label="ChangedBaseDomain">
<#Include Label="Randomize">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="List Like Operations for Vector Objects">
<Heading>List Like Operations for Vector Objects</Heading>

The following operations that are defined for lists are useful
also for vector objects.
(More such operations can be added if this is appropriate.)

<#Include Label="ElementAccessVectorObj">
<#Include Label="MatObj_PositionNonZero">
<#Include Label="MatObj_PositionLastNonZero">
<#Include Label="MatObj_ListOp">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Arithmetical Operations for Vector Objects">
<Heading>Arithmetical Operations for Vector Objects</Heading>

<#Include Label="VectorObj_UnaryArithmetics">
<#Include Label="VectorObj_BinaryArithmetics">
<#Include Label="MatObj_AddVector">
<#Include Label="MatObj_MultVectorLeft">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Operations for Vector Objects">
<Heading>Operations for Vector Objects</Heading>

<#Include Label="MatObj_ConcatenationOfVectors">
<#Include Label="MatObj_ExtractSubVector">
<#Include Label="CopySubVector">
<#Include Label="MatObj_WeightOfVector">
<#Include Label="MatObj_DistanceOfVectors">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Arithmetical Operations for Matrix Objects">
<Heading>Arithmetical Operations for Matrix Objects</Heading>

<#Include Label="MatrixObj_UnaryArithmetics">
<#Include Label="MatrixObj_BinaryArithmetics">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Operations for Matrix Objects">
<Heading>Operations for Matrix Objects</Heading>

<#Include Label="MatObj_MatElm">
<#Include Label="MatObj_SetMatElm">
<#Include Label="ExtractSubMatrix">
<#Include Label="MutableCopyMatrix">
<#Include Label="CopySubMatrix">
<#Include Label="CompatibleVector">
<#Include Label="RowsOfMatrix">
<#Include Label="MatObj_CompanionMatrix">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Operations for Row List Matrix Objects">
<Heading>Operations for Row List Matrix Objects</Heading>

In general, matrix objects are not lists in the sense of <Ref Filt="IsList"/>,
and they need not behave like lists,
that is, they need not obey all the rules for lists that are stated in
Chapter <Ref Chap="Lists"/>.
There are situations where one wants to have matrix objects
that can on the one hand benefit from &GAP;'s method selection,
as is explained in
Section <Ref Sect="Concepts and Rules for Vector and Matrix Objects"/>,
and do on the other hands support access to &GAP; objects that represent
their rows (which are suitable vector objects).
Matrix objects whose
<Ref Attr="ConstructingFilter" Label="for a matrix object"/> value implies
<Ref Filt="IsRowListMatrix"/> support the operations described in this
section.

<P/>

One implementation of such matrices is given by the
<Ref Attr="ConstructingFilter" Label="for a matrix object"/> value
<Ref Filt="IsPlistMatrixRep"/>,
and any row of these matrices is a vector object in
<Ref Filt="IsPlistVectorRep"/>.
Note that these objects do <E>not</E> lie in <Ref Filt="IsList"/>
(and in particular not in <Ref Filt="IsPlistRep"/>),
thus we are allowed to define the above operations only restrictively,
as follows.

<P/>

Unbinding an entry in a row or unbinding a row in a matrix is allowed only
in the last position,
that is, the vector and matrix objects insist on being dense.
All rows of a matrix must have the same length and the same base domain.

<#Include Label="RowListMatObj_[]">
<#Include Label="RowListMatObj_[]_ASS">
<#Include Label="RowListMatObj_{}">
<#Include Label="RowListMatObj_{}_ASS">
<#Include Label="RowListMatObj_IsBound">
<#Include Label="RowListMatObj_Unbind">
<#Include Label="RowListMatObj_Add">
<#Include Label="RowListMatObj_Remove">
<#Include Label="RowListMatObj_Append">
<#Include Label="RowListMatObj_ShallowCopy">
<#Include Label="RowListMatObj_ListOp">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Basic operations for row/column reductions">
<Heading>Basic operations for row/column reductions</Heading>

<#Include Label="MultMatrixRow">
<#Include Label="MultMatrixRowRight">
<#Include Label="MultMatrixColumn">
<#Include Label="MultMatrixColumnLeft">
<#Include Label="AddMatrixRows">
<#Include Label="AddMatrixRowsRight">
<#Include Label="AddMatrixColumns">
<#Include Label="AddMatrixColumnsLeft">
<#Include Label="SwapMatrixRows">
<#Include Label="SwapMatrixColumns">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Implementing New Vector and Matrix Objects Types">
<Heading>Implementing New Vector and Matrix Objects Types</Heading>

The first step in the design of a new type of vector or matrix objects
is to create a new filter that serves as the
<Ref Attr="ConstructingFilter" Label="for a vector object"/>
of the new objects,
see the sections <Ref Sect="Available Representations of Vector Objects"/>
and <Ref Sect="Available Representations of Matrix Objects"/>
for an overview of such filters that are already available.

<P/>

Here we list those operations for vector and matrix objects
for which no default methods can be installed.
When one implements a new type of vector or matrix objects
then one has to install specific methods at least for these operations,
in order to make the objects behave as described in this chapter.
It is advisable to install specific methods also for other
operations, for performance reasons.
The installations of default methods can be found in the file
<F>lib/matobj.gi</F> of the &GAP; distribution.
There one can check for which operations it makes sense to overload them
for the new type of vector or matrix objects.
Note that the specific methods must be installed with
<Ref Func="InstallTagBasedMethod"/> whenever the default method is installed
with this function.

<P/>

<E>Vector objects</E>

<List>
<Item>
  <Ref Attr="BaseDomain" Label="for a vector object"/>,
</Item>
<Item>
  <Ref Attr="Length" Label="for a vector object"/>,
</Item>
<Item>
  <Ref Oper="\[\]" Label="for a vector object and an integer"/>,
</Item>
<Item>
  <Ref Oper="\[\]\:\=" Label="for a vector object and an integer"/>
  (with consistency checks if the global option <C>check</C> is not set to
  <K>false</K>),
</Item>
<Item>
  <Ref Oper="\&lt;"/> (see <Ref Oper="\&lt;" Label="for two vector objects"/>),
</Item>
<Item>
  <Ref Attr="ConstructingFilter" Label="for a vector object"/>,
</Item>
<Item>
  <Ref Oper="NewVector"/>
  (with consistency checks if the global option <C>check</C> is not set to
  <K>false</K>, install the method with <Ref Func="InstallTagBasedMethod"/>).
</Item>
</List>

<P/>

<E>Matrix objects</E>

<List>
<Item>
  <Ref Attr="BaseDomain" Label="for a matrix object"/>,
</Item>
<Item>
  <Ref Attr="NumberRows" Label="for a matrix object"/>,
</Item>
<Item>
  <Ref Attr="NumberColumns" Label="for a matrix object"/>,
</Item>
<Item>
  <Ref Oper="MatElm"/>,
</Item>
<Item>
  <Ref Oper="SetMatElm"/>
  (with consistency checks if the global option <C>check</C> is not set to
  <K>false</K>),
</Item>
<Item>
  <Ref Oper="\&lt;"/> (see <Ref Oper="\&lt;" Label="for two matrix objects"/>),
</Item>
<Item>
  <Ref Attr="ConstructingFilter" Label="for a matrix object"/>,
</Item>
<Item>
  <Ref Attr="CompatibleVectorFilter" Label="for a matrix object"/>,
</Item>
<Item>
  <Ref Oper="NewMatrix"/>
  (with consistency checks if the global option <C>check</C> is not set to
  <K>false</K>, install the method with <Ref Func="InstallTagBasedMethod"/>).
</Item>
</List>

<P/>

Methods for <Ref Oper="NewVector"/> and
<Ref Oper="NewMatrix"/> must check their arguments for consistency
(do the given filter and base domain fit together,
are the entries compatible with the given base domain,
is the number of matrix entries a multiple of the given number of columns)
except if the global option <C>check</C> is set to <K>false</K>.
(See Chapter <Ref Chap="Options Stack"/> for information about global
options.)
The same holds for methods for operations that modify mutable vector
or matrix objects,
such as <Ref Oper="\[\]\:\=" Label="for a vector object and an integer"/>,
<Ref Oper="SetMatElm"/>, <Ref Oper="CopySubVector"/>,
<Ref Oper="CopySubMatrix"/>,
and for those methods of
<Ref Oper="Vector" Label="for filter, base domain, and list"/> and
<Ref Oper="Matrix" Label="for filter, base domain, list, ncols"/>
that do not delegate to <Ref Oper="NewVector"/> and
<Ref Oper="NewMatrix"/>, respectively.

</Section>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Available Representations of Vector Objects">
<Heading>Available Representations of Vector Objects</Heading>

The following filters define vector objects for which the the functionality
described in this chapter is supported.

<#Include Label="IsGF2VectorRep">
<#Include Label="Is8BitVectorRep">
<#Include Label="IsPlistVectorRep">
<#Include Label="IsZmodnZVectorRep">

</Section>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Available Representations of Matrix Objects">
<Heading>Available Representations of Matrix Objects</Heading>

The following filters define matrix objects for which the the functionality
described in this chapter is supported.

<#Include Label="IsGF2MatrixRep">
<#Include Label="Is8BitMatrixRep">
<#Include Label="IsPlistMatrixRep">
<#Include Label="IsZmodnZMatrixRep">

</Section>

</Chapter>