File: iterator.xml

package info (click to toggle)
gap-utils 0.93-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 1,504 kB
  • sloc: xml: 2,167; javascript: 155; makefile: 105
file content (172 lines) | stat: -rw-r--r-- 5,333 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
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
<!-- ------------------------------------------------------------------- -->
<!--                                                                     -->
<!--  iterator.xml          Utils documentation                          -->
<!--                                                                     -->
<!--  Copyright (C) 2015-2019, The GAP Group                             --> 
<!--                                                                     -->
<!-- ------------------------------------------------------------------- -->

<?xml version="1.0" encoding="UTF-8"?>

<Chapter Label="chap-iterator">
<Heading>Iterators</Heading>

<Section Label="sec-group-iters">
<Heading>Some iterators for groups and their isomorphisms</Heading>

<Index>Iterators</Index>
The motivation for adding these operations is partly to give a simple example 
of an iterator for a list that does not yet exist, and need not be created.
<P/>

<ManSection>
   <Oper Name="AllIsomorphismsIterator"
         Arg="G H" />
   <Oper Name="AllIsomorphismsNumber"
         Arg="G H" />
   <Oper Name="AllIsomorphisms"
         Arg="G H" />
<Description>
The main &GAP; library contains functions producing complete lists of 
group homomorphisms such as <C>AllHomomorphisms</C>; <C>AllEndomorphisms</C> 
and <C>AllAutomorphisms</C>. 
Here we add the missing <C>AllIsomorphisms(G,H)</C> for a list of isomorphisms 
from <M>G</M> to <M>H</M>. 
The method is simple -- find one isomorphism <M>G \to H</M> and compose this 
with all the automorphisms of <M>G</M>. 
In all these cases it may not be desirable to construct a list of 
homomorphisms, but just implement an iterator, and that is what is done here. 
The operation <C>AllIsomorphismsNumber</C> returns the number of isomorphisms 
iterated over (this is, of course, just the order of the automorphisms group). 
The operation <C>AllIsomorphisms</C> produces the list or isomorphisms.
<P/> 
</Description>
</ManSection>
<Example>
<![CDATA[
gap> G := SmallGroup( 6,1);; 
gap> iter := AllIsomorphismsIterator( G, s3 );;
gap> NextIterator( iter );
[ f1, f2 ] -> [ (6,7), (5,6,7) ]
gap> n := AllIsomorphismsNumber( G, s3 );
6
gap> AllIsomorphisms( G, s3 );
[ [ f1, f2 ] -> [ (6,7), (5,6,7) ], [ f1, f2 ] -> [ (5,7), (5,6,7) ], 
  [ f1, f2 ] -> [ (5,6), (5,7,6) ], [ f1, f2 ] -> [ (6,7), (5,7,6) ], 
  [ f1, f2 ] -> [ (5,7), (5,7,6) ], [ f1, f2 ] -> [ (5,6), (5,6,7) ] ]
gap> iter := AllIsomorphismsIterator( G, s3 );;
gap> for h in iter do Print( ImageElm( h, G.1 ) = (6,7), ", " ); od;
true, false, false, true, false, false,
]]>
</Example>

<ManSection>
   <Oper Name="AllSubgroupsIterator"
         Arg="G" />
<Description> 
The manual entry for the operation <C>AllSubgroups</C> states that it is only 
intended to be used on small examples in a classroom situation. 
Access to all subgroups was required by the <Package>XMod</Package> package, 
so this iterator was introduced here. 
It used the operations <C>LatticeSubgroups(G)</C> 
and <C>ConjugacyClassesSubgroups(lat)</C>, and then iterates 
over the entries in these classes. 
<P/> 
</Description>
</ManSection>
<Example>
<![CDATA[
gap> c3c3 := Group( (1,2,3), (4,5,6) );; 
gap> iter := AllSubgroupsIterator( c3c3 );
<iterator>
gap> while not IsDoneIterator(iter) do Print(NextIterator(iter),"\n"); od;
Group( () )
Group( [ (4,5,6) ] )
Group( [ (1,2,3) ] )
Group( [ (1,2,3)(4,5,6) ] )
Group( [ (1,3,2)(4,5,6) ] )
Group( [ (4,5,6), (1,2,3) ] )
]]>
</Example>

</Section> 


<Section Label="sec-iter-ops">
<Heading>Operations on iterators</Heading>

This section considers ways of producing an iterator 
from one or more iterators. 
It may be that operations equivalent to these are available elsewhere 
in the library -- if so, the ones here can be removed in due course. 

<ManSection>
   <Oper Name="CartesianIterator"
         Arg="iter1 iter2" />
<Description> 
This iterator returns all pairs <M>[x,y]</M> where <M>x</M> is the output 
of a first iterator and <M>y</M> is the output of a second iterator. 
<P/> 
</Description>
</ManSection>
<Example>
<![CDATA[
gap> it1 := Iterator( [ 1, 2, 3 ] );;
gap> it2 := Iterator( [ 4, 5, 6 ] );;
gap> iter := CartesianIterator( it1, it2 );;
gap> while not IsDoneIterator(iter) do Print(NextIterator(iter),"\n"); od;
[ 1, 4 ]
[ 1, 5 ]
[ 1, 6 ]
[ 2, 4 ]
[ 2, 5 ]
[ 2, 6 ]
[ 3, 4 ]
[ 3, 5 ]
[ 3, 6 ]
]]>
</Example>

<ManSection>
   <Oper Name="UnorderedPairsIterator"
         Arg="iter" />
<Description> 
This operation returns pairs <M>[x,y]</M> where <M>x,y</M> are output 
from a given iterator <C>iter</C>.  
Unlike the output from <C>CartesianIterator(iter,iter)</C>, 
unordered pairs are returned. 
In the case <M>L = [1,2,3,\ldots]</M> the pairs are ordered as 
<M>[1,1],[1,2],[2,2],[1,3],[2,3],[3,3],\ldots</M>. 
<P/> 
</Description>
</ManSection>
<Example>
<![CDATA[
gap> L := [6,7,8,9];;
gap> iterL := IteratorList( L );; 
gap> pairsL := UnorderedPairsIterator( iterL );;                              
gap> while not IsDoneIterator(pairsL) do Print(NextIterator(pairsL),"\n"); od;
[ 6, 6 ]
[ 6, 7 ]
[ 7, 7 ]
[ 6, 8 ]
[ 7, 8 ]
[ 8, 8 ]
[ 6, 9 ]
[ 7, 9 ]
[ 8, 9 ]
[ 9, 9 ]
gap> iter4 := IteratorList( [ 4 ] );
<iterator>
gap> pairs4 := UnorderedPairsIterator(iter4);
<iterator>
gap> NextIterator( pairs4 );
[ 4, 4 ]
gap> IsDoneIterator( pairs4 );
true
]]>
</Example>

</Section> 

</Chapter>