CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418384
1
#include "defs.h"
2
3
extern char inf0[],inf1[],inf2[],inf3[],outf1[],outf2[],outf3[],temp1[],temp2[],
4
ofstr[],ngn[],expg,exph,cr,dcr,hg,triv,cong;
5
extern int trsp,trptr;
6
extern int nfuse,tree[],perm[],gorb[],lorbg[],lorbh[],base[],
7
fpt[],bpt[],coh_index[],*cp[],*trad[],*sv[],
8
*tailad[],**cpad[],**svgptr[],**svhptr[],
9
npt,**lcp,**ucp,*stop,*pst,*pend,nb,fnt,lnt,
10
ind,coind,oind,cind,bno,pt,**expp,npg;
11
extern FILE *ip,*op;
12
13
/* The basic aim of this part of the program is to compute permutations of G
14
as permutations on the left cosets of H. This is used to compute double
15
coset reps if required.
16
*/
17
int
18
cnprg2 (void)
19
{ int i,j,k,l,m,n,ncp,pno,mexh,lorb,ndcr,nntb,*orb,rep,*q,**p,**conp,
20
*len,*orbptr,*cperm,flct,inch;
21
char ngth,fuse; int c;
22
if (exph)
23
{ mexh= (pend-pst)/npt; lcp=cp; j=0;
24
for (i=1;i<=lnt;i++) j+=(lorbh[i]-1);
25
if (j<mexh) for (i=1;i<=lnt;i++)
26
{ for (j=1;j<=npt;j++) expp[j]=0; expp[base[i]]=stop;
27
p=svhptr[i];
28
for (j=1;j<=npt;j++) if (p[j]!=0 && p[j]!=stop)
29
{ expp[j]=pst; ucp=lcp-1; addsvf(j,p);
30
for (k=1;k<=npt;k++) pst[k]=image(k); pst+=npt;
31
}
32
for (j=1;j<=npt;j++) p[j]=expp[j];
33
}
34
else {printf("Not enough room to expand H.\n"); exph=0; }
35
}
36
conp=cp+2*npt;
37
if (cong)
38
{ strcat(inf1,".cp"); op=fopen(inf1,"w"); fprintf(op,"%4d%4d\n",ind,npg);
39
printf("Computing coeffs of perms in G.\n");
40
for (pno=1;pno<=npg;pno++)
41
{ *conp= perm+(pno-1)*2*npt-1;
42
printf("Coeffs of permutation no %d.\n",pno);
43
/* The basic conversion algorithm now follows. In this case, coefficents
44
are being output, as well as the perms themselves.
45
*/
46
ucp=conp; q=tree;
47
for (bno=fnt;bno!= -1;bno=fpt[bno])
48
{ tailad[bno]=q; q+=2; cpad[bno]=ucp+1; }
49
for (cind=1;cind<=ind;cind++)
50
{ if (cind>1) advance(); lcp=conp; trptr=0;
51
for (bno=1;bno<=nb;bno++)
52
{ if (fpt[bno]!=0)
53
{ i=tree[trptr]; j=image(i);
54
while (svhptr[bno][j]==0)
55
{ trptr=tree[trptr+1]; i=tree[trptr]; j=image(i); }
56
if (expg)
57
{ q=svgptr[bno][i]; if (q!=stop) {lcp--; *lcp=q+npt; } }
58
else addsvb(i,svgptr[bno]);
59
trptr+=2;
60
}
61
else j=image(base[bno]);
62
if (exph) { q=svhptr[bno][j]; if (q!=stop) {ucp++; *ucp=q; }}
63
else addsvf(j,svhptr[bno]);
64
fprintf(op," %d",j);
65
}
66
fprintf(op," %6d ",tree[trptr]);
67
} /* for (cind=1;... */
68
fprintf(op,"\n");
69
} /* for (pno=1;... */
70
fclose(op);
71
} /* if (cong) */
72
if (hg==0) return(0);
73
74
*conp= expg ? perm-1 : pst-1; flct= -1;
75
printf("Converting permutations from %s.\n",inf3);
76
if ((ip=fopen(inf3,"r"))==0)
77
{ fprintf(stderr,"Cannot open %s.\n",inf3); return(-1); }
78
fscanf(ip,"%d%d%d%d",&i,&ncp,&j,&k);
79
if (k!=0) k=3; else if (j>0) k=2; else k=1;
80
if (i!=npt) {fprintf(stderr,"npt wrong in %s.\n",inf3); return(-1); }
81
for (i=1;i<=k;i++) while ((c=getc(ip))!='\n');
82
op=fopen(temp1,"w"); fprintf(op,"%4d%4d%4d%4d\n",ind,ncp,0,0);
83
84
while (1)
85
{ for (pno=1;pno<=ncp;pno++)
86
{ printf("Converting perm no %d.\n",pno);
87
q= *conp+1;
88
for (i=1;i<=npt;i++) {fscanf(ip,"%d",q); q++;}
89
while ((c=getc(ip))!='\n');
90
ucp=conp; q=tree;
91
for (bno=fnt;bno!= -1;bno=fpt[bno])
92
{ tailad[bno]=q; q+=2; cpad[bno]=ucp+1; }
93
for (cind=1;cind<=ind;cind++)
94
{ if (cind>1) advance(); lcp=conp; trptr=0;
95
for (bno=1;bno<=lnt;bno++)
96
{ if (fpt[bno]!=0)
97
{ i=tree[trptr]; j=image(i);
98
while (svhptr[bno][j]==0)
99
{ trptr=tree[trptr+1]; i=tree[trptr]; j=image(i); }
100
if (expg)
101
{ q=svgptr[bno][i]; if (q!=stop) {lcp--; *lcp=q+npt; } }
102
else addsvb(i,svgptr[bno]);
103
trptr+=2;
104
}
105
else j=image(base[bno]);
106
if (exph) { q=svhptr[bno][j]; if (q!=stop) {ucp++; *ucp=q; }}
107
else addsvf(j,svhptr[bno]);
108
}
109
fprintf(op," %3d",tree[trptr]);
110
}
111
fprintf(op,"\n");
112
} /* for (pno=1;... */
113
fclose(op); fclose(ip);
114
flct++; if (flct>nfuse) break;
115
if (flct==0)
116
{ strcpy(inf2,inf0); strcat(inf2,ngn);
117
if ((ip=fopen(inf2,"r"))==0)
118
{ flct++; if (flct>nfuse) break; ngth=0; }
119
else ngth=1;
120
}
121
if (flct>0)
122
{ strcpy(inf2,inf0); strcat(inf2,"dcr"); ofstr[0]=flct+'0';
123
strcat(inf2,ofstr);
124
}
125
strcpy(outf3,inf2); strcat(outf3,".nr");
126
if ((ip=fopen(inf2,"r"))==0)
127
{ fprintf(stderr,"Cannot open %s.\n",inf2); return(-1); }
128
fscanf(ip,"%d%d",&i,&ncp); while (getc(ip)!='\n');
129
if (i!=npt) {fprintf(stderr,"npt wrong in %s.\n",inf2); return(-1);}
130
op=fopen(outf3,"w"); fprintf(op,"%3d\n",ncp);
131
printf("Converting permutations from %s.\n",inf2);
132
} /* while(1) */
133
134
/* We are now ready to compute orbits of the new perms if necessary, in order
135
to compute double coset reps. The tree information is no longer required,
136
and the tree space is used to store the new permutations.
137
*/
138
if (dcr)
139
{ if (trsp<4*ind)
140
{ fprintf(stderr,"No room to compute orbits. Increase TRSP.\n");return(-1);}
141
ndcr=ind-1; orb=tree-1; len=orb+ind; orbptr=len+ind; cperm=orbptr+ind;
142
for (i=1;i<=ind;i++) {orb[i]=i; len[i]=1; orbptr[i]=0;}
143
printf("Computing orbits of con perms from %s.\n",outf1);
144
ip=fopen(temp1,"r");fscanf(ip,"%d%d",&i,&ncp);
145
while ((c=getc(ip))!='\n'); flct= -1; fuse=0;
146
while (1)
147
{ for (i=1;i<=ncp;i++)
148
{ q=cperm;
149
for (j=1;j<=ind;j++) { q++; fscanf(ip,"%d",q); }
150
for (j=1;j<=ind;j++)
151
{ k=orb[j]; l=orb[cperm[j]];
152
if (k!=l)
153
{ if (fuse) {if (len[l]<len[k]) {m=k;k=l;l=m;}}
154
else len[k]+=len[l];
155
len[l]=0; n=k;
156
while ((m=orbptr[n])!=0) n=m;
157
orbptr[n]=l;
158
while (l!=0) {orb[l]=k;l=orbptr[l];}
159
ndcr--;
160
}
161
}
162
}
163
fclose(ip); flct++;
164
if (flct==0) unlink(temp1); else unlink(outf3);
165
if (flct>nfuse) break;
166
if (flct==0) {fuse=1; if (ngth==0) flct++; if (flct>nfuse) break;}
167
strcpy(outf3,inf0);
168
if (flct==0) strcat(outf3,ngn);
169
else { strcat(outf3,"dcr"); ofstr[0]=flct+'0'; strcat(outf3,ofstr);}
170
strcat(outf3,".nr");
171
ip=fopen(outf3,"r"); fscanf(ip,"%d",&ncp);
172
printf("Computing orbits of con perms from %s.\n",outf3);
173
}
174
printf("Computing dcreps.\n");
175
if (len[1]!=1) printf("Warning. Orb of 1 is greater than one.\n");
176
nntb=0; for (i=fnt;i!= -1;i=fpt[i]) nntb++;
177
lcp=cp; ip=fopen(temp2,"r"); op=fopen(outf2,"w");
178
fprintf(op,"%4d %3d%4d%4d\n",npt,ndcr,0,0);
179
for (rep=2;rep<=ind;rep++) if ((lorb=len[rep])>0)
180
{ ucp=lcp-1;
181
for (bno=fnt;bno!= -1;bno=fpt[bno])
182
{ fscanf(ip,"%d",&inch);
183
if (expg) { q=svgptr[bno][inch]; if (q!=stop) {ucp++; *ucp=q;} }
184
else addsvf(inch,svgptr[bno]);
185
}
186
if (npt>=1000)
187
for (i=1;i<=npt;i++) fprintf(op,"%5d",image(i));
188
else for (i=1;i<=npt;i++) fprintf(op,"%4d",image(i));
189
fprintf(op," %4d\n",lorb);
190
}
191
else for (i=1;i<=nntb;i++) fscanf(ip,"%d",&inch);
192
fclose(op); fclose(ip); unlink(temp2);
193
}
194
/* If we are keeping the converted permutations, then invert them, to
195
get action on right cosets
196
*/
197
if (hg && dcr==0)
198
{ ip=fopen(temp1,"r"); op=fopen(outf1,"w");
199
fscanf(ip,"%d%d",&i,&ncp); while ((c=getc(ip))!='\n');
200
if (triv) fprintf(op,"%4d%4d%4d%4d\n1\n",ind,ncp,1,0);
201
else fprintf(op,"%4d%4d%4d%4d\n",ind,ncp,0,0);
202
for (i=1;i<=ncp;i++)
203
{ for (j=1;j<=ind;j++) {fscanf(ip,"%d",&k); tree[k]=j;}
204
for (j=1;j<=ind;j++) fprintf(op," %3d",tree[j]); fprintf(op,"\n");
205
}
206
fclose(ip); fclose(op);
207
unlink(temp1);
208
}
209
return(0);
210
}
211
212