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

563648 views
1
#include "defs.h"
2
#include "permfns.h"
3
4
#define tmalloc(D,T,N) {D = (T *) malloc(sizeof(T)*(N)); \
5
if (D==0) { fprintf(stderr,"Out of space.\n"); return(-1);}}
6
#define tfree(D) {if (D) free( (char *) D); D=0;}
7
8
extern char mult,inf1[],inf2[],inf3[],outf[];
9
extern short rwd[],
10
***scoeff[],**cdpsp[],*cpsp[],csp[],wd1[],wd2[],wd3[],wd4[];
11
extern int cspace,psp,space,cptrsp,svsp;
12
extern short perm[],sv[],orb[],imsp[],*ptsp[],**simcos[],pinv[],gno[],
13
base[],lorb[],pno[],*pptr[],*svptr[],cord[],
14
invg[],rno[],cp[],mspace[],*vec[],**mat[],
15
mp,cdptrsp,mwl2,mpt,mb,mdim,mpr,ptrsp,mm,msp,mv,mwdl,mlwdl;
16
int rsp;
17
short endr,maxcos,*fpt,*bpt,nelim,bno,lo,**imcos,*spst,**pspst,dim,
18
prime,ccos,lastd,cind,nfree,stcr,endcr,fcos,bcos,lcl,npt,np2,*rel,
19
*spv,**spm,ng,rwl,nb;
20
short *cst,*cend,***coeff,**cpst,***cdpst,fullsc,clsd,lkah,conch,**cco,*ocst,
21
**def;
22
FILE *ip,*op;
23
24
int
25
extpprog (void)
26
{ short i,j,k,l,m,n,b,l1,nperms,npt1,mxp,maxv,maxm,pos,*p,*q,*r;
27
int quot;
28
short **dp,**dq,**dr,*pc; float a;
29
if ((ip=fopen(inf1,"r"))==0)
30
{ fprintf(stderr,"Cannot open %s.\n",inf1); return(-1); }
31
fscanf(ip,"%hd%hd%hd%hd",&npt,&nperms,&nb,&k);
32
if (npt>mpt) {fprintf(stderr,"npt too big. Increase NPT.\n"); return(-1); }
33
if (nb>mb) {fprintf(stderr,"nb too big. Increase MB.\n"); return(-1); }
34
if (nb*npt>svsp)
35
{ fprintf(stderr,"Not enough sv space. Increase SVSP.\n"); return(-1); }
36
if (k<=2) {fprintf(stderr,"Wrong input format.\n"); return(-1); }
37
npt1=npt+1; np2=2*nperms-1;
38
quot=psp/npt1; if (quot>mp) quot=mp; mxp=quot;
39
if (np2>=mxp)
40
{ fprintf(stderr,"Too many permutations. Increase MP and/or PSP.\n");
41
return(-1);
42
}
43
for (i=0;i<mxp;i++) pptr[i]=perm+i*npt1-1;
44
for (i=1;i<=nb;i++) svptr[i]=sv+(i-1)*npt-1;
45
readbaselo(nb,base,lorb); readpsv(0,nb,nperms,svptr);
46
fclose(ip);
47
for (i=0;i<np2;i+=2) { invg[i]=i+1; invg[i+1]=i; }
48
49
/* We need to read in matrices for generators when action is nontrivial */
50
if (mult==0)
51
{ if ((ip=fopen(inf3,"r"))==0)
52
{ fprintf(stderr,"Cannot open %s.\n",inf3); return(-1); }
53
fscanf(ip,"%hd%hd%hd",&prime,&dim,&k);
54
if (prime>mpr)
55
{ fprintf(stderr,"Prime too big. Increase MPR.\n"); return(-1); }
56
if (dim>mdim)
57
{ fprintf(stderr,"Dim too big. Increase MDIM.\n"); return(-1); }
58
if (k!=nperms) { fprintf(stderr,"No of mats wrong.\n"); return(-1); }
59
setpinv();
60
maxv=msp/dim; if (maxv>mv) maxv=mv;
61
for (i=0;i<maxv;i++) vec[i]=mspace-1+i*dim;
62
maxm=maxv/dim-1; if (maxm>=mm) maxm=mm-1;
63
if (np2>=maxm)
64
{ fprintf(stderr,"Not enough mat space. Increase MSP and/or MV,MM.\n");
65
return(-1);
66
}
67
for (i=0;i<=maxm;i++) mat[i]=vec-1+i*dim;
68
spm=mat[maxm]; spv=spm[1];
69
for (i=0;i<np2;i+=2) { readmat(mat[i]); inv(mat[i],mat[i+1]);}
70
fclose(ip);
71
}
72
73
printf("Input a,b,l1.\nmaxcos = a*lorb+b\n");
74
printf("Exit lookahead after eliminating abs(l1) cosets.\n");
75
printf("l1 negative for consistency checking.\n");
76
scanf("%f%hd%hd",&a,&b,&l1);
77
if (l1<0) {l1= -l1; conch=1;} else conch=0;
78
79
/* Now we read in the relations */
80
if ((ip=fopen(inf2,"r"))==0)
81
{ fprintf(stderr,"Cannot open %s.\n",inf2); return(-1); }
82
fscanf(ip,"%hd%hd",&i,&j);
83
if (i!=nb || (mult==0 && j!=dim))
84
{ fprintf(stderr,"Error in %s, line 1.\n",inf2); return(-1); }
85
for (i=1;i<=nb;i++) fscanf(ip,"%hd",rno+i);
86
if (mult) {dim=j; for (i=1;i<=dim;i++) fscanf(ip,"%hd",cord+i); }
87
rel=imsp; spst=rel;
88
for (i=1;i<=2*rno[1];i++)
89
{ fscanf(ip,"%hd",spst); l= *spst;
90
for (j=1;j<=l;j++) fscanf(ip,"%hd",spst+j);
91
spst+=(l+1);
92
}
93
fclose(ip);
94
95
/* Now we are ready to start the modified Todd-Coxeter procedure. This
96
follows the ordinary tcrun with procedures added in the appropriate
97
places to compute the coefficients as words in the generators of G and M.
98
The Tood-Coxeter procedures are in exb.c and the word operation
99
procedures in exc.c
100
*/
101
pos=0; endr= -1; pspst=ptsp; cst=csp; ocst=cst; cend=csp+cspace-1; cpst=cpsp;
102
cdpst=cdpsp; rsp=cspace;
103
for (bno=nb;bno>=1;bno--)
104
{ printf("bno=%d.\n",bno);
105
l=rno[bno]-pos;
106
for (i=1;i<=2*l;i++) {endr++; endr+= rel[endr];}
107
pos=rno[bno];
108
lo=lorb[bno];
109
if (lo==1) continue;
110
maxcos=lo*a+b; ng=0;
111
tmalloc(def,short *,maxcos+1);
112
for (i=0;i<np2;i+=2) if (pptr[i][npt1]>=bno) ng+=2; else break;
113
k=(ng+1)*maxcos; l=k+maxcos+1; k-=lo;
114
if (cpst+k-cpsp>cptrsp)
115
{ fprintf(stderr,"Out of cptrsp. Increase CPTRSP.\n"); return(-1); }
116
if (spst+l-imsp>space)
117
{ fprintf(stderr,"Out of im space. Increase SPACE.\n"); return(-1); }
118
if (pspst+ng-ptsp>ptrsp)
119
{ fprintf(stderr,"Out of ptrsp. Increase PTRSP.\n"); return(-1); }
120
if (cdpst+ng-cdpsp>cdptrsp)
121
{ fprintf(stderr,"Out of cdptr Increase CDPTRSP.\n"); return(-1); }
122
imcos=pspst; pspst+=ng; gno[bno]=ng;
123
for (i=0;i<ng;i++)
124
{imcos[i]=spst-1; p=imcos[i]; spst+=maxcos; while (++p<spst) *p=0;}
125
fpt=spst; bpt=spst+maxcos;
126
coeff=cdpst; cdpst+=ng;
127
for (i=0;i<ng;i++)
128
{coeff[i]=cpst-1; dp=cpst-1; cpst+=maxcos; while (++dp<cpst) *dp=0;}
129
cco=cpst-lo-1;
130
*pno=0;
131
for (i=0;i<np2;i+=2) if (pptr[i][npt1]>=bno)
132
{ (*pno)++; pno[*pno]=i;
133
if (pptr[i][npt1]>bno)
134
{ imcos[i][1]=1; imcos[i+1][1]=1;
135
coeff[i][1]=cst; *cst=1; *(++cst)=i; *(++cst)=0; cst++;
136
coeff[i+1][1]=cst; *cst=1; *(++cst)=i+1; *(++cst)=0; cst++; rsp-=6;
137
}
138
}
139
if (orbitsv(base[bno],svptr[bno],0)!=lo)
140
{ fprintf(stderr,"Orbit length wrong!\n"); return(-1); }
141
if (mult==0)
142
{ tmalloc(def[1],short,1); def[1][0]=0;}
143
for (l=1;l<=lo;l++)
144
{ n=orb[l]; cp[n]=l;
145
if ((k=svptr[bno][n])!= -1)
146
{ j=pptr[k][n]; m=cp[j]; imcos[k-1][m]=l; imcos[k][l]=m;
147
if (mult==0)
148
{ tmalloc(def[l],short,def[m][0]+2);
149
def[l][0]=def[m][0]+1; def[l][1]=k;
150
for (i=1;i<=def[m][0];i++) def[l][i+1]=def[m][i];
151
}
152
}
153
}
154
155
lastd=lo; cind=lo; nfree=lo+1;
156
for (i=1;i<=lo;i++) bpt[i]=i-1;
157
for (i=0;i<maxcos;i++) fpt[i]=i+1;
158
fpt[lo]=0; fpt[maxcos]=0;
159
ccos=1; lkah=0;
160
/* At last we are ready to proceed with the enumeration */
161
while (ccos!=0)
162
{ clsd=1; endcr= -1;
163
while (endcr!=endr)
164
{ if (scanrel()== -1) return(-1);
165
if (fullsc==0)
166
{ clsd=0;
167
if (lkah==0)
168
{ lcl=bpt[ccos]; lkah=1; nelim=0;
169
printf("Entering lookahead.\n");
170
}
171
}
172
}
173
ccos=fpt[ccos];
174
if (lkah)
175
{ if (nelim>=l1 || ccos==0)
176
{ if (cind!=maxcos)
177
{ printf("Exiting lookahead. cind=%d.\n",cind);
178
ccos=fpt[lcl]; lkah=0;
179
}
180
else { fprintf(stderr,"maxcos too small.\n"); return(-1); }
181
}
182
}
183
} /* while ccos!=0 */
184
/* End of enumeration. Tidy up and prepare for next bno */
185
p=imcos[0]+lo; q=imcos[1]; k=maxcos-lo; dp=coeff[0]+lo; dq=coeff[1];
186
for (i=1;i<ng;i++)
187
{ imcos[i]=p; r=p+lo;
188
while (++p<=r) *p= *(++q);
189
q+=k;
190
coeff[i]=dp; dr=dp+lo;
191
while (++dp<=dr) *dp= *(++dq);
192
dq+=k;
193
}
194
spst=p+1; cpst=dp+1; simcos[bno]=imcos; scoeff[bno]=coeff;
195
if (bno>1) { maxcos=lo; gc(); ocst=cst; }
196
if (mult==0)
197
for (i=1;i<=lo;i++) tfree(def[i]);
198
tfree(def);
199
} /* for (bno=;... */
200
201
/* End of program. Now output */
202
op=fopen(outf,"w");
203
fprintf(op,"%4d%4d\n",nb,dim);
204
for (i=1;i<=nb;i++) fprintf(op," %3d",lorb[i]); fprintf(op,"\n");
205
if (mult) {for (i=1;i<=dim;i++) fprintf(op,"%4d",cord[i]); fprintf(op,"\n");}
206
for (i=1;i<=nb;i++) fprintf(op,"%4d",gno[i]); fprintf(op,"\n");
207
for (i=1;i<=nb;i++) if ((l=lorb[i])>1) for (j=0;j<gno[i];j++)
208
{ p=simcos[i][j];
209
for (k=1;k<=l;k++) fprintf(op," %3d",p[k]); fprintf(op,"\n");
210
dp=scoeff[i][j];
211
for (k=1;k<=l;k++)
212
{ if ((pc=dp[k])==0) fprintf(op,"%3d %3d ",0,0);
213
else
214
{ fprintf(op,"%3d ",*pc);
215
for (m=1;m<= *pc;m++) fprintf(op," %2d",pc[m]);
216
pc+= (1+ *pc); fprintf(op," %3d ",*pc);
217
for (m=1;m<= *pc;m++) fprintf(op," %2d",pc[m]);
218
}
219
}
220
fprintf(op,"\n");
221
}
222
fclose(op); return(0);
223
}
224
225