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 "ZZ.h"
2
#include "typedef.h"
3
#include "getput.h"
4
#include "name.h"
5
#include "bravais.h"
6
#include "datei.h"
7
#include "matrix.h"
8
#include "voronoi.h"
9
#include "autgrp.h"
10
#include "symm.h"
11
#include "base.h"
12
#include "zass.h"
13
#include "gmp.h"
14
#include "longtools.h"
15
16
#define DATABASE_NAME TOPDIR "/tables/qcatalog/data"
17
18
19
20
bravais_TYP *get_qclass_by_name(char *name,
21
matrix_TYP **PRES,
22
int dim)
23
{
24
25
int found = FALSE,
26
i;
27
28
database *database;
29
30
char filename[1024];
31
32
bravais_TYP *G;
33
34
while (!found){
35
database = load_database (DATABASE_NAME,dim);
36
37
i = 0;
38
while (!found && i<database->nr ){
39
found = (strcmp(database->entry[i].abbreviation,name) == 0);
40
i++;
41
}
42
43
if (found){
44
i--;
45
46
sprintf(filename,"%s/tables/qcatalog/dim%d/dir.%s/ordnung.%d/%s/%s",
47
TOPDIR,dim,database->entry[i].symbol,
48
database->entry[i].order,
49
database->entry[i].discriminant,name);
50
G = get_bravais(filename);
51
52
sprintf(filename,"%s/tables/qcatalog/dim%d/dir.%s/ordnung.%d/%s/pres.%s",
53
TOPDIR,dim,database->entry[i].symbol,
54
database->entry[i].order,
55
database->entry[i].discriminant,name);
56
*PRES = get_mat(filename);
57
}
58
else if (dim == 6){
59
fprintf(stderr,"group with this name not in the catalog of Q-classes\n");
60
fprintf(stderr,"name was %s\n",name);
61
exit(4);
62
}
63
64
free_database (database);
65
dim++;
66
}
67
68
return G;
69
70
}
71
72
bravais_TYP *get_zclass_by_name(bravais_TYP *G,
73
int *first,
74
int *second,
75
int ignore)
76
{
77
78
bravais_TYP **QCLASS,
79
*H,
80
*RES,
81
**TMP;
82
83
int number,
84
i;
85
86
87
/* calculate the space of invariant forms of G, we'll need it */
88
if (G->form_no == 0)
89
G->form = formspace(G->gen,G->gen_no,1,&G->form_no);
90
91
QCLASS = q2z(G,&number,TRUE,NULL,TRUE);
92
93
94
if (number < *first){
95
if (ignore){
96
*first = number;
97
}
98
else{
99
fprintf(stderr,"there is no zclass with this number this Q-class\n");
100
exit(4);
101
}
102
}
103
104
for (i=0;i<number;i++){
105
if (i+1 != *first){
106
free_bravais(QCLASS[i]);
107
QCLASS[i] = NULL;
108
}
109
}
110
111
H = QCLASS[*first - 1];
112
free(QCLASS);
113
114
if (H->zentr_no < *second){
115
if (ignore){
116
*second = H->zentr_no;
117
}
118
else{
119
fprintf(stderr,"there is no zclass with this number this Q-class\n");
120
exit(4);
121
}
122
}
123
124
for (i=0;i<H->zentr_no;i++){
125
if (i+1 != *second){
126
free_mat(H->zentr[i]);
127
H->zentr[i] = NULL;
128
}
129
}
130
131
TMP = get_groups(&H,1,&i);
132
RES = TMP[*second - 1];
133
134
free_bravais(H);
135
free(TMP);
136
137
if (RES == NULL){
138
fprintf(stderr,"error in get_zclass_by_name\n");
139
exit(4);
140
}
141
142
return RES;
143
144
}
145
146
147
bravais_TYP *split_extension(bravais_TYP *G)
148
{
149
150
int i;
151
152
bravais_TYP *R;
153
154
R = init_bravais(G->dim+1);
155
R->gen = (matrix_TYP **) malloc(G->gen_no * sizeof(matrix_TYP *));
156
for (i=0;i<G->gen_no;i++){
157
R->gen[i] = copy_mat(G->gen[i]);
158
extend(R->gen[i]);
159
}
160
R->gen_no = G->gen_no;
161
162
return R;
163
164
}
165
166
bravais_TYP *get_affine_class_by_name(bravais_TYP *G,
167
matrix_TYP *PRES,
168
MP_INT *aff_name,
169
int check)
170
{
171
172
bravais_TYP *R;
173
174
matrix_TYP **COH,
175
*coz_mat,
176
**matinv,
177
**Y;
178
179
word *relator;
180
181
MP_INT standart_name,
182
coho_size;
183
184
int i,
185
j,
186
den;
187
188
long dim;
189
190
191
if (mpz_cmp_si(aff_name,0) == 0){
192
/* handle the split extension case seperately */
193
return split_extension(G);
194
}
195
196
/* do the cohomology calculations */
197
relator = (word *) calloc(PRES->rows,sizeof(word));
198
for (i=0;i<PRES->rows;i++){
199
matrix_2_word(PRES,relator+i,i);
200
}
201
202
203
matinv = (matrix_TYP **) calloc(G->gen_no , sizeof(matrix_TYP *));
204
COH = cohomology(&dim,G->gen,matinv,relator,G->gen_no,PRES->rows);
205
206
if (dim > 0){
207
fprintf(stderr,"error in get_affine_class_by_name\n");
208
exit(4);
209
}
210
211
if (COH[0]->cols > 0){
212
213
mpz_init(&coho_size);
214
mpz_set_si(&coho_size,1);
215
for (i=0;i<COH[1]->rows;i++)
216
if (COH[1]->array.SZ[i][i]){
217
mpz_mul_ui(&coho_size,&coho_size,
218
(unsigned long)COH[1]->array.SZ[i][i]);
219
}
220
221
mpz_init(&standart_name);
222
mpz_mod(&standart_name,aff_name,&coho_size);
223
224
coz_mat = reverse_valuation(&standart_name,COH[1]);
225
226
R = space_group_from_matrix(G,coz_mat,COH[0],COH[1]);
227
228
if (check == 1 || check == 3){
229
/* test whether the name we have got so far is the
230
name CARAT would give */
231
den = 1;
232
for (i=0;i<G->gen_no;i++)
233
den = KGV(R->gen[i]->kgv,den);
234
free_mat(coz_mat);
235
coz_mat = init_mat(G->dim*G->gen_no,1,"i");
236
for (i=0;i<G->gen_no;i++)
237
for (j=0;j<G->dim;j++)
238
coz_mat->array.SZ[j + G->dim * i][0] = den / R->gen[i]->kgv *
239
R->gen[i]->array.SZ[j][G->dim];
240
coz_mat->kgv = den;
241
242
Y = identify(COH[0],COH[1],COH[2],G,&coz_mat,&standart_name,1,
243
TRUE,NULL,NULL);
244
245
/* now standart_name will contain the name CARAT would assign
246
to this group. check ist now */
247
if (mpz_cmp(&standart_name,aff_name) != 0){
248
if (check == 3){
249
mpz_set(aff_name,&standart_name);
250
}
251
else{
252
fprintf(stderr,"the given name is not CARAT`s name\n");
253
exit(4);
254
}
255
}
256
257
free_mat(Y[0]); free(Y);
258
}
259
260
free_mat(coz_mat);
261
mpz_clear(&standart_name);
262
mpz_clear(&coho_size);
263
}
264
else{
265
/* things are easy here, there is only the split extension */
266
R = split_extension(G);
267
268
if (check == 1 && mpz_cmp_si(aff_name,0) != 0){
269
fprintf(stderr,"wrong name for the space group\n");
270
exit(4);
271
}
272
else{
273
mpz_set_si(aff_name,0);
274
}
275
276
}
277
278
for (i=0;i<G->gen_no;i++){
279
if (matinv[i] != NULL)
280
free_mat(matinv[i]);
281
}
282
free(matinv);
283
for (i=0;i<3;i++) free_mat(COH[i]); free(COH);
284
for (i=0;i<PRES->rows;i++) wordfree(relator+i);
285
free(relator);
286
287
288
return R;
289
}
290
291
292
bravais_TYP *reverse_name(char qname[1024],
293
int zname[2],
294
MP_INT aff_name,
295
int i,
296
boolean iflag,
297
char **affstring)
298
{
299
bravais_TYP *R,
300
*DATAQ,
301
*DATAZ;
302
303
matrix_TYP *PRES;
304
305
306
307
DATAQ = get_qclass_by_name(qname, &PRES, 1);
308
DATAZ = get_zclass_by_name(DATAQ, zname, zname+1, iflag);
309
R = get_affine_class_by_name(DATAZ, PRES, &aff_name, i);
310
311
affstring[0] = (char * ) malloc( mpz_sizeinbase( &aff_name , 10) + 2 );
312
mpz_get_str (affstring[0] , 10, &aff_name);
313
314
315
free_mat(PRES);
316
free_bravais(DATAZ);
317
free_bravais(DATAQ);
318
319
cleanup_prime();
320
mpz_clear(&aff_name);
321
322
return(R);
323
}
324
325
326
327
328