Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Testing latest pari + WASM + node.js... and it works?! Wow.

28485 views
License: GPL3
ubuntu2004
1
/* Copyright (C) 2000 The PARI group.
2
3
This file is part of the PARI/GP package.
4
5
PARI/GP is free software; you can redistribute it and/or modify it under the
6
terms of the GNU General Public License as published by the Free Software
7
Foundation; either version 2 of the License, or (at your option) any later
8
version. It is distributed in the hope that it will be useful, but WITHOUT
9
ANY WARRANTY WHATSOEVER.
10
11
Check the License for details. You should have received a copy of it, along
12
with the package; see the file 'COPYING'. If not, write to the Free Software
13
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
14
15
#include "pari.h"
16
#include "paripriv.h"
17
18
#define DEBUGLEVEL DEBUGLEVEL_polgalois
19
20
/**************************************************************/
21
/* Galois group for degree in [8, 11] */
22
/**************************************************************/
23
24
#define NMAX 11 /* maximum degree */
25
26
typedef GEN PERM;
27
typedef PERM *GROUP;
28
typedef struct {
29
PERM *a;
30
long nm, nv;
31
} resolv; /* resolvent */
32
33
typedef struct {
34
long pr, prmax, N;
35
GEN p, r, coef;
36
} buildroot;
37
38
static long isin_G_H(buildroot *BR, long n1, long n2);
39
40
/* k-1 entries filled so far
41
* m = maximal allowed value, n = sum to reach with remaining elements */
42
static void
43
do_par(GEN T, long k, long n, long m, long *par_vec)
44
{
45
long i;
46
if (n <= 0)
47
{
48
GEN t = cgetg(k, t_VECSMALL);
49
for (i=1; i<k; i++) t[i] = par_vec[i];
50
gel(T, ++T[0]) = t; return;
51
}
52
if (n < m) m = n;
53
for (i=1; i<=m; i++) { par_vec[k] = i; do_par(T, k+1, n-i, i, par_vec); }
54
}
55
56
/* compute the partitions of n, as decreasing t_VECSMALLs */
57
static GEN
58
partitions_galois(long n)
59
{
60
pari_sp av;
61
long i, p;
62
GEN T, par_vec;
63
64
switch(n) /* optimized for galoismoduloX ... */
65
{
66
case 8: p = 22; break;
67
case 9: p = 30; break;
68
case 10:p = 42; break;
69
default:
70
if (n < 0) pari_err_TYPE("partitions_galois", stoi(n));
71
av = avma; p = itos( numbpart(stoi(n)) ); set_avma(av); break;
72
}
73
T = new_chunk(p + 1); T[0] = 0;
74
par_vec = cgetg(n+1, t_VECSMALL); /* not Garbage Collected later */
75
do_par(T,1,n,n,par_vec);
76
if (DEBUGLEVEL > 7)
77
{
78
err_printf("Partitions of %ld (%ld)\n",n, p);
79
for (i=1; i<=p; i++) err_printf("i = %ld: %Ps\n",i,gel(T,i));
80
}
81
T[0] = evallg(p + 1) | evaltyp(t_VEC); return T;
82
}
83
84
/* affect to the permutation x the N arguments that follow */
85
static void
86
_aff(long N, PERM x,...)
87
{
88
va_list args; long i;
89
va_start(args,x); for (i=1; i<=N; i++) x[i] = va_arg(args,int);
90
va_end(args);
91
}
92
93
/* return an array of length |len| from the arguments (for galoismodulo) */
94
static GEN
95
_gr(long len,...)
96
{
97
va_list args;
98
long i, l = labs(len);
99
GEN x = new_chunk(l+1);
100
101
va_start(args,len); x[0] = len;
102
for (i=1; i<=l; i++) x[i] = va_arg(args,int);
103
va_end(args); return x;
104
}
105
106
/* return a VECSMALL of length l from the arguments (for galoismodulo11) */
107
static GEN
108
_typ(long l,...)
109
{
110
va_list args;
111
long i;
112
GEN x = cgetg(l+1, t_VECSMALL);
113
114
va_start(args,l);
115
for (i=1; i<=l; i++) x[i] = va_arg(args,int);
116
va_end(args); return x;
117
}
118
119
/* create a permutation with the N arguments of the function */
120
static PERM
121
_cr(long N, long a,...)
122
{
123
va_list args;
124
long i;
125
GEN x = new_chunk(NMAX+1);
126
va_start(args, a); x[0] = N; x[1] = a;
127
for (i=2; i<=N; i++) x[i] = va_arg(args,int);
128
va_end(args); return x;
129
}
130
131
static PERM
132
permmul(PERM s1, PERM s2)
133
{
134
long i, n1 = s1[0];
135
PERM s3 = (PERM)stack_malloc((n1+1) * sizeof(long));
136
for (i=1; i<=n1; i++) s3[i] = s1[s2[i]];
137
s3[0] = n1; return s3;
138
}
139
140
static void
141
printperm(PERM perm)
142
{
143
long i, n = perm[0];
144
err_printf("(");
145
for (i=1; i<=n; i++) err_printf(" %d",perm[i]);
146
err_printf(" )\n");
147
}
148
149
static int
150
raye(long *g, long num)
151
{
152
long i, nb = labs(g[0]);
153
for (i=1; i<=nb; i++)
154
if (g[i] == num) return 0;
155
return 1;
156
}
157
158
/* we can never determine the group completely in there */
159
static long
160
rayergroup11(long EVEN, long num, long *gr)
161
{
162
long r = 0;
163
164
if (EVEN)
165
switch(num)
166
{
167
case 2: case 5:
168
if (gr[3]) { gr[3]=0; r++; }
169
case 3: case 6: case 7:
170
if (gr[2]) { gr[2]=0; r++; }
171
case 4:
172
if (gr[1]) { gr[1]=0; r++; }
173
}
174
else
175
switch(num)
176
{
177
case 2: case 3:
178
if (gr[1]) { gr[1]=0; r++; }
179
}
180
return r;
181
}
182
183
static long
184
rayergroup(long EVEN, long **GR, long num, long *gr)
185
{
186
long i,nbgr,r;
187
188
if (!GR) return rayergroup11(EVEN,num,gr);
189
nbgr = lg(GR); r = 0 ;
190
if (EVEN)
191
{
192
for (i=1; i<nbgr; i++)
193
if (gr[i] && GR[i][0] < 0 && raye(GR[i],num)) { gr[i]=0; r++; }
194
}
195
else
196
{
197
for (i=1; i<nbgr; i++)
198
if (gr[i] && GR[i][0] > 0 && raye(GR[i],num)) { gr[i]=0; r++; }
199
}
200
return r;
201
}
202
203
static long
204
galmodp(long EVEN, GEN pol, GEN dpol, GEN TYP, long *gr, long **GR)
205
{
206
long i,k,l,n,nbremain;
207
GEN p1, dtyp;
208
forprime_t T;
209
210
switch(degpol(pol))
211
{
212
case 8: nbremain = EVEN? 28: 22; break;
213
case 9: nbremain = EVEN? 18: 16; break;
214
case 10: nbremain = EVEN? 12: 33; break;
215
default: nbremain = EVEN? 5: 3; break; /* case 11 */
216
}
217
218
u_forprime_init(&T, 2, ULONG_MAX);
219
dtyp = new_chunk(NMAX+1);
220
k = gr[0]; for (i=1; i<k; i++) gr[i]=1;
221
for (k=1; k<15; k++)
222
{
223
ulong p = u_forprime_next(&T);
224
if (!umodiu(dpol,p)) continue; /* p divides dpol */
225
226
p1 = gel(Flx_degfact(ZX_to_Flx(pol,p),p),1);
227
l = lg(p1);
228
dtyp[0] = evaltyp(t_VECSMALL)|evallg(l);
229
for (i=1; i<l; i++) dtyp[i] = p1[l-i]; /* decreasing order */
230
n = RgV_isin(TYP, dtyp);
231
if (!n) return 1; /* only for N=11 */
232
nbremain -= rayergroup(EVEN,GR,n,gr);
233
if (nbremain==1) return 1;
234
}
235
return 0;
236
}
237
238
static void
239
preci(GEN o, long p)
240
{
241
long i, l = lg(o);
242
for (i=1; i<l; i++)
243
{
244
GEN x = gel(o,i);
245
if (typ(x)==t_COMPLEX) { setprec(gel(x,1),p); setprec(gel(x,2),p); } else setprec(x,p);
246
}
247
}
248
static void
249
fixprec(buildroot *BR)
250
{
251
GEN r = BR->r;
252
long i, l = lg(r), p = BR->pr;
253
254
if (p > BR->prmax) pari_err_BUG("fixprex [precision too large]");
255
for (i = 1; i < l; i++) preci(gel(r,i), p);
256
}
257
258
static long
259
getpreci(buildroot *BR)
260
{
261
GEN x = gmael(BR->r,1,1);
262
return (typ(x)==t_COMPLEX)? realprec(gel(x,1)): realprec(x);
263
}
264
265
#define setcard_obj(x,n) ((x)[0] = (PERM)(n))
266
#define getcard_obj(x) ((long)((x)[0]))
267
268
/* allocate a list of m arrays of length n (index 0 is codeword) */
269
static PERM *
270
alloc_pobj(long n, long m)
271
{
272
long i;
273
PERM *g = (PERM*) stack_malloc( (m+1)*sizeof(PERM) + (n+1)*m * sizeof(long) );
274
PERM gpt = (PERM) (g + (m+1));
275
276
for (i=1; i<=m; i++) { g[i] = gpt; gpt += (n+1); }
277
setcard_obj(g, m); return g;
278
}
279
280
static GROUP
281
allocgroup(long n, long card)
282
{
283
GROUP gr = alloc_pobj(n,card);
284
long i;
285
286
for (i=1; i<=card; i++) gr[i][0] = n;
287
return gr;
288
}
289
290
static pariFILE *
291
galopen(const char *pre, long n, long n1, long n2)
292
{
293
pari_sp av = avma;
294
char *s = stack_malloc(strlen(pari_datadir) + 3 + 4 * 20 + 1 + 3);
295
pariFILE *f;
296
297
(void)sprintf(s, "%s/galdata/%s%ld_%ld_%ld", pari_datadir, pre, n, n1, n2);
298
f = pari_fopengz(s);
299
if (!f) pari_err_FILE("galois file",s);
300
set_avma(av); return f;
301
}
302
303
static char
304
bin(char c)
305
{
306
if (c>='0' && c<='9') c -= '0';
307
else if (c>='A' && c<='Z') c -= 'A'-10;
308
else if (c>='a' && c<='z') c -= 'a'-36;
309
else pari_err_TYPE("bin [not alphanumeric]", stoi(c));
310
return c;
311
}
312
313
#define BUFFS 512
314
/* fill in g[i][j] (i<=n, j<=m) with (buffered) data from f->file */
315
static void
316
read_obj(PERM *g, pariFILE *f, long n, long m)
317
{
318
long i, j, k, N = m*n;
319
char *ch = stack_malloc(N);
320
pari_fread_chars(ch, N, f->file);
321
for (k = 0, i = 1; i <= n; i++)
322
for (j = 1; j <= m; j++,k++) g[i][j] = bin(ch[k]);
323
pari_fclose(f);
324
}
325
#undef BUFFS
326
327
/* the first 8 bytes contain size data (possibly padded with \0) */
328
static GROUP
329
lirecoset(long n1, long n2, long n)
330
{
331
GROUP gr;
332
char c, ch[8];
333
long m, cardgr;
334
pariFILE *f = galopen("COS", n, n1, n2);
335
pari_fread_chars(&c, 1, f->file); m=bin(c);
336
pari_fread_chars(&c, 1, f->file);
337
pari_fread_chars(ch, 6, f->file); cardgr=atol(ch);
338
gr=allocgroup(m,cardgr);
339
read_obj(gr, f,cardgr,m); return gr;
340
}
341
342
static void
343
lireresolv(long n1, long n2, long n, resolv *R)
344
{
345
char ch[5];
346
long nm, nv;
347
pariFILE *f = galopen("RES", n, n1, n2);
348
pari_fread_chars(ch,5,f->file); nm = atol(ch);
349
pari_fread_chars(ch,3,f->file); nv = atol(ch);
350
R->a = alloc_pobj(nv,nm);
351
read_obj(R->a, f,nm,nv);
352
R->nm = nm;
353
R->nv = nv;
354
}
355
356
static int
357
cmp_re(GEN x, GEN y)
358
{
359
if (typ(x) != t_COMPLEX) return -1;
360
if (typ(y) != t_COMPLEX) return 1; /* t_REALS are smallest */
361
return gcmp(gel(x,1), gel(y,1));
362
}
363
364
/* multiply the r o bb. Sort first to detect pairs of conjugate */
365
static GEN
366
Monomial(GEN r, PERM bb, long nbv)
367
{
368
GEN t, R = cgetg(nbv + 1, t_VEC);
369
long i, s = 1;
370
371
for (i = 1; i <= nbv; i++)
372
{
373
t = gel(r,bb[i]);
374
if (typ(t) == t_COMPLEX && signe(gel(t,1)) < 0) { s = -s; t = gneg(t); }
375
gel(R,i) = t;
376
}
377
if (nbv > 2)
378
gen_sort_inplace(R, (void*)&cmp_re, cmp_nodata, NULL);
379
else if (nbv == 2 && typ(gel(R,2)) != t_COMPLEX)
380
swap(gel(R,1), gel(R,2));
381
t = NULL;
382
for (i=1; i<=nbv; i++)
383
{
384
GEN c = gel(R,i);
385
if (typ(c) == t_COMPLEX && i < nbv)
386
{ /* detect conjugates */
387
GEN n = gel(R,++i);
388
if (!abscmprr(gel(n,1), gel(c,1))
389
&& !abscmprr(gel(n,2), gel(c,2))
390
&& signe(gel(c,2)) != signe(gel(n,2)))
391
c = addrr(sqrr(gel(c,1)), sqrr(gel(c,2)));
392
else
393
c = gmul(c,n);
394
}
395
t = t? gmul(t, c): c;
396
}
397
if (s < 0) t = gneg(t);
398
return t;
399
}
400
401
/* sum(i = 1, R->nm, Monomial(r, R->a[i], R->nv)). Sort real / imaginary part
402
* separately by increasing absolute values, to increase stability */
403
static GEN
404
gpolynomial(GEN r, resolv *R)
405
{
406
GEN RE = cgetg(R->nm+1, t_VEC), IM = cgetg(R->nm+1, t_VEC), re, im;
407
long i, k;
408
for (i = k = 1; i <= R->nm; i++)
409
{
410
GEN m = Monomial(r,R->a[i], R->nv);
411
if (typ(m) == t_REAL)
412
gel(RE, i) = m;
413
else {
414
gel(RE, i) = gel(m,1);
415
gel(IM, k++) = gel(m,2);
416
}
417
}
418
setlg(IM, k);
419
gen_sort_inplace(RE, (void*)&abscmprr, cmp_nodata, NULL);
420
gen_sort_inplace(IM, (void*)&abscmprr, cmp_nodata, NULL);
421
re = gel(RE,1);
422
for (i = 2; i <= R->nm; i++) re = addrr(re, gel(RE,i));
423
if (k == 1) return re;
424
im = gel(IM,1);
425
for (i = 2; i < k; i++) im = addrr(im, gel(IM,i));
426
return mkcomplex(re, im);
427
}
428
429
static void
430
zaux1(GEN *z, GEN *r)
431
{
432
GEN p2,p1;
433
p2=gsub(r[1], gadd(r[2],r[5]));
434
p2=gmul(p2, gsub(r[2],r[5]));
435
p1=gmul(p2,r[1]);
436
p2=gsub(r[3],gadd(r[2],r[4]));
437
p2=gmul(p2,gsub(r[4],r[2]));
438
p1=gadd(p1,gmul(p2,r[3]));
439
p2=gmul(r[5],gsub(r[4],r[5]));
440
z[1]=gadd(p1,gmul(p2,r[4]));
441
442
p2=gsub(r[1],gadd(r[3],r[4]));
443
p2=gmul(p2,gsub(r[3],r[4]));
444
p1=gmul(p2,r[1]);
445
p2=gsub(r[5],gadd(r[3],r[2]));
446
p2=gmul(p2,gsub(r[2],r[3]));
447
p1=gadd(p1,gmul(p2,r[5]));
448
p2=gmul(r[4],gsub(r[2],r[4]));
449
z[2]=gadd(p1,gmul(p2,r[2]));
450
}
451
452
static void
453
zaux(GEN *z, GEN *r)
454
{
455
zaux1(z, r); zaux1(z+2, r+5);
456
}
457
458
static GEN
459
gpoly(GEN rr, long n1, long n2)
460
{
461
const long N = lg(rr)-1;
462
GEN p1,p2,z[6], *r = (GEN*)rr; /* syntaxic kludge */
463
long i,j;
464
465
if (N==8)
466
{
467
if (n1==47 && n2==46)
468
{
469
p1=gsub(r[3],r[4]);
470
for (i=1; i<3; i++) for (j=i+1; j<5; j++) p1 = gmul(p1,gsub(r[i],r[j]));
471
for (i=5; i<8; i++) for (j=i+1; j<9; j++) p1 = gmul(p1,gsub(r[i],r[j]));
472
p2=r[1];
473
for (i=2; i<5; i++) p2=gadd(p2,r[i]);
474
for (i=5; i<9; i++) p2=gsub(p2,r[i]);
475
}
476
else /* n1==44 && n2==40 */
477
{
478
for (i=1; i<5; i++) z[i] = gadd(r[2*i-1],r[2*i]);
479
p1 = gsub(r[1],r[2]);
480
for (i=2; i<5; i++) p1 = gmul(p1,gsub(r[2*i-1],r[2*i]));
481
p2=gsub(z[3],z[4]);
482
for (i=1; i<3; i++) for (j=i+1; j<5; j++) p2 = gmul(p2,gsub(z[i],z[j]));
483
}
484
return gmul(p1,p2);
485
}
486
487
if (N==9)
488
{
489
if (n1==31 && n2==29)
490
{
491
p1=gsub(r[2],r[3]);
492
for (j=2; j<4; j++) p1 = gmul(p1,gsub(r[1],r[j]));
493
for (i=4; i<6; i++) for (j=i+1; j<7; j++) p1 = gmul(p1,gsub(r[i],r[j]));
494
p2 = gsub(r[8],r[9]);
495
for (j=8; j<10; j++) p2 = gmul(p2,gsub(r[7],r[j]));
496
}
497
else /* ((n1==34 && n2==31) || (n1=33 && n2==30)) */
498
{
499
p1=r[1]; for (i=2; i<4; i++) p1=gadd(p1,r[i]);
500
p2=r[4]; for (i=5; i<7; i++) p2=gadd(p2,r[i]);
501
p1=gmul(p1,p2);
502
p2=r[7]; for (i=8; i<10; i++) p2=gadd(p2,r[i]);
503
}
504
return gmul(p1,p2);
505
}
506
507
if (N==10)
508
{
509
if ((n1==45 && n2==43) || (n1==44 && n2==42))
510
{
511
p1=r[1]; for (i=2; i<6; i++) p1=gadd(p1,r[i]);
512
p2=r[6]; for (i=7; i<11; i++) p2=gadd(p2,r[i]);
513
return gmul(p1,p2);
514
}
515
else if ((n1==45 && n2==39) || (n1==44 && n2==37))
516
{
517
p1 = gadd(r[1],r[2]);
518
for (i=2; i<6; i++) p1 = gmul(p1,gadd(r[2*i-1],r[2*i]));
519
return p1;
520
}
521
else if ((n1==43 && n2==41) || (n1==33 && n2==27))
522
{
523
p1=gsub(r[4],r[5]);
524
for (i=1; i<4; i++) for (j=i+1; j<6; j++) p1=gmul(p1,gsub(r[i],r[j]));
525
p2=gsub(r[9],r[10]);
526
for (i=6; i<9; i++) for (j=i+1; j<11; j++) p2=gmul(p2,gsub(r[i],r[j]));
527
return gmul(p1,p2);
528
}
529
else if ((n1==43 && n2==33) || (n1==42 && n2==28) || (n1==41 && n2==27)
530
|| (n1==40 && n2==21))
531
{
532
p2=gadd(r[2],r[5]);
533
p2=gsub(p2,gadd(r[3],r[4]));
534
p1=gmul(p2,r[1]);
535
p2=gsub(r[3],gadd(r[4],r[5]));
536
p1=gadd(p1,gmul(p2,r[2]));
537
p2=gsub(r[4],r[5]);
538
p1=gadd(p1,gmul(p2,r[3]));
539
z[1]=gadd(p1,gmul(r[4],r[5]));
540
541
p2=gadd(r[7],r[10]);
542
p2=gsub(p2,gadd(r[8],r[9]));
543
p1=gmul(p2,r[6]);
544
p2=gsub(r[8],gadd(r[9],r[10]));
545
p1=gadd(p1,gmul(p2,r[7]));
546
p2=gsub(r[9],r[10]);
547
p1=gadd(p1,gmul(p2,r[8]));
548
z[2]=gadd(p1,gmul(r[9],r[10]));
549
return gadd(gsqr(z[1]), gsqr(z[2]));
550
}
551
else if (n1==41 && n2==40)
552
{
553
p1=gsub(r[4],r[5]);
554
for (i=1; i<4; i++) for (j=i+1; j<6; j++) p1 = gmul(p1,gsub(r[i],r[j]));
555
p2=gsub(r[9],r[10]);
556
for (i=6; i<9; i++) for (j=i+1; j<11; j++) p2 = gmul(p2,gsub(r[i],r[j]));
557
return gadd(p1,p2);
558
}
559
else if ((n1==41 && n2==22) || (n1==40 && n2==11) || (n1==17 && n2==5)
560
|| (n1==10 && n2==4) || (n1==9 && n2==3) || (n1==6 && n2==1))
561
{
562
p1=gadd(r[1],r[6]);
563
for (i=2; i<6; i++) p1=gmul(p1,gadd(r[i],r[i+5]));
564
return p1;
565
}
566
else if ((n1==39 && n2==38) || (n1==29 && n2==25))
567
{
568
for (i=1; i<6; i++) z[i]=gadd(r[2*i-1],r[2*i]);
569
p1=gsub(r[1],r[2]);
570
for (i=2; i<6; i++) p1=gmul(p1,gsub(r[2*i-1],r[2*i]));
571
p2=gsub(z[4],z[5]);
572
for (i=1; i<4; i++) for (j=i+1; j<6; j++) p2=gmul(p2,gsub(z[i],z[j]));
573
return gmul(p1,p2);
574
}
575
else if ((n1==39 && n2==36) || (n1==37 && n2==34) || (n1==29 && n2==23)
576
|| (n1==24 && n2==15))
577
{
578
for (i=1; i<6; i++) z[i]=gadd(r[2*i-1],r[2*i]);
579
p1=gsub(z[4],z[5]); p2=gmul(gsub(z[3],z[4]),gsub(z[3],z[5]));
580
for (i=1; i<3; i++) for (j=i+1; j<6; j++) p2=gmul(p2,gsub(z[i],z[j]));
581
return gmul(p1,p2);
582
}
583
else if ((n1==39 && n2==29) || (n1==38 && n2==25) || (n1==37 && n2==24)
584
|| (n1==36 && n2==23) || (n1==34 && n2==15))
585
{
586
for (i=1; i<6; i++) z[i]=gadd(r[2*i-1],r[2*i]);
587
p2=gadd(z[2],z[5]);
588
p2=gsub(p2,gadd(z[3],z[4]));
589
p1=gmul(p2,z[1]);
590
p2=gsub(z[3],gadd(z[4],z[5]));
591
p1=gadd(p1,gmul(p2,z[2]));
592
p2=gsub(z[4],z[5]);
593
p1=gadd(p1,gmul(p2,z[3]));
594
p1=gadd(p1,gmul(z[4],z[5]));
595
return gsqr(p1);
596
}
597
else if ((n1==39 && n2==22) || (n1==38 && n2==12) || (n1==36 && n2==11)
598
|| (n1==29 && n2== 5) || (n1==25 && n2== 4) || (n1==23 && n2== 3)
599
|| (n1==16 && n2== 2) || (n1==14 && n2== 1))
600
{
601
p1=r[1]; for (i=2; i<6; i++) p1=gadd(p1,r[2*i-1]);
602
p2=r[2]; for (i=2; i<6; i++) p2=gadd(p2,r[2*i]);
603
return gmul(p1,p2);
604
}
605
else if (n1==28 && n2==18)
606
{
607
zaux(z, r);
608
p1=gmul(z[1],gsub(z[3],z[4]));
609
p2=gmul(z[2],gadd(z[3],z[4])); return gadd(p1,p2);
610
}
611
else if (n1==27 && n2==20)
612
{
613
zaux(z, r); p1=gmul(z[1],z[3]); p2=gmul(z[2],z[4]);
614
p1 = gsub(p1,p2); p2=r[1];
615
for (i=2; i<6 ; i++) p2=gadd(p2,r[i]);
616
for ( ; i<11; i++) p2=gsub(p2,r[i]);
617
return gmul(p1,p2);
618
}
619
else if (n1==27 && n2==19)
620
{
621
zaux(z, r); p1=gmul(z[1],z[3]); p2=gmul(z[2],z[4]);
622
return gsub(p1,p2);
623
}
624
else if ((n1==27 && n2==17) || (n1==21 && n2==9))
625
{
626
zaux(z, r); p1=gmul(z[1],z[3]); p2=gmul(z[2],z[4]);
627
return gadd(p1,p2);
628
}
629
else if (n1==23 && n2==16)
630
{
631
for (i=1; i<6; i++) z[i]=gadd(r[2*i-1],r[2*i]);
632
p1=gsub(z[1],gadd(z[2],z[5])); p1=gmul(p1,gsub(z[2],z[5]));
633
p2=gmul(p1,z[1]); p1=gsub(z[3],gadd(z[2],z[4]));
634
p1=gmul( p1,gsub(z[4],z[2])); p2=gadd(p2,gmul(p1,z[3]));
635
p1=gmul(z[5],gsub(z[4],z[5])); p2=gadd(p2,gmul(p1,z[4]));
636
p1=gsub(r[1],r[2]);
637
for (i=2; i<6; i++) p1=gmul(p1,gsub(r[2*i-1],r[2*i]));
638
return gmul(p1,p2);
639
}
640
else if (n1==22 && n2==12)
641
{
642
for (i=1; i<6; i++) z[i]=gadd(r[i],r[i+5]);
643
p1=gsub(r[1],r[6]);
644
for (i=2; i<6; i++) p1=gmul(p1,gsub(r[i],r[i+5]));
645
p2=gsub(z[4],z[5]);
646
for (i=1; i<4; i++) for (j=i+1; j<6; j++) p2=gmul(p2,gsub(z[i],z[j]));
647
return gmul(p1,p2);
648
}
649
else if ((n1==22 && n2==11) || (n1==5 && n2==3))
650
{
651
for (i=1; i<6; i++) z[i]=gadd(r[i],r[i+5]);
652
p1=gsub(z[4],z[5]); p2=gmul(gsub(z[3],z[4]),gsub(z[3],z[5]));
653
for (i=1; i<3; i++) for (j=i+1; j<6; j++) p2=gmul(p2,gsub(z[i],z[j]));
654
return gmul(p1,p2);
655
}
656
else if ((n1==22 && n2==5) || (n1==12 && n2==4) || (n1==11 && n2==3))
657
{
658
for (i=1; i<6; i++) z[i]=gadd(r[i],r[i+5]);
659
p2=gadd(z[2],z[5]); p2=gsub(p2,gadd(z[3],z[4])); p1=gmul(p2,z[1]);
660
p2=gsub(z[3],gadd(z[4],z[5])); p1=gadd(p1,gmul(p2,z[2]));
661
p2=gsub(z[4],z[5]);
662
p1=gadd(p1,gmul(p2,z[3])); p1=gadd(p1,gmul(z[4],z[5]));
663
return gsqr(p1);
664
}
665
else if (n1==21 && n2==10)
666
{
667
zaux(z, r); p1=gmul(z[1],z[4]); p2=gmul(z[2],z[3]);
668
return gsub(p1,p2);
669
}
670
}
671
pari_err_TYPE("gpoly [undefined invariant polynomial]", mkvecsmall2(n1,n2));
672
return NULL; /* LCOV_EXCL_LINE */
673
}
674
675
/* a is a t_VECSMALL representing a polynomial */
676
static GEN
677
new_pol(long N, GEN r, GEN a)
678
{
679
long i, j, l = lg(a);
680
GEN x, z, v = cgetg(N+1, t_VEC);
681
for (i=1; i<=N; i++)
682
{
683
z = gel(r,i); x = gaddsg(a[2], z);
684
for (j = 3; j < l; j++) x = gaddsg(a[j], gmul(z,x));
685
gel(v,i) = x;
686
}
687
return gclone(v);
688
}
689
690
/* BR->r[l], BR->coef[l] hold data related to Tschirnausen transform of
691
* degree l - 1 */
692
static void
693
tschirn(buildroot *BR)
694
{
695
long i, k, v = varn(BR->p), l = lg(BR->r);
696
GEN a, h, r;
697
698
if (l >= BR->N) pari_err_BUG("tschirn");
699
if (DEBUGLEVEL)
700
err_printf("\n$$$$$ Tschirnhaus transformation of degree %ld: $$$$$\n",l-1);
701
702
a = gel(BR->coef,l); /* fill with random polynomial of degree <= l-1 */
703
do
704
{
705
a[1]=0;
706
for (i=2; i < l+2; i++) a[i] = random_bits(3) + 1;
707
h = Flx_to_ZX(Flx_renormalize(a,l+2));
708
} while (degpol(h) <= 0 || !ZX_is_squarefree(h));
709
setvarn(h, v); k = 0;
710
(void)ZXQ_charpoly_sqf(BR->p, h, &k, v);
711
a[2] += k;
712
713
r = gel(BR->r,1);
714
preci(r, BR->prmax); /* max accuracy original roots */
715
vectrunc_append(BR->r, new_pol(BR->N, r, a));
716
fixprec(BR); /* restore accuracy */
717
}
718
719
static GEN
720
sortroots(GEN newr, GEN oldr)
721
{
722
long e, e0, i, j, k, l = lg(newr);
723
GEN r = cgetg(l, t_VEC), z = cgetg(l, t_VEC), t = const_vecsmall(l-1, 1);
724
k = 0; /* gcc -Wall */
725
for (i=1; i<l; i++)
726
{
727
e0 = EXPOBITS;
728
for (j=1; j<l; j++)
729
if (t[j])
730
{
731
e = gexpo(gsub(gel(oldr,i), gel(newr,j)));
732
if (e < e0) { e0 = e; k = j; }
733
}
734
gel(z,i) = gel(newr,k); t[k] = 0;
735
}
736
for (i=1; i<l; i++) gel(r,i) = gel(z,i);
737
return r;
738
}
739
740
static void
741
delete_roots(buildroot *BR)
742
{
743
GEN r = BR->r;
744
long i, l = lg(r);
745
for (i = 1; i < l; i++) gunclone(gel(r,i));
746
setlg(r, 1);
747
}
748
749
/* increase the roots accuracy */
750
static void
751
moreprec(buildroot *BR)
752
{
753
long d = BR->pr - BR->prmax;
754
if (d > 0)
755
{ /* recompute roots */
756
pari_sp av = avma;
757
long l = lg(BR->r);
758
GEN ro;
759
760
if (d < BIGDEFAULTPREC-2) d = BIGDEFAULTPREC-2;
761
BR->prmax = maxss(BR->prmax+d, (long)(BR->prmax * 1.2));
762
if (DEBUGLEVEL) err_printf("$$$$$ New prec = %ld\n",BR->prmax);
763
ro = sortroots(QX_complex_roots(BR->p,BR->prmax), gel(BR->r,1));
764
delete_roots(BR);
765
vectrunc_append(BR->r, gclone(ro));
766
for (d = 2; d < l; d++)
767
vectrunc_append(BR->r, new_pol(BR->N, ro, gel(BR->coef,d)));
768
set_avma(av);
769
}
770
fixprec(BR);
771
}
772
773
/* determine "sufficient" extra bit-precision such that we may decide
774
* (heuristic) whether z is an integer. */
775
static GEN
776
get_ro(long N, GEN rr, PERM S1, PERM S2, resolv *R)
777
{
778
GEN r = cgetg(N+1, t_VEC);
779
long i;
780
for (i=1; i<=N; i++) r[i] = rr[ S1[S2[i] ] ];
781
return R->a? gpolynomial(r, R): gpoly(r,R->nm,R->nv);
782
}
783
/* typ(z) = t_REAL, return zi = t_INT approximation */
784
static long
785
sufprec_r(GEN z)
786
{
787
long p = bit_prec(z);
788
/* bit accuracy of fractional part large enough ? */
789
return ( p - expo(z) > maxss(3*32, (long)0.2*p) );
790
}
791
/* typ(z) = t_REAL or t_COMPLEX, return zi = t_INT approximation */
792
static long
793
sufprec(GEN z)
794
{
795
if (typ(z) == t_REAL)
796
return sufprec_r(z);
797
else
798
return sufprec_r(gel(z,2)) && sufprec_r(gel(z,1));
799
}
800
801
static GEN
802
get_ro_perm(PERM S1, PERM S2, long d, resolv *R, buildroot *BR)
803
{
804
GEN ro, roi;
805
long e;
806
for (;;)
807
{
808
ro = get_ro(BR->N, gel(BR->r, d), S1,S2,R); roi = grndtoi(ro, &e);
809
if (e < 0)
810
{
811
if (e < -64 || sufprec(ro)) break;
812
e = 0;
813
}
814
BR->pr += nbits2extraprec(e + 10);
815
moreprec(BR);
816
}
817
if (e > -10 || typ(roi) == t_COMPLEX) return NULL;
818
/* compute with 128 more bits */
819
BR->pr += MEDDEFAULTPREC-2;
820
moreprec(BR);
821
ro = get_ro(BR->N, gel(BR->r, d), S1,S2,R);
822
BR->pr -= MEDDEFAULTPREC-2;
823
fixprec(BR);
824
/* ro closer to roi (32 more bits) ? */
825
return (gexpo(gsub(ro, roi)) < e - 32) ? roi: NULL;
826
}
827
828
static void
829
dbg_rac(long nri,long nbracint,long numi[],GEN racint[],long multi[])
830
{
831
long k;
832
err_printf("\t# rational integer roots = %ld:",nbracint-nri);
833
for (k = nri+1; k <= nbracint; k++) err_printf(" %ld^%ld", numi[k], multi[k]);
834
err_printf("\n");
835
for (k = nri+1; k <= nbracint; k++) err_printf("\t%2ld: %Ps\n", numi[k], racint[k]);
836
}
837
838
#define M 2521
839
/* return NULL if not included, the permutation of the roots otherwise */
840
static PERM
841
check_isin(buildroot *BR, resolv *R, GROUP tau, GROUP ss)
842
{
843
long nogr, nocos, init, i, j, k, l, d;
844
pari_sp av1 = avma, av2;
845
long nbgr,nbcos,nbracint,nbrac,lastnbri,lastnbrm;
846
long numi[M],numj[M],lastnum[M],multi[M],norac[M],lastnor[M];
847
GEN racint[M], roint;
848
849
if (getpreci(BR) != BR->pr) fixprec(BR);
850
nbcos = getcard_obj(ss);
851
nbgr = getcard_obj(tau);
852
lastnbri = lastnbrm = -1; nbracint = nbrac = 0; /* gcc -Wall*/
853
for (nogr=1; nogr<=nbgr; nogr++)
854
{
855
PERM T = tau[nogr];
856
if (DEBUGLEVEL) err_printf(" ----> Group # %ld/%ld:\n",nogr,nbgr);
857
init = 0; d = 1;
858
for (;;)
859
{
860
if (!init)
861
{
862
av2 = avma; nbrac = nbracint = 0;
863
for (nocos=1; nocos<=nbcos; nocos++, set_avma(av2))
864
{
865
roint = get_ro_perm(T, ss[nocos], d, R, BR);
866
if (!roint) continue;
867
868
nbrac++;
869
if (nbrac >= M)
870
{
871
pari_warn(warner, "more than %ld rational integer roots\n", M);
872
set_avma(av1); goto NEXT;
873
}
874
for (j=1; j<=nbracint; j++)
875
if (equalii(roint,racint[j])) { multi[j]++; break; }
876
if (j > nbracint)
877
{
878
nbracint = j; multi[j] = 1; numi[j] = nocos;
879
racint[j] = gerepileuptoint(av2,roint); av2 = avma;
880
}
881
numj[nbrac] = nocos; norac[nbrac] = j;
882
}
883
if (DEBUGLEVEL) dbg_rac(0,nbracint,numi,racint,multi);
884
for (i=1; i<=nbracint; i++)
885
if (multi[i]==1) return permmul(T, ss[numi[i]]);
886
init = 1;
887
}
888
else
889
{
890
nbrac = nbracint = 0;
891
for (l=1; l<=lastnbri; l++, set_avma(av1))
892
{
893
long nri = nbracint;
894
av2 = avma;
895
for (k=1; k<=lastnbrm; k++)
896
if (lastnor[k]==l)
897
{
898
nocos = lastnum[k];
899
roint = get_ro_perm(T, ss[nocos], d, R, BR);
900
if (!roint) { set_avma(av2); continue; }
901
902
nbrac++;
903
for (j=nri+1; j<=nbracint; j++)
904
if (equalii(roint,racint[j])) { multi[j]++; break; }
905
if (j > nbracint)
906
{
907
nbracint = j; multi[j] = 1; numi[j] = nocos;
908
racint[j] = gerepileuptoint(av2,roint); av2=avma;
909
}
910
numj[nbrac] = nocos; norac[nbrac] = j;
911
}
912
if (DEBUGLEVEL) dbg_rac(nri,nbracint,numi,racint,multi);
913
for (i=nri+1; i<=nbracint; i++)
914
if (multi[i]==1) return permmul(T, ss[numi[i]]);
915
}
916
}
917
set_avma(av1); if (!nbracint) break;
918
919
lastnbri = nbracint; lastnbrm = nbrac;
920
for (j=1; j<=nbrac; j++) { lastnum[j] = numj[j]; lastnor[j] = norac[j]; }
921
922
NEXT:
923
if (DEBUGLEVEL) {
924
err_printf(" all integer roots are double roots\n");
925
err_printf(" Working with polynomial #%ld:\n", d+1);
926
}
927
if (++d >= lg(BR->r)) tschirn(BR);
928
}
929
}
930
return NULL;
931
}
932
#undef M
933
934
/* DEGREE 8 */
935
static long
936
galoisprim8(long EVEN, buildroot *BR)
937
{
938
long rep;
939
940
rep=isin_G_H(BR,50,43);
941
if (rep) return EVEN? 37: 43;
942
if (!EVEN) return 50;
943
rep=isin_G_H(BR,49,48);
944
if (!rep) return 49;
945
rep=isin_G_H(BR,48,36);
946
if (!rep) return 48;
947
rep=isin_G_H(BR,36,25);
948
return rep? 25: 36;
949
}
950
951
static long
952
galoisimpodd8(buildroot *BR, long nh)
953
{
954
long rep;
955
if (nh!=47) goto IMPODD_8_6;
956
rep=isin_G_H(BR,47,46);
957
if (!rep) goto IMPODD_8_5;
958
rep=isin_G_H(BR,46,28);
959
if (rep) goto IMPODD_8_7; else return 46;
960
961
IMPODD_8_5:
962
rep=isin_G_H(BR,47,35);
963
if (rep) goto IMPODD_8_9; else return 47;
964
965
IMPODD_8_6:
966
rep=isin_G_H(BR,44,40);
967
if (rep) goto IMPODD_8_10; else goto IMPODD_8_11;
968
969
IMPODD_8_7:
970
rep=isin_G_H(BR,28,21);
971
if (rep) return 21; else goto IMPODD_8_33;
972
973
IMPODD_8_9:
974
rep=isin_G_H(BR,35,31);
975
if (rep) goto IMPODD_8_13; else goto IMPODD_8_14;
976
977
IMPODD_8_10:
978
rep=isin_G_H(BR,40,26);
979
if (rep) goto IMPODD_8_15; else goto IMPODD_8_16;
980
981
IMPODD_8_11:
982
rep=isin_G_H(BR,44,38);
983
if (rep) goto IMPODD_8_17; else goto IMPODD_8_18;
984
985
IMPODD_8_12:
986
rep=isin_G_H(BR,16,7);
987
if (rep) goto IMPODD_8_19; else return 16;
988
989
IMPODD_8_13:
990
rep=isin_G_H(BR,31,21);
991
return rep? 21: 31;
992
993
IMPODD_8_14:
994
rep=isin_G_H(BR,35,30);
995
if (rep) goto IMPODD_8_34; else goto IMPODD_8_20;
996
997
IMPODD_8_15:
998
rep=isin_G_H(BR,26,16);
999
if (rep) goto IMPODD_8_12; else goto IMPODD_8_21;
1000
1001
IMPODD_8_16:
1002
rep=isin_G_H(BR,40,23);
1003
if (rep) goto IMPODD_8_22; else return 40;
1004
1005
IMPODD_8_17:
1006
rep=isin_G_H(BR,38,31);
1007
if (rep) goto IMPODD_8_13; else return 38;
1008
1009
IMPODD_8_18:
1010
rep=isin_G_H(BR,44,35);
1011
if (rep) goto IMPODD_8_9; else return 44;
1012
1013
IMPODD_8_19:
1014
rep=isin_G_H(BR,7,1);
1015
return rep? 1: 7;
1016
1017
IMPODD_8_20:
1018
rep=isin_G_H(BR,35,28);
1019
if (rep) goto IMPODD_8_7; else goto IMPODD_8_23;
1020
1021
IMPODD_8_21:
1022
rep=isin_G_H(BR,26,17);
1023
if (rep) goto IMPODD_8_24; else goto IMPODD_8_25;
1024
1025
IMPODD_8_22:
1026
rep=isin_G_H(BR,23,8);
1027
if (rep) goto IMPODD_8_26; else return 23;
1028
1029
IMPODD_8_23:
1030
rep=isin_G_H(BR,35,27);
1031
if (rep) goto IMPODD_8_27; else goto IMPODD_8_28;
1032
1033
IMPODD_8_24:
1034
rep=isin_G_H(BR,17,7);
1035
if (rep) goto IMPODD_8_19; else return 17;
1036
1037
IMPODD_8_25:
1038
rep=isin_G_H(BR,26,15);
1039
if (rep) goto IMPODD_8_29; else return 26;
1040
1041
IMPODD_8_26:
1042
rep=isin_G_H(BR,8,1);
1043
return rep? 1: 8;
1044
1045
IMPODD_8_27:
1046
rep=isin_G_H(BR,27,16);
1047
if (rep) goto IMPODD_8_12; else return 27;
1048
1049
IMPODD_8_28:
1050
rep=isin_G_H(BR,35,26);
1051
if (rep) goto IMPODD_8_15; else return 35;
1052
1053
IMPODD_8_29:
1054
rep=isin_G_H(BR,15,7);
1055
if (rep) goto IMPODD_8_19;
1056
rep=isin_G_H(BR,15,6);
1057
if (!rep) goto IMPODD_8_32;
1058
rep=isin_G_H(BR,6,1);
1059
return rep? 1: 6;
1060
1061
IMPODD_8_32:
1062
rep=isin_G_H(BR,15,8);
1063
if (rep) goto IMPODD_8_26; else return 15;
1064
1065
IMPODD_8_33:
1066
rep=isin_G_H(BR,28,16);
1067
if (rep) goto IMPODD_8_12; else return 28;
1068
1069
IMPODD_8_34:
1070
rep=isin_G_H(BR,30,21);
1071
return rep? 21: 30;
1072
}
1073
1074
static long
1075
galoisimpeven8(buildroot *BR, long nh)
1076
{
1077
long rep;
1078
if (nh!=45) goto IMPEVEN_8_6;
1079
rep=isin_G_H(BR,45,42);
1080
if (!rep) goto IMPEVEN_8_5;
1081
rep=isin_G_H(BR,42,34);
1082
if (rep) goto IMPEVEN_8_7; else goto IMPEVEN_8_8;
1083
1084
IMPEVEN_8_5:
1085
rep=isin_G_H(BR,45,41);
1086
if (rep) goto IMPEVEN_8_9; else return 45;
1087
1088
IMPEVEN_8_6:
1089
rep=isin_G_H(BR,39,32);
1090
if (rep) goto IMPEVEN_8_10; else goto IMPEVEN_8_11;
1091
1092
IMPEVEN_8_7:
1093
rep=isin_G_H(BR,34,18);
1094
if (rep) goto IMPEVEN_8_21; else goto IMPEVEN_8_45;
1095
1096
IMPEVEN_8_8:
1097
rep=isin_G_H(BR,42,33);
1098
if (rep) goto IMPEVEN_8_14; else return 42;
1099
1100
IMPEVEN_8_9:
1101
rep=isin_G_H(BR,41,34);
1102
if (rep) goto IMPEVEN_8_7; else goto IMPEVEN_8_15;
1103
1104
IMPEVEN_8_10:
1105
rep=isin_G_H(BR,32,22);
1106
if (rep) goto IMPEVEN_8_16; else goto IMPEVEN_8_17;
1107
1108
IMPEVEN_8_11:
1109
rep=isin_G_H(BR,39,29);
1110
if (rep) goto IMPEVEN_8_18; else goto IMPEVEN_8_19;
1111
1112
IMPEVEN_8_12:
1113
rep=isin_G_H(BR,14,4);
1114
return rep? 4: 14;
1115
1116
IMPEVEN_8_14:
1117
rep=isin_G_H(BR,33,18);
1118
if (rep) goto IMPEVEN_8_21; else goto IMPEVEN_8_22;
1119
1120
IMPEVEN_8_15:
1121
rep=isin_G_H(BR,41,33);
1122
if (rep) goto IMPEVEN_8_14; else goto IMPEVEN_8_23;
1123
1124
IMPEVEN_8_16:
1125
rep=isin_G_H(BR,22,11);
1126
if (rep) goto IMPEVEN_8_24; else goto IMPEVEN_8_25;
1127
1128
IMPEVEN_8_17:
1129
rep=isin_G_H(BR,32,13);
1130
if (rep) goto IMPEVEN_8_26; else goto IMPEVEN_8_27;
1131
1132
IMPEVEN_8_18:
1133
rep=isin_G_H(BR,29,22);
1134
if (rep) goto IMPEVEN_8_16; else goto IMPEVEN_8_28;
1135
1136
IMPEVEN_8_19:
1137
rep=isin_G_H(BR,39,24);
1138
if (rep) goto IMPEVEN_8_29; else return 39;
1139
1140
IMPEVEN_8_20:
1141
rep=isin_G_H(BR,9,4);
1142
if (rep) return 4; else goto IMPEVEN_8_30;
1143
1144
IMPEVEN_8_21:
1145
rep=isin_G_H(BR,18,10);
1146
if (rep) goto IMPEVEN_8_31; else goto IMPEVEN_8_32;
1147
1148
IMPEVEN_8_22:
1149
rep=isin_G_H(BR,33,13);
1150
if (rep) goto IMPEVEN_8_26; else return 33;
1151
1152
IMPEVEN_8_23:
1153
rep=isin_G_H(BR,41,29);
1154
if (rep) goto IMPEVEN_8_18; else goto IMPEVEN_8_33;
1155
1156
IMPEVEN_8_24:
1157
rep=isin_G_H(BR,11,5);
1158
if (rep) return 5; else goto IMPEVEN_8_34;
1159
1160
IMPEVEN_8_25:
1161
rep=isin_G_H(BR,22,9);
1162
if (rep) goto IMPEVEN_8_20; else return 22;
1163
1164
IMPEVEN_8_26:
1165
rep=isin_G_H(BR,13,3);
1166
return rep? 3: 13;
1167
1168
IMPEVEN_8_27:
1169
rep=isin_G_H(BR,32,12);
1170
if (rep) goto IMPEVEN_8_35; else return 32;
1171
1172
IMPEVEN_8_28:
1173
rep=isin_G_H(BR,29,20);
1174
if (rep) goto IMPEVEN_8_36; else goto IMPEVEN_8_37;
1175
1176
IMPEVEN_8_29:
1177
rep=isin_G_H(BR,24,14);
1178
if (rep) goto IMPEVEN_8_12; else goto IMPEVEN_8_38;
1179
1180
IMPEVEN_8_30:
1181
rep=isin_G_H(BR,9,3);
1182
if (rep) return 3; else goto IMPEVEN_8_39;
1183
1184
IMPEVEN_8_31:
1185
rep=isin_G_H(BR,10,2);
1186
return rep? 2: 10;
1187
1188
IMPEVEN_8_32:
1189
rep=isin_G_H(BR,18,9);
1190
if (rep) goto IMPEVEN_8_20; else return 18;
1191
1192
IMPEVEN_8_33:
1193
rep=isin_G_H(BR,41,24);
1194
if (rep) goto IMPEVEN_8_29; else return 41;
1195
1196
IMPEVEN_8_34:
1197
rep=isin_G_H(BR,11,4);
1198
if (rep) return 4; else goto IMPEVEN_8_44;
1199
1200
IMPEVEN_8_35:
1201
rep=isin_G_H(BR,12,5);
1202
return rep? 5: 12;
1203
1204
IMPEVEN_8_36:
1205
rep=isin_G_H(BR,20,10);
1206
if (rep) goto IMPEVEN_8_31; else return 20;
1207
1208
IMPEVEN_8_37:
1209
rep=isin_G_H(BR,29,19);
1210
if (rep) goto IMPEVEN_8_40; else goto IMPEVEN_8_41;
1211
1212
IMPEVEN_8_38:
1213
rep=isin_G_H(BR,24,13);
1214
if (rep) goto IMPEVEN_8_26; else goto IMPEVEN_8_42;
1215
1216
IMPEVEN_8_39:
1217
rep=isin_G_H(BR,9,2);
1218
return rep? 2: 9;
1219
1220
IMPEVEN_8_40:
1221
rep=isin_G_H(BR,19,10);
1222
if (rep) goto IMPEVEN_8_31; else goto IMPEVEN_8_43;
1223
1224
IMPEVEN_8_41:
1225
rep=isin_G_H(BR,29,18);
1226
if (rep) goto IMPEVEN_8_21; else return 29;
1227
1228
IMPEVEN_8_42:
1229
rep=isin_G_H(BR,24,9);
1230
if (rep) goto IMPEVEN_8_20; else return 24;
1231
1232
IMPEVEN_8_43:
1233
rep=isin_G_H(BR,19,9);
1234
if (rep) goto IMPEVEN_8_20; else return 19;
1235
1236
IMPEVEN_8_44:
1237
rep=isin_G_H(BR,11,2);
1238
return rep? 2: 11;
1239
1240
IMPEVEN_8_45:
1241
rep=isin_G_H(BR,34,14);
1242
if (rep) goto IMPEVEN_8_12; else return 34;
1243
}
1244
1245
static long
1246
closure8(long EVEN, buildroot *BR)
1247
{
1248
long rep;
1249
1250
if (!EVEN)
1251
{
1252
rep=isin_G_H(BR,50,47);
1253
if (rep) return galoisimpodd8(BR,47);
1254
rep=isin_G_H(BR,50,44);
1255
if (rep) return galoisimpodd8(BR,44);
1256
}
1257
else
1258
{
1259
rep=isin_G_H(BR,49,45);
1260
if (rep) return galoisimpeven8(BR,45);
1261
rep=isin_G_H(BR,49,39);
1262
if (rep) return galoisimpeven8(BR,39);
1263
}
1264
return galoisprim8(EVEN, BR);
1265
}
1266
1267
static GROUP
1268
initgroup(long n, long nbgr)
1269
{
1270
GROUP t = allocgroup(n,nbgr);
1271
PERM ID = t[1];
1272
long i;
1273
for (i = 1; i <= n; i++) ID[i] = i;
1274
return t;
1275
}
1276
1277
static PERM
1278
data8(long N, long n1, long n2, GROUP *t)
1279
{
1280
switch(n1)
1281
{
1282
case 7: if (n2!=1) break;
1283
*t=initgroup(N,2);
1284
_aff(N, (*t)[2], 1, 2, 3, 4, 6, 5, 8, 7);
1285
return (*t)[1];
1286
case 9: if (n2!=4) break;
1287
*t=initgroup(N,2);
1288
_aff(N, (*t)[2], 1, 2, 4, 3, 5, 6, 8, 7);
1289
return (*t)[1];
1290
case 10: if (n2!=2) break;
1291
*t=initgroup(N,2);
1292
_aff(N, (*t)[2], 1, 2, 3, 4, 6, 5, 8, 7);
1293
return (*t)[1];
1294
case 11:
1295
switch(n2)
1296
{
1297
case 2:
1298
*t=initgroup(N,2);
1299
_aff(N, (*t)[2], 1, 2, 5, 6, 3, 4, 8, 7);
1300
return _cr(N, 1, 3, 5, 8, 2, 4, 6, 7);
1301
case 4:
1302
*t=initgroup(N,1);
1303
return _cr(N, 1, 3, 7, 5, 2, 4, 8, 6);
1304
}break;
1305
case 14: if (n2!=4) break;
1306
*t=initgroup(N,1);
1307
return _cr(N, 1, 2, 4, 3, 5, 6, 8, 7);
1308
case 15: if (n2!=6 && n2!=8) break;
1309
*t=initgroup(N,2);
1310
_aff(N, (*t)[2], 1, 2, 3, 4, 6, 5, 8, 7);
1311
return (*t)[1];
1312
case 16: if (n2!=7) break;
1313
*t=initgroup(N,2);
1314
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 8, 7);
1315
return (*t)[1];
1316
case 18:
1317
switch(n2)
1318
{
1319
case 9: *t=initgroup(N,3);
1320
_aff(N, (*t)[2], 1, 5, 3, 7, 2, 6, 4, 8);
1321
_aff(N, (*t)[3], 1, 2, 3, 4, 6, 5, 8, 7);
1322
return (*t)[1];
1323
case 10: *t=initgroup(N,3);
1324
_aff(N, (*t)[2], 1, 6, 3, 8, 2, 5, 4, 7);
1325
_aff(N, (*t)[3], 1, 5, 3, 7, 2, 6, 4, 8);
1326
return (*t)[1];
1327
}break;
1328
case 19: if (n2!=9) break;
1329
*t=initgroup(N,1);
1330
return _cr(N, 1, 5, 3, 8, 2, 6, 4, 7);
1331
case 20: if (n2!=10) break;
1332
*t=initgroup(N,2);
1333
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 8, 7);
1334
return (*t)[1];
1335
case 22:
1336
switch(n2)
1337
{
1338
case 9: *t=initgroup(N,6);
1339
_aff(N, (*t)[2], 1, 2, 7, 8, 3, 4, 6, 5);
1340
_aff(N, (*t)[3], 1, 2, 7, 8, 3, 4, 5, 6);
1341
_aff(N, (*t)[4], 1, 2, 5, 6, 3, 4, 8, 7);
1342
_aff(N, (*t)[5], 1, 2, 5, 6, 3, 4, 7, 8);
1343
_aff(N, (*t)[6], 1, 2, 3, 4, 5, 6, 8, 7);
1344
return _cr(N, 1, 3, 5, 7, 2, 4, 6, 8);
1345
case 11: *t=initgroup(N,6);
1346
_aff(N, (*t)[2], 1, 2, 5, 6, 7, 8, 4, 3);
1347
_aff(N, (*t)[3], 1, 2, 5, 6, 7, 8, 3, 4);
1348
_aff(N, (*t)[4], 1, 2, 3, 4, 7, 8, 6, 5);
1349
_aff(N, (*t)[5], 1, 2, 3, 4, 7, 8, 5, 6);
1350
_aff(N, (*t)[6], 1, 2, 3, 4, 5, 6, 8, 7);
1351
return (*t)[1];
1352
}break;
1353
case 23: if (n2!=8) break;
1354
*t=initgroup(N,1);
1355
return _cr(N, 1, 2, 3, 4, 6, 5, 8, 7);
1356
case 26: if (n2!=15 && n2!=17) break;
1357
*t=initgroup(N,2);
1358
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 8, 7);
1359
return (*t)[1];
1360
case 28: if (n2!=21) break;
1361
*t=initgroup(N,1);
1362
return _cr(N, 1, 2, 3, 4, 7, 8, 5, 6);
1363
case 29: if (n2!=18 && n2!=19) break;
1364
*t=initgroup(N,2);
1365
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 8, 7);
1366
return (*t)[1];
1367
case 30: if (n2!=21) break;
1368
*t=initgroup(N,1);
1369
return _cr(N, 1, 2, 3, 4, 7, 8, 5, 6);
1370
case 31: if (n2!=21) break;
1371
*t=initgroup(N,3);
1372
_aff(N, (*t)[2], 1, 2, 3, 4, 7, 8, 5, 6);
1373
_aff(N, (*t)[3], 1, 2, 5, 6, 7, 8, 3, 4);
1374
return (*t)[1];
1375
case 32: if (n2!=12 && n2!=13) break;
1376
*t=initgroup(N,2);
1377
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 8, 7);
1378
return (*t)[1];
1379
case 33:
1380
switch(n2)
1381
{
1382
case 13: *t=initgroup(N,1);
1383
return _cr(N, 1, 5, 2, 6, 3, 7, 4, 8);
1384
case 18: *t=initgroup(N,1);
1385
return _cr(N, 1, 2, 5, 6, 3, 4, 7, 8);
1386
}break;
1387
case 34:
1388
switch(n2)
1389
{
1390
case 14: *t=initgroup(N,3);
1391
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 8, 6, 7);
1392
_aff(N, (*t)[3], 1, 2, 3, 4, 5, 7, 8, 6);
1393
return _cr(N, 1, 5, 2, 6, 3, 7, 4, 8);
1394
case 18: *t=initgroup(N,1);
1395
return _cr(N, 1, 2, 5, 6, 3, 4, 8, 7);
1396
}break;
1397
case 39: if (n2!=24) break;
1398
*t=initgroup(N,2);
1399
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 8, 7);
1400
return (*t)[1];
1401
case 40: if (n2!=23) break;
1402
*t=initgroup(N,2);
1403
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 8, 7);
1404
return (*t)[1];
1405
case 41:
1406
switch(n2)
1407
{
1408
case 24: *t=initgroup(N,1);
1409
return _cr(N, 1, 5, 2, 6, 3, 7, 4, 8);
1410
case 29: *t=initgroup(N,1);
1411
return _cr(N, 1, 2, 5, 6, 3, 4, 7, 8);
1412
}break;
1413
case 42: if (n2!=34) break;
1414
*t=initgroup(N,1);
1415
return _cr(N, 1, 2, 3, 4, 5, 6, 8, 7);
1416
case 45: if (n2!=41 && n2!=42) break;
1417
*t=initgroup(N,2);
1418
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 8, 7);
1419
return (*t)[1];
1420
case 46: if (n2!=28) break;
1421
*t=initgroup(N,1);
1422
return _cr(N, 1, 2, 5, 6, 3, 4, 7, 8);
1423
case 47: if (n2!=35) break;
1424
*t=initgroup(N,1);
1425
return _cr(N, 1, 2, 5, 6, 3, 4, 7, 8);
1426
case 49: if (n2!=48) break;
1427
*t=initgroup(N,2);
1428
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 8, 7);
1429
return (*t)[1];
1430
}
1431
*t=initgroup(N,1); return (*t)[1];
1432
}
1433
1434
static long
1435
galoismodulo8(long EVEN, GEN pol, GEN dpol)
1436
{
1437
long res, gr[51];
1438
pari_sp av = avma;
1439
long **GR = (long**)cgeti(49);
1440
GEN TYP = partitions_galois(8);
1441
1442
/* List of possible types in group j: GR[j][0] = #GR[j] if
1443
* the group is odd, - #GR[j] if even */
1444
GR[ 1]= _gr( 4, 1,5,15,22);
1445
GR[ 2]= _gr( -3, 1,5,15);
1446
GR[ 3]= _gr( -2, 1,5);
1447
GR[ 4]= _gr( -3, 1,5,15);
1448
GR[ 5]= _gr( -3, 1,5,15);
1449
GR[ 6]= _gr( 5, 1,4,5,15,22);
1450
GR[ 7]= _gr( 5, 1,3,5,15,22);
1451
GR[ 8]= _gr( 5, 1,4,5,15,22);
1452
GR[ 9]= _gr( -4, 1,3,5,15);
1453
GR[10]= _gr( -4, 1,3,5,15);
1454
GR[11]= _gr( -4, 1,3,5,15);
1455
GR[12]= _gr( -5, 1,5,9,15,20);
1456
GR[13]= _gr( -4, 1,5,9,20);
1457
GR[14]= _gr( -4, 1,5,9,15);
1458
GR[15]= _gr( 6, 1,3,4,5,15,22);
1459
GR[16]= _gr( 5, 1,3,5,15,22);
1460
GR[17]= _gr( 7, 1,3,5,11,13,15,22);
1461
GR[18]= _gr( -4, 1,3,5,15);
1462
GR[19]= _gr( -5, 1,3,5,12,15);
1463
GR[20]= _gr( -4, 1,3,5,15);
1464
GR[21]= _gr( 5, 1,3,5,13,15);
1465
GR[22]= _gr( -4, 1,3,5,15);
1466
GR[23]= _gr( 7, 1,4,5,9,15,20,22);
1467
GR[24]= _gr( -6, 1,3,5,9,15,20);
1468
GR[25]= _gr( -3, 1,5,21);
1469
GR[26]= _gr( 8, 1,3,4,5,11,13,15,22);
1470
GR[27]= _gr( 8, 1,2,3,4,5,13,15,22);
1471
GR[28]= _gr( 7, 1,3,5,12,13,15,22);
1472
GR[29]= _gr( -5, 1,3,5,12,15);
1473
GR[30]= _gr( 7, 1,3,4,5,11,13,15);
1474
GR[31]= _gr( 7, 1,2,3,4,5,13,15);
1475
GR[32]= _gr( -6, 1,3,5,9,15,20);
1476
GR[33]= _gr( -6, 1,3,5,9,15,20);
1477
GR[34]= _gr( -5, 1,3,5,9,15);
1478
GR[35]= _gr( 10, 1,2,3,4,5,11,12,13,15,22);
1479
GR[36]= _gr( -5, 1,5,9,20,21);
1480
GR[37]= _gr( -5, 1,5,9,15,21);
1481
GR[38]= _gr( 11, 1,2,3,4,5,9,10,13,15,19,20);
1482
GR[39]= _gr( -7, 1,3,5,9,12,15,20);
1483
GR[40]= _gr( 10, 1,3,4,5,9,11,13,15,20,22);
1484
GR[41]= _gr( -7, 1,3,5,9,12,15,20);
1485
GR[42]= _gr( -8, 1,3,5,6,8,9,15,20);
1486
GR[43]= _gr( 8, 1,4,5,9,15,19,21,22);
1487
GR[44]= _gr( 14, 1,2,3,4,5,9,10,11,12,13,15,19,20,22);
1488
GR[45]= _gr( -9, 1,3,5,6,8,9,12,15,20);
1489
GR[46]= _gr( 10, 1,3,5,6,8,9,12,13,15,22);
1490
GR[47]= _gr( 16, 1,2,3,4,5,6,7,8,9,11,12,13,14,15,20,22);
1491
GR[48]= _gr( -8, 1,3,5,9,12,15,20,21);
1492
gr[0]=51; res = galmodp(EVEN,pol,dpol,TYP,gr,GR);
1493
return gc_long(av, res? (EVEN? 49: 50): 0);
1494
}
1495
1496
/* DEGREE 9 */
1497
static long
1498
galoisprim9(long EVEN, buildroot *BR)
1499
{
1500
long rep;
1501
1502
if (!EVEN)
1503
{
1504
rep=isin_G_H(BR,34,26);
1505
if (!rep) return 34;
1506
rep=isin_G_H(BR,26,19);
1507
if (!rep) return 26;
1508
rep=isin_G_H(BR,19,16);
1509
if (rep) return 16;
1510
rep=isin_G_H(BR,19,15);
1511
return rep? 15: 19;
1512
}
1513
rep=isin_G_H(BR,33,32);
1514
if (!rep) goto PRIM_9_7;
1515
rep=isin_G_H(BR,32,27);
1516
return rep? 27: 32;
1517
1518
PRIM_9_7:
1519
rep=isin_G_H(BR,33,23);
1520
if (!rep) return 33;
1521
rep=isin_G_H(BR,23,14);
1522
if (!rep) return 23;
1523
rep=isin_G_H(BR,14,9);
1524
return rep? 9: 14;
1525
}
1526
1527
static long
1528
galoisimpodd9(buildroot *BR)
1529
{
1530
long rep;
1531
1532
rep=isin_G_H(BR,31,29);
1533
if (!rep) goto IMPODD_9_5;
1534
rep=isin_G_H(BR,29,20);
1535
if (!rep) return 29;
1536
IMPODD_9_3:
1537
rep=isin_G_H(BR,20,12);
1538
if (!rep) return 20;
1539
IMPODD_9_4:
1540
rep=isin_G_H(BR,12,4);
1541
return rep? 4: 12;
1542
1543
IMPODD_9_5:
1544
rep=isin_G_H(BR,31,28);
1545
if (!rep) goto IMPODD_9_9;
1546
rep=isin_G_H(BR,28,22);
1547
if (!rep) return 28;
1548
IMPODD_9_7:
1549
rep=isin_G_H(BR,22,13);
1550
if (!rep) return 22;
1551
IMPODD_9_8:
1552
rep=isin_G_H(BR,13,4);
1553
return rep? 4: 13;
1554
1555
IMPODD_9_9:
1556
rep=isin_G_H(BR,31,24);
1557
if (!rep) return 31;
1558
rep=isin_G_H(BR,24,22);
1559
if (rep) goto IMPODD_9_7;
1560
rep=isin_G_H(BR,24,20);
1561
if (rep) goto IMPODD_9_3;
1562
rep=isin_G_H(BR,24,18);
1563
if (!rep) return 24;
1564
rep=isin_G_H(BR,18,13);
1565
if (rep) goto IMPODD_9_8;
1566
rep=isin_G_H(BR,18,12);
1567
if (rep) goto IMPODD_9_4;
1568
rep=isin_G_H(BR,18,8);
1569
if (!rep) return 18;
1570
rep=isin_G_H(BR,8,4);
1571
return rep? 4: 8;
1572
}
1573
1574
static long
1575
galoisimpeven9(buildroot *BR)
1576
{
1577
long rep;
1578
1579
rep=isin_G_H(BR,30,25);
1580
if (!rep) goto IMPEVEN_9_7;
1581
rep=isin_G_H(BR,25,17);
1582
if (!rep) return 25;
1583
IMPEVEN_9_3:
1584
rep=isin_G_H(BR,17,7);
1585
if (!rep) goto IMPEVEN_9_5;
1586
IMPEVEN_9_4:
1587
rep=isin_G_H(BR,7,2);
1588
return rep? 2: 7;
1589
1590
IMPEVEN_9_5:
1591
rep=isin_G_H(BR,17,6);
1592
if (!rep) return 17;
1593
IMPEVEN_9_6:
1594
rep=isin_G_H(BR,6,1);
1595
return rep? 1: 6;
1596
1597
IMPEVEN_9_7:
1598
rep=isin_G_H(BR,30,21);
1599
if (!rep) return 30;
1600
rep=isin_G_H(BR,21,17);
1601
if (rep) goto IMPEVEN_9_3;
1602
rep=isin_G_H(BR,21,11);
1603
if (!rep) goto IMPEVEN_9_13;
1604
rep=isin_G_H(BR,11,7);
1605
if (rep) goto IMPEVEN_9_4;
1606
rep=isin_G_H(BR,11,5);
1607
if (!rep) return 11;
1608
rep=isin_G_H(BR,5,2);
1609
return rep? 2: 5;
1610
1611
IMPEVEN_9_13:
1612
rep=isin_G_H(BR,21,10);
1613
if (!rep) return 21;
1614
rep=isin_G_H(BR,10,6);
1615
if (rep) goto IMPEVEN_9_6;
1616
rep=isin_G_H(BR,10,3);
1617
if (!rep) return 10;
1618
rep=isin_G_H(BR,3,1);
1619
return rep? 1: 3;
1620
}
1621
1622
static long
1623
closure9(long EVEN, buildroot *BR)
1624
{
1625
long rep;
1626
if (!EVEN)
1627
{
1628
rep=isin_G_H(BR,34,31);
1629
if (rep) return galoisimpodd9(BR);
1630
}
1631
else
1632
{
1633
rep=isin_G_H(BR,33,30);
1634
if (rep) return galoisimpeven9(BR);
1635
}
1636
return galoisprim9(EVEN, BR);
1637
}
1638
1639
static PERM
1640
data9(long N, long n1, long n2, GROUP *t)
1641
{
1642
switch(n1)
1643
{
1644
case 6: if (n2!=1) break;
1645
*t=initgroup(N,3);
1646
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 8, 9, 7);
1647
_aff(N, (*t)[3], 1, 2, 3, 4, 5, 6, 9, 7, 8);
1648
return (*t)[1];
1649
case 7: if (n2!=2) break;
1650
*t=initgroup(N,3);
1651
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 8, 9, 7);
1652
_aff(N, (*t)[3], 1, 2, 3, 4, 5, 6, 9, 7, 8);
1653
return (*t)[1];
1654
case 8: if (n2!=4) break;
1655
*t=initgroup(N,2);
1656
_aff(N, (*t)[2], 1, 4, 7, 2, 5, 8, 3, 6, 9);
1657
return (*t)[1];
1658
case 12: if (n2!=4) break;
1659
*t=initgroup(N,3);
1660
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 8, 9, 7);
1661
_aff(N, (*t)[3], 1, 2, 3, 4, 5, 6, 9, 7, 8);
1662
return (*t)[1];
1663
case 13: if (n2!=4) break;
1664
*t=initgroup(N,1);
1665
return _cr(N, 1, 4, 7, 2, 5, 8, 3, 6, 9);
1666
case 14: if (n2!=9) break;
1667
*t=initgroup(N,3);
1668
_aff(N, (*t)[2], 1, 2, 3, 5, 6, 4, 9, 7, 8);
1669
_aff(N, (*t)[3], 1, 2, 3, 6, 4, 5, 8, 9, 7);
1670
return (*t)[1];
1671
case 17: if (n2!=6) break;
1672
*t=initgroup(N,2);
1673
_aff(N, (*t)[2], 1, 2, 3, 7, 8, 9, 4, 5, 6);
1674
return (*t)[1];
1675
case 21: if (n2!=10) break;
1676
*t=initgroup(N,2);
1677
_aff(N, (*t)[2], 1, 2, 3, 7, 8, 9, 4, 5, 6);
1678
return (*t)[1];
1679
case 33: if (n2!=32) break;
1680
*t=initgroup(N,2);
1681
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 7, 9, 8);
1682
return (*t)[1];
1683
}
1684
*t=initgroup(N,1); return (*t)[1];
1685
}
1686
1687
static long
1688
galoismodulo9(long EVEN, GEN pol, GEN dpol)
1689
{
1690
long res, gr[35];
1691
pari_sp av = avma;
1692
long **GR = (long**) cgeti(33);
1693
GEN TYP = partitions_galois(9);
1694
1695
/* 42 TYPES ORDONNES CROISSANT (T[1],...,T[30])*/
1696
1697
GR[ 1]= _gr( -3, 1,12,30);
1698
GR[ 2]= _gr( -2, 1,12);
1699
GR[ 3]= _gr( -4, 1,5,12,30);
1700
GR[ 4]= _gr( 4, 1,4,12,26);
1701
GR[ 5]= _gr( -3, 1,5,12);
1702
GR[ 6]= _gr( -4, 1,10,12,30);
1703
GR[ 7]= _gr( -3, 1,10,12);
1704
GR[ 8]= _gr( 5, 1,4,5,12,26);
1705
GR[ 9]= _gr( -4, 1,5,12,18);
1706
GR[10]= _gr( -6, 1,5,10,12,25,30);
1707
GR[11]= _gr( -5, 1,5,10,12,25);
1708
GR[12]= _gr( 5, 1,4,10,12,26);
1709
GR[13]= _gr( 5, 1,4,10,12,26);
1710
GR[14]= _gr( -4, 1,5,12,18);
1711
GR[15]= _gr( 5, 1,5,12,18,29);
1712
GR[16]= _gr( 6, 1,4,5,12,18,26);
1713
GR[17]= _gr( -5, 1,6,10,12,30);
1714
GR[18]= _gr( 7, 1,4,5,10,12,25,26);
1715
GR[19]= _gr( 7, 1,4,5,12,18,26,29);
1716
GR[20]= _gr( 9, 1,4,6,9,10,12,24,26,30);
1717
GR[21]= _gr( -7, 1,5,6,10,12,25,30);
1718
GR[22]= _gr( 7, 1,4,6,10,12,26,30);
1719
GR[23]= _gr( -6, 1,5,10,12,18,25);
1720
GR[24]= _gr( 11, 1,4,5,6,9,10,12,24,25,26,30);
1721
GR[25]= _gr( -7, 1,3,6,8,10,12,30);
1722
GR[26]= _gr( 9, 1,4,5,10,12,18,25,26,29);
1723
GR[27]= _gr( -5, 1,5,12,27,30);
1724
GR[28]= _gr( 12, 1,2,3,4,6,7,8,10,11,12,26,30);
1725
GR[29]= _gr( 12, 1,3,4,6,8,9,10,12,15,24,26,30);
1726
GR[30]= _gr(-11, 1,3,5,6,8,10,12,14,17,25,30);
1727
GR[31]= _gr( 19, 1,2,3,4,5,6,7,8,9,10,11,12,14,15,17,24,25,26,30);
1728
GR[32]= _gr( -7, 1,5,10,12,25,27,30);
1729
1730
gr[0]=35; res = galmodp(EVEN,pol,dpol,TYP,gr,GR);
1731
set_avma(av); if (!res) return 0;
1732
return EVEN? 33: 34;
1733
}
1734
1735
/* DEGREE 10 */
1736
static long
1737
galoisprim10(long EVEN, buildroot *BR)
1738
{
1739
long rep;
1740
if (EVEN)
1741
{
1742
rep=isin_G_H(BR,44,31);
1743
if (!rep) return 44;
1744
rep=isin_G_H(BR,31,26);
1745
if (!rep) return 31;
1746
rep=isin_G_H(BR,26,7);
1747
return rep? 7: 26;
1748
}
1749
else
1750
{
1751
rep=isin_G_H(BR,45,35);
1752
if (!rep) return 45;
1753
rep=isin_G_H(BR,35,32);
1754
if (!rep) goto PRIM_10_7;
1755
rep=isin_G_H(BR,32,13);
1756
return rep? 13: 32;
1757
1758
PRIM_10_7:
1759
rep=isin_G_H(BR,35,30);
1760
return rep? 30: 35;
1761
}
1762
}
1763
1764
static long
1765
galoisimpeven10(buildroot *BR, long nogr)
1766
{
1767
long rep;
1768
if (nogr==42)
1769
{
1770
rep=isin_G_H(BR,42,28);
1771
if (!rep) return 42;
1772
rep=isin_G_H(BR,28,18);
1773
return rep? 18: 28;
1774
}
1775
else
1776
{
1777
rep=isin_G_H(BR,37,34);
1778
if (!rep) goto IMPEVEN_10_5;
1779
rep=isin_G_H(BR,34,15);
1780
if (rep) goto IMPEVEN_10_7; else return 34;
1781
1782
IMPEVEN_10_5:
1783
rep=isin_G_H(BR,37,24);
1784
if (!rep) return 37;
1785
rep=isin_G_H(BR,24,15);
1786
if (!rep) return 24;
1787
IMPEVEN_10_7:
1788
rep=isin_G_H(BR,15,8);
1789
return rep? 8: 15;
1790
}
1791
}
1792
1793
static long
1794
galoisimpodd10(buildroot *BR, long nogr)
1795
{
1796
long rep;
1797
if (nogr==43)
1798
{
1799
rep=isin_G_H(BR,43,41);
1800
if (!rep) goto IMPODD_10_3;
1801
rep=isin_G_H(BR,41,40);
1802
if (rep) goto IMPODD_10_4; else goto IMPODD_10_5;
1803
1804
IMPODD_10_3:
1805
rep=isin_G_H(BR,43,33);
1806
if (rep) goto IMPODD_10_6; else return 43;
1807
1808
IMPODD_10_4:
1809
rep=isin_G_H(BR,40,21);
1810
if (rep) goto IMPODD_10_7; else goto IMPODD_10_8;
1811
1812
IMPODD_10_5:
1813
rep=isin_G_H(BR,41,27);
1814
if (rep) goto IMPODD_10_9; else goto IMPODD_10_10;
1815
1816
IMPODD_10_6:
1817
rep=isin_G_H(BR,33,27);
1818
if (rep) goto IMPODD_10_9; else return 33;
1819
1820
IMPODD_10_7:
1821
rep=isin_G_H(BR,21,10);
1822
if (rep) goto IMPODD_10_12; else goto IMPODD_10_13;
1823
1824
IMPODD_10_8:
1825
rep=isin_G_H(BR,40,12);
1826
if (rep) goto IMPODD_10_14; else goto IMPODD_10_15;
1827
1828
IMPODD_10_9:
1829
rep=isin_G_H(BR,27,21);
1830
if (rep) goto IMPODD_10_7; else goto IMPODD_10_16;
1831
1832
IMPODD_10_10:
1833
rep=isin_G_H(BR,41,22);
1834
if (!rep) return 41;
1835
rep=isin_G_H(BR,22,12);
1836
if (rep) goto IMPODD_10_14; else goto IMPODD_10_18;
1837
1838
IMPODD_10_12:
1839
rep=isin_G_H(BR,10,4);
1840
return rep? 4: 10;
1841
1842
IMPODD_10_13:
1843
rep=isin_G_H(BR,21,9);
1844
if (rep) goto IMPODD_10_19; else return 21;
1845
IMPODD_10_14:
1846
rep=isin_G_H(BR,12,4);
1847
return rep? 4: 12;
1848
1849
IMPODD_10_15:
1850
rep=isin_G_H(BR,40,11);
1851
if (rep) goto IMPODD_10_20; else return 40;
1852
IMPODD_10_16:
1853
rep=isin_G_H(BR,27,20);
1854
if (!rep) goto IMPODD_10_21;
1855
rep=isin_G_H(BR,20,10);
1856
if (rep) goto IMPODD_10_12; return 20;
1857
1858
IMPODD_10_18:
1859
rep=isin_G_H(BR,22,11);
1860
if (rep) goto IMPODD_10_20; else goto IMPODD_10_23;
1861
1862
IMPODD_10_19:
1863
rep=isin_G_H(BR,9,6);
1864
if (rep) goto IMPODD_10_24; else goto IMPODD_10_25;
1865
1866
IMPODD_10_20:
1867
rep=isin_G_H(BR,11,3);
1868
if (rep) goto IMPODD_10_26; else return 11;
1869
1870
IMPODD_10_21:
1871
rep=isin_G_H(BR,27,19);
1872
if (rep) goto IMPODD_10_27;
1873
rep=isin_G_H(BR,27,17);
1874
if (rep) goto IMPODD_10_28; else return 27;
1875
1876
IMPODD_10_23:
1877
rep=isin_G_H(BR,22,5);
1878
if (rep) goto IMPODD_10_29; else return 22;
1879
1880
IMPODD_10_24:
1881
rep=isin_G_H(BR,6,2);
1882
if (rep) return 2; else goto IMPODD_10_30;
1883
1884
IMPODD_10_25:
1885
rep=isin_G_H(BR,9,3);
1886
if (!rep) return 9;
1887
IMPODD_10_26:
1888
rep=isin_G_H(BR,3,2);
1889
if (rep) return 2; else goto IMPODD_10_31;
1890
1891
IMPODD_10_27:
1892
rep=isin_G_H(BR,19,9);
1893
if (rep) goto IMPODD_10_19; else return 19;
1894
1895
IMPODD_10_28:
1896
rep=isin_G_H(BR,17,10);
1897
if (rep) goto IMPODD_10_12; else goto IMPODD_10_32;
1898
1899
IMPODD_10_29:
1900
rep=isin_G_H(BR,5,4);
1901
if (rep) return 4; else goto IMPODD_10_33;
1902
1903
IMPODD_10_30:
1904
rep=isin_G_H(BR,6,1);
1905
return rep? 1: 6;
1906
1907
IMPODD_10_31:
1908
rep=isin_G_H(BR,3,1);
1909
return rep? 1: 3;
1910
1911
IMPODD_10_32:
1912
rep=isin_G_H(BR,17,9);
1913
if (rep) goto IMPODD_10_19; else goto IMPODD_10_60;
1914
1915
IMPODD_10_33:
1916
rep=isin_G_H(BR,5,3);
1917
if (rep) goto IMPODD_10_26; else return 5;
1918
1919
IMPODD_10_60:
1920
rep=isin_G_H(BR,17,5);
1921
if (rep) goto IMPODD_10_29; else return 17;
1922
}
1923
else
1924
{
1925
rep=isin_G_H(BR,39,38);
1926
if (!rep) goto IMPODD_10_36;
1927
rep=isin_G_H(BR,38,25);
1928
if (rep) goto IMPODD_10_37; else goto IMPODD_10_38;
1929
1930
IMPODD_10_36:
1931
rep=isin_G_H(BR,39,36);
1932
if (rep) goto IMPODD_10_39; else goto IMPODD_10_40;
1933
1934
IMPODD_10_37:
1935
rep=isin_G_H(BR,25,4);
1936
return rep? 4: 25;
1937
1938
IMPODD_10_38:
1939
rep=isin_G_H(BR,38,12);
1940
if (rep) goto IMPODD_10_41; else return 38;
1941
1942
IMPODD_10_39:
1943
rep=isin_G_H(BR,36,23);
1944
if (rep) goto IMPODD_10_42; else goto IMPODD_10_43;
1945
1946
IMPODD_10_40:
1947
rep=isin_G_H(BR,39,29);
1948
if (rep) goto IMPODD_10_44; else goto IMPODD_10_45;
1949
1950
IMPODD_10_41:
1951
rep=isin_G_H(BR,12,4);
1952
return rep? 4: 12;
1953
1954
IMPODD_10_42:
1955
rep=isin_G_H(BR,23,16);
1956
if (rep) goto IMPODD_10_46; else goto IMPODD_10_47;
1957
1958
IMPODD_10_43:
1959
rep=isin_G_H(BR,36,11);
1960
if (rep) goto IMPODD_10_48; else return 36;
1961
1962
IMPODD_10_44:
1963
rep=isin_G_H(BR,29,25);
1964
if (rep) goto IMPODD_10_37; else goto IMPODD_10_49;
1965
1966
IMPODD_10_45:
1967
rep=isin_G_H(BR,39,22);
1968
if (rep) goto IMPODD_10_50; else return 39;
1969
1970
IMPODD_10_46:
1971
rep=isin_G_H(BR,16,2);
1972
return rep? 2: 16;
1973
1974
IMPODD_10_47:
1975
rep=isin_G_H(BR,23,14);
1976
if (rep) goto IMPODD_10_51; else goto IMPODD_10_52;
1977
1978
IMPODD_10_48:
1979
rep=isin_G_H(BR,11,3);
1980
if (rep) goto IMPODD_10_53; else return 11;
1981
1982
IMPODD_10_49:
1983
rep=isin_G_H(BR,29,23);
1984
if (rep) goto IMPODD_10_42; else goto IMPODD_10_54;
1985
1986
IMPODD_10_50:
1987
rep=isin_G_H(BR,22,12);
1988
if (rep) goto IMPODD_10_41; else goto IMPODD_10_55;
1989
1990
IMPODD_10_51:
1991
rep=isin_G_H(BR,14,1);
1992
return rep? 1: 14;
1993
1994
IMPODD_10_52:
1995
rep=isin_G_H(BR,23,3);
1996
if (!rep) return 23;
1997
IMPODD_10_53:
1998
rep=isin_G_H(BR,3,2);
1999
if (rep) return 2; else goto IMPODD_10_57;
2000
2001
IMPODD_10_54:
2002
rep=isin_G_H(BR,29,5);
2003
if (rep) goto IMPODD_10_58; else return 29;
2004
2005
IMPODD_10_55:
2006
rep=isin_G_H(BR,22,11);
2007
if (rep) goto IMPODD_10_48;
2008
rep=isin_G_H(BR,22,5);
2009
if (rep) goto IMPODD_10_58; else return 22;
2010
2011
IMPODD_10_57:
2012
rep=isin_G_H(BR,3,1);
2013
return rep? 1: 3;
2014
2015
IMPODD_10_58:
2016
rep=isin_G_H(BR,5,4);
2017
if (rep) return 4;
2018
rep=isin_G_H(BR,5,3);
2019
if (rep) goto IMPODD_10_53; else return 5;
2020
}
2021
}
2022
2023
static long
2024
closure10(long EVEN, buildroot *BR)
2025
{
2026
long rep;
2027
if (EVEN)
2028
{
2029
rep=isin_G_H(BR,44,42);
2030
if (rep) return galoisimpeven10(BR,42);
2031
rep=isin_G_H(BR,44,37);
2032
if (rep) return galoisimpeven10(BR,37);
2033
}
2034
else
2035
{
2036
rep=isin_G_H(BR,45,43);
2037
if (rep) return galoisimpodd10(BR,43);
2038
rep=isin_G_H(BR,45,39);
2039
if (rep) return galoisimpodd10(BR,39);
2040
}
2041
return galoisprim10(EVEN, BR);
2042
}
2043
2044
static PERM
2045
data10(long N, long n1,long n2,GROUP *t)
2046
{
2047
switch(n1)
2048
{
2049
case 6: if (n2!=2) break;
2050
*t=initgroup(N,1);
2051
return _cr(N, 1, 2, 3, 4, 5, 6, 10, 9, 8, 7);
2052
case 9: if (n2!=3 && n2!=6) break;
2053
*t=initgroup(N,2);
2054
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 10, 9, 8, 7);
2055
return (*t)[1];
2056
case 10: *t=initgroup(N,2);
2057
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 10, 9, 8, 7);
2058
return (*t)[1];
2059
case 14: case 16:*t=initgroup(N,1);
2060
return _cr(N, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10);
2061
case 17: if (n2!=5) break;
2062
*t=initgroup(N,2);
2063
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 10, 9, 8, 7);
2064
return (*t)[1];
2065
case 19: case 20: *t=initgroup(N,2);
2066
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 8, 10, 7, 9);
2067
return (*t)[1];
2068
case 21: if (n2!=10) break;
2069
*t=initgroup(N,1);
2070
return _cr(N, 1, 2, 3, 4, 5, 6, 8, 10, 7, 9);
2071
case 23: if (n2!=3) break;
2072
*t=initgroup(N,1);
2073
return _cr(N, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10);
2074
case 25: *t=initgroup(N,1);
2075
return _cr(N, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10);
2076
case 26: *t=initgroup(N,2);
2077
_aff(N, (*t)[2], 1, 2, 4, 9, 6, 8, 10, 3, 7, 5);
2078
return _cr(N, 1, 2, 3, 10, 6, 5, 7, 4, 8, 9);
2079
case 27: if (n2!=17 && n2!=21) break;
2080
*t=initgroup(N,2);
2081
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 8, 10, 7, 9);
2082
return (*t)[1];
2083
case 28: *t=initgroup(N,2);
2084
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 8, 10, 7, 9);
2085
return (*t)[1];
2086
case 29: if (n2!=5) break;
2087
*t=initgroup(N,1);
2088
return _cr(N, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10);
2089
case 32: *t=initgroup(N,2);
2090
_aff(N, (*t)[2], 1, 2, 4, 9, 6, 8, 10, 3, 7, 5);
2091
return _cr(N, 1, 2, 3, 10, 6, 5, 7, 4, 8, 9);
2092
case 36: if (n2!=11) break;
2093
*t=initgroup(N,1);
2094
return _cr(N, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10);
2095
case 38: if (n2!=12) break;
2096
*t=initgroup(N,1);
2097
return _cr(N, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10);
2098
case 39: if (n2!=22) break;
2099
*t=initgroup(N,1);
2100
return _cr(N, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10);
2101
case 40: if (n2!=12) break;
2102
*t=initgroup(N,1);
2103
return _cr(N, 1, 2, 3, 4, 5, 6, 7, 8, 10, 9);
2104
case 41: if (n2!=22 && n2!=40) break;
2105
*t=initgroup(N,2);
2106
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 7, 8, 10, 9);
2107
return (*t)[1];
2108
}
2109
*t=initgroup(N,1); return (*t)[1];
2110
}
2111
2112
static long
2113
galoismodulo10(long EVEN, GEN pol, GEN dpol)
2114
{
2115
long res, gr[46];
2116
pari_sp av = avma;
2117
long **GR = (long**) cgeti(45);
2118
GEN TYP = partitions_galois(10);
2119
2120
GR[ 1]= _gr( 4, 1,6,30,42);
2121
GR[ 2]= _gr( 3, 1,6,30);
2122
GR[ 3]= _gr( 5, 1,5,6,30,42);
2123
GR[ 4]= _gr( 4, 1,5,23,30);
2124
GR[ 5]= _gr( 7, 1,5,6,22,23,30,42);
2125
GR[ 6]= _gr( 5, 1,6,24,30,42);
2126
GR[ 7]= _gr( -4, 1,5,14,30);
2127
GR[ 8]= _gr( -4, 1,3,5,30);
2128
GR[ 9]= _gr( 6, 1,5,6,24,30,42);
2129
GR[10]= _gr( 5, 1,5,23,24,30);
2130
GR[11]= _gr( 7, 1,5,6,11,30,33,42);
2131
GR[12]= _gr( 7, 1,5,6,11,23,30,33);
2132
GR[13]= _gr( 7, 1,4,5,14,23,30,34);
2133
GR[14]= _gr( 8, 1,2,3,4,5,6,30,42);
2134
GR[15]= _gr( -6, 1,3,5,18,22,30);
2135
GR[16]= _gr( 7, 1,3,5,6,17,23,30);
2136
GR[17]= _gr( 8, 1,5,6,22,23,24,30,42);
2137
GR[18]= _gr( -6, 1,5,22,24,30,40);
2138
GR[19]= _gr( 7, 1,5,6,22,24,30,42);
2139
GR[20]= _gr( 6, 1,5,22,23,24,30);
2140
GR[21]= _gr( 9, 1,3,5,6,23,24,26,30,42);
2141
GR[22]= _gr( 11, 1,3,5,6,11,13,22,23,30,33,42);
2142
GR[23]= _gr( 12, 1,2,3,4,5,6,17,18,22,23,30,42);
2143
GR[24]= _gr( -7, 1,3,5,18,22,30,40);
2144
GR[25]= _gr( 8, 1,3,5,18,22,23,30,39);
2145
GR[26]= _gr( -5, 1,5,14,22,30);
2146
GR[27]= _gr( 10, 1,3,5,6,22,23,24,26,30,42);
2147
GR[28]= _gr( -8, 1,3,5,22,24,26,30,40);
2148
GR[29]= _gr( 14, 1,2,3,4,5,6,17,18,22,23,30,39,40,42);
2149
GR[30]= _gr( 8, 1,5,6,14,22,30,39,42);
2150
GR[31]= _gr( -6, 1,5,14,22,30,40);
2151
GR[32]= _gr( 8, 1,4,5,14,22,23,30,34);
2152
GR[33]= _gr( 14, 1,3,5,6,15,17,22,23,24,26,29,30,40,42);
2153
GR[34]= _gr( -9, 1,3,5,11,13,18,22,30,32);
2154
GR[35]= _gr( 12, 1,4,5,6,14,22,23,30,34,39,40,42);
2155
GR[36]= _gr( 18, 1,2,3,4,5,6,11,12,13,17,18,22,23,30,31,32,33,42);
2156
GR[37]= _gr(-12, 1,3,5,11,13,16,18,22,30,32,35,40);
2157
GR[38]= _gr( 18, 1,3,4,5,6,11,13,15,17,18,21,22,23,30,32,33,35,39);
2158
GR[39]= _gr( 24, 1,2,3,4,5,6,11,12,13,15,16,17,18,21,22,23,30,31,32,33,35,39,40,42);
2159
GR[40]= _gr( 14, 1,3,5,6,7,9,11,23,24,26,27,30,33,42);
2160
GR[41]= _gr( 18, 1,3,5,6,7,9,11,13,16,20,22,23,24,26,27,30,33,42);
2161
GR[42]= _gr(-17, 1,3,5,7,9,11,13,16,18,20,22,24,26,27,30,35,40);
2162
GR[43]= _gr( 32, 1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,17,18,19,20,22,23,24,25,26,27,28,29,30,33,35,40,42);
2163
GR[44]= _gr(-22, 1,3,5,7,9,11,13,14,16,18,20,22,24,26,27,30,32,35,36,38,40,41);
2164
gr[0]=46; res = galmodp(EVEN,pol,dpol,TYP,gr,GR);
2165
return gc_long(av, res? (EVEN? 44:45): 0);
2166
}
2167
2168
/* DEGREE 11 */
2169
static long
2170
closure11(long EVEN, buildroot *BR)
2171
{
2172
long rep;
2173
if (EVEN)
2174
{
2175
rep=isin_G_H(BR,7,6);
2176
if (!rep) return 7;
2177
rep=isin_G_H(BR,6,5);
2178
if (!rep) return 6;
2179
rep=isin_G_H(BR,5,3);
2180
if (!rep) return 5;
2181
rep=isin_G_H(BR,3,1);
2182
return rep? 1: 3;
2183
}
2184
else
2185
{
2186
GEN h = BR->p, r = compositum(h, h);
2187
r = gel(r,lg(r)-1);
2188
if (degpol(r) == 22) return 2; /* D11 */
2189
h = leafcopy(h); setvarn(h, fetch_var());
2190
setvarn(r, 0); r = nffactor(h, r);
2191
/* S11 (P10*P10*P90) or F_110[11] (11 factors of degree 10) */
2192
(void)delete_var();
2193
return (lgcols(r)-1 == 11)? 4: 8;
2194
}
2195
}
2196
2197
static PERM
2198
data11(long N, long n1, GROUP *t)
2199
{
2200
switch(n1)
2201
{
2202
case 5: *t=initgroup(N,1);
2203
return _cr(N, 1, 2, 3, 7, 8, 6, 11, 5, 9, 4, 10);
2204
case 6: *t=initgroup(N,1);
2205
return _cr(N, 1, 2, 3, 4, 6, 10, 11, 9, 7, 5, 8);
2206
case 7: *t=initgroup(N,2);
2207
_aff(N, (*t)[2], 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 10);
2208
return (*t)[1];
2209
}
2210
*t=initgroup(N,1); return (*t)[1];
2211
}
2212
2213
static long
2214
galoismodulo11(long EVEN, GEN pol, GEN dpol)
2215
{
2216
long res, gr[6] = {0, 1, 1, 1, 1, 1};
2217
pari_sp av = avma;
2218
GEN TYP = cgetg(EVEN? 9: 6, t_VEC);
2219
2220
gel(TYP,1) = _typ(1, 11);
2221
if (EVEN)
2222
{
2223
gel(TYP,2) = _typ(3, 8,2,1);
2224
gel(TYP,3) = _typ(3, 6,3,2);
2225
gel(TYP,4) = _typ(3, 5,5,1);
2226
gel(TYP,5) = _typ(5, 4,4,1,1,1);
2227
gel(TYP,6) = _typ(5, 3,3,3,1,1);
2228
gel(TYP,7) = _typ(7, 2,2,2,2,1,1,1);
2229
gel(TYP,8) = _typ(11, 1,1,1,1,1,1,1,1,1,1,1);
2230
}
2231
else
2232
{
2233
gel(TYP,2) = _typ(2, 10,1);
2234
gel(TYP,3) = _typ(3, 5,5,1);
2235
gel(TYP,4) = _typ(6, 2,2,2,2,2,1);
2236
gel(TYP,5) = _typ(11, 1,1,1,1,1,1,1,1,1,1,1);
2237
}
2238
res = galmodp(EVEN,pol,dpol,TYP,gr,NULL);
2239
return gc_long(av, res? (EVEN? 7: 8): 0);
2240
}
2241
2242
static void
2243
init_isin(long N, long n1, long n2, GROUP *tau, PERM *s0, resolv *R)
2244
{
2245
int fl = 1;
2246
if (DEBUGLEVEL) err_printf("\n*** Entering isin_%ld_G_H_(%ld,%ld)\n",N,n1,n2);
2247
switch(N)
2248
{
2249
case 8:
2250
if ((n1==47 && n2==46) || (n1==44 && n2==40)) fl=0;
2251
*s0=data8(N, n1,n2,tau); break;
2252
case 9:
2253
if ((n1==31 && n2==29) || (n1==34 && n2==31) || (n1==33 && n2==30)) fl=0;
2254
*s0=data9(N,n1,n2,tau); break;
2255
case 10:
2256
if ((n1==45 && (n2==43||n2==39))
2257
|| (n1==44 && (n2==42||n2==37))
2258
|| (n1==43 && (n2==41||n2==33))
2259
|| (n1==42 && n2==28)
2260
|| (n1==41 && (n2==40||n2==27||n2==22))
2261
|| (n1==40 && (n2==21||n2==11))
2262
|| (n1==39 && (n2==38||n2==36||n2==29||n2==22))
2263
|| (n1==38 && (n2==25||n2==12))
2264
|| (n1==37 && (n2==34||n2==24))
2265
|| (n1==36 && (n2==23||n2==11))
2266
|| (n1==34 && n2==15)
2267
|| (n1==33 && n2==27)
2268
|| (n1==29 && (n2==25||n2==23||n2==5))
2269
|| (n1==28 && n2==18)
2270
|| (n1==27 && (n2==20||n2==19||n2==17))
2271
|| (n1==25 && n2==4)
2272
|| (n1==24 && n2==15)
2273
|| (n1==23 && (n2==16||n2==3))
2274
|| (n1==22 && (n2==12||n2==11||n2==5))
2275
|| (n1==21 && (n2==10||n2==9))
2276
|| (n1==17 && n2==5)
2277
|| (n1==16 && n2==2)
2278
|| (n1==14 && n2==1)
2279
|| (n1==12 && n2==4)
2280
|| (n1==11 && n2==3)
2281
|| (n1==10 && n2==4)
2282
|| (n1== 9 && n2==3)
2283
|| (n1== 6 && n2==1)
2284
|| (n1== 5 && n2==3)) fl = 0;
2285
*s0=data10(N,n1,n2,tau); break;
2286
default: /* case 11: */
2287
*s0=data11(N,n1,tau); break;
2288
}
2289
if (fl) lireresolv(n1,n2,N,R); else { R->a = NULL; R->nm = n1; R->nv = n2; }
2290
}
2291
2292
static long
2293
isin_G_H(buildroot *BR, long n1, long n2)
2294
{
2295
pari_sp av = avma;
2296
const long N = BR->N;
2297
PERM s0, ww;
2298
GROUP tau, ss = lirecoset(n1,n2,N);
2299
resolv R;
2300
2301
init_isin(N,n1,n2, &tau, &s0, &R);
2302
ww = check_isin(BR, &R, tau, ss);
2303
if (ww)
2304
{
2305
GEN z = cgetg(N+1, t_VEC);
2306
long i, j, l = lg(BR->r);
2307
s0 = permmul(ww, s0);
2308
if (DEBUGLEVEL)
2309
{
2310
err_printf("\n Output of isin_%ld_G_H(%ld,%ld): %ld",N,n1,n2,n2);
2311
err_printf("\n Reordering of the roots: "); printperm(s0);
2312
}
2313
for (i = 1; i < l; i++)
2314
{
2315
GEN p1 = gel(BR->r,i);
2316
for (j=1; j<=N; j++) gel(z,j) = gel(p1,s0[j]);
2317
for (j=1; j<=N; j++) gel(p1,j) = gel(z,j);
2318
}
2319
return gc_long(av, n2);
2320
}
2321
if (DEBUGLEVEL)
2322
err_printf(" Output of isin_%ld_G_H(%ld,%ld): not included.\n",N,n1,n2);
2323
return gc_long(av, 0);
2324
}
2325
2326
static GEN
2327
polgaloisnamesbig(long n, long k)
2328
{
2329
pari_sp av = avma;
2330
char *s = stack_malloc(strlen(pari_datadir) + 13 + 20 + 3);
2331
pariFILE *f;
2332
GEN V;
2333
2334
(void)sprintf(s, "%s/galdata/NAM%ld", pari_datadir, n);
2335
f = pari_fopengz(s);
2336
V = f? gp_read_stream(f->file): NULL;
2337
if (!V || typ(V)!=t_VEC || k>=lg(V)) pari_err_FILE("galois file %s",s);
2338
pari_fclose(f);
2339
return gerepilecopy(av, gel(V,k));
2340
}
2341
2342
/* pol a monic ZX */
2343
static GEN
2344
galoisbig(GEN pol, long prec)
2345
{
2346
pari_sp av = avma;
2347
const long *tab;
2348
const long tab8[]={0,
2349
8,8,8,8,8,16,16,16,16,16, 16,24,24,24,32,32,32,32,32,32,
2350
32,32,48,48,56,64,64,64,64,64, 64,96,96,96,128,168,168,192,192,192,
2351
192,288,336,384,576,576,1152,1344,20160,40320};
2352
const long tab9[]={0,
2353
9,9,18,18,18,27,27,36,36,54, 54,54,54,72,72,72,81,108,144,162,
2354
162,162,216,324,324,432,504,648,648,648, 1296,1512,181440,362880};
2355
const long tab10[]={0,
2356
10,10,20,20,40,50,60,80,100,100, 120,120,120,160,160,160,200,200,200,200,
2357
200,240,320,320,320,360,400,400,640,720, 720,720,800,960,1440,
2358
1920,1920,1920,3840,7200,14400,14400,28800,1814400,3628800};
2359
const long tab11[]={0, 11,22,55,110,660,7920,19958400,39916800};
2360
GEN res, dpol = ZX_disc(pol);
2361
long t = 0, N = degpol(pol), EVEN = Z_issquare(dpol);
2362
2363
if (DEBUGLEVEL)
2364
{
2365
err_printf("Galoisbig: polynomial #1 = %Ps\n", pol);
2366
err_printf("%s group\n", EVEN? "EVEN": "ODD");
2367
}
2368
switch(N)
2369
{
2370
case 8: t = galoismodulo8(EVEN,pol,dpol); tab=tab8; break;
2371
case 9: t = galoismodulo9(EVEN,pol,dpol); tab=tab9; break;
2372
case 10:t = galoismodulo10(EVEN,pol,dpol); tab=tab10; break;
2373
case 11:t = galoismodulo11(EVEN,pol,dpol); tab=tab11; break;
2374
default: pari_err_IMPL("galois in degree > 11");
2375
return NULL; /* LCOV_EXCL_LINE */
2376
}
2377
if (!t)
2378
{
2379
buildroot BR;
2380
long i;
2381
GEN r, z = cgetg(N + 1, t_VEC);
2382
for (i = 1; i <= N; i++)
2383
{
2384
GEN v = cgetg(i+2,t_VECSMALL);
2385
gel(z,i) = v; v[1] = 0;
2386
}
2387
BR.coef = z;
2388
BR.p = pol;
2389
BR.pr = prec + nbits2extraprec((long)fujiwara_bound(pol));
2390
BR.prmax = BR.pr + BIGDEFAULTPREC-2;
2391
BR.N = N;
2392
BR.r = vectrunc_init(N+1);
2393
r = gclone ( QX_complex_roots(BR.p, BR.prmax) );
2394
vectrunc_append(BR.r, r); preci(r, BR.pr);
2395
switch(N)
2396
{
2397
case 8: t = closure8(EVEN, &BR); break;
2398
case 9: t = closure9(EVEN, &BR); break;
2399
case 10: t = closure10(EVEN, &BR); break;
2400
case 11: t = closure11(EVEN, &BR); break;
2401
}
2402
for (i = 1; i < lg(BR.r); i++) gunclone(gel(BR.r,i));
2403
}
2404
set_avma(av);
2405
res = cgetg(5,t_VEC);
2406
gel(res,1) = stoi(tab[t]);
2407
gel(res,2) = stoi(EVEN? 1: -1);
2408
gel(res,3) = stoi(t);
2409
gel(res,4) = polgaloisnamesbig(N,t);
2410
return res;
2411
}
2412
2413
/**************************************************************/
2414
/* Galois group for degree <= 7 */
2415
/**************************************************************/
2416
2417
/* exchange elements i and j in vector x */
2418
static GEN
2419
transroot(GEN x, int i, int j)
2420
{ x = leafcopy(x); swap(gel(x,i), gel(x,j)); return x; }
2421
2422
/* x1*x2^2 + x2*x3^2 + x3*x4^2 + x4*x1^2 */
2423
static GEN
2424
F4(GEN x)
2425
{
2426
return gadd(
2427
gmul(gel(x,1), gadd(gsqr(gel(x,2)), gmul(gel(x,4),gel(x,1)))),
2428
gmul(gel(x,3), gadd(gsqr(gel(x,4)), gmul(gel(x,2),gel(x,3)))));
2429
}
2430
2431
static GEN
2432
roots_to_ZX(GEN z, long *e)
2433
{
2434
GEN a = roots_to_pol(z,0);
2435
GEN b = grndtoi(real_i(a),e);
2436
long e1 = gexpo(imag_i(a));
2437
if (e1 > *e) *e = e1;
2438
return b;
2439
}
2440
2441
static GEN
2442
polgaloisnames(long a, long b)
2443
{
2444
const char * const t[]={"S1", "S2", "A3", "S3",
2445
"C(4) = 4", "E(4) = 2[x]2", "D(4)", "A4", "S4",
2446
"C(5) = 5", "D(5) = 5:2", "F(5) = 5:4", "A5", "S5",
2447
"C(6) = 6 = 3[x]2", "D_6(6) = [3]2", "D(6) = S(3)[x]2",
2448
"A_4(6) = [2^2]3", "F_18(6) = [3^2]2 = 3 wr 2",
2449
"2A_4(6) = [2^3]3 = 2 wr 3", "S_4(6d) = [2^2]S(3)",
2450
"S_4(6c) = 1/2[2^3]S(3)", "F_18(6):2 = [1/2.S(3)^2]2",
2451
"F_36(6) = 1/2[S(3)^2]2", "2S_4(6) = [2^3]S(3) = 2 wr S(3)",
2452
"L(6) = PSL(2,5) = A_5(6)", "F_36(6):2 = [S(3)^2]2 = S(3) wr 2",
2453
"L(6):2 = PGL(2,5) = S_5(6)", "A6", "S6",
2454
"C(7) = 7", "D(7) = 7:2", "F_21(7) = 7:3", "F_42(7) = 7:6",
2455
"L(7) = L(3,2)", "A7", "S7"};
2456
2457
const long idx[]={0,1,2,4,9,14,30};
2458
return strtoGENstr(t[idx[a-1]+b-1]);
2459
}
2460
2461
static GEN
2462
galois_res(long d, long n, long s, long k)
2463
{
2464
GEN z = cgetg(5,t_VEC);
2465
long kk;
2466
if (new_galois_format)
2467
kk = k;
2468
else
2469
kk = (d == 6 && (k==6 || k==2))? 2: 1;
2470
gel(z,1) = stoi(n);
2471
gel(z,2) = stoi(s);
2472
gel(z,3) = stoi(kk);
2473
gel(z,4) = polgaloisnames(d,k);
2474
return z;
2475
}
2476
2477
GEN
2478
polgalois(GEN x, long prec)
2479
{
2480
pari_sp av = avma, av1;
2481
long i,j,k,n,f,l,l2,e,e1,pr,ind;
2482
GEN x1,p1,p2,p3,p4,p5,w,z,ee;
2483
const int ind5[20]={2,5,3,4, 1,3,4,5, 1,5,2,4, 1,2,3,5, 1,4,2,3};
2484
const int ind6[60]={3,5,4,6, 2,6,4,5, 2,3,5,6, 2,4,3,6, 2,5,3,4,
2485
1,4,5,6, 1,5,3,6, 1,6,3,4, 1,3,4,5, 1,6,2,5,
2486
1,2,4,6, 1,5,2,4, 1,3,2,6, 1,2,3,5, 1,4,2,3};
2487
if (typ(x)!=t_POL) pari_err_TYPE("galois",x);
2488
n=degpol(x);
2489
if (n>11) pari_err_IMPL("galois of degree higher than 11");
2490
x = Q_primpart(x);
2491
RgX_check_ZX(x, "galois");
2492
if (!ZX_is_irred(x)) pari_err_IRREDPOL("galois",x);
2493
2494
if (n<4)
2495
{
2496
if (n == 1) { set_avma(av); return galois_res(n,1, 1,1); }
2497
if (n == 2) { set_avma(av); return galois_res(n,2,-1,1); }
2498
/* n = 3 */
2499
f = Z_issquare(ZX_disc(x));
2500
set_avma(av);
2501
return f? galois_res(n,3,1,1):
2502
galois_res(n,6,-1,2);
2503
}
2504
x1 = x = ZX_Q_normalize(x,NULL); av1=avma;
2505
if (n > 7) return galoisbig(x, prec);
2506
for(;;)
2507
{
2508
double fb = fujiwara_bound(x);
2509
switch(n)
2510
{
2511
case 4: z = cgetg(7,t_VEC);
2512
prec = nbits2prec((long)(fb*18.) + 64);
2513
for(;;)
2514
{
2515
p1=QX_complex_roots(x,prec);
2516
gel(z,1) = F4(p1);
2517
gel(z,2) = F4(transroot(p1,1,2));
2518
gel(z,3) = F4(transroot(p1,1,3));
2519
gel(z,4) = F4(transroot(p1,1,4));
2520
gel(z,5) = F4(transroot(p1,2,3));
2521
gel(z,6) = F4(transroot(p1,3,4));
2522
p5 = roots_to_ZX(z, &e); if (e <= -10) break;
2523
prec = precdbl(prec);
2524
}
2525
if (!ZX_is_squarefree(p5)) goto tchi;
2526
p2 = gel(ZX_factor(p5),1);
2527
switch(lg(p2)-1)
2528
{
2529
case 1: f = Z_issquare(ZX_disc(x)); set_avma(av);
2530
return f? galois_res(n,12,1,4): galois_res(n,24,-1,5);
2531
2532
case 2: set_avma(av); return galois_res(n,8,-1,3);
2533
2534
case 3: set_avma(av);
2535
return (degpol(gel(p2,1))==2)? galois_res(n,4,1,2)
2536
: galois_res(n,4,-1,1);
2537
2538
default: pari_err_BUG("galois (bug1)");
2539
}
2540
2541
case 5: z = cgetg(7,t_VEC);
2542
ee= cgetg(7,t_VECSMALL);
2543
w = cgetg(7,t_VECSMALL);
2544
prec = nbits2prec((long)(fb*21.) + 64);
2545
for(;;)
2546
{
2547
for(;;)
2548
{
2549
p1=QX_complex_roots(x,prec);
2550
for (l=1; l<=6; l++)
2551
{
2552
p2=(l==1)?p1: ((l<6)?transroot(p1,1,l): transroot(p1,2,5));
2553
p3=gen_0;
2554
for (k=0,i=1; i<=5; i++,k+=4)
2555
{
2556
p5 = gadd(gmul(gel(p2,ind5[k]),gel(p2,ind5[k+1])),
2557
gmul(gel(p2,ind5[k+2]),gel(p2,ind5[k+3])));
2558
p3 = gadd(p3, gmul(gsqr(gel(p2,i)),p5));
2559
}
2560
gel(w,l) = grndtoi(real_i(p3),&e);
2561
e1 = gexpo(imag_i(p3)); if (e1>e) e=e1;
2562
ee[l]=e; gel(z,l) = p3;
2563
}
2564
p5 = roots_to_ZX(z, &e); if (e <= -10) break;
2565
prec = precdbl(prec);
2566
}
2567
if (!ZX_is_squarefree(p5)) goto tchi;
2568
p3=gel(ZX_factor(p5),1);
2569
f=Z_issquare(ZX_disc(x));
2570
if (lg(p3)-1==1)
2571
{
2572
set_avma(av);
2573
return f? galois_res(n,60,1,4): galois_res(n,120,-1,5);
2574
}
2575
if (!f) { set_avma(av); return galois_res(n,20,-1,3); }
2576
2577
pr = - (prec2nbits(prec) >> 1);
2578
for (l=1; l<=6; l++)
2579
if (ee[l] <= pr && gequal0(poleval(p5,gel(w,l)))) break;
2580
if (l>6) pari_err_BUG("galois (bug4)");
2581
p2=(l==6)? transroot(p1,2,5):transroot(p1,1,l);
2582
p3=gen_0;
2583
for (i=1; i<=5; i++)
2584
{
2585
j = (i == 5)? 1: i+1;
2586
p3 = gadd(p3,gmul(gmul(gel(p2,i),gel(p2,j)),
2587
gsub(gel(p2,j),gel(p2,i))));
2588
}
2589
p5=gsqr(p3); p4=grndtoi(real_i(p5),&e);
2590
e1 = gexpo(imag_i(p5)); if (e1>e) e=e1;
2591
if (e <= -10)
2592
{
2593
if (gequal0(p4)) goto tchi;
2594
f = Z_issquare(p4); set_avma(av);
2595
return f? galois_res(n,5,1,1): galois_res(n,10,1,2);
2596
}
2597
prec = precdbl(prec);
2598
}
2599
2600
case 6: z = cgetg(7, t_VEC);
2601
prec = nbits2prec((long) (fb * 42) + 64);
2602
for(;;)
2603
{
2604
for(;;)
2605
{
2606
p1=QX_complex_roots(x,prec);
2607
for (l=1; l<=6; l++)
2608
{
2609
p2=(l==1)?p1:transroot(p1,1,l);
2610
p3=gen_0; k=0;
2611
for (i=1; i<=5; i++) for (j=i+1; j<=6; j++)
2612
{
2613
p5=gadd(gmul(gel(p2,ind6[k]),gel(p2,ind6[k+1])),
2614
gmul(gel(p2,ind6[k+2]),gel(p2,ind6[k+3])));
2615
p3=gadd(p3,gmul(gsqr(gmul(gel(p2,i),gel(p2,j))),p5));
2616
k += 4;
2617
}
2618
gel(z,l) = p3;
2619
}
2620
p5 = roots_to_ZX(z, &e); if (e <= -10) break;
2621
prec = precdbl(prec);
2622
}
2623
if (!ZX_is_squarefree(p5)) goto tchi;
2624
p2=gel(ZX_factor(p5),1);
2625
switch(lg(p2)-1)
2626
{
2627
case 1:
2628
z = cgetg(11,t_VEC); ind=0;
2629
p3=gadd(gmul(gmul(gel(p1,1),gel(p1,2)),gel(p1,3)),
2630
gmul(gmul(gel(p1,4),gel(p1,5)),gel(p1,6)));
2631
gel(z,++ind) = p3;
2632
for (i=1; i<=3; i++)
2633
for (j=4; j<=6; j++)
2634
{
2635
p2=transroot(p1,i,j);
2636
p3=gadd(gmul(gmul(gel(p2,1),gel(p2,2)),gel(p2,3)),
2637
gmul(gmul(gel(p2,4),gel(p2,5)),gel(p2,6)));
2638
gel(z,++ind) = p3;
2639
}
2640
p5 = roots_to_ZX(z, &e);
2641
if (e <= -10)
2642
{
2643
if (!ZX_is_squarefree(p5)) goto tchi;
2644
p2 = gel(ZX_factor(p5),1);
2645
f = Z_issquare(ZX_disc(x));
2646
set_avma(av);
2647
if (lg(p2)-1==1)
2648
return f? galois_res(n,360,1,15): galois_res(n,720,-1,16);
2649
else
2650
return f? galois_res(n,36,1,10): galois_res(n,72,-1,13);
2651
}
2652
prec = precdbl(prec); break;
2653
2654
case 2: l2=degpol(gel(p2,1)); if (l2>3) l2=6-l2;
2655
switch(l2)
2656
{
2657
case 1: f = Z_issquare(ZX_disc(x));
2658
set_avma(av);
2659
return f? galois_res(n,60,1,12): galois_res(n,120,-1,14);
2660
case 2: f = Z_issquare(ZX_disc(x));
2661
if (f) { set_avma(av); return galois_res(n,24,1,7); }
2662
p3 = (degpol(gel(p2,1))==2)? gel(p2,2): gel(p2,1);
2663
f = Z_issquare(ZX_disc(p3));
2664
set_avma(av);
2665
return f? galois_res(n,24,-1,6): galois_res(n,48,-1,11);
2666
case 3: f = Z_issquare(ZX_disc(gel(p2,1)))
2667
|| Z_issquare(ZX_disc(gel(p2,2)));
2668
set_avma(av);
2669
return f? galois_res(n,18,-1,5): galois_res(n,36,-1,9);
2670
}
2671
case 3:
2672
for (l2=1; l2<=3; l2++)
2673
if (degpol(gel(p2,l2)) >= 3) p3 = gel(p2,l2);
2674
if (degpol(p3) == 3)
2675
{
2676
f = Z_issquare(ZX_disc(p3)); set_avma(av);
2677
return f? galois_res(n,6,-1,1): galois_res(n,12,-1,3);
2678
}
2679
else
2680
{
2681
f = Z_issquare(ZX_disc(x)); set_avma(av);
2682
return f? galois_res(n,12,1,4): galois_res(n,24,-1,8);
2683
}
2684
case 4: set_avma(av); return galois_res(n,6,-1,2);
2685
default: pari_err_BUG("galois (bug3)");
2686
}
2687
}
2688
2689
case 7: z = cgetg(36,t_VEC);
2690
prec = nbits2prec((long)(fb*7.) + 64);
2691
for(;;)
2692
{
2693
ind = 0; p1=QX_complex_roots(x,prec);
2694
for (i=1; i<=5; i++)
2695
for (j=i+1; j<=6; j++)
2696
{
2697
GEN t = gadd(gel(p1,i),gel(p1,j));
2698
for (k=j+1; k<=7; k++) gel(z,++ind) = gadd(t, gel(p1,k));
2699
}
2700
p5 = roots_to_ZX(z, &e); if (e <= -10) break;
2701
prec = precdbl(prec);
2702
}
2703
if (!ZX_is_squarefree(p5)) goto tchi;
2704
p2=gel(ZX_factor(p5),1);
2705
switch(lg(p2)-1)
2706
{
2707
case 1: f = Z_issquare(ZX_disc(x)); set_avma(av);
2708
return f? galois_res(n,2520,1,6): galois_res(n,5040,-1,7);
2709
case 2: f = degpol(gel(p2,1)); set_avma(av);
2710
return (f==7 || f==28)? galois_res(n,168,1,5): galois_res(n,42,-1,4);
2711
case 3: set_avma(av); return galois_res(n,21,1,3);
2712
case 4: set_avma(av); return galois_res(n,14,-1,2);
2713
case 5: set_avma(av); return galois_res(n,7,1,1);
2714
default: pari_err_BUG("galois (bug2)");
2715
}
2716
}
2717
tchi: set_avma(av1); x = tschirnhaus(x1);
2718
}
2719
}
2720
2721