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

563645 views
1
# include <stdio.h>
2
extern char wrd,nt,isbase,inf[],outf1[],outf2[],fixed[];
3
extern int perm[],sv[],cp[],actgen[],orb[],
4
base[],lorb[],order[],pno[], *pptr[],*svptr[],
5
mp,mb,mnpt;
6
extern int psp,svsp;
7
int npt;
8
FILE *fopen(),*ip,*op;
9
10
/* The data structures in this program are similar to most permutation group
11
programs. Permutations are numbered 0,1,2,3,... (where 2x+1 is usually the
12
inverse of 2x) and stored in the array perm. Perm no x is pointed to by
13
pptr[x]. npt=no. of points. Usually pptr[i][npt+1] gives the number of the
14
group in the stabilizer chain in which the perm lies. So this no is i if the
15
perm fixes the first i-1 base points. nb=no of base points.
16
The base and the lengths of the orbits in the stab chain are stored in base
17
and lorb.
18
Schreier vectors are stored in sv, and pointed to by svptr[i], i=1,..,nb.
19
pno is a list of *pno (=pno[0]) perm nos.
20
cp is a similar list of length *cp, but it is used to represent the product
21
of the perms cp[1]cp[2]..cp[*cp]. This product can be evaluated by the
22
procedure image in permfns.c
23
*/
24
int
25
gpprog (void)
26
{ int i,j,k,l,m,n,nperms,nb,jobt,np2,seek,cord,ocord,given,ordknown,trivrel,
27
lsv,u,v,w,x,y,z,mxp,mnb,bpt,bno,id;
28
int quot;
29
float grporder;
30
31
if ((ip=fopen(inf,"r"))== 0)
32
{ fprintf(stderr,"Cannot open file %s\n",inf); return(-1); }
33
fscanf(ip,"%d%d%d%d",&npt,&nperms,&nb,&jobt);
34
if (npt>mnpt) { fprintf(stderr,"npt too big. Increase NPT.\n"); return(-1); }
35
if (jobt>0) { fprintf(stderr,"Wrong input format.\n"); return(-1); }
36
quot=psp/(npt+1); if (quot>mp) quot=mp; mxp=quot;
37
quot=svsp/npt; if (quot>mb) quot=mb; mnb=quot; if (mnb>=npt) mnb=npt-1;
38
if (nb>mnb)
39
{ fprintf(stderr,"nb to big. Increase SVSP (or MB).\n"); return(-1); }
40
/* pptr[i] is the i th permutation, svptr[i] is the i the Schreier vector. */
41
for (i=0;i<mxp;i++) pptr[i]=perm+i*(npt+1)-1;
42
for (i=1;i<=mnb;i++) svptr[i]=sv+(i-1)*npt-1;
43
44
/* Next we read any base points and orbit lengths */
45
if (nb!=0)
46
{ for (i=1;i<=npt;i++) orb[i]=0;
47
for (i=1;i<=nb;i++)
48
{ fscanf(ip,"%d",base+i); if (orb[base[i]]!=0)
49
{ fprintf(stderr,"Repeated base element.\n"); return(-1); }
50
orb[base[i]]=1;
51
}
52
}
53
if (jobt<0)
54
{ jobt= -jobt; if (jobt>nb) {fprintf(stderr,"jobt too big.\n"); return(-1); }
55
seek=jobt; given=jobt; ordknown=1;
56
for (i=1;i<=jobt;i++) fscanf(ip,"%d",order+i);
57
}
58
else ordknown=0;
59
60
/* Now we read the generating permutations */
61
np2=2*nperms-2;
62
for (i=0;i<=np2;i+=2)
63
{ k=i/2 +1; j=readperm(pptr[i]);
64
if (j==2)
65
{ fprintf(stderr,"Generator no %d is not a permutation.\n",k); return(-1); }
66
if (j==1)
67
{ fprintf(stderr,"Generator no %d is the identity.\n",k);
68
if (nt) return(-1);
69
nperms-=1; np2-=2; i-=2;
70
}
71
else
72
{ invert(pptr[i],pptr[i+1]); actgen[i]=1; x=1;
73
for (z=base[x];x<=nb && pptr[i][z]==z;z=base[x]) x++;
74
pptr[i][npt+1]=x;
75
if (x>nb)
76
{ if (isbase)
77
{ fprintf(stderr,"Given base is not a base!\n"); return(-1);}
78
nb++; for (z=1;pptr[i][z]==z;z++); base[nb]=z;
79
printf("New base element no %d is %d.\n",nb,z);
80
}
81
if (x==1) printf("Generator no %d moves first base point.\n",k);
82
else printf("Generator no %d fixes first %d base point(s).\n",k,x-1);
83
}
84
if (nperms==0) { fprintf(stderr,"Trivial group!\n"); return(-1); }
85
}
86
fclose(ip);
87
88
if (wrd) {op=fopen(outf2,"w"); fprintf(op,"%4d\n",nperms); }
89
bno=nb; for (i=0;i<=mnb;i++) lorb[i]=0;
90
91
/* Now the main algorithm begins */
92
loop:
93
*pno=0; if (ordknown) ocord= (bno==nb) ? 1 : order[bno+1];
94
/* We make a list of the perm nos that fix the first bno-1 base pts */
95
for (i=0;i<=np2;i+=2)
96
{ if (pptr[i][npt+1]>=bno && actgen[i]<=bno)
97
{ (*pno)++; pno[*pno]=i; }
98
}
99
lorb[bno]=orbitsv(base[bno],svptr[bno],0);
100
if (ordknown)
101
{ cord= (bno>=given) ? ocord*lorb[bno] : lorb[bno];
102
if (bno==seek && cord==order[bno])
103
{ seek--; printf("Order is now as given for bno = %d.\n",bno);
104
bno--; if (bno==0) goto foundorder; goto loop;
105
}
106
}
107
/* Now we start generating the Schreier generators that fix the firat bno
108
base points, test them for membership, and add them as new generators
109
if necessary.
110
*/
111
if (*pno!=0)
112
{ nperms++; np2+=2; y=np2+1;
113
if (y>=mxp)
114
{fprintf(stderr,"Out of space. Increase PSP (or MP).\n"); return(-1); }
115
for (i=1;i<=npt;i++) fixed[i]=0;
116
for (i=1;i<bno;i++)
117
{ u=base[i]; fixed[u]=1; pptr[np2][u]=u; pptr[y][u]=u; }
118
for (i=1;i<=lorb[bno];i++)
119
{ *cp=0; addsv(orb[i],svptr[bno]);
120
for (w=1,x= *cp;w<=x;w++,x--)
121
{ if (w==x) cp[w]-=1; else {u=cp[w]; cp[w]=cp[x]-1; cp[x]=u-1;}}
122
lsv= *cp;
123
for (j=1;j<=*pno;j++)
124
{ *cp=lsv; u=pno[j]+1;
125
trivrel = (*cp>0) ? cp[*cp]==(u-1) : 0;
126
if (trivrel==0)
127
{ (*cp)++; cp[*cp]=u; id=0;
128
for (l=bno;l<=nb;l++) fixed[base[l]]=0;
129
for (l=bno;l<=nb;l++)
130
{ v=base[l]; u=image(v);
131
if (svptr[l][u]==0) goto newgen;
132
addsv(u,svptr[l]); pptr[np2][v]=v; pptr[y][v]=v; fixed[v]=1;
133
}
134
l=nb+1; id=1;
135
newgen: if (isbase==0)
136
for (k=1;k<=npt;k++)
137
{ if (fixed[k]==0)
138
{ u=image(k); pptr[np2][k]=u; pptr[y][u]=k;
139
if (id && k!=u)
140
{ id=0; nb++;
141
if (nb>mnb) { fprintf(stderr,"nb to big. Increase SVSP (or MB).\n"); return(-1); }
142
base[nb]=k;
143
printf("New base point no %d is %d.\n",nb,k);
144
}
145
}
146
}
147
if (id==0)
148
{ pptr[np2][npt+1]=l; actgen[np2]=bno+1;
149
if (isbase) for (k=1;k<=npt;k++)
150
{ u=image(k); pptr[np2][k]=u; pptr[y][u]=k;}
151
printf("New generator no %d, fixing first %d base pts is:\n",
152
nperms,l-1);
153
for (m=1;m<=*cp;m++)
154
{ z=cp[m]; y=z/2; x= (z==2*y) ? y+1 : -(y+1);
155
printf("%3d",x); if (m== *cp) printf("\n"); else printf("*");
156
}
157
if (wrd)
158
{for (m=0;m<=*cp;m++) fprintf(op,"%4d",cp[m]);fprintf(op,"\n");}
159
bno=l; goto loop;
160
}
161
}
162
}
163
}
164
nperms--; np2-=2;
165
}
166
if (ordknown && bno>given) order[bno]=cord;
167
bno--;
168
169
foundorder:
170
if (bno==0)
171
{ printf("The order of the group is:\n");
172
for (i=1;i<=nb;i++)
173
{ printf("%3d",lorb[i]);
174
if (i==nb) printf(" =\n"); else printf("*");
175
}
176
grporder=1; for (i=1;i<=nb;i++) grporder *= lorb[i];
177
printf("%g\n",grporder);
178
}
179
else goto loop;
180
if (wrd) { fprintf(op,"%d\n",-1); fclose(op); }
181
182
/* Now we output the generating perms and Schreier vectors */
183
op=fopen(outf1,"w");
184
fprintf(op,"%4d%4d%4d%4d\n",npt,nperms,nb,1);
185
printbaselo(nb,base,lorb); *pno=0;
186
for (i=1;i<=nperms;i++) {(*pno)++; pno[*pno]=2*(i-1);}
187
printpsv(nb,pno,svptr);
188
fclose(op); return(0);
189
}
190
191