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

563665 views
1
#include <signal.h>
2
#include <stdlib.h>
3
#include "typedef.h"
4
#include "voronoi.h"
5
#include "matrix.h"
6
#include "tools.h"
7
#include "ZZ_P.h"
8
#include "ZZ_cen_fun_P.h"
9
#include "ZZ_zclass_P.h"
10
#include "ZZ.h"
11
#include "longtools.h"
12
13
boolean QUIET = FALSE, TEMPORAER = FALSE, SHORTLIST = FALSE, NURUMF = FALSE,
14
U_option = TRUE, G_option = TRUE, LLLREDUCED = FALSE;
15
16
int ZCLASS;
17
extern int *SUB_VEC;
18
extern matrix_TYP **PrI;
19
20
int COUNTER = 0;
21
int NUMBER = 1000, SUBDIRECT = FALSE, LEVEL = 500; /*Default-Werte der maximalen Anzahl der berechneten
22
Zentrierungen bzw. Anzahl der Level */
23
FILE *ZZ_temp, *ZZ_list;
24
int MAT_ALLOC = 0;
25
int constituents = 0;
26
int verbose = 0;
27
//changed 09-03-2008: these varaibles are not extern
28
//extern ZZ_super_TYP **SUPER_info, *SUPER_INFO;
29
ZZ_super_TYP **SUPER_info, *SUPER_INFO;
30
31
32
/*------------------------------------------------------------------------------- */
33
static int suche_mat(matrix_TYP *mat,
34
matrix_TYP **liste,
35
int anz)
36
{
37
int i;
38
39
for (i = 0; i < anz; i++){
40
if (cmp_mat(mat, liste[i]) == 0)
41
return(i);
42
}
43
return(-1);
44
}
45
46
47
/*------------------------------------------------------------------------------- */
48
void ZZ_intern (Gram, data, tree, inzidenz)
49
matrix_TYP *Gram;
50
ZZ_data_t *data;
51
ZZ_tree_t *tree;
52
QtoZ_TYP *inzidenz;
53
{
54
ZZ_node_t *act, *new, *nnn;
55
int g, i, j, k, l, m, n, d, di, end_num, act_anz, flag, nr, NEU, zahl, flagge;
56
int ABBRUCH = FALSE;
57
matrix_TYP *gitter, *tmp, *X, *Li;
58
59
60
act = tree->root;
61
do {
62
if (ZCLASS == 1 && GRAPH){
63
flag = suche_mat(act->U, inzidenz->gitter, inzidenz->anz);
64
if (flag == -1 && inzidenz->anz != 0){
65
/* Das aktuelle Gitter kommt nicht vor in der Liste */
66
fprintf(stderr,"ERROR 1 in ZZ_intern\n");
67
exit(2);
68
}
69
if (flag == -1 && inzidenz->anz == 0){
70
/* insert start-lattice */
71
inzidenz->anz++;
72
inzidenz->gitter[0] = copy_mat(act->U);
73
inzidenz->tr_gitter[0] = tr_pose(inzidenz->gitter[0]);
74
inzidenz->inv_tr_gitter[0] = mat_inv(inzidenz->tr_gitter[0]);
75
inzidenz->entry[0] = (QtoZ_entry_TYP *)calloc(1024, sizeof(QtoZ_entry_TYP));
76
flag = 0;
77
}
78
}
79
for (i = 0; i < data->p_consts.k; i++) {
80
for (j = 0; j < data->p_consts.s[i]; j++) {
81
d = ZZ_epimorphs (data, i, j);
82
di = d;
83
end_num = data->EnCo[i][j].hi + 1;
84
if (d != 0) {
85
act_anz = 0;
86
for (k = 1; d > 0; d--, k *= end_num) {
87
for (n = k; n < 2 * k; n++) {
88
act_anz++;
89
ZZ_pick_epi (data, n, i, j);
90
new = ZZ_center (data, act, i, j);
91
nr = 0;
92
NEU = 0;
93
94
if (ZCLASS == 1 && GRAPH){
95
gitter = tr_pose(new->U);
96
}
97
flagge = 0;
98
ABBRUCH = ZZ_ins_node (Gram, data, tree,
99
act, new, i, j,
100
inzidenz, &nr, &NEU, &flagge, &g, &nnn);
101
if (ZCLASS == 1 && GRAPH){
102
if (NEU != 1){
103
/* not a new lattice for the graph or lattice in another zoo */
104
if (nr == -1){
105
/* lattice possibly in another zoo */
106
zahl = inzidenz->entry[flag][0].anz;
107
if (zahl == 0){
108
inzidenz->entry[flag][0].I = (int *)calloc(1024,
109
sizeof(int));
110
inzidenz->entry[flag][0].J = (int *)calloc(1024,
111
sizeof(int));
112
inzidenz->entry[flag][0].flag = (int *)calloc(1024,
113
sizeof(int));
114
inzidenz->entry[flag][0].lattice = (matrix_TYP
115
**)calloc(1024, sizeof(matrix_TYP *));
116
inzidenz->zoogitter[flag] = (matrix_TYP **)calloc(1024,
117
sizeof(matrix_TYP *));
118
}
119
inzidenz->entry[flag][0].I[zahl] = i;
120
inzidenz->entry[flag][0].J[zahl] = j;
121
inzidenz->entry[flag][0].flag[zahl] = -10;
122
inzidenz->zoogitter[flag][zahl] = gitter;
123
124
/* This isn't the correct conjugating matrix yet! */
125
inzidenz->entry[flag][0].lattice[zahl] =
126
copy_mat(inzidenz->inv_tr_gitter[flag]);
127
gitter = NULL;
128
inzidenz->entry[flag][0].anz++;
129
}
130
else{
131
/* not a new lattice */
132
nr++;
133
zahl = inzidenz->entry[flag][nr].anz;
134
if (zahl == 0){
135
inzidenz->entry[flag][nr].I = (int *)calloc(1024,
136
sizeof(int));
137
inzidenz->entry[flag][nr].J = (int *)calloc(1024,
138
sizeof(int));
139
inzidenz->entry[flag][nr].flag = (int *)calloc(1024,
140
sizeof(int));
141
inzidenz->entry[flag][nr].lattice = (matrix_TYP
142
**)calloc(1024, sizeof(matrix_TYP *));
143
}
144
inzidenz->entry[flag][nr].I[zahl] = i;
145
inzidenz->entry[flag][nr].J[zahl] = j;
146
inzidenz->entry[flag][nr].flag[zahl] = flagge;
147
inzidenz->entry[flag][nr].anz++;
148
149
switch (flagge){
150
case 1:
151
/*
152
inzidenz->entry[flag][nr].lattice[zahl] =
153
mat_mul(inzidenz->inv_tr_gitter[flag],
154
inzidenz->tr_gitter[nr - 1]);
155
fprintf(stderr, "F A L L 1!!!!!!!!!!!!!\n");
156
break;
157
*/
158
case 100:
159
inzidenz->entry[flag][nr].lattice[zahl] =
160
mat_mul(inzidenz->inv_tr_gitter[flag],
161
inzidenz->tr_gitter[nr - 1]);
162
for (l = 0; l < gitter->rows; l++){
163
for (m = 0; m < gitter->cols; m++){
164
inzidenz->entry[flag][nr].lattice[zahl]->array.SZ[l][m]
165
*= g;
166
}
167
}
168
break;
169
170
case 10:
171
Li = mat_inv(gitter);
172
X = konjugierende(Li, tree->root->col_group, nnn);
173
free_mat(Li);
174
if (X == NULL){
175
fprintf(stderr, "ERROR 2 in ZZ_intern!\n");
176
exit(9);
177
}
178
inzidenz->entry[flag][nr].lattice[zahl] =
179
mat_mul(inzidenz->inv_tr_gitter[flag], gitter);
180
mat_muleq(inzidenz->entry[flag][nr].lattice[zahl], X);
181
free_mat(X);
182
break;
183
}
184
}
185
}
186
else{
187
/* new lattice in the graph */
188
inzidenz->gitter[inzidenz->anz] = copy_mat(new->U);
189
inzidenz->tr_gitter[inzidenz->anz] = tr_pose(new->U);
190
inzidenz->inv_tr_gitter[inzidenz->anz] =
191
mat_inv(inzidenz->tr_gitter[inzidenz->anz]);
192
inzidenz->entry[inzidenz->anz] = (QtoZ_entry_TYP *)calloc(1024,
193
sizeof(QtoZ_entry_TYP));
194
inzidenz->anz++;
195
inzidenz->entry[flag][inzidenz->anz].anz = 1;
196
inzidenz->entry[flag][inzidenz->anz].I = (int *)calloc(1024,
197
sizeof(int));
198
inzidenz->entry[flag][inzidenz->anz].J = (int *)calloc(1024,
199
sizeof(int));
200
inzidenz->entry[flag][inzidenz->anz].flag = (int *)calloc(1024,
201
sizeof(int));
202
inzidenz->entry[flag][inzidenz->anz].lattice = (matrix_TYP
203
**)calloc(1024, sizeof(matrix_TYP *));
204
inzidenz->entry[flag][inzidenz->anz].I[0] = i;
205
inzidenz->entry[flag][inzidenz->anz].J[0] = j;
206
inzidenz->entry[flag][inzidenz->anz].flag[0] = 0;
207
inzidenz->entry[flag][inzidenz->anz].lattice[0] =
208
mat_mul(inzidenz->inv_tr_gitter[flag],
209
inzidenz->tr_gitter[inzidenz->anz - 1]);
210
}
211
if (gitter != NULL)
212
free_mat(gitter);
213
}
214
}
215
}
216
act->anz_tg = act_anz;
217
218
for (k = 0; k < di; k++) {
219
free_mat (data->epi_base[k]);
220
}
221
free (data->epi_base);
222
data->epi_base = NULL;
223
}
224
}
225
}
226
} while ((!ABBRUCH) && (ZZ_successor (data, &act)));
227
ZZ_fput_data (data, tree, ABBRUCH);
228
nnn = NULL;
229
}
230
231
232
233
234
/******************************************************************************/
235
void ZZ_transpose_array (int **array, int size)
236
{
237
int i, j, ZZ_swap;
238
239
for (i = 0; i < size; i++) {
240
for (j = i + 1; j < size; j++) {
241
ZZ_swap = array[i][j];
242
array[i][j] = array[j][i];
243
array[j][i] = ZZ_swap;
244
}
245
}
246
}
247
248
/******************************************************************************
249
@
250
@ (void)ZZ( group, gram, divisors, options );
251
@
252
@ or
253
@
254
@ (void)ZZ( group, gram, divisors, options, num_sublattices, dim1, dim2, ... )
255
@
256
@ bravais_TYP *group;
257
@ matrix_TYP *gram;
258
@ int *divisors;
259
@ char *options;
260
@ int num_sublattices, dim1, ...
261
@
262
@ group: bravais group, the algorithm applies the ZZ-algorithm with regard
263
@ to the prime-divisors of the order of the group.
264
@ gram: a gram matrix of a quadratic form that is invariant under the group
265
@ This form must be totally anisotropic.
266
@ divisors: an array of integers that REALLY MUST HAVE 100 (ONEHUNDRET)
267
@ entries. The index of the array specifies the prime number and the
268
@ contents of the array the multiplicity of the prime as divisor of
269
@ the group order. The ZZ function does not need the multiplicity
270
@ it just uses a subset of the prime divisors of the group order
271
@ to compute irreducible constituents of the matrix representation
272
@ of the group modulo those primes. Thus it is all right to set
273
@ the entries of the array to some non-zero number, e. g. if one
274
@ wants to compute the irreducible constituents modulo 2 and
275
@ modulo 5, then one has to write
276
@
277
@ divisors[2] = 1; divisors[5] = 1;
278
@
279
@ All other entries must be set to zero. (at least those that belong
280
@ to prime number indices).
281
@
282
@ If one simply wants to compute the irreducible constituents for
283
@ all divisors of the group order, it suffices to specify the
284
@ value NULL for the argument divisors.
285
@
286
@ options: a string of characters, (i.e. "n30l24rq"), supported are:
287
@ num_sublattices, dim1, ... : see option "p". Must only be specified if the
288
@ option "p" was specified
289
@
290
@ "n#": terminate after computation of "#" centerings
291
@ "l#": terminate afer "#" iterations of the algorithm
292
@ "r" : use the "lll"-algorithm on the Z-bases of the centerings
293
@ "q" : "quit-mode" - suppress messages on stdout/stderr
294
@ "v" : "verbose-mode" - opposite of "q"
295
@ "t" : create a file in the current directory that
296
@ contains additional information. See also options "ugsb"
297
@ This feature is on by default and the file name defaults
298
@ to ZZ.tmp. If this option is given the argument
299
@ "none", then no output file is created.
300
@ "u" : computes elementary divisors of the matrices that contain
301
@ the bases of the invariant sublattices (i.e. of
302
@ group->zentr[i]) and writes them to the
303
@ outputfile.
304
@ "g" : computes the elementary divisors of the gram-matrices of
305
@ the invariant sublattices and writes them to the output file.
306
@ Implies option "t".
307
@ "s" : "shortlist" - prints in short form the messages that are
308
@ suppressed by "q". Independent of "q" option
309
@ "b" : "print change of base only" -- suppresses the output of
310
@ the gram-matrices and elementary devisors to the output file.
311
@ "p" : "projections" -- compute only thos sublattices, that have
312
@ surjective projections on a given number of sublattices
313
@ with a given dimension. The number of the sublattices is
314
@ given by the first argument after "options", that is, by
315
@ "num_sublattices". The dimension of the first sublattice
316
@ is given by "dim1", the second by the argument "dim2" etc
317
@
318
@ NOTE: the number of the "dim#" arguments MUST match the
319
@ "num_sublattices"
320
@
321
@ Given this information, the algorithm devides the original
322
@ lattice in sublattices that are spanned by
323
@ <e_1, ..., e_dim1>,
324
@ <e_(dim1+1), ..., e_(dim1+dim2)>, etc
325
@
326
@ The computed centerings are stored in "group->zentr" as Z-bases
327
@ (matrix_TYP **zentr). The number of centerings is stored in
328
@ "group->zentr_no".
329
@
330
@ The functions exits by calling exit() in case of an error of if
331
@ the parameters are inconsistent.
332
@
333
@ NOTE: the bravais group is supposed to operate on a lattice of column
334
@ vectors. "SPALTENKONVENTION"
335
@
336
@ TODO:
337
@ write more documentation.
338
@
339
******************************************************************************/
340
341
static void scan_options (char *options, int *projections, FILE *outputfile)
342
{
343
char *optp, *help;
344
int num_proj;
345
char *temp_name = "ZZ.tmp";
346
347
SHORTLIST = FALSE;
348
ZCLASS = 0;
349
NURUMF = FALSE; /* only write the matrices of change of base to the
350
* file "ZZ.tmp", i.e. the Z-bases of the invariant
351
* sublattices.
352
*/
353
/*
354
* Default-Werte der maximalen Anzahl der berechneten
355
* Zentrierungen bzw. Anzahl der Level
356
*/
357
NUMBER = 1000;
358
LEVEL = 500;
359
LLLREDUCED = FALSE; /* so what? */
360
TEMPORAER = TRUE; /* schreibt einige Information ueber die gefundenen
361
* Zentrierungen in die Datei "ZZ.tmp"
362
*/
363
ZZ_temp = NULL;
364
QUIET = FALSE; /* make less noise */
365
SUBDIRECT = FALSE; /* berechnet nur solche Untergitter deren
366
* Projektionen auf bestimmte Teilgitter surjektiv
367
* sind
368
*/
369
U_option = TRUE; /* berechnet Elementarteiler der Basen der
370
* inv. TG
371
*/
372
G_option = TRUE; /* berechnet Elementarteiler der Grammatrizen */
373
374
if ((optp = strchr (options, (int) 'l')) != NULL) {
375
LEVEL = atoi (optp + 1);
376
}
377
if ((optp = strchr (options, (int) 'n')) != NULL) {
378
NUMBER = atoi (optp + 1);
379
}
380
if ((optp = strchr (options, (int) 'r')) != NULL) {
381
LLLREDUCED = TRUE;
382
}
383
if ((optp = strchr (options, (int) 'q')) != NULL) {
384
QUIET = TRUE;
385
}
386
if ((optp = strchr (options, (int) 'v')) != NULL) {
387
QUIET = FALSE;
388
}
389
if ((optp = strchr (options, (int) 'p')) != NULL) {
390
SUBDIRECT = TRUE;
391
projections[0] = atoi (optp + 1);
392
if (projections[0] == 0) {
393
fprintf (stderr, "\"p\" option requires number of sublattices and their dimensions to be given.\n");
394
exit (3);
395
} else if (projections[0] > 8) {
396
fprintf (stderr, "Maximal dimension is 8\n");
397
exit(3);
398
} else {
399
#if DEBUG
400
printf ("%d\n", projections[0]);
401
#endif
402
help = optp + 1;
403
for (num_proj = 1;
404
num_proj <= projections[0];
405
num_proj++){
406
if ((help = strchr (help, '/')) != NULL) {
407
help++;
408
projections[num_proj] = atoi (help);
409
if (projections[num_proj] == 0) {
410
fprintf (stderr, "\"p\" option requires number of sublattices and their dimensions to be given.\n");
411
exit (3);
412
}
413
} else {
414
fprintf (stderr, "\"p\" option requires number of sublattices and their dimensions to be given.\n");
415
exit (3);
416
}
417
}
418
}
419
}
420
if ((optp = strchr (options, (int) 't')) != NULL) {
421
if (outputfile == NULL) {
422
TEMPORAER = FALSE;
423
} else {
424
TEMPORAER = TRUE;
425
ZZ_temp = outputfile;
426
}
427
}
428
if ((optp = strchr (options, (int) 'u')) != NULL) {
429
U_option = FALSE;
430
}
431
if ((optp = strchr (options, (int) 'z')) != NULL) {
432
ZCLASS = 1;
433
}
434
if ((optp = strchr (options, (int) 'Z')) != NULL) {
435
ZCLASS = 2;
436
}
437
if ((optp = strchr (options, (int) 'g')) != NULL) {
438
G_option = FALSE;
439
}
440
if ((optp = strchr (options, (int) 's')) != NULL) {
441
SHORTLIST = TRUE;
442
}
443
if ((optp = strchr (options, (int) 'b')) != NULL) {
444
NURUMF = TRUE;
445
}
446
if (U_option || G_option || NURUMF) {
447
TEMPORAER = TRUE;
448
}
449
/*
450
* globale Abbruchvariable
451
*/
452
COUNTER = 0; /* Anzahl der Zentrierungen */
453
if (TEMPORAER && ZZ_temp == NULL) {
454
if ((ZZ_temp = fopen (temp_name, "w+")) == NULL) {
455
fprintf (stderr, "ZZ: scan_arg: Error, could not open temporary file \n");
456
TEMPORAER = FALSE;
457
}
458
}
459
}
460
461
void *ZZ(group, gram, divisors, inzidenz, options, outputfile, super_nr, konst_flag)
462
bravais_TYP *group;
463
matrix_TYP *gram;
464
int *divisors;
465
QtoZ_TYP *inzidenz;
466
char *options;
467
FILE *outputfile;
468
int super_nr;
469
int konst_flag;
470
{
471
ZZ_data_t *data;
472
ZZ_tree_t *tree;
473
int i, result = 0;
474
matrix_TYP *sylv, *help;
475
int projections[9];
476
QtoZ_konst_TYP *data_neu;
477
ZZ_node_t *n, *t;
478
ZZ_super_TYP *DATEN;
479
480
/* zuerst wird getestet, ob alle noetigen Daten vorhanden sind. */
481
if (group == NULL) {
482
printf("ZZ: Error: no bravais group specified.\n");
483
exit(3);
484
}
485
if (gram == NULL) {
486
printf("ZZ: Error: no gram matrix specified.\n");
487
exit(3);
488
}
489
sylv = dsylv(gram);
490
for (i=0;i <sylv->rows;i++) {
491
if (sylv->array.SZ[i][i] <= 0) {
492
fput_mat( stderr, gram, "Gram", 0);
493
free_mat(sylv);
494
printf("ZZ: Error: gram matrix not positiv definite");
495
exit(3);
496
}
497
}
498
free_mat(sylv);
499
if (divisors == NULL) {
500
divisors = group->divisors;
501
}
502
result = 0;
503
for (i = 1; i < 100 && result == 0; i++) {
504
if (divisors[i] != 0) {
505
#if DEBUG
506
printf("divisors[%d] = %d\n", i, divisors[i]);
507
#endif
508
result = divisors[i];
509
}
510
}
511
if (result == 0) {
512
printf("ZZ: Error: prime divisors not specified.\n");
513
exit(3);
514
}
515
if (group->gen_no == 0) {
516
printf("ZZ: Error: bravais group with unknown number of generators?\n");
517
exit(3);
518
}
519
if (group->gen == NULL) {
520
printf("ZZ: Error: bravais group without generators?\n");
521
exit(3);
522
}
523
scan_options (options, projections, outputfile);
524
for (i = 0; i < group->gen_no; i++) {
525
ZZ_transpose_array(group->gen[i]->array.SZ,
526
group->gen[i]->cols);
527
}
528
/* Now check whether the gram matrix is really invariant under the
529
* group
530
*
531
* NOTE: scal_pr() is a ROW scalar product.
532
533
for (i = 0; i < group->gen_no ; i++) {
534
int check;
535
536
help = scal_pr(group->gen[i], gram, TRUE);
537
check = cmp_mat(help, gram);
538
free_mat(help);
539
if (check != 0) {
540
fput_mat( stdout, gram, "form", 0);
541
printf("i: %d\n", i);
542
printf("The gram matrix isn't invariant under the group.\n");
543
exit(3);
544
}
545
} */
546
547
548
data = (ZZ_data_t *)calloc(1, sizeof(ZZ_data_t));
549
tree = (ZZ_tree_t *)calloc(1, sizeof(ZZ_tree_t));
550
551
ZZ_get_data (group, gram, divisors, data, tree, projections, konst_flag);
552
ZZ_intern (gram, data, tree, inzidenz);
553
ZZ_put_data (group, data, tree);
554
555
if (!GRAPH){
556
/* free tree and data */
557
n = tree->root;
558
do {
559
t = n->next;
560
ZZ_free_node (data, n);
561
} while ((n = t) != NULL);
562
ZZ_free_data(data);
563
free(data);
564
free(tree);
565
}
566
else{
567
DATEN = (ZZ_super_TYP *)calloc(1,sizeof(ZZ_super_TYP));
568
if (SUBDIRECT) {
569
if (PrI) {
570
for (i = 0; i < SUBDIRECT; i++) {
571
if (PrI[i]) {
572
free_mat (PrI[i]);
573
}
574
}
575
free (PrI);
576
PrI = NULL;
577
}
578
if (SUB_VEC) {
579
free (SUB_VEC);
580
SUB_VEC = NULL;
581
}
582
}
583
DATEN->tree = tree;
584
DATEN->data = data;
585
}
586
587
for (i = 0; i < group->zentr_no; i++) {
588
ZZ_transpose_array(group->zentr[i]->array.SZ,
589
group->zentr[i]->cols);
590
}
591
for (i = 0; i < group->gen_no; i++) {
592
ZZ_transpose_array (group->gen[i]->array.SZ,
593
group->gen[i]->cols);
594
}
595
596
597
if (ZCLASS == 2 && GRAPH){
598
SUPER_INFO = DATEN;
599
}
600
if (ZCLASS == 1 && GRAPH){
601
SUPER_info[super_nr] = DATEN;
602
}
603
}
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618