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

563580 views
1
/* last change: 14.09.2000 by Oliver Heidbuechel */
2
3
4
#include <typedef.h>
5
#include <getput.h>
6
#include <matrix.h>
7
#include <base.h>
8
#include <gmp.h>
9
#include <zass.h>
10
#include <longtools.h>
11
#include <orbit.h>
12
#include <bravais.h>
13
#include <graph.h>
14
15
16
17
matrix_TYP **extensions_o(matrix_TYP *cozycle,
18
matrix_TYP *D,
19
matrix_TYP *R,
20
bravais_TYP *G,
21
int **lengths,
22
MP_INT **names,
23
int *number_of_orbits,
24
int ****WORDS,
25
int **NUMBER_OF_WORDS,
26
matrix_TYP ***N,
27
MP_INT coho_size,
28
int option,
29
int *list_of_names);
30
31
32
/* -------------------------------------------------------------------- */
33
/* matrix_on_diagonal: */
34
/* Creates the matrix M = diag(mat, ... , mat) */
35
/* -------------------------------------------------------------------- */
36
matrix_TYP *matrix_on_diagonal(matrix_TYP *mat,
37
int anz)
38
{
39
int i, j, k;
40
41
matrix_TYP *M;
42
43
44
M = init_mat(mat->rows * anz, mat->cols * anz, "");
45
for (i = 0; i < anz; i++){
46
for (j = 0; j < mat->rows; j++){
47
for (k = 0; k < mat->cols; k++){
48
M->array.SZ[i*mat->rows + j][i*mat->cols + k] = mat->array.SZ[j][k];
49
}
50
}
51
}
52
M->kgv = mat->kgv;
53
M->flags.Integral = mat->flags.Integral;
54
Check_mat(M);
55
56
return(M);
57
}
58
59
60
61
/* -------------------------------------------------------------------- */
62
/* extract_r */
63
/* returns the spacegroup to the pointgroup G and the cozykel X */
64
/* code is taken out of extract.c */
65
/* -------------------------------------------------------------------- */
66
bravais_TYP *extract_r(bravais_TYP *G,
67
matrix_TYP *X)
68
{
69
bravais_TYP *H;
70
71
int i, j;
72
73
char comment[1000];
74
75
76
rat2kgv(X);
77
Check_mat(X);
78
79
/* is it a valid cozycle? */
80
if ((G->dim * G->gen_no != X->rows) || (X->cols != 1)){
81
fprintf(stderr,"The cozycle is not compatible to this point group\n");
82
fprintf(stderr,"It should have %d * %d = %d rows\n",G->dim,G->gen_no,
83
G->dim*G->gen_no);
84
exit(3);
85
}
86
87
H = init_bravais(G->dim+1);
88
H->gen_no = G->gen_no;
89
H->gen = (matrix_TYP **) malloc(G->gen_no * sizeof(matrix_TYP *));
90
91
for (i=0;i<H->gen_no;i++){
92
H->gen[i] = copy_mat(G->gen[i]);
93
rat2kgv(H->gen[i]);
94
Check_mat(H->gen[i]);
95
real_mat(H->gen[i],H->dim,H->dim);
96
iscal_mul(H->gen[i],X->kgv);
97
H->gen[i]->kgv = H->gen[i]->kgv * X->kgv;
98
for (j=0;j<H->dim-1;j++)
99
H->gen[i]->array.SZ[j][H->dim-1] = X->array.SZ[i*(H->dim-1)+j][0];
100
H->gen[i]->array.SZ[H->dim-1][H->dim-1] = X->kgv;
101
Check_mat(H->gen[i]);
102
}
103
sprintf(comment,"space group to the point group of %s and cozycle %s",
104
FILENAMES[0],FILENAMES[1]);
105
106
return(H);
107
}
108
109
110
111
/* -------------------------------------------------------------------- */
112
/* all_cocycles: */
113
/* Calculates the coycles for the spacegroup in the Z-class given by */
114
/* the pointgroup G. */
115
/* -------------------------------------------------------------------- */
116
/* relator_input: presentation of G */
117
/* G : pointgroup representing the Z-class */
118
/* CAUTION: the programm will only work correctly, if */
119
/* the correct normalizer of the pointgroup is given. */
120
/* anzahl : the function will set anzahl = number of affine */
121
/* classes */
122
/* The following code is a part of the mainfunction of the programm */
123
/* Extensions! */
124
/* -------------------------------------------------------------------- */
125
126
matrix_TYP **all_cocycles(matrix_TYP *relator_input,
127
bravais_TYP *G,
128
int *anzahl,
129
matrix_TYP **matinv,
130
matrix_TYP ***X,
131
MP_INT **names,
132
int ****WORDS,
133
int **NUMBER_OF_WORDS,
134
matrix_TYP ***N,
135
int *coho_size,
136
int **list_of_names,
137
boolean l_option)
138
{
139
matrix_TYP **Y;
140
141
word *relator;
142
143
int *len, i;
144
145
long dim;
146
147
char comment[1000];
148
149
MP_INT cohom_size;
150
151
152
/* we have to have at least the identity to generate the normalizer */
153
if (G->normal_no == 0){
154
G->normal_no = 1;
155
G->normal = (matrix_TYP **) malloc(1 * sizeof(matrix_TYP *));
156
G->normal[0] = init_mat(G->dim,G->dim,"1");
157
}
158
159
/* speicher fuer die worte */
160
relator = (word *) calloc(relator_input->rows,sizeof(word));
161
162
/* konvertieren der inputmatrix in relator-format */
163
for (i=0;i<relator_input->rows;i++){
164
matrix_2_word(relator_input,relator+i,i);
165
}
166
167
X[0] = cohomology(&dim,G->gen,matinv,relator,G->gen_no,relator_input->rows);
168
169
/* there is a special case to handle, which is the case that there
170
isn't a cohomology group at all */
171
if (X[0][0]->cols <1){
172
Y = (matrix_TYP **)malloc(sizeof(matrix_TYP));
173
Y[0] = init_mat(G->gen_no * G->dim,1,"");
174
anzahl[0] = 1;
175
N[0] = NULL;
176
coho_size[0] = 1;
177
names[0] = (MP_INT *) malloc(sizeof(MP_INT));
178
mpz_init_set_si(names[0], 0);
179
}
180
else {
181
cohom_size = cohomology_size(X[0][1]);
182
coho_size[0] = mpz_get_ui(&cohom_size);
183
184
if (l_option){
185
list_of_names[0] = NULL;
186
}
187
else{
188
if (coho_size[0] < TWOTO21){
189
list_of_names[0] = (int *)calloc(coho_size[0], sizeof(int));
190
}
191
else{
192
fprintf(stderr, "The cohomology group is too big!\n");
193
fprintf(stderr, "If you are really interested in the graph of group - subgroup relations\n");
194
fprintf(stderr, "please start the program again with the option -l!\n");
195
exit(9);
196
}
197
}
198
199
Y = extensions_o(X[0][0],X[0][1],X[0][2],G,&len,names,anzahl,
200
WORDS, NUMBER_OF_WORDS, N, cohom_size, 0, list_of_names[0]);
201
free(len);
202
mpz_clear(&cohom_size);
203
}
204
205
for (i=0;i<relator_input->rows;i++) wordfree(relator+i);
206
free(relator);
207
208
if (INFO_LEVEL & 12){
209
pointer_statistics(0,0);
210
}
211
212
return(Y);
213
}
214
215
216
217
/* -------------------------------------------------------------------- */
218
/* transform a representative into the representation of */
219
/* C_d1 x ... x C_dn */
220
/* -------------------------------------------------------------------- */
221
/* coz: cocycle in question */
222
/* GLS: inverse of the third matrix returned by cohomology */
223
/* D: second matrix returned by cohomology */
224
/* -------------------------------------------------------------------- */
225
matrix_TYP *standard_rep(matrix_TYP *coz,
226
matrix_TYP *GLS,
227
matrix_TYP *D)
228
{
229
int i, j,
230
denominator,
231
first, last, diff;
232
233
matrix_TYP *tmp,
234
*rep;
235
236
237
for (first = 0; first < D->cols && D->array.SZ[first][first] == 1; first++);
238
for (last = first; last < D->cols && D->array.SZ[last][last] != 0; last++);
239
diff = last - first;
240
tmp = mat_mul(GLS, coz);
241
if (diff == 0)
242
rep = init_mat(0, 0, "");
243
else
244
rep = init_mat(diff, 1, "");
245
denominator = tmp->kgv;
246
247
for (i = 0; i < diff; i++){
248
j = tmp->array.SZ[i + first][0] * D->array.SZ[i + first][i + first];
249
if ((j % denominator) != 0){
250
fprintf(stderr,"ERROR in standard_rep: are you sure this is a cozycle?\n");
251
fprintf(stderr,"If so, please report to the authors: [email protected]\n");
252
exit(3);
253
}
254
else{
255
rep->array.SZ[i][0] = (j / denominator) % D->array.SZ[i + first][i + first];
256
while (rep->array.SZ[i][0] < 0)
257
rep->array.SZ[i][0] += D->array.SZ[i + first][i + first];
258
}
259
}
260
261
free_mat(tmp);
262
263
return(rep);
264
}
265
266
267
268
/* -------------------------------------------------------------------- */
269
/* returns 1, if m in list; returns 0 otherwise */
270
/* -------------------------------------------------------------------- */
271
int yet_there(matrix_TYP *m,
272
matrix_TYP **list,
273
int no)
274
{
275
int i;
276
277
for (i = 0; i < no; i++)
278
if (cmp_mat(m, list[i]) == 0)
279
return(1);
280
return(0);
281
}
282
283
284
285
/* -------------------------------------------------------------------- */
286
/* returns 1, if m = (0)_i,j, returns 0 otherwise */
287
/* -------------------------------------------------------------------- */
288
int equal_zero(matrix_TYP *m)
289
{
290
int i, j;
291
292
for (i = 0; i < m->rows; i++)
293
for (j = 0; j < m->cols; j++)
294
if (m->array.SZ[i][j] != 0)
295
return(0);
296
return(1);
297
}
298
299
300
/* -------------------------------------------------------------------- */
301
/* Generate list of matrices with the columns of M */
302
/* only the entries in M->array.SZ are copied */
303
/* -------------------------------------------------------------------- */
304
matrix_TYP **col_to_list(matrix_TYP *M)
305
{
306
matrix_TYP **list;
307
308
int i, j, rows, cols;
309
310
311
cols = M->cols;
312
rows = M->rows;
313
list = (matrix_TYP **)calloc(cols, sizeof(matrix_TYP *));
314
315
for (i = 0; i < cols; i++){
316
list[i] = init_mat(rows, 1, "");
317
for (j = 0; j < rows; j++){
318
list[i]->array.SZ[j][0] = M->array.SZ[j][i];
319
}
320
}
321
322
return(list);
323
}
324
325
326
327
/* -------------------------------------------------------------------- */
328
void free_H1_mod_ker_TYP(H1_mod_ker_TYP H1_mod_ker)
329
{
330
int i, j;
331
332
if (H1_mod_ker.flag == 0){
333
for (i = 0; i < H1_mod_ker.erz_no; i++){
334
free_mat(H1_mod_ker.M[i]);
335
}
336
free(H1_mod_ker.M);
337
free_mat(H1_mod_ker.D);
338
free_mat(H1_mod_ker.i);
339
}
340
}
341
342
343
344
/* -------------------------------------------------------------------- */
345
static void mod(int *a, int b)
346
{
347
a[0] = a[0] % b;
348
if (a[0]<0) a[0] += b;
349
}
350
351
352
353
/* -------------------------------------------------------------------- */
354
/* return the number of the affine class for the cocylce coz */
355
/* -------------------------------------------------------------------- */
356
/* data: Informationen ueber die Q-Klasse */
357
/* coz: Cozykel als Element von H^1 */
358
/* i: Nummer der Z-Klasse */
359
/* flag: true => gebe -(Nummer der aff. Klasse) zurueck, falls nicht */
360
/* Standardvertreter der affinen Klasse */
361
/* wortflag: speichere ein Wort fuer Normalisatorelement, welches */
362
/* coz zu Standardverterter konjugiert */
363
/* wort: speicher Wort hier */
364
/* -------------------------------------------------------------------- */
365
int number_of_affine_class(Q_data_TYP *data,
366
matrix_TYP *coz,
367
int i,
368
int flag,
369
boolean wortflag,
370
int **wort)
371
{
372
matrix_TYP *rep;
373
374
MP_INT nummer;
375
376
int anz, n, first, last, zahl, pos;
377
378
char *B;
379
380
381
382
mpz_init(&nummer);
383
for (first = 0; first < data->X[i][1]->cols && data->X[i][1]->array.SZ[first][first] == 1; first++);
384
for (last = first; last < data->X[i][1]->cols && data->X[i][1]->array.SZ[last][last] != 0; last++);
385
for (n = first; n < last; n++){
386
mod(coz->array.SZ[n - first], data->X[i][1]->array.SZ[n][n]);
387
}
388
389
390
if (data->l_option == TRUE || wortflag){
391
B = (char *)calloc(data->coho_size[i], sizeof(char));
392
rep = orbit_rep(coz, data->N[i], data->Z[i]->normal_no, data->X[i][1], 0,
393
B, &nummer, &anz, wort, wortflag, NULL, NULL);
394
395
pos = mpz_get_ui(&nummer);
396
for (n = 0; n < data->aff_no[i]; n++){
397
if (mpz_cmp(&nummer, &data->names[i][n]) == 0){
398
break;
399
}
400
}
401
if (n == data->aff_no[i]){
402
fprintf(stderr, "ERROR in number_of_affine_class!\n");
403
exit(6);
404
}
405
406
free_mat(rep);
407
free(B);
408
409
if (flag == 1){
410
valuation(coz, data->X[i][1], &nummer);
411
if (pos != mpz_get_ui(&nummer)){
412
mpz_clear(&nummer);
413
return(-n);
414
}
415
}
416
mpz_clear(&nummer);
417
}
418
else{
419
valuation(coz, data->X[i][1], &nummer);
420
pos = mpz_get_ui(&nummer);
421
zahl = data->list_of_names[i][pos];
422
mpz_clear(&nummer);
423
424
for (n = 0; n < data->aff_no[i]; n++){
425
if (zahl == data->names_int[i][n]){
426
break;
427
}
428
}
429
if (n == data->aff_no[i]){
430
fprintf(stderr, "ERROR in number_of_affine_class!\n");
431
exit(6);
432
}
433
if (flag == 1 && pos != zahl)
434
return(-n);
435
}
436
437
return(n);
438
}
439
440
441
442
/* -------------------------------------------------------------------- */
443
/* adds to all elements a row with "1" */
444
/* -------------------------------------------------------------------- */
445
void kernel_elements_2_affine(matrix_TYP **elem,
446
int coho_size)
447
{
448
int i, rows;
449
450
451
rows = elem[0]->rows;
452
453
for (i = 0; i < coho_size; i++){
454
if (elem[i] != NULL){
455
real_mat(elem[i], rows + 1, 1);
456
elem[i]->array.SZ[rows][0] = 1;
457
}
458
}
459
}
460
461
462
463
/* -------------------------------------------------------------------- */
464
/* append G->cen to G->normal and set G->cen = NULL */
465
/* -------------------------------------------------------------------- */
466
void cen_to_norm(bravais_TYP *G)
467
{
468
int i;
469
470
if (G->cen_no > 0){
471
G->normal = (matrix_TYP **)realloc(G->normal,
472
(G->cen_no + G->normal_no) * sizeof(matrix_TYP));
473
for (i = 0; i < G->cen_no; i++){
474
G->normal[G->normal_no + i] = G->cen[i];
475
}
476
free(G->cen);
477
G->cen = NULL;
478
G->normal_no += G->cen_no;
479
G->cen_no = 0;
480
}
481
}
482
483
484
485
486
487
488
489
490
491
492
493
494
495