File: autoops.gi

package info (click to toggle)
gap-autpgrp 1.5-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 560 kB
  • ctags: 19
  • sloc: makefile: 107; sh: 9
file content (252 lines) | stat: -rw-r--r-- 7,083 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
#############################################################################
##
#W  autoops.gi               AutPGrp package                     Bettina Eick
##
#H  @(#)$Id: autoops.gi,v 1.5 2003/08/18 12:10:28 gap Exp $
##
Revision.("autpgrp/gap/autoops_gi") :=
    "@(#)$Id: autoops.gi,v 1.5 2003/08/18 12:10:28 gap Exp $";


#############################################################################
##
#F PGAutomorphism( <G>, <gens>, <imgs> )
##
InstallMethod( PGAutomorphism,
   "for p-groups", true, [IsPGroup, IsList, IsList ], 0,

function( G, gens, imgs )
    local filter, type, r, p, pcgs, base, pcgsimgs, baseimgs, def, d;

    # cache the default type in the group
    if not IsBound( G!.PGAutomType ) then
        filter := IsPGAutomorphism and IsBijective;
        type   := TypeOfDefaultGeneralMapping( G, G, filter );
        G!.PGAutomType := type;
    else
        type := G!.PGAutomType;
    fi;

    # get images correct
    r := RankPGroup( G );
    p := PrimePGroup( G );
    pcgs := Pcgs( G );
    base := pcgs{[1..r]};
    
    if gens = pcgs then
        pcgsimgs := imgs;  
        baseimgs := imgs{[1..r]};
    elif gens = base then
        baseimgs := ShallowCopy( imgs );
        pcgsimgs := ShallowCopy( imgs );
        for d in G!.definitions do
            if not IsNegRat( d ) then
                Add( pcgsimgs, SubstituteDef( d, pcgsimgs, p ) );
            fi;
        od;
    else
        Print("# W computing pcgs in PGAutomorphism \n");
        pcgsimgs := CanonicalPcgsByGeneratorsWithImages( pcgs, gens, imgs );
        baseimgs := pcgsimgs{[1..r]};
    fi;

    # create homomorphism
    return Objectify( type, rec( pcgs := pcgs, pcgsimgs := pcgsimgs,
                                 base := base, baseimgs := baseimgs ) );
end);

#############################################################################
##
#F IdentityPGAutomorphism( <G> )
##
InstallGlobalFunction( IdentityPGAutomorphism, function( G )
    return PGAutomorphism( G, Pcgs(G), AsList(Pcgs(G)) );
end );

#############################################################################
##
#F PrintObj(auto)
##
InstallMethod( PrintObj,
               "for group automorphisms",
               true,
               [IsPGAutomorphism],
               SUM_FLAGS,
function( auto )
    if IsBound( auto!.mat ) then 
        Print("Aut + Mat: ",auto!.pcgsimgs);
    else
        Print("Aut: ",auto!.pcgsimgs);
    fi;
end);

#############################################################################
##
#F ViewObj(auto)
##
InstallMethod( ViewObj,
               "for group automorphisms",
               true,
               [IsPGAutomorphism],
               SUM_FLAGS,
function( auto )
    if IsBound( auto!.mat ) then 
        Print("Aut + Mat: ",auto!.pcgsimgs);
    else
        Print("Aut: ",auto!.pcgsimgs);
    fi;
end);

#############################################################################
##
#F \= 
##
InstallMethod( \=,
               "for group automorphisms",
               IsIdenticalObj,
               [IsPGAutomorphism, IsPGAutomorphism],
               0,
function( auto1, auto2 )
    return auto1!.base = auto2!.base and auto1!.baseimgs = auto2!.baseimgs;
end);

#############################################################################
##
#F ImagesRepresentative( auto, g )
##
InstallMethod( ImagesRepresentative,
               "for group automorphisms",
               true,
               [IsPGAutomorphism, IsObject],
               0,
function( auto, g )
    return MappedPcElement( g, auto!.pcgs, auto!.pcgsimgs );
end ); 

