GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
% This file was created automatically from misc.msk.1% DO NOT EDIT!2\Chapter{Some functions for everyday use}34This chapter contains a number of functions that did not fit in5anywhere else. Some of them might be useful for other people, too, so6they were included here.78%%%%%%%%%%%%%%%%%%%%9\Section{Groups and actions}1011\>OnSubgroups( <subgroup>, <aut> ) F1213For a group $G$ and an automorphism <aut> of $G$,14`OnSubgroups(<subgroup>,<aut>)' is the image of <subgroup> under <aut>151617\beginexample18gap> G:=Group((1,2,3),(2,3));19Group([ (1,2,3), (2,3) ])20gap> alpha:=InnerAutomorphism(G,(1,2,3));21^(1,2,3)22gap> OnSubgroups(Subgroup(G,[(2,3)]),alpha);23Group([ (1,3) ])24\endexample2526\>RepsCClassesGivenOrder( <group>, <order> ) O2728`RepsCClassesGivenOrder( <group>, <order> )' returns all elements of29order <order> up to conjugacy. Note that the representatives are *not*30always the smallest elements of each conjugacy class.313233\beginexample34gap> RepsCClassesGivenOrder(SymmetricGroup(5),2);35[ (4,5), (2,3)(4,5) ]36\endexample3738%%%%%%%%%%%%%%%%%%%%39\Section{Iterators}4041\>CartesianIterator( <tuplelist> ) O4243Returns an iterator for `Cartesian(<tuplelist>)'44454647\>ConcatenationOfIterators( <iterlist> ) F4849`ConcatenationOfIterators(<iterlist>)' returns an iterator which runs50through all iterators in <iterlist>. Note that the returned iterator loops51over the iterators in <iterlist> *sequentially* beginning with the first52one.5354555657\beginexample58gap> it:=Iterator([1,2,3]);;59gap> it2:=CartesianIterator([[9,10],[11]]);;60gap> cit:=ConcatenationOfIterators([it,it2]);;61gap> repeat62> Print(NextIterator(cit),",\c");63> until IsDoneIterator(cit);641,2,3,[ 9, 11 ],[ 10, 11 ],65\endexample6667%%%%%%%%%%%%%%%%%%%%68\Section{Lists and Matrices}6970\>IsListOfIntegers( <list> ) P7172`IsListOfIntegers( <list> )' returns `IsSubset(Integers, <list> )' if <list>73is a dense list and `false' otherwise.74757677\>List2Tuples( <list>, <int> ) O7879If `Size( <list> )' is divisible by <int>, `List2Tuples( <list>,<int>)'80returns a list <list2> of size <int> such that81`Concatenation( <list2> )= <list>' and every element of <list2> has the82same size.838485\beginexample86gap> List2Tuples([1..6],2);87[ [ 1, 2, 3 ], [ 4, 5, 6 ] ]88\endexample8990\>MatTimesTransMat( <mat> ) O9192does the same as `<mat>*TransposedMat( <mat> )' but uses slightly less93space and time for large matrices.94959697\>PartitionByFunctionNF( <list>, <f> ) O9899`PartitionByFunctionNF( <list>, <f> )' partitions the list <list>100according to the values of the function <f> defined on <list>.101If <f> returns `fail' for some element of <list>,102`PartitionByFunctionNF( <list>, <f> )' enters a break loop.103Leaving the break loop with 'return;' is safe because104`PartitionByFunctionNF' treats `fail' as all other results of <f>.105106107108\>PartitionByFunction( <list>, <f> ) O109110`PartitionByFunction( <list>, <f> )' partitions the list <list>111according to the values of the function <f> defined on <list>.112All elements, for which <f> returns `fail' are omitted, so113`PartitionByFunction' does not necessarily return a partition.114If `InfoLevel(InfoRDS)'\index{InfoRDS@{\tt InfoRDS}} is at least 2, the number of115elements for which <f> returns `fail' is shown116(if `fail' is returned at all).117118119\begintt120121gap> PartitionByFunctionNF([-1..5],x->x^2);122[ [ 0 ], [ -1, 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ] ]123gap> test:=function(x)124> if x>0 then return Sqrt(x);125> else return fail;126> fi;127> end;128function( x ) ... end129gap> PartitionByFunction([-1..5],test);130[ [ 1 ], [ 4 ], [ 5 ], [ 2 ], [ 3 ] ]131gap> SetInfoLevel(InfoRDS,2);132gap> PartitionByFunction([-1..5],test);133#I -2-134[ [ 1 ], [ 4 ], [ 5 ], [ 2 ], [ 3 ] ]135gap> PartitionByFunctionNF([-1..5],test);136Error, function returned <fail> called from137...138brk> return;139[ [ 1 ], [ 4 ], [ 5 ], [ 2 ], [ 3 ], [ -1, 0 ] ]140\endtt141142%%%%%%%%%%%%%%%%%%%%143\Section{Cyclotomic numbers}144145\>IsRootOfUnity( <cyc> ) P146147`IsRootOfUnity' tests if a given cyclotomic is actually a root of unity.148149150151\>CoeffList2CyclotomicList( <list>, <root> ) O152153`CoeffList2CyclogomicList( <list>, <root> )' takes a list of integers154<list> and a root of unity <root> and returns a list <list2>, where155<list2[i]=list[i]\* root^(i-1)>.156157158159\>AbssquareInCyclotomics( <list>, <root> ) O160161For a list of integers and a root of unity,162`AbssquareInCyclotomics( <list>, <root> )' returns163the modulus of `Sum(CoeffList2CyclotomicList( <list>, <root> ))'.164165166167\>CycsGivenCoeffSum( <sum>, <root> ) O168169`CycsGivenCoeffSum( <sum>, <root> )' returns all elements of $\Z[ root ]$170such that the coefficient sum is <sum> and all coefficients are171non-negative.172The returned list has the following form:173The cyclotomic numbers are represented by coefficients.174"CoeffList2CyclotomicList" can be used to get the175algebraic number represented by <list>.176The list is partitioned into equivalence classes of elements having the177same modulus.178For each class the modulus is returned.179This means that `CycsGivenCoeffSum' returns a list of pairs where the first180entry of each pair is the square of the modulus of an element of the181second entry. And the second entry is a list of coefficient lists of182cyclotomics in $\Z[ <root> ]$ having the coefficient sum <sum>.183184185\beginexample186gap> CycsGivenCoeffSum(3,E(3));187[ [ 0, [ [ 1, 1, 1 ] ] ],188[ 3, [ [ 0, 1, 2 ], [ 0, 2, 1 ], [ 1, 0, 2 ], [ 1, 2, 0 ], [ 2, 0, 1 ],189[ 2, 1, 0 ] ] ], [ 9, [ [ 0, 0, 3 ], [ 0, 3, 0 ], [ 3, 0, 0 ] ] ] ]190gap> CycsGivenCoeffSum(2,E(2));191[ [ 0, [ [ 1, 1 ] ] ], [ 4, [ [ 0, 2 ], [ 2, 0 ] ] ] ]192\endexample193194%%%%%%%%%%%%%%%%%%%%195\Section{Filters and Categories}196197The following was originally posted at the \GAP\ forum by Thomas198Breuer \cite{BreuersAnswer}.199200Each filter in \GAP\ is either a simple filter or a meet of filters.201For example, `IsInt' and `IsPosRat' are simple filters,202and `IsPosInt' is defined as their meet `IsInt and IsPosRat'.203204Each *simple filter* is of one of the following kinds.2052062071. property:208Such a filter is an operation, the filter value can be computed.209The (unary) methods of this operation must return `true' or `false',210and the return value is stored in the argument,211except if the argument is of a basic data type such as cyclotomic212(including rationals and integers), finite field element, permutation,213or internally represented list --the latter with a few exceptions.214Examples of properties are `IsFinite', `IsAbelian', `IsSSortedList'.2152162. attribute tester:217Such a filter is associated to an operation that has been created218via `DeclareAttribute',219in the sense that the value is `true' if and only if a return value220for (a unary method of) this operation is stored in the argument.221Currently, attribute values are stored in objects in the filter222`IsAttributeStoringRep'.223Examples of attribute testers are `HasSize', `HasCentre',224`HasDerivedSubgroup'.2252262.' property tester:227Such a filter is similar to an attribute tester,228but the associated operation is a property.229So property testers can return `true' also if the argument is not in230the filter `IsAttributeStoringRep'.231Examples of property testers are `HasIsFinite', `HasIsAbelian',232`HasIsSSortedList'.2332343. category or representation:235These filters are not associated to operations, their values cannot236be computed but are set upon creation of an object and should not be237changed later, such that for a filter of this kind, one can rely on238the fact that if the value is `true' then it was `true' already when239the object in question was created.240241The distinction between representation and category is intended to242express dependency on or independence of the way how the object is243stored internally.244For example, `IsPositionalObjectRep', `IsComponentObjectRep', and245`IsInternalRep' are filters of the representation kind;246the idea is that such filters are used in low level methods,247and that higher level methods can be implemented without referring248to these filters.249250Examples of categories are `IsInt', `IsRat', `IsPerm', `IsFFE',251and filters expressing algebraic structures,252such as `IsMagma', `IsMagmaWithOne', `IsAdditiveMagma'.253When one calls such a filter, one can be sure that no computation is254triggered.255For example, whenever a quotient of two integers is formed, the result256is clearly in the filter `IsRat', but the system also stores the value257of `IsInt', i.e., \GAP\ does not support ``unevaluated rationals'' for258which the `IsInt' value is computed on demand and then stored.2592604. other filters:261Some filters do not belong to the above kinds,262they are not associated to operations but they are intended to be263set (or even reset) by the user or by functions also after the creation264of objects.265Examples are `IsQuickPositionList', `CanEasilyTestMembership',266`IsHandledByNiceBasis'.267268Each *meet of filters* can involve computable simple filters (properties,269attribute and property testers) and not computable simple filters270(categories, representations, other filters).271When one calls a meet of two filters then the two filters from which272the meet was formed are evaluated (if necessary).273So a meet of filters is computable only if at least one computable simple274filter is involved.275276\>IsComputableFilter( <filter> ) F277278279280281'IsComputableFilter(<filter>)' returns <true> if a the filter <filter>282is computable. Filters for which 'IsComputableFilter' returns <false>283may be used in 'DeclareOperation'.284285\beginexample286gap> IsComputableFilter( IsFinite );287true288gap> IsComputableFilter( HasSize );289true290gap> IsComputableFilter( HasIsFinite );291true292gap> IsComputableFilter( IsPositionalObjectRep );293false294gap> IsComputableFilter( IsInt );295false296gap> IsComputableFilter( IsQuickPositionList );297false298gap> IsComputableFilter( IsInt and IsPosRat );299false300gap> IsComputableFilter( IsMagma );301false302\endexample303304%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%305%E misc.msk ... end of file.306307308