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

612113 views
1
% This file was created automatically from misc.msk.
2
% DO NOT EDIT!
3
\Chapter{Some functions for everyday use}
4
5
This chapter contains a number of functions that did not fit in
6
anywhere else. Some of them might be useful for other people, too, so
7
they were included here.
8
9
%%%%%%%%%%%%%%%%%%%%
10
\Section{Groups and actions}
11
12
\>OnSubgroups( <subgroup>, <aut> ) F
13
14
For a group $G$ and an automorphism <aut> of $G$,
15
`OnSubgroups(<subgroup>,<aut>)' is the image of <subgroup> under <aut>
16
17
18
\beginexample
19
gap> G:=Group((1,2,3),(2,3));
20
Group([ (1,2,3), (2,3) ])
21
gap> alpha:=InnerAutomorphism(G,(1,2,3));
22
^(1,2,3)
23
gap> OnSubgroups(Subgroup(G,[(2,3)]),alpha);
24
Group([ (1,3) ])
25
\endexample
26
27
\>RepsCClassesGivenOrder( <group>, <order> ) O
28
29
`RepsCClassesGivenOrder( <group>, <order> )' returns all elements of
30
order <order> up to conjugacy. Note that the representatives are *not*
31
always the smallest elements of each conjugacy class.
32
33
34
\beginexample
35
gap> RepsCClassesGivenOrder(SymmetricGroup(5),2);
36
[ (4,5), (2,3)(4,5) ]
37
\endexample
38
39
%%%%%%%%%%%%%%%%%%%%
40
\Section{Iterators}
41
42
\>CartesianIterator( <tuplelist> ) O
43
44
Returns an iterator for `Cartesian(<tuplelist>)'
45
46
47
48
\>ConcatenationOfIterators( <iterlist> ) F
49
50
`ConcatenationOfIterators(<iterlist>)' returns an iterator which runs
51
through all iterators in <iterlist>. Note that the returned iterator loops
52
over the iterators in <iterlist> *sequentially* beginning with the first
53
one.
54
55
56
57
58
\beginexample
59
gap> it:=Iterator([1,2,3]);;
60
gap> it2:=CartesianIterator([[9,10],[11]]);;
61
gap> cit:=ConcatenationOfIterators([it,it2]);;
62
gap> repeat
63
> Print(NextIterator(cit),",\c");
64
> until IsDoneIterator(cit);
65
1,2,3,[ 9, 11 ],[ 10, 11 ],
66
\endexample
67
68
%%%%%%%%%%%%%%%%%%%%
69
\Section{Lists and Matrices}
70
71
\>IsListOfIntegers( <list> ) P
72
73
`IsListOfIntegers( <list> )' returns `IsSubset(Integers, <list> )' if <list>
74
is a dense list and `false' otherwise.
75
76
77
78
\>List2Tuples( <list>, <int> ) O
79
80
If `Size( <list> )' is divisible by <int>, `List2Tuples( <list>,<int>)'
81
returns a list <list2> of size <int> such that
82
`Concatenation( <list2> )= <list>' and every element of <list2> has the
83
same size.
84
85
86
\beginexample
87
gap> List2Tuples([1..6],2);
88
[ [ 1, 2, 3 ], [ 4, 5, 6 ] ]
89
\endexample
90
91
\>MatTimesTransMat( <mat> ) O
92
93
does the same as `<mat>*TransposedMat( <mat> )' but uses slightly less
94
space and time for large matrices.
95
96
97
98
\>PartitionByFunctionNF( <list>, <f> ) O
99
100
`PartitionByFunctionNF( <list>, <f> )' partitions the list <list>
101
according to the values of the function <f> defined on <list>.
102
If <f> returns `fail' for some element of <list>,
103
`PartitionByFunctionNF( <list>, <f> )' enters a break loop.
104
Leaving the break loop with 'return;' is safe because
105
`PartitionByFunctionNF' treats `fail' as all other results of <f>.
106
107
108
109
\>PartitionByFunction( <list>, <f> ) O
110
111
`PartitionByFunction( <list>, <f> )' partitions the list <list>
112
according to the values of the function <f> defined on <list>.
113
All elements, for which <f> returns `fail' are omitted, so
114
`PartitionByFunction' does not necessarily return a partition.
115
If `InfoLevel(InfoRDS)'\index{InfoRDS@{\tt InfoRDS}} is at least 2, the number of
116
elements for which <f> returns `fail' is shown
117
(if `fail' is returned at all).
118
119
120
\begintt
121
122
gap> PartitionByFunctionNF([-1..5],x->x^2);
123
[ [ 0 ], [ -1, 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ] ]
124
gap> test:=function(x)
125
> if x>0 then return Sqrt(x);
126
> else return fail;
127
> fi;
128
> end;
129
function( x ) ... end
130
gap> PartitionByFunction([-1..5],test);
131
[ [ 1 ], [ 4 ], [ 5 ], [ 2 ], [ 3 ] ]
132
gap> SetInfoLevel(InfoRDS,2);
133
gap> PartitionByFunction([-1..5],test);
134
#I -2-
135
[ [ 1 ], [ 4 ], [ 5 ], [ 2 ], [ 3 ] ]
136
gap> PartitionByFunctionNF([-1..5],test);
137
Error, function returned <fail> called from
138
...
139
brk> return;
140
[ [ 1 ], [ 4 ], [ 5 ], [ 2 ], [ 3 ], [ -1, 0 ] ]
141
\endtt
142
143
%%%%%%%%%%%%%%%%%%%%
144
\Section{Cyclotomic numbers}
145
146
\>IsRootOfUnity( <cyc> ) P
147
148
`IsRootOfUnity' tests if a given cyclotomic is actually a root of unity.
149
150
151
152
\>CoeffList2CyclotomicList( <list>, <root> ) O
153
154
`CoeffList2CyclogomicList( <list>, <root> )' takes a list of integers
155
<list> and a root of unity <root> and returns a list <list2>, where
156
<list2[i]=list[i]\* root^(i-1)>.
157
158
159
160
\>AbssquareInCyclotomics( <list>, <root> ) O
161
162
For a list of integers and a root of unity,
163
`AbssquareInCyclotomics( <list>, <root> )' returns
164
the modulus of `Sum(CoeffList2CyclotomicList( <list>, <root> ))'.
165
166
167
168
\>CycsGivenCoeffSum( <sum>, <root> ) O
169
170
`CycsGivenCoeffSum( <sum>, <root> )' returns all elements of $\Z[ root ]$
171
such that the coefficient sum is <sum> and all coefficients are
172
non-negative.
173
The returned list has the following form:
174
The cyclotomic numbers are represented by coefficients.
175
"CoeffList2CyclotomicList" can be used to get the
176
algebraic number represented by <list>.
177
The list is partitioned into equivalence classes of elements having the
178
same modulus.
179
For each class the modulus is returned.
180
This means that `CycsGivenCoeffSum' returns a list of pairs where the first
181
entry of each pair is the square of the modulus of an element of the
182
second entry. And the second entry is a list of coefficient lists of
183
cyclotomics in $\Z[ <root> ]$ having the coefficient sum <sum>.
184
185
186
\beginexample
187
gap> CycsGivenCoeffSum(3,E(3));
188
[ [ 0, [ [ 1, 1, 1 ] ] ],
189
[ 3, [ [ 0, 1, 2 ], [ 0, 2, 1 ], [ 1, 0, 2 ], [ 1, 2, 0 ], [ 2, 0, 1 ],
190
[ 2, 1, 0 ] ] ], [ 9, [ [ 0, 0, 3 ], [ 0, 3, 0 ], [ 3, 0, 0 ] ] ] ]
191
gap> CycsGivenCoeffSum(2,E(2));
192
[ [ 0, [ [ 1, 1 ] ] ], [ 4, [ [ 0, 2 ], [ 2, 0 ] ] ] ]
193
\endexample
194
195
%%%%%%%%%%%%%%%%%%%%
196
\Section{Filters and Categories}
197
198
The following was originally posted at the \GAP\ forum by Thomas
199
Breuer \cite{BreuersAnswer}.
200
201
Each filter in \GAP\ is either a simple filter or a meet of filters.
202
For example, `IsInt' and `IsPosRat' are simple filters,
203
and `IsPosInt' is defined as their meet `IsInt and IsPosRat'.
204
205
Each *simple filter* is of one of the following kinds.
206
207
208
1. property:
209
Such a filter is an operation, the filter value can be computed.
210
The (unary) methods of this operation must return `true' or `false',
211
and the return value is stored in the argument,
212
except if the argument is of a basic data type such as cyclotomic
213
(including rationals and integers), finite field element, permutation,
214
or internally represented list --the latter with a few exceptions.
215
Examples of properties are `IsFinite', `IsAbelian', `IsSSortedList'.
216
217
2. attribute tester:
218
Such a filter is associated to an operation that has been created
219
via `DeclareAttribute',
220
in the sense that the value is `true' if and only if a return value
221
for (a unary method of) this operation is stored in the argument.
222
Currently, attribute values are stored in objects in the filter
223
`IsAttributeStoringRep'.
224
Examples of attribute testers are `HasSize', `HasCentre',
225
`HasDerivedSubgroup'.
226
227
2.' property tester:
228
Such a filter is similar to an attribute tester,
229
but the associated operation is a property.
230
So property testers can return `true' also if the argument is not in
231
the filter `IsAttributeStoringRep'.
232
Examples of property testers are `HasIsFinite', `HasIsAbelian',
233
`HasIsSSortedList'.
234
235
3. category or representation:
236
These filters are not associated to operations, their values cannot
237
be computed but are set upon creation of an object and should not be
238
changed later, such that for a filter of this kind, one can rely on
239
the fact that if the value is `true' then it was `true' already when
240
the object in question was created.
241
242
The distinction between representation and category is intended to
243
express dependency on or independence of the way how the object is
244
stored internally.
245
For example, `IsPositionalObjectRep', `IsComponentObjectRep', and
246
`IsInternalRep' are filters of the representation kind;
247
the idea is that such filters are used in low level methods,
248
and that higher level methods can be implemented without referring
249
to these filters.
250
251
Examples of categories are `IsInt', `IsRat', `IsPerm', `IsFFE',
252
and filters expressing algebraic structures,
253
such as `IsMagma', `IsMagmaWithOne', `IsAdditiveMagma'.
254
When one calls such a filter, one can be sure that no computation is
255
triggered.
256
For example, whenever a quotient of two integers is formed, the result
257
is clearly in the filter `IsRat', but the system also stores the value
258
of `IsInt', i.e., \GAP\ does not support ``unevaluated rationals'' for
259
which the `IsInt' value is computed on demand and then stored.
260
261
4. other filters:
262
Some filters do not belong to the above kinds,
263
they are not associated to operations but they are intended to be
264
set (or even reset) by the user or by functions also after the creation
265
of objects.
266
Examples are `IsQuickPositionList', `CanEasilyTestMembership',
267
`IsHandledByNiceBasis'.
268
269
Each *meet of filters* can involve computable simple filters (properties,
270
attribute and property testers) and not computable simple filters
271
(categories, representations, other filters).
272
When one calls a meet of two filters then the two filters from which
273
the meet was formed are evaluated (if necessary).
274
So a meet of filters is computable only if at least one computable simple
275
filter is involved.
276
277
\>IsComputableFilter( <filter> ) F
278
279
280
281
282
'IsComputableFilter(<filter>)' returns <true> if a the filter <filter>
283
is computable. Filters for which 'IsComputableFilter' returns <false>
284
may be used in 'DeclareOperation'.
285
286
\beginexample
287
gap> IsComputableFilter( IsFinite );
288
true
289
gap> IsComputableFilter( HasSize );
290
true
291
gap> IsComputableFilter( HasIsFinite );
292
true
293
gap> IsComputableFilter( IsPositionalObjectRep );
294
false
295
gap> IsComputableFilter( IsInt );
296
false
297
gap> IsComputableFilter( IsQuickPositionList );
298
false
299
gap> IsComputableFilter( IsInt and IsPosRat );
300
false
301
gap> IsComputableFilter( IsMagma );
302
false
303
\endexample
304
305
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
306
%E misc.msk ... end of file.
307
308