#############################################################################
##
#F PGMult( auto1, auto2 )
##
InstallMethod( PGMult, true, [IsPGAutomorphism, IsPGAutomorphism], 0,
function( auto1, auto2 )
    local new, aut;

    # 1. version
    new := List( auto1!.pcgsimgs, x -> ImagesRepresentative( auto2, x ) );
    if IsBound( auto1!.mat ) and IsBound( auto2!.mat ) then
	aut := PGAutomorphism( Source(auto1), auto1!.pcgs, new );
        aut!.mat := auto1!.mat * auto2!.mat;
    else
	aut := PGAutomorphism( Source(auto1), auto1!.pcgs, new );
    fi;
    return aut;

    # 2. version
    new  := List( auto2!.baseimgs, x -> ImagesRepresentative( auto1, x ) );
    return PGAutomorphism( Source(auto2), auto2!.base, new );
end );

#############################################################################
##
#F CompositionMapping2( auto1, auto2 )
##
InstallMethod( CompositionMapping2,
               "for group automorphisms",
               true,
               [IsPGAutomorphism, IsPGAutomorphism],
               0,
function( auto2, auto1 )
    return PGMult( auto1, auto2 );
end );
               
#############################################################################
##
#F PGMultList( autl ) 
##
InstallMethod( PGMultList, true, [IsList], 0,
function( autl )
    local l, r, new;
    if Length( autl ) = 1 then return autl[1]; fi;
    if Length( autl ) = 2 then return PGMult(autl[1],autl[2]); fi;
    l := Length( autl );
    r := QuoInt( l, 2 );
    new := List( [1..r], x -> PGMult( autl[2*x-1], autl[2*x] ));
    if not IsInt( l/2 ) then Add( new, autl[l] ); fi;
    return PGMultList( new );
end );

#############################################################################
##
#F PGPower( n, aut )
##
InstallMethod( PGPower, true, [IsInt, IsPGAutomorphism], 0,
function( n, aut )
    local c, l, i, j, new;

    if n <= 0 then return fail; fi;
    if n = 1 then return aut; fi;
    c := CoefficientsQadic( n, 2 );

    # create power list, if necessary 
    if not IsBound( aut!.power ) then aut!.power := []; fi;

    # add powers, if necessary
    l := Length( aut!.power );
    if l = 0 then
        new := aut;
    else
        new := aut!.power[l];
    fi;
    for i in [l+1..Length(c)-1] do
        new := PGMult( new, new );
        Add( aut!.power, new );
    od; 

    # multiply powers together
    if c[1] = 1 then
        new := [aut];
    else 
        new := [];
    fi;
    for i in [2..Length(c)] do
        if c[i] = 1 then
            Add( new, aut!.power[i-1] );
        fi;
    od;
    return PGMultList( new );
end );

#############################################################################
##
#F PGInverse( aut )
##
InstallMethod( PGInverse, true, [IsPGAutomorphism], 0,
function( aut )
    local new, inv;
    if not IsBound( aut!.inv ) then 
        new := CanonicalPcgsByGeneratorsWithImages( 
                aut!.pcgs, aut!.pcgsimgs, aut!.pcgs);
        inv := PGAutomorphism( Source( aut ), aut!.pcgs, new[2] );
    else 
        inv := aut!.inv;
    fi;

    if IsBound( aut!.mat ) and not IsBound( inv!.mat) then
        inv!.mat := aut!.mat^-1;
    fi;

    aut!.inv := inv;
    return aut!.inv;
end );

#############################################################################
##
#F InverseGeneralMapping(auto)
##
InstallOtherMethod( InverseGeneralMapping,
               "for group automorphism",
               true,
               [IsPGAutomorphism],
               SUM_FLAGS,
function( auto ) return PGInverse( auto ); end );