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

563667 views
1
#include "typedef.h"
2
#include "matrix.h"
3
#include"getput.h"
4
#include"datei.h"
5
#include"longtools.h"
6
/**************************************************************************\
7
@---------------------------------------------------------------------------
8
@---------------------------------------------------------------------------
9
@ FILE: gittstab.c
10
@---------------------------------------------------------------------------
11
@---------------------------------------------------------------------------
12
@
13
\**************************************************************************/
14
15
static int is_in(M, B)
16
matrix_TYP *M;
17
bravais_TYP *B;
18
{
19
int i,j,k;
20
matrix_TYP *mtr;
21
matrix_TYP *F, *A;
22
int erg;
23
erg = TRUE;
24
25
mtr = init_mat(M->cols, M->rows, "");
26
for(i=0; i<M->cols; i++)
27
for(j=0; j<M->rows; j++)
28
mtr->array.SZ[i][j] = M->array.SZ[j][i];
29
30
for(i=0; i<B->form_no && erg == TRUE; i++)
31
{
32
A = mat_mul(mtr, B->form[i]);
33
F = mat_mul(A, M);
34
free_mat(A);
35
for(j=0; j<F->rows && erg == TRUE; j++)
36
for(k=0; k<F->cols && erg == TRUE; k++)
37
if(F->array.SZ[j][k] != B->form[i]->array.SZ[j][k])
38
erg = FALSE;
39
free_mat(F);
40
}
41
free_mat(mtr);
42
return(erg);
43
}
44
45
46
47
/*--------------------------------------------------------------------*\
48
| test if a matrix Y is already contained in a list of matices |
49
| with length 'anz'. |
50
| If Y is not contained in the list, the result is -1, else |
51
| the result is the position where Y was found. |
52
\*--------------------------------------------------------------------*/
53
static int such(Y, linv, anz)
54
matrix_TYP *Y;
55
matrix_TYP **linv;
56
int anz;
57
{
58
int schonda, i;
59
matrix_TYP *G;
60
61
schonda = -1;
62
for(i=0; i<anz && schonda == -1; i++)
63
{
64
G = mat_mul(linv[i], Y);
65
Check_mat(G);
66
if(G->kgv == 1)
67
schonda = i;
68
free_mat(G);
69
}
70
return schonda;
71
}
72
73
/*--------------------------------------------------------------------*\
74
| if A is not the identity-matrix and A is not contained in the |
75
| geneator-matrices of stab the result is TRUE, else FALSE |
76
\*--------------------------------------------------------------------*/
77
static int mat_such(stab, A)
78
bravais_TYP *stab;
79
int **A;
80
{
81
int i,j,k, neu;
82
i=0; j=0; neu = 0;
83
while(i<stab->dim && neu == 0)
84
{
85
j=0;
86
while(j<stab->dim && neu == 0)
87
{
88
if(i==j && A[i][j] != 1)
89
neu = 1;
90
if(i != j && A[i][j] != 0)
91
neu = 1;
92
j++;
93
}
94
i++;
95
}
96
if(neu == 0)
97
return(neu);
98
99
if(stab->gen_no == 0)
100
return(1);
101
neu = 1;
102
i=0;
103
do
104
{
105
j=0; k = stab->dim;
106
while(j<stab->dim && k == stab->dim)
107
{
108
k=0;
109
while(k<stab->dim && A[j][k] == stab->gen[i]->array.SZ[j][k])
110
k++;
111
j++;
112
}
113
if(j == stab->dim && k == stab->dim)
114
neu =0;
115
i++;
116
}while (neu == 1 && i<stab->gen_no);
117
return(neu);
118
}
119
120
121
122
/**************************************************************************\
123
@---------------------------------------------------------------------------
124
@ bravais_TYP *Z_class(B, zen)
125
@ bravais_TYP *B;
126
@ matrix_TYP *zen;
127
@
128
@---------------------------------------------------------------------------
129
@
130
@ calculates the intersection of zen^(-1)*B*zen with GL_n(Z) |
131
\**************************************************************************/
132
bravais_TYP *Z_class(B, zen)
133
bravais_TYP *B;
134
matrix_TYP *zen;
135
{
136
int i,
137
j;
138
bravais_TYP *S;
139
bravais_TYP *C;
140
bravais_TYP *N;
141
bravais_TYP *CS;
142
bravais_TYP *NS;
143
matrix_TYP *A1, *A2;
144
matrix_TYP *zinv,
145
*ztr;
146
int *count;
147
int anz;
148
int *noetig = NULL;
149
150
extern matrix_TYP *einheitsmatrix();
151
152
S = gittstabneu(B, zen);
153
154
/* deleted this output 25/4/97 tilman
155
put_bravais(S, NULL, "Stabilisator noch nicht konjugiert"); */
156
157
zinv = mat_inv(zen);
158
for(i=0; i<S->gen_no; i++)
159
{
160
A1 = mat_mul(zinv, S->gen[i]);
161
A2 = mat_mul(A1, zen);
162
free_mat(A1); free_mat(S->gen[i]);
163
Check_mat(A2);
164
S->gen[i] = A2;
165
}
166
C = (bravais_TYP *)calloc(1, sizeof(bravais_TYP) );
167
C->gen_no = B->cen_no;
168
C->dim = B->dim;
169
C->gen = (matrix_TYP **) malloc(C->gen_no *sizeof(matrix_TYP *));
170
for(i=0; i<C->gen_no; i++)
171
C->gen[i] = B->cen[i];
172
if(C->gen_no > 0)
173
CS = gittstabneu(C, zen);
174
S->form = (matrix_TYP **) malloc(B->form_no *sizeof(matrix_TYP));
175
S->form_no = B->form_no;
176
ztr = init_mat(zen->cols, zen->rows, "");
177
for(i=0; i<zen->rows; i++)
178
for(j=0; j<zen->cols; j++)
179
ztr->array.SZ[j][i] = zen->array.SZ[i][j];
180
for(i=0; i<B->form_no; i++)
181
{
182
A1 = mat_mul(ztr, B->form[i]);
183
S->form[i] = mat_mul(A1, zen);
184
Check_mat(S->form[i]);
185
S->form[i]->kgv = 1;
186
S->form[i]->flags.Integral = TRUE;
187
free_mat(A1);
188
}
189
190
/* inserted 05/05/97 tilman: do an rein on the formspace of S
191
to give a Z-basis */
192
long_rein_formspace(S->form,S->form_no,1);
193
194
if(C->gen_no > 0)
195
{
196
S->cen_no = CS->gen_no;
197
S->cen = (matrix_TYP **) malloc(S->cen_no *sizeof(matrix_TYP));
198
for(i=0; i<CS->gen_no; i++)
199
{
200
A1 = mat_mul(zinv, CS->gen[i]);
201
A2 = mat_mul(A1, zen);
202
free_mat(A1);
203
Check_mat(A2);
204
S->cen[i] = A2;
205
}
206
}
207
if(B->normal_no == 1)
208
Check_mat(B->normal[0]);
209
if(B->normal_no > 1 || (B->normal_no == 1 && B->normal[0]->flags.Scalar == FALSE))
210
{
211
N = (bravais_TYP *)calloc(1, sizeof(bravais_TYP));
212
N->gen_no = B->normal_no + B->gen_no + B->cen_no;
213
N->dim = B->dim;
214
N->gen = (matrix_TYP **) malloc(N->gen_no *sizeof(matrix_TYP *));
215
for(i=0; i<B->gen_no ; i++)
216
N->gen[i] = B->gen[i];
217
for(i=0; i<B->normal_no; i++)
218
N->gen[i+B->gen_no] = B->normal[i];
219
for(i=0; i<B->cen_no; i++)
220
N->gen[i+B->gen_no+B->normal_no] = B->cen[i];
221
NS = gittstabneu(N, zen);
222
noetig = (int *) malloc(NS->gen_no *sizeof(int));
223
for(i=0; i<NS->gen_no; i++)
224
{
225
noetig[i] = TRUE;
226
if(is_in(NS->gen[i], B) == TRUE)
227
noetig[i] = FALSE;
228
if(noetig[i] == TRUE)
229
{
230
A1 = mat_inv(NS->gen[i]);
231
for(j=0; j<i && noetig[i] == TRUE; j++)
232
{
233
A2 = mat_mul(A1, NS->gen[j]);
234
if(is_in(A2, B) == TRUE)
235
noetig[i] = FALSE;
236
free_mat(A2);
237
}
238
free_mat(A1);
239
}
240
}
241
anz = 0;
242
for(i=0; i<NS->gen_no; i++)
243
if(noetig[i] == TRUE)
244
anz++;
245
if(anz == 0)
246
anz = 1;
247
S->normal_no = anz;
248
S->normal = (matrix_TYP **) malloc(S->normal_no *sizeof(matrix_TYP));
249
250
/* we don't used count at all (as far as I see) : tilman 7/5/97
251
count = (int *) malloc(NS->gen_no *sizeof(int)); */
252
253
anz = 0;
254
for(i=0; i<NS->gen_no; i++)
255
{
256
if(noetig[i] == TRUE)
257
{
258
A1 = mat_mul(zinv, NS->gen[i]);
259
A2 = mat_mul(A1, zen);
260
free_mat(A1);
261
Check_mat(A2);
262
S->normal[anz] = A2;
263
anz++;
264
}
265
}
266
free_bravais(NS);
267
free(N->gen);
268
free(N);
269
if(anz == 0)
270
S->normal[0] = einheitsmatrix(B->dim);
271
}
272
if(B->normal_no == 1 && B->normal[0]->flags.Scalar == TRUE)
273
{
274
S->normal_no = 1;
275
S->normal = (matrix_TYP **) malloc(S->normal_no *sizeof(matrix_TYP));
276
S->normal[0] = einheitsmatrix(B->dim);
277
}
278
if(C->gen_no > 0)
279
free_bravais(CS);
280
free(C->gen);
281
free(C);
282
free_mat(zinv); free_mat(ztr);
283
284
/* inserted 7/6/97 tilman */
285
if (noetig != NULL) free(noetig);
286
287
return(S);
288
}
289
290
291
292
293
294
/**************************************************************************\
295
@---------------------------------------------------------------------------
296
@ bravais_TYP *gittstab(grp, X)
297
@ bravais_TYP *grp;
298
@ matrix_TYP *X;
299
@
300
@ gittstab calculates the stabilizer of a lattice X under the |
301
@ operation of the group 'grp' acting via left-multiplication |
302
@---------------------------------------------------------------------------
303
@
304
\**************************************************************************/
305
bravais_TYP *gittstab(grp, X)
306
bravais_TYP *grp;
307
matrix_TYP *X;
308
{
309
int i, j, k;
310
matrix_TYP **list;
311
matrix_TYP **list_inv;
312
matrix_TYP **history;
313
matrix_TYP *Y, *Yinv;
314
matrix_TYP *Z;
315
matrix_TYP *G, *Hinv;
316
bravais_TYP *stab;
317
int *index;
318
int num, erz, schonda, norm = 0;
319
int neu, anz = 0;
320
int suchanfang;
321
322
extern void store_mat();
323
extern matrix_TYP *mat_mul();
324
extern matrix_TYP *mat_inv();
325
extern matrix_TYP *init_mat();
326
extern int such();
327
extern int *factorize();
328
extern void positivieren();
329
330
if(grp->dim != X->rows)
331
{
332
printf("Matrixgruppe und Vektorraum haben unterschiedliche Dimension\n");
333
exit(3);
334
}
335
if(X->cols != X->rows)
336
{
337
printf("Teilgitter hat nicht vollen Rang\n");
338
exit(3);
339
}
340
list = (matrix_TYP **) malloc(1 *sizeof(matrix_TYP *));
341
list_inv = (matrix_TYP **) malloc(1 *sizeof(matrix_TYP *));
342
history = (matrix_TYP **) malloc(1 *sizeof(matrix_TYP *));
343
stab = (bravais_TYP *) calloc(1, sizeof(bravais_TYP) );
344
stab->dim = grp->dim;
345
stab->gen_no = 0;
346
stab->form_no = 0;
347
stab->zentr_no = 0;
348
stab->normal_no = 0;
349
stab->order = 0;
350
Z = init_mat(X->rows, X->rows, "");
351
for(i=0; i<X->rows; i++)
352
Z->array.SZ[i][i] = 1;
353
354
Y = init_mat(X->rows, X->rows, "");
355
for(i=0; i<X->rows; i++)
356
for(j=0; j<X->cols; j++)
357
Y->array.SZ[i][j] = X->array.SZ[i][j];
358
Yinv = mat_inv(Y);
359
list[anz] = Y; /* init the orbit of X under 'grp' */
360
list_inv[anz] = Yinv;
361
history[anz] = Z; /* history[n] * list[0] = list[n] */
362
anz++;
363
num = 0;
364
erz = 0;
365
/*--------------------------------------------------------------------*\
366
| algorithmen to calculate the orbit of X |
367
\*--------------------------------------------------------------------*/
368
do
369
{
370
Y = mat_mul(grp->gen[erz], list[num]);
371
Z = mat_mul(grp->gen[erz], history[num]);
372
schonda = such(Y, list_inv, anz);
373
/*------------------------------------------------------------*\
374
| if new lattice in the orbit |
375
\*------------------------------------------------------------*/
376
if (schonda == -1)
377
{
378
list = (matrix_TYP **) realloc(list, (anz+1) *sizeof(matrix_TYP *));
379
list_inv = (matrix_TYP **) realloc(list_inv, (anz+1) *sizeof(matrix_TYP *));
380
history = (matrix_TYP **) realloc(history, (anz+1) *sizeof(matrix_TYP *));
381
Yinv = mat_inv(Y);
382
list[anz] = Y;
383
list_inv[anz] = Yinv;
384
history[anz] = Z;
385
anz++;
386
}
387
/*------------------------------------------------------------*\
388
| if lattice already found, calculate stabilizer-element |
389
\*------------------------------------------------------------*/
390
else
391
{
392
Hinv = mat_inv(history[schonda]);
393
G = mat_mul(Hinv, Z);
394
neu = mat_such(stab, G->array.SZ);
395
if(neu == 1)
396
{
397
if(stab->gen_no != 0)
398
stab->gen = (matrix_TYP **) realloc(stab->gen, (stab->gen_no+1) *sizeof(matrix_TYP *));
399
if(stab->gen_no == 0)
400
stab->gen = (matrix_TYP **) malloc(1 *sizeof(matrix_TYP *));
401
stab->gen[stab->gen_no] = G;
402
stab->gen_no++;
403
}
404
else
405
free_mat(G);
406
free_mat(Hinv); free_mat(Z); free_mat(Y);
407
}
408
if (num == anz-1 && erz == grp->gen_no-1)
409
break;
410
if (erz < grp->gen_no-1)
411
++erz;
412
else
413
{erz = 0;
414
++num;}
415
}while (1);
416
/**************
417
for(i=0; i<anz; i++)
418
put_mat(list_inv[i], NULL, "list_inv" , 2);
419
*****************/
420
/*--------------------------------------------------------------------*\
421
| calculation of the order of the stabilizer |
422
\*--------------------------------------------------------------------*/
423
index = factorize(anz);
424
for(i=1; i<100; i++)
425
stab->divisors[i] = grp->divisors[i] - index[i];
426
if(grp->divisors[0] != 0 || index[0] != 0)
427
{
428
stab->divisors[0] = 1;
429
stab->order = 0;
430
}
431
else
432
{
433
stab->order = 1;
434
for(i=2; i<100; i++)
435
for(j=0; j<stab->divisors[i]; j++)
436
stab->order *= i;
437
}
438
for(i=0; i<anz; i++)
439
{
440
free_mat(list[i]);
441
free_mat(list_inv[i]);
442
free_mat(history[i]);
443
}
444
free(list);
445
free(list_inv);
446
free(history);
447
free(index);
448
return(stab);
449
}
450
451