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