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