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 *cst,**cpst,***cdpst,
5
csp[],*cpsp[],**cdpsp[],***coeff[];
6
extern int space,cptrsp,cspace;
7
extern short sp[],**mat[],*psp[],**imcos[],**cpco[],lorb[],pinv[],
8
wdl,ptrsp,cdptrsp,mpr,marg,
9
*spst,**pspst,npt,nb,nph,nph2,rno,orno,coh_index,*invg;
10
short *wd1,*wd2;
11
short *gno,*cord,cl,dim,prime,**vec,**spm,*spv,wv,*val;
12
FILE *ipr,*op,*ipx,*ip;
13
14
int
15
crprog2 (void)
16
/* In the second half, the values of the words in H in the module or
17
multiplier are computed, using the coefficients computed in extprun.
18
*/
19
{ short i,j,k,l,m,n,rct,inct,x,l1,l2,*ps,*qs; short *p,*q,*r,*v2,*ex,c;
20
int prod;
21
printf("Beginning crprog2.\n");
22
spst=sp+nph2; pspst=psp; strcpy(inf0,inf2);
23
if (mult==0)
24
{ strcat(inf2,"mat");
25
if ((ip=fopen(inf2,"r"))==0)
26
{ fprintf(stderr,"Cannot open %s.\n",inf2); return(-1);}
27
fscanf(ip,"%hd%hd%hd",&prime,&dim,&k);
28
if (prime>mpr)
29
{ fprintf(stderr,"Prime too big. Increase MPR.\n"); return(-1);}
30
if (k!=nph) {fprintf(stderr,"No of mats wrong.\n"); return(-1); }
31
setpinv();
32
vec=psp; n=(nph2+1)*dim; pspst+=n;
33
if (pspst-psp>=ptrsp)
34
{ fprintf(stderr,"Out of ptr space. Increase PTRSP.\n"); return(-1);}
35
for (i=0;i<n;i++) vec[i]=spst-1+i*dim; spst+=(dim*n);
36
if (spst-sp>space)
37
{ fprintf(stderr,"Out of space. Increase SPACE.\n"); return(-1);}
38
for (i=0;i<=nph2;i++) mat[i]=vec-1+i*dim;
39
spm=mat[nph2]; spv=spm[1];
40
for (i=0;i<nph2;i+=2) {readmat(mat[i]); inv(mat[i],mat[i+1]); }
41
fclose(ip);
42
}
43
44
/* Now we read in the output of extprun */
45
wd1=csp-1; wd2=wd1+wdl; cst=csp+2*wdl; cpst=cpsp; cdpst=cdpsp;
46
strcpy(inf2,inf0); strcat(inf2,".ep");
47
if ((ip=fopen(inf2,"r"))==0)
48
{ fprintf(stderr,"Cannot open %s.\n",inf2); return(-1);}
49
fscanf(ip,"%hd%hd",&i,&j);
50
if (i!=nb || (mult==0 && j!=dim))
51
{ fprintf(stderr,"%s has line 1 wrong.\n",inf2); return(-1); }
52
if (mult) { dim=j; cord=spst-1; spst+=dim; }
53
gno=spst-1; spst+=nb; val=spst-1; spst+=dim;
54
for (i=1;i<=nb;i++)
55
{ fscanf(ip,"%hd",&j);
56
if (j!=lorb[i]) {fprintf(stderr,"lorb wrong in %s.\n",inf2); return(-1); }
57
}
58
if (mult) for (i=1;i<=dim;i++) fscanf(ip,"%hd",cord+i);
59
for (i=1;i<=nb;i++) fscanf(ip,"%hd",gno+i);
60
for (i=1;i<=nb;i++)
61
{ n=gno[i];
62
if ((l=lorb[i])>1)
63
{ if (pspst+n-psp>ptrsp)
64
{ fprintf(stderr,"Out of ptrsp. Increase PTRSP.\n"); return(-1); }
65
if (cdpst+n-cdpsp>cdptrsp)
66
{ fprintf(stderr,"Out of cdsp. Increase CDPTRSP.\n");return(-1);}
67
prod=n*l;
68
if (spst+prod-sp>space)
69
{ fprintf(stderr,"Out of space. Increase SPACE.\n"); return(-1);}
70
if (cpst+prod-cpsp>cptrsp)
71
{ fprintf(stderr,"Out of cptrsp. Increase CPTRSP.\n"); return(-1); }
72
imcos[i]=pspst; pspst+=n; coeff[i]=cdpst; cdpst+=n;
73
for (j=0;j<n;j++)
74
{ imcos[i][j]=spst-1;
75
for (k=1;k<=l;k++) {fscanf(ip,"%hd",spst); spst++;}
76
coeff[i][j]=cpst-1;
77
for (k=1;k<=l;k++)
78
{ fscanf(ip,"%hd",&l1);
79
if (l1==0)
80
{ fscanf(ip,"%hd",&l2);
81
if (l2==0) *(cpst++)=0;
82
else
83
{ *(cpst++)=cst; *(cst++)=0; *(cst++)=l2;
84
for (m=1;m<=l2;m++) {fscanf(ip,"%hd",&x); *(cst++)=x;}
85
}
86
}
87
else
88
{ *(cpst++)=cst; *(cst++)=l1;
89
for (m=1;m<=l1;m++) {fscanf(ip,"%hd",&x); *(cst++)=x;}
90
fscanf(ip,"%hd",&l2); *(cst++)=l2;
91
for (m=1;m<=l2;m++) {fscanf(ip,"%hd",&x); *(cst++)=x;}
92
}
93
}
94
if (cst+marg-csp>cspace)
95
{ fprintf(stderr,"Running out of cspace. Increase CSP.\n");return(-1);}
96
}
97
}
98
}
99
fclose(ip);
100
/* End of input. Now computation can begin */
101
102
op=fopen(outf,"w"); ipr=fopen(inf1,"r");
103
fscanf(ipr,"%hd",&i); fprintf(op,"%4d%4d\n",nb,dim);
104
for (i=1;i<=nb;i++) { fscanf(ipr,"%hd",&j); fprintf(op," %4d",j); }
105
while (getc(ipr)!='\n');
106
fprintf(op,"\n");
107
if (mult) {for (i=1;i<=dim;i++) fprintf(op,"%4d",cord[i]); fprintf(op,"\n");}
108
wv=wdl-dim-1;
109
ipx=fopen(outft,"r");
110
111
for (rct=1;rct<=rno;rct++)
112
{ printf("Scanning relation no %d\n",rct);
113
if (rct==orno+1)
114
{ while ((c=getc(ipr))!='\n') putc(c,op); putc('\n',op); }
115
while ((c=getc(ipr))!='\n') putc(c,op); putc('\n',op);
116
if (mult==0)
117
{ if ((ip=fopen(inf3,"r"))==0)
118
{ fprintf(stderr,"Cannot open %s.\n",inf3); return(-1);}
119
fscanf(ip,"%hd%hd%hd",&i,&j,&k);
120
if (i!=prime || j!=dim || k!=(coh_index-1))
121
{ fprintf(stderr,"%s has line 1 wrong.\n",inf3); return(-1); }
122
}
123
for (j=1;j<=dim;j++) val[j]=0;
124
for (inct=1;inct<=coh_index;inct++)
125
{ fscanf(ipx,"%hd",&l2);
126
for (k=1;k<=l2;k++) {fscanf(ipx,"%hd",&l); wd2[k]=l;}
127
p=wd1+wv; q=wd2+wv; r=p+dim;
128
while (++p<=r) { *p=0; *(++q)=0; }
129
for (k=1;k<=nb;k++) if (lorb[k]>1)
130
{ if (scan(k,&l2)== -1) return(-1);
131
ex=wd1; wd1=wd2; wd2=ex;
132
}
133
v2=wd2+wv; ps=val;
134
if (inct>1 && mult==0)
135
{ readmat(spm);
136
for (i=1;i<=dim;i++)
137
{ ps++; p=v2;
138
for (j=1;j<=dim;j++)
139
{ *ps+= (*(++p)* spm[j][i]); *ps%=prime; }
140
}
141
}
142
else
143
{ p=v2; r=p+dim;
144
if (mult) while (++p<=r) {*(++ps)+= *p; x=cord[p-v2]; *ps%=x; }
145
else while (++p<=r) {*(++ps)+= *p; *ps%=prime; }
146
}
147
}
148
l=0; ps=val; qs=val+dim;
149
while (++ps<=qs) if (*ps!=0) l+=2;
150
fprintf(op,"%4d ",l);
151
ps=val;
152
while (++ps<=qs) if (*ps!=0) fprintf(op,"%4d%4d",ps-val,*ps);
153
fprintf(op,"\n");
154
if (mult==0) fclose(ip);
155
}
156
fclose(ipx); unlink(outft);
157
return(0);
158
}
159
160
int
161
scan (int bno, short *la)
162
/* This is the computation of one word as described above */
163
{ short cos,nl,min,canct,**cim; short c,*v1,*conco,*p,*q,*r,***cco,*wp,*wr;
164
v1=wd1+wv; cco=coeff[bno]; cim=imcos[bno];
165
cos=1; wp=wd2; wr=wp+ *la; nl=0;
166
while (++wp<=wr)
167
{ conco=cco[*wp][cos]; cos=cim[*wp][cos];
168
if (conco!=0)
169
{ q=conco+ *conco+1; r=q+ *q;
170
if (mult)
171
{ while (++q<r) {c= *(q++); v1[c]+= *q; v1[c]%=cord[c]; }}
172
else
173
{ action(v1,conco);
174
while (++q<=r) {c= *(q++); v1[c]+= *q; v1[c]%=prime;}
175
}
176
min= (nl<= *conco) ? nl : *conco;
177
canct=0; p=wd1+nl; q=conco+1;
178
while (canct<min && *p==invg[*q]) {canct++; p--; q++; }
179
r=conco+ *conco;
180
while (q<=r) *(++p)= *(q++);
181
nl+= (*conco-2*canct);
182
}
183
}
184
if (cos!=1)
185
{ fprintf(stderr,
186
"One of the relations is not satisfied by the permutations.\n");
187
return(-1);
188
}
189
if (bno>1)
190
{ p=v1; q=wd2+wv; r=p+dim;
191
if (mult) while (++p<=r) {*p+= *(++q); *p%=cord[p-v1]; *q=0; }
192
else while (++p<=r) {*p+= *(++q); *p%=prime; *q=0; }
193
}
194
*la=nl;
195
if (nl>wdl)
196
{ fprintf(stderr,"Word too long. Increase WDL.\n"); return(-1); }
197
return(0);
198
}
199
200
int
201
action (short *a, short *b)
202
{ short z,*be,c,*p,*ae; short *spve,*s,*v;
203
z=1; p=a; ae=a+dim;
204
while (++p<=ae) if (*p!=0) {z=0; break;}
205
if (z) return(0);
206
spve=spv+dim; be=b+ *b;
207
while (++b<=be)
208
{ s=spv;
209
while (++s<=spve) *s=0;
210
p=a;
211
while (++p<=ae) if ((c= *p)!=0)
212
{ v=mat[*b][p-a]; s=spv;
213
while (++s<=spve) {*s+=(c* *(++v)); *s%=prime; }
214
}
215
p=a; s=spv;
216
while (++p<=ae) *p= *(++s);
217
}
218
return(0);
219
}
220
221
int
222
setpinv (void)
223
{ short i,j;
224
for (i=0;i<prime;i++) pinv[i]=0;
225
for (i=1;i<prime;i++) if (pinv[i]==0) for (j=1;j<prime;j++)
226
if (i*j % prime ==1) { pinv[i]=j; pinv[j]=i; break; }
227
return(0);
228
}
229
230