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

563642 views
1
#include <signal.h>
2
#include "typedef.h"
3
#include "getput.h"
4
#include "tools.h"
5
#include "bravais.h"
6
#include "base.h"
7
#include "matrix.h"
8
#include "longtools.h"
9
#include "voronoi.h"
10
#include "ZZ_P.h"
11
#include "ZZ_irr_const_P.h"
12
#include "ZZ_lll_P.h"
13
#include "ZZ_cen_fun_P.h"
14
15
extern int IDEM_NO;
16
int *SUB_VEC;
17
matrix_TYP **PrI;
18
QtoZ_konst_TYP *KONSTITUENTEN = NULL;
19
20
/* eingefuegt von Oliver am 5.2.99 */
21
int OANZ = 0;
22
matrix_TYP **OMAT;
23
int OFLAG = FALSE;
24
/* ------------------------------- */
25
26
27
/*============================================================*\
28
|| ||
29
|| Enthaelt die speziellen Funktionen des Zentrierungs- ||
30
|| algorithmus. Zunaechst die Ein- und Ausgaberoutinen ||
31
|| und ihre Hilfsfunktionen. ||
32
|| ||
33
\*============================================================*/
34
35
/*-------------------------------------------------------------------*\
36
| takes the matrices in MAT as a generating set for a matrix-ring |
37
| over p and evaluates any linearcombination to get the whole ring |
38
\*-------------------------------------------------------------------*/
39
40
static matrix_TYP **gen_sys (int *num, int l, matrix_TYP ** MAT);
41
42
static matrix_TYP **gen_sys (num, l, MAT)
43
int *num;
44
int l;
45
matrix_TYP **MAT;
46
{
47
int i, j, *s, n, anz, w;
48
int **Z, **Q1, **Q2;
49
int row;
50
matrix_TYP **ring;
51
int a = 0;
52
53
#if 0
54
if (l == 1) { /* there`s only the identical Endomorphism and all
55
GF(p) multiples */
56
ring = MAT;
57
*num = act_prime - 1;
58
return (ring);
59
}
60
#endif
61
62
a = intpow (act_prime, l);
63
anz = a - 1;
64
row = MAT[0]->rows;
65
66
ring = (matrix_TYP **) malloc (anz * sizeof (matrix_TYP *));
67
*num = anz;
68
s = (int *)calloc (l, sizeof (int));
69
n = 0; /* number of the actuell matrix */
70
anz = 0; /* highest coefficient in s */
71
s[0] = 1;
72
ring[0] = MAT[0];
73
while (anz < l) {
74
a = 0; /* Laufindex ueber s */
75
while ((a <= anz) && ((s[a] = S (s[a], 1)) == 0)) {
76
a++;
77
}
78
if (a <= anz) {
79
n++;
80
ring[n] = init_mat(row, row, "p");
81
Z = Q1 = ring[n]->array.SZ;
82
for (a = 0; a <= anz; a++) {
83
if ((w = s[a]) == 0) {
84
continue;
85
}
86
Q2 = MAT[a]->array.SZ;
87
for (i = 0; i < row; i++) {
88
for (j = 0; j < row; j++) {
89
Z[i][j] = S(Q1[i][j],
90
P(Q2[i][j], w));
91
}
92
}
93
}
94
Check_mat(ring[n]);
95
} else {
96
if (++anz < l) {
97
s[anz] = 1;
98
s[anz - 1] = 0;
99
n++;
100
ring[n] = MAT[anz];
101
}
102
}
103
}
104
free (MAT);
105
free (s);
106
return (ring);
107
}
108
109
void ZZ_free_node (data, n)
110
ZZ_data_t *data;
111
ZZ_node_t *n;
112
{
113
int i,j;
114
ZZ_couple_t *m, *tm;
115
116
if (n->group != NULL){
117
free_bravais(n->group);
118
}
119
if (n->stab_chain != NULL){
120
for (i=0;i<n->col_group->dim;i++){
121
free_bahn(n->stab_chain[i]);
122
free(n->stab_chain[i]);
123
}
124
free(n->stab_chain);
125
}
126
if (n->col_group != NULL){
127
free_bravais(n->col_group);
128
}
129
if (n->brav != NULL){
130
free_bravais(n->brav);
131
}
132
if (n->perfect != NULL && n->perfect_no > 0){
133
for (i=0;i<n->perfect_no;i++){
134
clear_voronoi(n->perfect[i]);
135
free(n->perfect[i]);
136
}
137
free(n->perfect);
138
n->perfect = NULL;
139
n->perfect_no = 0;
140
}
141
if (n->N_no_orbits > 0 && n->N_orbits != NULL){
142
for (i=0;i<n->N_no_orbits;i++){
143
for (j=0;j<n->N_lengths[i];j++)
144
free_mat(n->N_orbits[i][j]);
145
free(n->N_orbits[i]);
146
}
147
free(n->N_lengths);
148
free(n->N_orbits);
149
}
150
if (n->U != NULL) {
151
free_mat (n->U);
152
}
153
if (n->Q != NULL) {
154
free_mat (n->Q);
155
}
156
if (n->U_inv != NULL) {
157
free_mat (n->U_inv);
158
}
159
if (n->el_div != NULL) {
160
free_mat (n->el_div);
161
}
162
free (n->path);
163
for (i = 0; i < data->p_consts.k; i++) {
164
free (n->k_vec[i]);
165
}
166
free (n->k_vec);
167
168
if ((m = n->parent) != NULL) {
169
do {
170
tm = m->elder;
171
free (m);
172
m = tm;
173
} while (m != NULL);
174
}
175
if ((m = n->child) != NULL) {
176
do {
177
tm = m->elder;
178
free (m);
179
m = tm;
180
} while (m != NULL);
181
}
182
free (n);
183
}
184
185
/*----------------------------------------------------------------*\
186
| calculate the Basis of the endomorphisms for any constituent |
187
| and generate the endomorphism-ring. The matrix set TMAT is |
188
| copied into data->Endo[i][j] by gen_sys, so there mustn`t be a |
189
| ZZ_free_mat at TMAT. |
190
\*----------------------------------------------------------------*/
191
void ZZ_make_endo (data)
192
ZZ_data_t *data;
193
{
194
int i, j, l;
195
matrix_TYP **TMAT;
196
197
for (i = 0; i < data->p_consts.k; i++) {
198
init_prime (data->p_consts.p[i]);
199
for (j = 0; j < data->p_consts.s[i]; j++) {
200
l = data->r;
201
TMAT = p_solve(&l,
202
data->p_consts.Delta[i][j],
203
data->p_consts.Delta[i][j], 2);
204
data->EnCo[i][j].low = l;
205
data->Endo[i][j] = gen_sys(&data->EnCo[i][j].hi,
206
l, TMAT);
207
}
208
}
209
}
210
211
212
213
/* tests if two constituents are isomorphic. Returns 1 if they are,
214
* 0 otherwise.
215
*
216
*/
217
218
static int test_two_constituents(data, i, j, k)
219
ZZ_data_t *data;
220
int i, j, k;
221
{
222
int ll, l, s;
223
matrix_TYP **temp;
224
225
#define P_CONST data->p_consts.Delta
226
if (data->n[i][j] == data->n[i][k]) {
227
for (ll = 0; ll < data->r; ll++) {
228
s = 0;
229
for (l = 0; l < data->n[i][j]; l++) {
230
s = S(S(s, P_CONST[i][j][ll]->array.SZ[l][l]),
231
-P_CONST[i][k][ll]->array.SZ[l][l]);
232
}
233
if (s != 0) {
234
break;
235
}
236
}
237
if (s == 0) {
238
s = data->r;
239
temp = p_solve(&s, P_CONST[i][j], P_CONST[i][k], 2);
240
if (s > 0) {
241
#if DEBUG
242
printf("p: %d, Konst. %d/%d\n", i, j ,k);
243
#endif
244
for (ll = 0; ll < s; ll++) {
245
free_mat(temp[ll]);
246
}
247
free(temp);
248
data->p_consts.s[i]--;
249
for (ll = 0; ll < data->r; ll++) {
250
free_mat(P_CONST[i][k][ll]);
251
}
252
free(P_CONST[i][k]);
253
P_CONST[i][k]= P_CONST[i][data->p_consts.s[i]];
254
data->n[i][k]= data->n[i][data->p_consts.s[i]];
255
return 1;
256
}
257
}
258
}
259
return 0;
260
#undef P_CONST
261
}
262
263
/*----------------------------------------------------------------*\
264
| Test if the set of constituents is redundant, i.e two of them |
265
| are isomorphic. |
266
\*----------------------------------------------------------------*/
267
void ZZ_test_konst (data)
268
ZZ_data_t *data;
269
{
270
int i, j, k;
271
272
for (i = 0; i < data->p_consts.k; i++) {
273
init_prime (data->p_consts.p[i]);
274
for (j = 0; j < data->p_consts.s[i] - 1; j++) {
275
for (k = j + 1; k < data->p_consts.s[i]; k++) {
276
if (test_two_constituents(data, i, j, k)) {
277
k--;
278
}
279
}
280
} /* Konstituenten */
281
} /* Primzahlen */
282
}
283
284
/*
285
* Diese Funktion fuellt die Datenstrukturen "data" und "tree"
286
* insbesondere werden die irreduziblen Konstituenten fuer die
287
* Primteiler der Gruppenordnung errechnet
288
* q2z ruft diese Fufnktion ueber ZZ mehrmals auf; einige Daten brauchen nicht mehrmals
289
* ausgerechnet werden; das kann noch verbessert werden!
290
*/
291
void ZZ_get_data (group, gram, divisors, data, tree, projections, konst_flag)
292
bravais_TYP *group;
293
matrix_TYP *gram;
294
int *divisors;
295
ZZ_data_t *data;
296
ZZ_tree_t *tree;
297
int *projections;
298
int konst_flag;
299
{
300
int i, j, k;
301
matrix_TYP **help2;
302
QtoZ_konst_TYP *data_neu;
303
304
305
if (konst_flag == -3 && GRAPH){
306
for (i = 0; i < KONSTITUENTEN->k; i++){
307
for (j = 0; j < KONSTITUENTEN->s[i]; j++){
308
for (k = 0; k < KONSTITUENTEN->r; k++){
309
free_mat(KONSTITUENTEN->Delta[i][j][k]);
310
}
311
free(KONSTITUENTEN->Delta[i][j]);
312
}
313
free(KONSTITUENTEN->Delta[i]);
314
}
315
free(KONSTITUENTEN->Delta);
316
free(KONSTITUENTEN->s);
317
free(KONSTITUENTEN);
318
return;
319
}
320
321
tree->root = tree->last = (ZZ_node_t *) malloc(sizeof(ZZ_node_t));
322
data->N = group->dim;
323
324
if (ZCLASS > 0){
325
group->gen_no -= IDEM_NO;
326
tree->root->col_group = tr_bravais(group,1,FALSE);
327
group->gen_no += IDEM_NO;
328
tree->root->group = tr_bravais(tree->root->col_group,1,FALSE);
329
tree->root->brav = NULL;
330
tree->root->stab_chain = NULL;
331
tree->root->N_orbits = NULL;
332
tree->root->N_lengths = NULL;
333
tree->root->N_no_orbits = 0;
334
tree->root->perfect = NULL;
335
tree->root->perfect_no = 0;
336
tree->root->Q = init_mat(data->N, data->N, "1");
337
} else {
338
tree->root->col_group = NULL;
339
tree->root->group = NULL;
340
tree->root->brav = NULL;
341
tree->root->stab_chain = NULL;
342
tree->root->N_orbits = NULL;
343
tree->root->N_lengths = NULL;
344
tree->root->N_no_orbits = 0;
345
tree->root->perfect = NULL;
346
tree->root->perfect_no = 0;
347
tree->root->Q = NULL;
348
}
349
350
tree->root->U = init_mat (data->N, data->N, "");
351
tree->root->U_inv = init_mat (data->N, data->N, "");
352
/* changed by oliver (6.11.00) from
353
tree->root->el_div = init_mat (1, data->N, "");
354
to: */
355
tree->root->el_div = init_mat (data->N, data->N, "");
356
for (i = 0; i < data->N; i++) {
357
tree->root->U->array.SZ[i][i] =
358
tree->root->U_inv->array.SZ[i][i] =
359
/* changed by oliver (6.11.00) from
360
tree->root->el_div->array.SZ[0][i] = 1;
361
to: */
362
tree->root->el_div->array.SZ[i][i] = 1;
363
}
364
tree->root->number =
365
tree->node_count =
366
tree->root->level =
367
tree->root->index = 1;
368
tree->root->path = (ZZ_prod_t *) calloc(1, sizeof(ZZ_prod_t));
369
tree->root->parent = NULL;
370
tree->root->next = NULL;
371
tree->root->child = NULL;
372
373
/*
374
* Read the number of generators and the generators.
375
*/
376
377
data->r = group->gen_no;
378
data->DELTA = (matrix_TYP **)malloc(data->r * sizeof(matrix_TYP *));
379
data->DELTA_M = (matrix_TYP **)malloc(data->r * sizeof(matrix_TYP *));
380
for (i = 0; i < data->r; i++) {
381
data->DELTA[i] = group->gen[i];
382
data->DELTA_M[i] = copy_mat(data->DELTA[i]);
383
}
384
385
/*
386
* Read the number of primes
387
*/
388
for (i = 0, data->p_consts.k = 0; i < 100; i++) {
389
if (divisors[i] != 0) {
390
data->p_consts.k++;
391
}
392
}
393
data->p_consts.p = (int *)malloc(data->p_consts.k * sizeof (int));
394
for (i = 0, j = 0; j < data->p_consts.k; i++) {
395
if (divisors[i] != 0) {
396
data->p_consts.p[j++] = i;
397
}
398
}
399
data->p_consts.s = (int *) malloc(data->p_consts.k * sizeof(int));
400
data->n = (int **) malloc(data->p_consts.k * sizeof(int *));
401
data->EnCo = (ZZ_prod_t **)malloc(data->p_consts.k *
402
sizeof(ZZ_prod_t *));
403
data->p_consts.Delta =
404
(matrix_TYP ****)malloc(data->p_consts.k *
405
sizeof (matrix_TYP ***));
406
data->Endo =
407
(matrix_TYP ****)malloc (data->p_consts.k *
408
sizeof (matrix_TYP ***));
409
/*
410
* Read the i'th prime and the number of constituents for i
411
*/
412
413
/* if - else eingefuegt von Oliver: 8.8.00 */
414
if (konst_flag == 0 && GRAPH){
415
for (i = 0; i < KONSTITUENTEN->k; i++) {
416
data->p_consts.s[i] = KONSTITUENTEN->s[i];
417
data->n[i] = (int *)malloc(data->p_consts.s[i] * sizeof (int));
418
data->p_consts.Delta[i] =
419
(matrix_TYP ***)malloc(data->p_consts.s[i] *
420
sizeof (matrix_TYP **));
421
for (j = 0; j < data->p_consts.s[i]; j++) {
422
data->p_consts.Delta[i][j] =
423
(matrix_TYP **)malloc(data->r *
424
sizeof (matrix_TYP *));
425
for (k = 0; k < KONSTITUENTEN->r; k++) {
426
data->p_consts.Delta[i][j][k] =
427
copy_mat(KONSTITUENTEN->Delta[i][j][k]);
428
data->p_consts.Delta[i][j][k]->prime =
429
data->p_consts.p[i];
430
}
431
data->n[i][j] = data->p_consts.Delta[i][j][0]->rows;
432
}
433
}
434
}
435
else{
436
/* alte Version */
437
for (i = 0; i < data->p_consts.k; i++) {
438
help2 = ZZ_irr_const (data->DELTA, data->r,
439
data->p_consts.p[i],
440
&data->p_consts.s[i]);
441
442
data->n[i] = (int *)malloc(data->p_consts.s[i] * sizeof (int));
443
data->p_consts.Delta[i] =
444
(matrix_TYP ***)malloc(data->p_consts.s[i] *
445
sizeof (matrix_TYP **));
446
for (j = 0; j < data->p_consts.s[i]; j++) {
447
data->p_consts.Delta[i][j] =
448
(matrix_TYP **)malloc(data->r *
449
sizeof (matrix_TYP *));
450
for (k = 0; k < data->r; k++) {
451
data->p_consts.Delta[i][j][k] =
452
help2[j * data->r + k];
453
data->p_consts.Delta[i][j][k]->prime =
454
data->p_consts.p[i];
455
}
456
data->n[i][j] = data->p_consts.Delta[i][j][0]->rows;
457
}
458
free (help2);
459
}
460
ZZ_test_konst(data);
461
ZZ_test_konst(data);
462
ZZ_test_konst(data);
463
}
464
465
/*
466
* initialize Endomorphisms
467
*/
468
for (i = 0; i < data->p_consts.k; i++) {
469
data->EnCo[i] =
470
(ZZ_prod_t *)malloc(data->p_consts.s[i] *
471
sizeof (ZZ_prod_t));
472
data->Endo[i] =
473
(matrix_TYP ***)malloc(data->p_consts.s[i] *
474
sizeof (matrix_TYP **));
475
}
476
477
data->epi_base = NULL;
478
data->epi = init_mat(data->N, data->N, "");
479
tree->root->k_vec = (int **)malloc(data->p_consts.k * sizeof(int *));
480
data->VK = (int **) malloc (data->p_consts.k * sizeof (int *));
481
for (i = 0; i < data->p_consts.k; i++) {
482
tree->root->k_vec[i] =
483
(int *)calloc(data->p_consts.s[i], sizeof (int));
484
data->VK[i] = (int *)calloc(data->p_consts.s[i] + 1,
485
sizeof(int));
486
data->VK[i]++;
487
}
488
ZZ_make_endo (data);
489
if (SUBDIRECT) {
490
SUBDIRECT = projections[0];
491
SUB_VEC = (int *) malloc (SUBDIRECT * sizeof (int));
492
#ifdef DEBUG
493
fprintf (stderr, "SUBDIRECT = %d\n", SUBDIRECT);
494
#endif
495
for (i = 0; i < SUBDIRECT; i++) {
496
SUB_VEC[i] = projections[i+1];
497
#ifdef DEBUG
498
fprintf(stderr, "Dimension[%d] = %d\n", i, SUB_VEC[i]);
499
#endif
500
}
501
PrI = (matrix_TYP **) malloc(SUBDIRECT * sizeof(matrix_TYP *));
502
k = 0;
503
for (i = 0; i < SUBDIRECT; i++) {
504
PrI[i] = init_mat (data->N, SUB_VEC[i], "");
505
for (j = 0; j < SUB_VEC[i]; j++) {
506
PrI[i]->array.SZ[k + j][j] = 1;
507
#ifdef DEBUG
508
fput_mat (stderr, PrI[i], "PrI[i]", 0);
509
#endif
510
}
511
k += SUB_VEC[i];
512
}
513
}
514
515
516
if (konst_flag == 1 && GRAPH){
517
KONSTITUENTEN = (QtoZ_konst_TYP *)calloc(1, sizeof(QtoZ_konst_TYP));
518
KONSTITUENTEN->k = data->p_consts.k;
519
KONSTITUENTEN->s = (int *)calloc(data->p_consts.k, sizeof(int));
520
KONSTITUENTEN->r = (data->r - IDEM_NO);
521
KONSTITUENTEN->Delta = (matrix_TYP ****)malloc(KONSTITUENTEN->k *
522
sizeof (matrix_TYP ***));
523
524
for (i = 0; i < data->p_consts.k; i++) {
525
KONSTITUENTEN->s[i] = data->p_consts.s[i];
526
KONSTITUENTEN->Delta[i] = (matrix_TYP ***)malloc(KONSTITUENTEN->s[i] *
527
sizeof (matrix_TYP **));
528
for (j = 0; j < KONSTITUENTEN->s[i]; j++) {
529
KONSTITUENTEN->Delta[i][j] = (matrix_TYP **)malloc(KONSTITUENTEN->r *
530
sizeof (matrix_TYP *));
531
for (k = 0; k < KONSTITUENTEN->r; k++) {
532
KONSTITUENTEN->Delta[i][j][k] =
533
copy_mat(data->p_consts.Delta[i][j][k]);
534
}
535
}
536
}
537
}
538
}
539
540
/*****************************************************************************/
541
/* */
542
/* input: global data-structure in data and the tree of Zentrierungen */
543
/* output: the structure-component group->zentr points to an array of */
544
/* of matrices, each containing a set of generators of a */
545
/* Zentrierung as Z-modul. group->zentr_no contains the number */
546
/* of the computed Zentrierungen */
547
/* */
548
/*****************************************************************************/
549
void ZZ_put_data (group, data, tree)
550
bravais_TYP *group;
551
ZZ_data_t *data;
552
ZZ_tree_t *tree;
553
{
554
ZZ_node_t *n, *t;
555
int i;
556
ZZ_couple_t *m;
557
558
group->zentr = (matrix_TYP **)malloc(tree->node_count *
559
sizeof (matrix_TYP *));
560
group->zentr_no = tree->node_count;
561
n = tree->root;
562
i = 0;
563
do {
564
group->zentr[i] = copy_mat(n->U);
565
/* n->U = NULL; oliver: 16.8.00 */
566
if (SHORTLIST) {
567
if (SUBDIRECT) {
568
printf ("\t L%d: Number of Sublattices: %d ",
569
n->number, n->anz_tg);
570
} else {
571
printf ("\t L%d: ", n->number);
572
}
573
if ((m = n->child) != NULL) {
574
do {
575
printf (" L%d ", m->he->number);
576
}
577
while ((m = m->elder) != NULL);
578
}
579
printf ("\n");
580
fflush (stdout);
581
}
582
i++;
583
t = n->next;
584
/* oliver: 11.8.00
585
ZZ_free_node (data, n); */
586
} while ((n = t) != NULL);
587
}
588
589
void ZZ_fput_data (data, tree, ABBRUCH)
590
ZZ_data_t *data;
591
ZZ_tree_t *tree;
592
int ABBRUCH;
593
{
594
ZZ_node_t *n, *t;
595
ZZ_couple_t *m;
596
int old_lev = 0, lev_cnt = 0;
597
598
n = tree->root;
599
if (TEMPORAER) {
600
fprintf (ZZ_temp,"\n==========================================================================\n");
601
}
602
do {
603
if (old_lev != n->level) {
604
if (TEMPORAER && (old_lev)) {
605
fprintf (ZZ_temp, "\n======= %d Lattices on level %d ====================================\n", lev_cnt, old_lev);
606
}
607
old_lev = n->level;
608
lev_cnt = 0;
609
}
610
if (TEMPORAER && !(ABBRUCH & 1)) {
611
fprintf (ZZ_temp,
612
"\n\t L%3.d: %13s\tConstituent\n",
613
n->number, "Lattice");
614
if (SUBDIRECT) {
615
fprintf (ZZ_temp,
616
"\n Number of sublattices: %d ",
617
n->anz_tg);
618
}
619
if ((m = n->parent) != NULL) {
620
fprintf (ZZ_temp, " parents :\n");
621
do {
622
fprintf(ZZ_temp,
623
"%25s%3-d\t(p=%d,Nr.=%d)\n",
624
"L", m->he->number,
625
data->p_consts.p[m->she.i],
626
m->she.j + 1);
627
} while ((m = m->elder) != NULL);
628
}
629
if ((m = n->child) != NULL) {
630
fprintf (ZZ_temp, " children :\n");
631
do {
632
fprintf (ZZ_temp,
633
"%25s%3-d\t(p=%d,Nr.=%d)\n",
634
"L",
635
m->he->number,
636
data->p_consts.p[m->she.i],
637
m->she.j + 1);
638
} while ((m = m->elder) != NULL);
639
}
640
}
641
lev_cnt++;
642
t = n->next;
643
} while ((n = t) != NULL);
644
if (TEMPORAER) {
645
fprintf (ZZ_temp,
646
"\n======= %d Lattices on level %d ====================================\n", lev_cnt, old_lev);
647
}
648
if (ABBRUCH & 2) {
649
if (TEMPORAER) {
650
fprintf (ZZ_temp, " \t ============================================================\n \t Algorithmus nach Berechnung von %d Zentrierungen abgebrochen \n \t ============================================================\n", NUMBER);
651
}
652
}
653
if (ABBRUCH & 4) {
654
if (TEMPORAER) {
655
fprintf (ZZ_temp, " \t ============================================================\n \t Algorithmus nach Berechnung von %d Levels abgebrochen \n \t ============================================================\n", LEVEL);
656
}
657
}
658
}
659
660
void ZZ_free_data (data)
661
ZZ_data_t *data;
662
{
663
int i, j, k;
664
665
if (SUBDIRECT) {
666
if (PrI) {
667
for (i = 0; i < SUBDIRECT; i++) {
668
if (PrI[i]) {
669
free_mat (PrI[i]);
670
}
671
}
672
free (PrI);
673
PrI = NULL;
674
}
675
if (SUB_VEC) {
676
free (SUB_VEC);
677
SUB_VEC = NULL;
678
}
679
}
680
681
for (i = 0; i < data->p_consts.k; i++) {
682
for (j = 0; j < data->p_consts.s[i]; j++) {
683
for (k = 0; k < data->r; k++) {
684
free_mat (data->p_consts.Delta[i][j][k]);
685
}
686
for (k = 0; k < data->EnCo[i][j].hi; k++) {
687
free_mat (data->Endo[i][j][k]);
688
}
689
free (data->p_consts.Delta[i][j]);
690
free (data->Endo[i][j]);
691
}
692
free (data->p_consts.Delta[i]);
693
free (data->Endo[i]);
694
free (data->EnCo[i]);
695
data->VK[i]--;
696
free (data->VK[i]);
697
free (data->n[i]);
698
}
699
700
free (data->p_consts.Delta);
701
free (data->Endo);
702
free (data->EnCo);
703
free (data->VK);
704
free (data->n);
705
706
for (i = 0; i < data->r; i++) {
707
free_mat (data->DELTA_M[i]);
708
}
709
free (data->DELTA);
710
free (data->DELTA_M);
711
712
free_mat (data->epi);
713
free (data->p_consts.s);
714
free (data->p_consts.p);
715
if (ZZ_temp) {
716
fclose (ZZ_temp);
717
ZZ_temp = NULL;
718
}
719
}
720
721
/*------------------------------------------------------------*\
722
| Variation of p_solve, it differs in the way of output |
723
\*------------------------------------------------------------*/
724
matrix_TYP *ZZ_p_vsolve (anz, L_mat, R_mat)
725
int *anz;
726
matrix_TYP **L_mat, **R_mat;
727
728
{
729
int **M, **N, *v, f, help;
730
int *M_j, *M_act, numax;
731
matrix_TYP *E;
732
boolean L_null, R_null;
733
int *ss, *nuin, p, i, j, jj, k, kk, l, cR, cL, cM, rR, rL, rM, rN;
734
int rg = 0, act;
735
736
737
p = act_prime;
738
L_null = (L_mat == NULL);
739
R_null = (R_mat == NULL);
740
741
cL = L_null ? 1 : L_mat[0]->cols;
742
rL = L_null ? 1 : L_mat[0]->rows;
743
rR = R_null ? 1 : R_mat[0]->rows;
744
cR = R_null ? 1 : R_mat[0]->cols;
745
746
cM = cL * rR;
747
rM = *anz * rL * cR;
748
rN = rL * cR;
749
rg = *anz * cR;
750
N = (int **)malloc(rN * sizeof(int *));
751
M = (int **)malloc(rM * sizeof(int *));
752
753
/* changed tilman 6/2/97 from
754
* nuin = (int *)malloc(cM * sizeof(int));
755
* to
756
*/
757
nuin = (int *)malloc((cM+1) * sizeof(int));
758
759
ss = (int *) malloc(cM * sizeof(int));
760
761
for (i = 0; i < *anz; i++) {
762
if (!L_null) {
763
if ((L_mat[i]->cols != cL) || (L_mat[i]->rows != rL)) {
764
fprintf (stderr, "Error in input\n");
765
exit (3);
766
}
767
}
768
if (!R_null) {
769
if ((R_mat[i]->rows != rR) || (R_mat[i]->cols != cR)) {
770
fprintf (stderr, "Error in input\n");
771
exit (3);
772
}
773
}
774
775
for (j = 0; j < rN; j++) {
776
N[j] = (int *) calloc (cM, sizeof (int));
777
}
778
779
if (!L_null) {
780
for (j = 0, jj = 0; j < rL; j++, jj += rR) {
781
for (k = 0, kk = 0; k < cL; k++, jj -= rR) {
782
if ((help=L_mat[i]->array.SZ[j][k] % p)
783
< 0) {
784
help += p;
785
}
786
if (help) {
787
for (l = 0;
788
l < rR; l++, jj++, kk++) {
789
N[jj][kk] = help;
790
}
791
} else {
792
jj += rR;
793
kk += rR;
794
}
795
}
796
}
797
}
798
if (!R_null) {
799
for (j = 0; j < cR; j++) {
800
for (k = 0; k < rR; k++) {
801
if ((help=R_mat[i]->array.SZ[k][j] % p)
802
< 0) {
803
help += p;
804
}
805
if (help) {
806
for (l = 0, jj = j, kk = k;
807
l < cL;
808
l++, jj += cR, kk += rR) {
809
N[jj][kk]= S(N[jj][kk],
810
-help);
811
}
812
}
813
}
814
}
815
}
816
817
/* permutierte Eingabe in Liste */
818
for (j = 0; j < rL; j++) {
819
for (k = 0; k < cR; k++) {
820
M[j*rg + i*cR + k] = N[(rL - 1 - j) * cR + k];
821
}
822
}
823
}
824
rg = 0;
825
/*
826
* Gauss Algorithm
827
*/
828
for (i = 0; i < cM; i++) {
829
ss[i] = -1;
830
/*
831
* Find the row with non-zero entry in i-th column
832
*/
833
for (j = rg; (j < rM) && (M[j][i] == 0); j++);
834
if (j == rM) {
835
continue;
836
}
837
act = j;
838
/*
839
* Normalize act-th row and mark the non-zero entries
840
*/
841
nuin[0] = 1;
842
f = P (1, -M[j][i]);
843
for (k = i; k < cM; k++) {
844
if ((help = M[act][k])) {
845
M[act][k] = P (help, f);
846
nuin[nuin[0]++] = k;
847
}
848
}
849
/*
850
* Swap act-th row and rg-th row
851
*/
852
v = M[rg];
853
M[rg] = M[act];
854
M[act] = v;
855
ss[rg] = i;
856
act = rg++;
857
/*
858
* Clear i-th column downwards
859
*/
860
M_act = M[act];
861
for (j = act + 1; j < rM; j++) {
862
if ((f = S (0, -M[j][i])) != 0) {
863
M_j = M[j];
864
M_j[i] = 0;
865
numax = nuin[0];
866
if (f == 1) {
867
for (k = 2, kk = nuin[2];
868
k < numax; kk = nuin[++k]) {
869
M_j[kk] = S(M_j[kk],M_act[kk]);
870
}
871
} else {
872
for (k = 2, kk = nuin[2];
873
k < numax; kk = nuin[++k]) {
874
M_j[kk] = S(M_j[kk],
875
P(M_act[kk], f));
876
}
877
}
878
}
879
}
880
}
881
if ((*anz = cM - rg) != 0) {
882
/*
883
* Matrix has not full rank: clear it upwards
884
*/
885
for (i = rg - 1; i > 0; i--) {
886
nuin[0] = 2;
887
nuin[1] = ss[i];
888
M_act = M[i];
889
for (j = ss[i] + 1; j < cM; j++) {
890
if (M_act[j]) {
891
nuin[nuin[0]++] = j;
892
}
893
}
894
if (nuin[0] == 2) {
895
j = ss[i];
896
for (k = i - 1; k > 0; k--) {
897
M[k][j] = 0;
898
}
899
} else {
900
for (j = i - 1; j >= 0; j--) {
901
if ((f = S (0, -M[j][ss[i]])) != 0) {
902
M_j = M[j];
903
M_j[ss[i]] = 0;
904
numax = nuin[0];
905
if (f == 1) {
906
for (k= 2,kk = nuin[2];
907
k < numax;
908
kk = nuin[++k]) {
909
M_j[kk] = S(M_j[kk], M_act[kk]);
910
}
911
} else {
912
for (k= 2, kk= nuin[2];
913
k < numax;
914
kk = nuin[++k]) {
915
M_j[kk] = S (M_j[kk], P (M_act[kk], f));
916
}
917
}
918
}
919
}
920
}
921
}
922
E = init_mat (rR, rR, "");
923
for (i = 0, k = 0, l = 0; i < cM; i++) {
924
if (i == ss[k]) {
925
E->array.SZ[l + (i / rR)][i % rR] = p;
926
l++;
927
k++;
928
continue;
929
}
930
for (j = 0; j < k; j++) {
931
if (M[j][i] != 0) {
932
E->array.SZ
933
[l + (ss[j] / rR)]
934
[ss[j] % rR] = p - M[j][i];
935
}
936
}
937
E->array.SZ[l + (i / rR)][i % rR] = 1;
938
l++;
939
}
940
}
941
for (i = 0; i < rM; i++) {
942
free (M[i]);
943
}
944
free (M);
945
free (N);
946
free (ss);
947
free (nuin);
948
949
return (E);
950
}
951
952
/*---------------------------------------------------------------*\
953
| Take the kk-th epimorphism from DELTA_M onto p_consts.Delta[ii][jj], |
954
| determine its kernel, extend to a generating set of the new |
955
| centering and calculate the common factors and index of that |
956
| centering. Return the possibly new node for checking, wether it |
957
| occured already earlier in the algorithm or not. |
958
\*---------------------------------------------------------------*/
959
ZZ_node_t *ZZ_center (data, father, ii, jj)
960
ZZ_data_t *data;
961
ZZ_node_t *father;
962
int ii, jj;
963
{
964
int flag, sg, i, j, d;
965
matrix_TYP *ker;
966
ZZ_node_t *n;
967
968
n = (ZZ_node_t *) malloc (sizeof (ZZ_node_t));
969
n->col_group = NULL;
970
n->group = NULL;
971
n->brav = NULL;
972
n->N_orbits = NULL;
973
n->N_lengths = NULL;
974
n->N_no_orbits = 0;
975
n->stab_chain = NULL;
976
n->perfect = NULL;
977
n->perfect_no = 0;
978
n->number = -1;
979
n->index = -1;
980
n->level = father->level + 1;
981
n->U = n->Q = n->U_inv = n->el_div = NULL;
982
n->next = NULL;
983
n->parent = n->child = NULL;
984
n->k_vec = (int **) malloc (data->p_consts.k * sizeof (int *));
985
for (i = 0; i < data->p_consts.k; i++) {
986
n->k_vec[i] =
987
(int *)malloc(data->p_consts.s[i] * sizeof (int));
988
memcpy (n->k_vec[i], father->k_vec[i],
989
data->p_consts.s[i] * sizeof (int));
990
}
991
n->k_vec[ii][jj]++;
992
d = father->level;
993
n->path = (ZZ_prod_t *) malloc ((d + 1) * sizeof (ZZ_prod_t));
994
memcpy (n->path, father->path, d * sizeof (ZZ_prod_t));
995
n->path[d].hi = ii;
996
n->path[d].low = jj;
997
998
/*------------------------------------------------------------*\
999
| Determine the kernel of the epimorphism |
1000
\*------------------------------------------------------------*/
1001
d = 1;
1002
ker = ZZ_p_vsolve (&d, NULL, &data->epi);
1003
if (d != 0) {
1004
/*
1005
* Express that kernel in the basis of the original lattice
1006
*/
1007
n->U = mat_mul (ker, father->U);
1008
free_mat (ker);
1009
/*
1010
* Make n->U a generating set of the new ZZ_centering by
1011
* appending to n->U p times the basis of father.
1012
*/
1013
} else {
1014
n->U = copy_mat (father->U);
1015
iscal_mul (n->U, act_prime);
1016
}
1017
/*
1018
* Calculate the invariant factors of that generating set
1019
*/
1020
Check_mat (n->U);
1021
1022
if (U_option) {
1023
n->el_div = long_elt_mat(NULL,n->U, NULL);
1024
/*
1025
* Calculate index as product of the invariant factors
1026
*/
1027
n->index = n->el_div->array.SZ[0][0];
1028
for (i = 1; i < n->el_div->cols; i++) {
1029
/* changed by oliver (6.11.00) from:
1030
n->index *= n->el_div->array.SZ[0][i];
1031
to: */
1032
n->index *= n->el_div->array.SZ[i][i];
1033
}
1034
} else {
1035
n->el_div = init_mat (1, 1, "");
1036
sg = n->U->array.SZ[0][0];
1037
for (i = 0; ((sg != 1) && (i < n->U->rows)); i++) {
1038
for (j = 0; ((sg != 1) && (j < n->U->cols)); j++) {
1039
sg = GGT (sg, n->U->array.SZ[i][j]);
1040
}
1041
}
1042
n->el_div->array.SZ[0][0] = (sg > 0) ? sg : -sg;
1043
}
1044
sg = n->el_div->array.SZ[0][0];
1045
if (sg != 1) {
1046
flag = TRUE;
1047
for (i = 0; flag && (i < data->p_consts.k); i++) {
1048
if (data->p_consts.p[i] == sg) {
1049
if (data->VK[i][-1] != 0) {
1050
for (j = 0;
1051
j < data->p_consts.s[i]; j++) {
1052
n->k_vec[i][j]-=data->VK[i][j];
1053
}
1054
n->level -= data->VK[i][-1];
1055
} else {
1056
data->VK[i][-1] = n->level - 1;
1057
memcpy (data->VK[i], n->k_vec[i],
1058
data->p_consts.s[i] *
1059
sizeof (int));
1060
memset(n->k_vec[i], 0,
1061
data->p_consts.s[i] *
1062
sizeof (int));
1063
n->level = 1;
1064
}
1065
flag = FALSE;
1066
}
1067
}
1068
}
1069
return (n);
1070
}
1071
1072
/*---------------------------------------------------------------*\
1073
| Let E be an epimorphism from DELTA_M onto p_consts.Delta[ii][jj] |
1074
| Solve the matrix-equation DELTA_M * E = E * p_consts.Delta[ii][jj] |
1075
| over F(p) and return a basis of the space of all solutions |
1076
\*---------------------------------------------------------------*/
1077
int ZZ_epimorphs (data, ii, jj)
1078
ZZ_data_t *data;
1079
int ii, jj;
1080
{
1081
int d, i, j, k, x, e;
1082
int **X, **M;
1083
int *bas, found, row, col, sae;
1084
int actlist, vor;
1085
int a = 0;
1086
matrix_TYP *TMP, *AMP, **liste;
1087
1088
init_prime (data->p_consts.p[ii]);
1089
1090
d = data->r;
1091
data->epi_base = p_solve(&d, data->DELTA_M,
1092
data->p_consts.Delta[ii][jj], 2);
1093
if (d > 1) {
1094
data->epi->cols = data->epi_base[0]->cols;
1095
if (data->EnCo[ii][jj].low != 1) {
1096
a = intpow (act_prime, d);
1097
if (d == data->EnCo[ii][jj].low) {
1098
/* All Epimorphisms differs only by an
1099
* endomorphism
1100
*/
1101
for (i = 1; i < d; i++) {
1102
free_mat (data->epi_base[i]);
1103
}
1104
data->epi_base =
1105
(matrix_TYP **)realloc(data->epi_base,
1106
sizeof(matrix_TYP *));
1107
d = 1;
1108
return (d);
1109
}
1110
sae = d / data->EnCo[ii][jj].low;
1111
liste = (matrix_TYP **) malloc(a*sizeof(matrix_TYP *));
1112
actlist = 0;
1113
bas = (int *) calloc (d, sizeof (int));
1114
row = data->epi_base[0]->rows;
1115
col = data->epi_base[0]->cols;
1116
found = 0;
1117
for (x = 0; x < d - 1; x++) {
1118
if (bas[x] == 1) {
1119
/* epim already found previously */
1120
continue;
1121
}
1122
if ((++found) == sae) {
1123
/* got a complete set of epi`s */
1124
for (++x; x < d; x++) {
1125
bas[x] = 1;
1126
}
1127
break;
1128
}
1129
/* Calculate the produts of the
1130
* Epimorphism X with all
1131
* Endomorphisms and compare to the
1132
* other Epi`s
1133
*/
1134
vor = actlist;
1135
for (e = 0; e < data->EnCo[ii][jj].hi; e++) {
1136
TMP = mat_mul (data->epi_base[x],
1137
data->Endo[ii][jj][e]);
1138
liste[actlist++] = TMP;
1139
M = TMP->array.SZ;
1140
for (i = x + 1; i < d; i++) {
1141
X= data->epi_base[i]->array.SZ;
1142
j = 0;
1143
while (
1144
(j < row) && ((memcmp (M[j], X[j], 4 * col)) == 0)) {
1145
j++;
1146
}
1147
if (j == row) {
1148
bas[i] = 1;
1149
break;
1150
}
1151
}
1152
for (k = 0; k < vor; k++) {
1153
AMP = pmat_add (TMP, liste[k],
1154
1, 1);
1155
liste[actlist++] = AMP;
1156
for (i = x + 1; i < d; i++) {
1157
X = data->epi_base[i]->array.SZ;
1158
j = 0;
1159
while (
1160
(j < row) && ((memcmp (M[j], X[j], 4 * col)) == 0)) {
1161
j++;
1162
}
1163
if (j == row) {
1164
bas[i] = 1;
1165
break;
1166
}
1167
}
1168
}
1169
}
1170
}
1171
/*
1172
* prepare the new epi_base for output
1173
*/
1174
for (i = 0; i < actlist; i++) {
1175
free_mat (liste[i]);
1176
}
1177
free (liste);
1178
found = 1;
1179
for (i = 1; i < d; i++) {
1180
if (bas[i] == 1) {
1181
free_mat (data->epi_base[i]);
1182
} else {
1183
data->epi_base[found++] =
1184
data->epi_base[i];
1185
}
1186
}
1187
d = found;
1188
data->epi_base =
1189
(matrix_TYP **)realloc(data->epi_base,
1190
d*sizeof(matrix_TYP *));
1191
}
1192
} else {
1193
if (d != 0) {
1194
data->epi->cols = data->epi_base[0]->cols;
1195
} else {
1196
data->epi->cols = 0;
1197
}
1198
}
1199
return (d);
1200
}
1201
1202
boolean ZZ_successor (data, act)
1203
ZZ_data_t *data;
1204
ZZ_node_t **act;
1205
1206
{
1207
int i;
1208
1209
if ((*act = (*act)->next) == NULL) {
1210
return (FALSE);
1211
}
1212
for (i = 0; i < data->r; i++) {
1213
free_mat (data->DELTA_M[i]);
1214
data->DELTA_M[i] = mat_kon((*act)->U, data->DELTA[i],
1215
(*act)->U_inv);
1216
}
1217
return (TRUE);
1218
}
1219
1220
1221
1222
/*------------------------------------------------------------------------------- */
1223
static int suche_mat(matrix_TYP *mat,
1224
matrix_TYP **liste,
1225
int anz)
1226
{
1227
int i;
1228
1229
for (i = 0; i < anz; i++){
1230
if (cmp_mat(mat, liste[i]) == 0)
1231
return(i);
1232
}
1233
return(-1);
1234
}
1235
1236
1237
1238
/*------------------------------------------------------------------------------- */
1239
int ZZ_ins_node (Gram, data, tree, father, new, ii, jj, inzidenz, nr, NEU, flagge, g, nnn)
1240
matrix_TYP *Gram;
1241
ZZ_data_t *data;
1242
ZZ_tree_t *tree;
1243
ZZ_node_t *father, *new;
1244
int ii, jj;
1245
QtoZ_TYP *inzidenz;
1246
int *nr;
1247
int *NEU;
1248
int *flagge;
1249
int *g;
1250
ZZ_node_t **nnn;
1251
{
1252
ZZ_node_t *n;
1253
ZZ_couple_t *c;
1254
matrix_TYP *Tmp1, *Tmp2, *U_vor, *tmp;
1255
matrix_TYP *Mat, *Trf, *el, *GMat;
1256
int **U, **CC, sum, f;
1257
int i, j, k, nl, flag, ff, gg;
1258
int ABBRUCH;
1259
1260
/* inserted tilman 6/2/97 */
1261
char filename[32];
1262
1263
sum =
1264
f =
1265
g[0] = 0;
1266
U = new->U->array.SZ;
1267
ABBRUCH = FALSE;
1268
1269
/*
1270
* Determine gcd of common factors of new->U
1271
*/
1272
1273
if (new->el_div->array.SZ[0][0] == 1) {
1274
n = father;
1275
} else {
1276
n = tree->root;
1277
}
1278
while ((n != NULL) && (n->level < new->level)) {
1279
n = n->next;
1280
}
1281
1282
if (n != NULL) {
1283
/* We found a node on the same level, now look for
1284
all on this level for an identical lattice */
1285
g[0] = new->el_div->array.SZ[0][0];
1286
nl = new->level;
1287
do {
1288
f = n->U_inv->kgv;
1289
f *= g[0];
1290
flag = TRUE;
1291
for (i = 0; (i < data->p_consts.k) && flag; i++) {
1292
flag = memcmp (n->k_vec[i],
1293
new->k_vec[i],
1294
data->p_consts.s[i] *
1295
sizeof (int)) == 0;
1296
}
1297
if (flag) {
1298
CC = n->U_inv->array.SZ;
1299
/*
1300
* Index-condition satisfied
1301
*/
1302
1303
/* Multiply new->U and n->U_inv and check
1304
* divisibility condition for each entry
1305
*/
1306
for (i = 0; i < new->U->rows; i++) {
1307
for (j = 0; j < new->U->cols; j++) {
1308
sum = 0;
1309
for (k = 0;
1310
k < n->U_inv->rows;
1311
k++) {
1312
sum += U[i][k] * CC[k][j];
1313
}
1314
if ((sum % f) != 0) {
1315
goto next;
1316
}
1317
}
1318
}
1319
c = father->child;
1320
while (c != NULL) {
1321
if (c->he == n) {
1322
ZZ_free_node (data, new);
1323
/* next 7 lines by oliver: 9.8.00: for graph for QtoZ */
1324
if (ZCLASS == 1 && GRAPH){
1325
nr[0] = suche_mat(n->U, inzidenz->gitter, inzidenz->anz);
1326
if (nr[0] == -1){
1327
fprintf(stderr,"ERROR 1 in ZZ_ins_node!\n");
1328
exit(2);
1329
}
1330
flagge[0] += 1;
1331
}
1332
return ABBRUCH;
1333
}
1334
c = c->elder;
1335
}
1336
break;
1337
}
1338
next:
1339
continue;
1340
} while (((n = n->next) != NULL) && (n->level == new->level));
1341
}
1342
1343
if ((n == NULL) || (n->level > nl)) {
1344
/* this is really a new lattice */
1345
1346
if (SUBDIRECT) {
1347
for (i = 0; i < SUBDIRECT; i++) {
1348
Tmp1 = mat_mul (new->U, PrI[i]);
1349
Tmp2 = long_elt_mat(NULL,Tmp1, NULL);
1350
free_mat (Tmp1);
1351
/* changed 30/06/97 tilman form:
1352
if (Tmp2->array.SZ[0][Tmp2->cols - 1] != 1) {
1353
to: */
1354
if (Tmp2->array.SZ[Tmp2->cols - 1]
1355
[Tmp2->cols - 1] != 1) {
1356
i = SUBDIRECT + 1;
1357
}
1358
free_mat (Tmp2);
1359
}
1360
if (i > SUBDIRECT) {
1361
ZZ_free_node (data, new);
1362
1363
/* next 2 lines by oliver: 9.8.00: for graph for QtoZ */
1364
if (GRAPH)
1365
nr[0] = -1;
1366
1367
return ABBRUCH;
1368
}
1369
}
1370
1371
if (ZCLASS == 1){
1372
/* second call of ZZ by q2z */
1373
if (orbit_under_normalizer(data,tree,father,new,ii,jj,inzidenz,nr,nnn)){
1374
ZZ_free_node (data, new);
1375
flagge[0] += 10;
1376
return ABBRUCH;
1377
}
1378
}
1379
if (ZCLASS == 2){
1380
/* first call of ZZ by q2z */
1381
if (deal_with_ZCLASS(data, tree, father, new)){
1382
ZZ_free_node (data, new);
1383
return ABBRUCH;
1384
}
1385
}
1386
1387
/*
1388
* New lattice:
1389
* Calculate the scalarproducts of the generating system
1390
*/
1391
NEU[0] = 1;
1392
1393
if (ZCLASS == 2 && GRAPH){
1394
U_vor = mat_inv(new->U);
1395
}
1396
1397
/* !!!!!!!!!!!!!! new->U is changed in scal_pr !!!!!!!!!!!!!!!!!!! */
1398
GMat = Mat = scal_pr (new->U, Gram, FALSE);
1399
if (ZCLASS == 2 && GRAPH){
1400
/* save transformation matrix */
1401
tmp = mat_mul(new->U, U_vor);
1402
new->Q = tr_pose(tmp);
1403
free_mat(tmp);
1404
free_mat(U_vor);
1405
}
1406
1407
if (ZCLASS == 1 && GRAPH){
1408
/* now calculate the (integral) representation
1409
on the new lattice (bare in mind that it is
1410
row invariant. There is a flaw: normalizer and
1411
centralizer won't be correct */
1412
ff = tree->root->group->normal_no;
1413
tree->root->group->normal_no = 0;
1414
gg = tree->root->group->cen_no;
1415
tree->root->group->cen_no = 0;
1416
new->group = konj_bravais(tree->root->group, new->U);
1417
tree->root->group->normal_no = ff;
1418
tree->root->group->cen_no = gg;
1419
1420
/* the second flaw of konj_bravais is the formspace */
1421
for (f = 0; f < new->group->form_no; f++)
1422
new->group->form[f]->kgv = 1;
1423
long_rein_formspace(new->group->form, new->group->form_no, 1);
1424
new->col_group = tr_bravais(new->group, 1, FALSE);
1425
}
1426
1427
if (LLLREDUCED) {
1428
/*
1429
* Perform MLLL-Reduction
1430
*/
1431
Trf = ZZ_lll (Mat, 0);
1432
real_mat (Trf, Mat->rows, Trf->cols);
1433
/* Store the new Gram matrix and the invariant
1434
* factors
1435
*/
1436
GMat = Mat;
1437
/* Apply the LLL-Transformation to the basis
1438
*/
1439
Mat = new->U;
1440
new->U = mat_mul (Trf, Mat);
1441
free_mat (Mat);
1442
free_mat(Trf);
1443
}
1444
if (G_option) {
1445
el = long_elt_mat(NULL,GMat, NULL);
1446
}
1447
/*
1448
* Invert the Basis-Transformation
1449
*/
1450
new->U_inv = mat_inv (new->U);
1451
new->number = ++tree->node_count;
1452
new->level = father->level + 1;
1453
tree->last->next = new;
1454
tree->last = new;
1455
1456
if (new->number > NUMBER) {
1457
ABBRUCH = 2;
1458
}
1459
if (new->level >= LEVEL) {
1460
ABBRUCH = 4;
1461
}
1462
1463
if (!QUIET) {
1464
fprintf (stderr, "L%d with (%d,%d) yields L%d\n",
1465
father->number, ii, jj, tree->node_count);
1466
}
1467
/*
1468
* write new lattice to temporary file ZZ.tmp
1469
*/
1470
if (TEMPORAER && !NURUMF) {
1471
fprintf (ZZ_temp, "L%d with (%d,%d) yields L%d\n",
1472
father->number, ii, jj, tree->node_count);
1473
1474
if (U_option) {
1475
fput_mat (ZZ_temp, new->el_div,
1476
"Elementary divisors :", 2);
1477
}
1478
ZZ_transpose_array(new->U->array.SZ, new->U->cols);
1479
/* fput_mat (ZZ_temp, new->U,
1480
"Change of basis :", 4); */
1481
ZZ_transpose_array(new->U->array.SZ, new->U->cols);
1482
1483
if (G_option) {
1484
fput_mat(ZZ_temp, el,
1485
"Elementary divisors of the Gram matrix:", 2);
1486
}
1487
fput_mat (ZZ_temp, GMat,
1488
"Gram matrix :", 2);
1489
fflush (ZZ_temp);
1490
}
1491
if (TEMPORAER && NURUMF) {
1492
ZZ_transpose_array(new->U->array.SZ, new->U->cols);
1493
fput_mat (ZZ_temp, new->U,
1494
"Change of basis:", 4);
1495
ZZ_transpose_array(new->U->array.SZ, new->U->cols);
1496
ZZ_transpose_array(new->U_inv->array.SZ, new->U->cols);
1497
fput_mat (ZZ_temp, new->U_inv,
1498
"Inverse of it :", 4);
1499
ZZ_transpose_array(new->U_inv->array.SZ, new->U->cols);
1500
fflush (ZZ_temp);
1501
}
1502
1503
/* eingefuegt von Oliver am 5.2.99 */
1504
if (OFLAG){
1505
OMAT[OANZ] = copy_mat(new->U);
1506
OANZ += 1;
1507
}
1508
/* ------------------ */
1509
1510
if (G_option) {
1511
free_mat (el);
1512
}
1513
free_mat (GMat);
1514
} else {
1515
/*
1516
* We got that lattice already
1517
*/
1518
if (!QUIET) {
1519
fprintf (stderr, "L%d with (%d,%d) yields %d.L%d\n",
1520
father->number, ii, jj, g[0], n->number);
1521
}
1522
if (TEMPORAER && !NURUMF) {
1523
fprintf (ZZ_temp, "L%d with (%d,%d) yields %d.L%d\n",
1524
father->number, ii, jj, g[0], n->number);
1525
}
1526
1527
/* next 7 lines by oliver: 9.8.00: for graph for QtoZ */
1528
if (ZCLASS == 1 && GRAPH){
1529
nr[0] = suche_mat(n->U, inzidenz->gitter, inzidenz->anz);
1530
if (nr[0] == -1){
1531
fprintf(stderr,"ERROR 2 in ZZ_ins_node!\n");
1532
exit(3);
1533
}
1534
flagge[0] += 100;
1535
}
1536
ZZ_free_node (data, new);
1537
new = n;
1538
}
1539
1540
/*
1541
* Tell the son, who's father
1542
*/
1543
c = (ZZ_couple_t *) malloc (sizeof (ZZ_couple_t));
1544
c->he = father;
1545
c->she.i = ii;
1546
c->she.j = jj;
1547
c->factor = g[0];
1548
c->elder = new->parent;
1549
new->parent = c;
1550
1551
/*
1552
* Tell father, he's got a new son
1553
*/
1554
c = (ZZ_couple_t *) malloc (sizeof (ZZ_couple_t));
1555
c->he = new;
1556
c->she.i = ii;
1557
c->she.j = jj;
1558
c->factor = g[0];
1559
c->elder = father->child;
1560
father->child = c;
1561
return ABBRUCH;
1562
}
1563
1564
1565
1566
1567
/*}}} */
1568
/*{{{ ZZ_pick_epi */
1569
void
1570
ZZ_pick_epi (data, number, ii, jj)
1571
ZZ_data_t *data;
1572
int number, ii, jj;
1573
{
1574
int **E, **hh;
1575
int q, i, j, k, f;
1576
matrix_TYP *H;
1577
1578
init_prime (data->p_consts.p[ii]);
1579
q = data->EnCo[ii][jj].hi + 1;
1580
E = data->epi->array.SZ;
1581
for (i = 0; i < data->epi->rows; i++)
1582
{
1583
for (j = 0; j < data->epi->cols; j++)
1584
{
1585
E[i][j] = 0;
1586
}
1587
}
1588
for (i = 0; number != 0; number /= q, i++)
1589
{
1590
if ((f = (number % q)) != 0)
1591
{
1592
H = mat_mul (data->epi_base[i], data->Endo[ii][jj][f - 1]);
1593
hh = H->array.SZ;
1594
for (j = 0; j < data->epi->rows; j++)
1595
{
1596
for (k = 0; k < data->epi->cols; k++)
1597
{
1598
E[j][k] = S (E[j][k], hh[j][k]);
1599
}
1600
}
1601
free_mat (H);
1602
}
1603
}
1604
}
1605
1606
/*}}} */
1607
1608