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

563595 views
1
#include"typedef.h"
2
#include"idem.h"
3
#include"longtools.h"
4
#include"getput.h"
5
#include"voronoi.h"
6
#include"bravais.h"
7
#include"datei.h"
8
#include"matrix.h"
9
#include"orbit.h"
10
#include"tools.h"
11
12
extern int INFO_LEVEL;
13
/*****************************************************************************
14
@
15
@-----------------------------------------------------------------------------
16
@ FILE: symbol.c
17
@-----------------------------------------------------------------------------
18
@
19
*****************************************************************************/
20
21
/*****************************************************************************
22
@
23
@-----------------------------------------------------------------------------
24
@
25
@ static constituent *homogenous(bravais_TYP *G,matrix_TYP *F,int *anz)
26
@
27
@-----------------------------------------------------------------------------
28
@
29
*****************************************************************************/
30
static constituent *homogenous(bravais_TYP *G,matrix_TYP *F,int *anz)
31
{
32
int i,
33
j,
34
rang,
35
dimc,
36
dimcc;
37
38
matrix_TYP **idem,
39
**solution,
40
*colspace,
41
*tmp;
42
43
constituent *result;
44
45
/* calculate the central primitive idempotents */
46
idem = idempotente(G->gen,G->gen_no,F,anz,&dimc,&dimcc,FALSE);
47
48
/* now we know allmost everything, just calculate a bit */
49
result = (constituent *)malloc(anz[0] * sizeof(constituent));
50
51
if (anz[0] > 1){
52
for (i=0;i<anz[0];i++){
53
54
/* calculate the dimension of the module the constiuent is acting on,
55
and a basis of it */
56
colspace = tr_pose(idem[i]);
57
rang = tgauss(colspace);
58
result[i].group = init_bravais(rang);
59
real_mat(colspace,rang,colspace->cols);
60
tmp = tr_pose(colspace);
61
free_mat(colspace);
62
colspace = tmp;
63
tmp = NULL;
64
65
result[i].group->gen = (matrix_TYP **) malloc(G->gen_no *
66
sizeof(matrix_TYP *));
67
result[i].group->gen_no = G->gen_no;
68
69
/* transform the generators */
70
for (j=0;j<G->gen_no;j++){
71
tmp = mat_mul(G->gen[j],colspace);
72
solution = long_solve_mat(tmp,colspace);
73
74
if (solution[1] != NULL){
75
fprintf(stderr,"error in homogenous: there shoudn't be\n");
76
fprintf(stderr,"an homogenous solutio\n");
77
exit(3);
78
}
79
result[i].group->gen[j] = solution[0];
80
free(solution);
81
free_mat(tmp);
82
}
83
84
/* now deal with the rest (not implemented yet) */
85
result[i].centralizer = NULL;
86
result[i].dimc=0;
87
result[i].ccentralizer = NULL;
88
result[i].dimcc=0;
89
90
/* and calculate the formspace */
91
result[i].group->form = formspace(result[i].group->gen,
92
result[i].group->gen_no,1,&result[i].group->form_no);
93
94
free_mat(colspace);
95
}
96
97
/* clean up the result returned by idem */
98
for (i=0;i<anz[0]+dimc+dimcc;i++) free_mat(idem[i]);
99
}
100
else{
101
/* just copy the result */
102
result[0].group = copy_bravais(G);
103
104
result[0].dimc = dimc;
105
result[0].dimcc = dimcc;
106
result[0].centralizer = (matrix_TYP **) malloc(dimc
107
* sizeof(matrix_TYP*));
108
result[0].ccentralizer = (matrix_TYP **) malloc(dimcc
109
* sizeof(matrix_TYP*));
110
for (i=0;i<dimc;i++)
111
result[0].centralizer[i] = idem[i+1];
112
for (i=0;i<dimcc;i++)
113
result[0].ccentralizer[i] = idem[i+1+dimc];
114
115
/* we promised the user that there will be a formspace */
116
if (G->form_no ==0)
117
result[0].group->form = formspace(result[0].group->gen,
118
result[0].group->gen_no,1,&result[0].group->form_no);
119
120
free_mat(idem[0]);
121
}
122
123
free(idem);
124
125
return result;
126
127
}
128
129
/*****************************************************************************
130
@
131
@-----------------------------------------------------------------------------
132
@
133
@ static char *identify_hom(bravais_TYP *G,int clear)
134
@
135
@-----------------------------------------------------------------------------
136
@
137
*****************************************************************************/
138
static char *identify_hom(bravais_TYP *G,int clear)
139
{
140
int i,
141
found=0,
142
flag,
143
multiplicity,
144
*list;
145
146
static int atom_no;
147
148
FILE *atom_file;
149
150
char *result,
151
tmp[20],
152
*pp,
153
bravais_file[1000];
154
155
static symbol_out *Atoms;
156
157
/* this program does only work for groups up to dimension 6
158
(it may even give wrong results otherwise), so tell the user */
159
if (G->dim > 6){
160
fprintf(stderr,"Error (in identify_hom), this program does only work\n");
161
fprintf(stderr,"in dimension up to 6.\n");
162
exit(3);
163
}
164
165
if (atom_no == 0){
166
/* read the file with all atoms */
167
sprintf(bravais_file,"%s%s",TOPDIR,"/tables/symbol/atom_list");
168
atom_file = fopen(bravais_file,"r");
169
170
if (atom_file == NULL){
171
fprintf(stderr,"I didn't find my library file. exiting.\n");
172
exit(4);
173
}
174
175
fscanf(atom_file,"%d\n",&atom_no);
176
177
/* now read the symbols */
178
Atoms = (symbol_out *) malloc(atom_no * sizeof(symbol_out));
179
for (i=0;i<atom_no;i++){
180
Atoms[i].fn = (char *) calloc(20,sizeof(char));
181
fscanf(atom_file,"%s\n",Atoms[i].fn);
182
}
183
fclose(atom_file);
184
185
/* and their respective groups */
186
for (i=0;i<atom_no;i++){
187
sprintf(bravais_file,"%s/tables/symbol/%s",TOPDIR,Atoms[i].fn);
188
Atoms[i].grp = get_bravais(bravais_file);
189
long_rein_formspace(G->form,G->form_no,1);
190
}
191
192
if (INFO_LEVEL & 4){
193
for (i=0;i<atom_no;i++){
194
printf("%s\n",Atoms[i].fn);
195
put_bravais(Atoms[i].grp,NULL,NULL);
196
}
197
}
198
}
199
200
if (G->order == 0){
201
fprintf(stderr,"this feature hasn't been implemented yet,\n");
202
fprintf(stderr,"must specify a group order in identify_hom\n");
203
exit(3);
204
}
205
206
list = (int *) malloc(atom_no * sizeof(int));
207
208
/* check up the cheap stuff, ie. order, dimension ... */
209
/* bare in mind that this is sufficient up to dimension 6 */
210
for (i=0;i<atom_no;i++){
211
flag = (Atoms[i].grp->order == G->order);
212
flag = flag && ((G->dim % Atoms[i].grp->dim)==0);
213
if (flag){
214
list[found] = i;
215
found++;
216
}
217
}
218
219
/* just look whether these bravais groups really do give
220
different families, or they look like (ie look for a,b,c's..)*/
221
if (found > 1){
222
/* to be implemented, it doesn't matter for dimensions up to 6 */
223
}
224
225
/* now list contains a list of representatives which are possible.
226
now rule out the rest */
227
if (found == 1){
228
multiplicity = G->dim / Atoms[list[0]].grp->dim;
229
}
230
else{
231
fprintf(stderr,"this feature hasn't been implemeneted yet\n");
232
fprintf(stdout,"please report this to [email protected]\n");
233
fprintf(stdout,"together with the output:\n");
234
put_bravais(G,NULL,"ERROR IN: identify_hom");
235
exit(3);
236
}
237
238
/* now we know the Q-Class of this homogenous module */
239
result = (char *) malloc(20*multiplicity*sizeof(char));
240
/* bare in mind to remove a,b,c and stuff from the end of the type */
241
pp = strchr(Atoms[list[0]].fn,'a');
242
if (pp == NULL) pp = strchr(Atoms[list[0]].fn,'b');
243
if (pp == NULL) pp = strchr(Atoms[list[0]].fn,'c');
244
if (pp == NULL) pp = strchr(Atoms[list[0]].fn,'d');
245
if (pp == NULL) pp = strchr(Atoms[list[0]].fn,'e');
246
if (pp == NULL) pp = strchr(Atoms[list[0]].fn,'f');
247
if (pp == NULL) pp = strchr(Atoms[list[0]].fn,'g');
248
if (pp == NULL){
249
sprintf(result,"%s",Atoms[list[0]].fn);
250
}
251
else{
252
strncpy(result,Atoms[list[0]].fn,pp - Atoms[list[0]].fn);
253
result[pp-Atoms[list[0]].fn] = 0;
254
}
255
sprintf(tmp,"%s",result);
256
for (i=1;i<multiplicity;i++){
257
sprintf(result,"%s,%s",result,tmp);
258
}
259
260
/* if we got the order, clean up the static allocated memory */
261
if (clear){
262
for (i=0;i<atom_no;i++){
263
free_bravais(Atoms[i].grp);
264
free(Atoms[i].fn);
265
}
266
free(Atoms);
267
atom_no = 0;
268
Atoms = NULL;
269
}
270
271
free(list);
272
273
return result;
274
}
275
276
static void bubblesort(char **S,int n)
277
{
278
int i=1;
279
280
char *tmp;
281
282
while (i<n){
283
if (strcmp(S[i-1],S[i])<0){
284
tmp = S[i-1];
285
S[i-1] = S[i];
286
S[i] = tmp;
287
bubblesort(S,n);
288
}
289
i++;
290
}
291
292
return;
293
}
294
295
/*****************************************************************************
296
@
297
@-----------------------------------------------------------------------------
298
@
299
@ char *symbol(bravais_TYP *G,matrix_TYP *F)
300
@
301
@ bravais_TYP *G: the group in question
302
@ matrix_TYP *F : a positive definite G-invariant form
303
@
304
@ Calculates the symbol of the FINITE INTEGRAL group in G.
305
@ F is assumed to be a positive definite G-invariant form.
306
@ The information needed from G are the records G->gen & G->gen_no,
307
@ and G->form & G->form_no.
308
@
309
@ Sideefects: The matrices in G->gen and G->form might be checked via
310
@ Check_mat
311
@-----------------------------------------------------------------------------
312
@
313
*****************************************************************************/
314
char *symbol(bravais_TYP *G,matrix_TYP *F)
315
{
316
int i,
317
j,
318
len=0,
319
hom_no; /* the number of homogenous constituents of this repr */
320
321
constituent *hom;
322
323
bravais_TYP *brav; /* holds the bravais group of a homogenous
324
representation */
325
326
char *result,
327
**symb;
328
329
/* firstly split the representation into homogenous parts */
330
hom = homogenous(G,F,&hom_no);
331
332
if (INFO_LEVEL & 4){
333
for (i=0;i<hom_no;i++){
334
put_bravais(hom[i].group,NULL,NULL);
335
}
336
}
337
338
symb = (char **) calloc(hom_no , sizeof(char *));
339
/* calculate the bravais group for each homogenous module,
340
and search it in the list */
341
for (i=0;i<hom_no;i++){
342
brav = bravais_group(hom[i].group,FALSE);
343
symb[i] = identify_hom(brav,i==(hom_no-1));
344
free_bravais(brav);
345
len += strlen(symb[i]);
346
}
347
348
/* swap the symbols in the right order */
349
bubblesort(symb,hom_no);
350
351
result = (char *) calloc((len + hom_no + 10),sizeof(char));
352
sprintf(result,"%s",symb[0]);
353
for (i=1;i<hom_no;i++){
354
sprintf(result,"%s;%s",result,symb[i]);
355
}
356
357
for (i=0;i<hom_no;i++){
358
free(symb[i]);
359
free_bravais(hom[i].group);
360
for (j=0;j<hom[i].dimc;j++)
361
free_mat(hom[i].centralizer[j]);
362
for (j=0;j<hom[i].dimcc;j++)
363
free_mat(hom[i].ccentralizer[j]);
364
365
if (hom[i].centralizer != NULL){
366
free(hom[i].centralizer);
367
hom[i].centralizer = NULL;
368
}
369
if (hom[i].ccentralizer != NULL){
370
free(hom[i].ccentralizer);
371
hom[i].ccentralizer = NULL;
372
}
373
374
}
375
free(symb);
376
free(hom);
377
378
return result;
379
380
}
381
382
383