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
3
extern char mult,inf0[],inf1[],inf2[],outf[],outft[],inf3[];
4
extern short csp[],*cpsp[],**cdpsp[],***coeff[];
5
extern int space,cspace;
6
extern short sp[],**mat[],*psp[],**imcos[],**cpco[],lorb[],
7
wdl,ptrsp,cdptrsp,mb;
8
short *cst,**cpst,***cdpst,**svptr,*cp,*rel;
9
short *spst,**pspst,**pptr,**cpptr,npt,nb,nph,nph2,npg,npg2,
10
rno,orno,coh_index,*invg;
11
FILE *ip,*op;
12
13
void seeknln (void) { while (getc(ip)!='\n'); }
14
15
/* This program differs from most other permutation programs in that perms are
16
all stored in the single array sp. Schreier vectors are stored in the short
17
array csp. This assumes that there are at most 127 perms, which will
18
probably always be the case. The first half of the program (crprog1)
19
involves relatively little short space, so it is assumed that there is enough
20
In the first half, coefficients as words in H generated by the relators
21
of G are computed using the output of conrun.
22
*/
23
int
24
crprog1 (void)
25
{ short *pc,*qc,ex,neg; int x;
26
short i,j,k,l,m,n,cl,rl,*p,ocl,im,pt,pt1,pn,ipt;
27
if ((ip=fopen(inf2,"r"))== 0)
28
{ fprintf(stderr,"Cannot open %s.\n",inf2); return(-1);}
29
fscanf(ip,"%hd%hd%hd%hd",&npt,&nph,&nb,&k);
30
if (nb>=mb) {fprintf(stderr,"nb too big. Increase MB.\n"); return(-1);}
31
if (k<=2) {fprintf(stderr,"inf2 has illegal format.\n"); return(-1); }
32
seeknln(); seeknln();
33
for (i=1;i<=nb;i++) fscanf(ip,"%hd",lorb+i);
34
pptr=psp-1; pspst=psp+nph; svptr=cpsp-1; cpst=cpsp+nb;
35
invg=sp; nph2=2*nph; spst=sp+nph2;
36
for (i=1;i<=nph;i++)
37
{ pptr[i]=spst+(i-1)*npt-1; p=pptr[i];
38
for (j=1;j<=npt;j++) {fscanf(ip,"%hd",&k); p[k]=j; }
39
invg[2*i-2]=2*i-1; invg[2*i-1]=2*i-2;
40
seeknln();
41
}
42
spst+=(npt*nph);
43
for (i=1;i<=nb;i++)
44
{ svptr[i]=csp+(i-1)*npt-1; pc=svptr[i];
45
for (j=1;j<=npt;j++) {fscanf(ip,"%hd",&k); pc[j]= k>0 ? (k+1)/2 : k;}
46
}
47
cp=csp+nb*npt; rel=cp+wdl;
48
fclose(ip);
49
/* It is assumed that there is enough space so far. */
50
51
strcpy(inf1,inf0); strcat(inf1,".cp");
52
if ((ip=fopen(inf1,"r"))==0)
53
{ fprintf(stderr,"Cannot open %s.\n",inf1); return(-1);}
54
fscanf(ip,"%hd%hd",&coh_index,&npg); npg2=2*npg-1;
55
x= (nb+2)*npg*coh_index;
56
if (spst+x-sp>space)
57
{ fprintf(stderr,"Not enough space. Increase SPACE.\n"); return(-1); }
58
if (pspst+(nb+2)*npg-psp>ptrsp)
59
{ fprintf(stderr,"Not enough ptrsp. Increase PTRSP.\n"); return(-1); }
60
cpptr=pspst; pspst+=2*npg;
61
for (i=0;i<=npg2;i++) { cpptr[i]=spst-1; spst+=coh_index; }
62
for (i=1;i<=nb;i++)
63
{ cpco[i]=pspst-1; pspst+=npg;
64
for (j=1;j<=npg;j++) {cpco[i][j]=spst-1; spst+=coh_index;}
65
}
66
for (i=1;i<=npg;i++)
67
{ j=2*i-2; k=j+1;
68
for (l=1;l<=coh_index;l++)
69
{ for (m=1;m<=nb;m++) fscanf(ip,"%hd",cpco[m][i]+l);
70
fscanf(ip,"%hd",&m); cpptr[j][l]=m; cpptr[k][m]=l;
71
}
72
}
73
fclose(ip);
74
75
strcpy(inf1,inf0); strcat(inf1,".rel");
76
if ((ip=fopen(inf1,"r"))==0)
77
{ fprintf(stderr,"Cannot open %s.\n",inf1); return(-1);}
78
fscanf(ip,"%hd%hd",&k,&rno); seeknln();
79
op=fopen(outft,"w");
80
/* Now we have read everything in, and the computation can start */
81
orno=0;
82
for (i=1;i<=rno;i++)
83
{ fscanf(ip,"%hd",&rl);
84
printf("Scanning rel no %d.\n",i);
85
for (j=1;j<=rl;j++) { fscanf(ip,"%hd",&k); rel[j]=k; }
86
for (j=1;j<=coh_index;j++)
87
{ pt=j; cl=0;
88
for (k=rl;k>=1;k--)
89
{ l=rel[k]; im=cpptr[l][pt];
90
if (l%2==1) {neg=1;pt1=im; m=(l+1)/2;}
91
else {neg=0; pt1=pt; m=(l+2)/2;}
92
ocl=cl;
93
for (n=1;n<=nb;n++)
94
{ ipt=cpco[n][m][pt1]; pn=svptr[n][ipt];
95
while (pn!= -1)
96
{ cl++; cp[cl]=2*(pn-1); ipt=pptr[pn][ipt]; pn=svptr[n][ipt]; }
97
}
98
if (neg)
99
{ pc=cp+ocl+1; qc=cp+cl;
100
while (pc<=qc)
101
{ if (pc==qc) (*pc)++;
102
else {ex= *pc; *pc= *qc+1; *qc= ex+1;}
103
pc++; qc--;
104
}
105
}
106
pt=im;
107
}
108
if (pt!=j)
109
{ fprintf(stderr,
110
"Relation number %d is not satisfied by the permutations.\n",i);
111
return(-1);
112
}
113
fprintf(op,"%4d",cl);
114
for (k=cl;k>=1;k--) fprintf(op," %2d",cp[k]);
115
fprintf(op,"\n");
116
} /* j loop */
117
if (i==rno && orno==0)
118
{ orno=rno; if (fscanf(ip,"%hd",&j)>0) rno+=j;}
119
120
} /* i loop */
121
printf("All relations scanned.\n");
122
fclose(op); fclose(ip);
123
return(0);
124
}
125
126