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

563641 views
1
#include <typedef.h>
2
#include <bravais.h>
3
#include <name.h>
4
#include <tsubgroups.h>
5
#include "tools.h"
6
#include "matrix.h"
7
#include "getput.h"
8
#include <string.h>
9
10
11
12
/* -------------------------------------------------------- */
13
/* Free TSubgroup_TYP and pointer to this! */
14
/* -------------------------------------------------------- */
15
void free_TSubgroup_TYP(TSubgroup_TYP *sbg)
16
{
17
if (sbg){
18
if (sbg->R)
19
free_bravais(sbg->R);
20
if (sbg->P)
21
free_bravais(sbg->P);
22
free(sbg);
23
}
24
}
25
26
27
28
/* -------------------------------------------------------- */
29
/* Free CARATname_TYP! */
30
/* -------------------------------------------------------- */
31
void free_CARATname_TYP(CARATname_TYP Name)
32
{
33
if (&Name.aff_name)
34
mpz_clear(&Name.aff_name);
35
if (Name.trafo)
36
free_mat(Name.trafo);
37
}
38
39
40
41
42
/* -------------------------------------------------------- */
43
/* Free TSUB_TYP! */
44
/* -------------------------------------------------------- */
45
void free_TSUB_TYP(TSUB_TYP TSUB)
46
{
47
int i;
48
49
for (i = 0; i < TSUB.word_no; i++){
50
if (TSUB.words[i])
51
free_mat(TSUB.words[i]);
52
}
53
}
54
55
56
/* -------------------------------------------------------- */
57
/* Get standardrepresentative of an affine class */
58
/* (compare with reverse_name_fct.c) */
59
/* -------------------------------------------------------- */
60
/* pfad: Pfad, wo Q-Klassen-Vertreter ist */
61
/* Name: CARAT-Name */
62
/* -------------------------------------------------------- */
63
bravais_TYP *get_std_rep(char *pfad,
64
CARATname_TYP Name)
65
{
66
bravais_TYP *R;
67
68
char filename[1024];
69
70
bravais_TYP *DATAZ, *DATAQ;
71
72
matrix_TYP *PRES;
73
74
75
/* calculate standard representative */
76
sprintf(filename, "%s/%s", pfad, Name.qname);
77
DATAQ = get_bravais(filename);
78
sprintf(filename,"%s/pres.%s", pfad, Name.qname);
79
PRES = get_mat(filename);
80
DATAZ = get_zclass_by_name(DATAQ, Name.zname, Name.zname+1, FALSE);
81
R = get_affine_class_by_name(DATAZ, PRES, &Name.aff_name, 1);
82
83
/* clean */
84
cleanup_prime();
85
free_bravais(DATAQ);
86
free_bravais(DATAZ);
87
free_mat(PRES);
88
89
return(R);
90
}
91
92
93
94
95
/* -------------------------------------------------------- */
96
/* hole die Worte fuer die t-Untergruppen einer Raumgruppe */
97
/* aus der Datenbank */
98
/* -------------------------------------------------------- */
99
/* pfad: Verzeichnis der Q-Klasse zu der Raumgruppe */
100
/* Name: CARATname der Raumgruppe */
101
/* aff_class_no: Anzahl der aff. Klassen in der Q-Klasse */
102
/* aflag: berechne die t-Untergr. bis auf Konjugation unter */
103
/* dem affinen Normalisator */
104
/* anzahl: speichere die Anzahl der t-Untergr. hier */
105
/* -------------------------------------------------------- */
106
matrix_TYP **get_words(char *pfad,
107
CARATname_TYP Name,
108
int aff_class_no,
109
boolean aflag,
110
int *anzahl)
111
{
112
int anz, k, i, z1, z2, *woerter, nr, laenge;
113
114
char filename[1024], string[512];
115
116
matrix_TYP **mat, **tmp;
117
118
FILE *infile;
119
120
MP_INT aff_name;
121
122
boolean FLAG;
123
124
125
/* oeffne Datei */
126
sprintf(filename, "%s/words.%s", pfad, Name.qname);
127
if ( (infile = fopen(filename, "r")) == NULL ) {
128
fprintf(stderr, "get_words: Error: Could not open input-file!\n");
129
exit (4);
130
}
131
132
/* Hole Worte fuer alle Untergruppen */
133
fscanf (infile, "%[^\n]",string);
134
if ( string[0] != '#' ) {
135
anz = 1;
136
mat = (matrix_TYP **)malloc(sizeof(matrix_TYP *));
137
rewind(infile);
138
mat[0] = fget_mat(infile);
139
}
140
else{
141
sscanf (string, "#%u", &anz);
142
mat = (matrix_TYP **)malloc(anz * sizeof(matrix_TYP *));
143
for (k = 0; k < anz; k++){
144
mat[k] = fget_mat(infile);
145
}
146
}
147
148
/* trivialer Fall */
149
if (anz == 0){
150
anzahl[0] = 0;
151
fclose(infile);
152
return(NULL);
153
}
154
155
if (aflag){
156
woerter = (int *)calloc(anz, sizeof(int));
157
FLAG = FALSE;
158
159
/* suche die richtige affine Klasse */
160
for (k = 0; k < aff_class_no; k++){
161
if (fscanf(infile, "%s%i%i", string, &z1, &z2) != 3){
162
fprintf (stderr, "Data has wrong structure.\n");
163
exit (4);
164
}
165
if (sscanf (string, "#%i", anzahl) != 1){
166
fprintf (stderr, "Data has wrong structure.\n");
167
exit (4);
168
}
169
mpz_init(&aff_name);
170
mpz_inp_str(&aff_name, infile, 10);
171
172
if (z1 == Name.zname[0] && z2 == Name.zname[1] &&
173
mpz_cmp(&aff_name, &Name.aff_name) == 0){
174
FLAG = TRUE;
175
}
176
mpz_clear(&aff_name);
177
178
/* lese Infos ueber die Vertreter der t-Untergr. bis auf Konj.
179
unter dem aff. Normalisator */
180
for (i = 0; i < anzahl[0]; i++){
181
if (fscanf(infile, "%i%i%s%i%i", &nr, &laenge, string, &z1, &z2) != 5){
182
fprintf (stderr, "Data has wrong structure.\n");
183
exit (4);
184
}
185
mpz_init(&aff_name);
186
mpz_inp_str(&aff_name, infile, 10);
187
mpz_clear(&aff_name);
188
if (FLAG){
189
woerter[nr]++;
190
191
/* Laenge der Bahn unter dem affinen Normalisator */
192
mat[nr]->array.SZ[mat[nr]->rows - 1][0] = laenge;
193
}
194
}
195
if (FLAG)
196
break;
197
}
198
if (!FLAG){
199
fprintf(stderr, "ERROR in get_words!\n");
200
exit(56);
201
}
202
203
/* lasse nur die Matrizen fuer die Vertreter uebrig */
204
tmp = (matrix_TYP **)calloc(anz, sizeof(matrix_TYP *));
205
i = 0;
206
for (k = 0; k < anz; k++){
207
if (woerter[k]){
208
if (woerter[k] != 1){
209
fprintf(stderr, "ERROR in get_words!\n");
210
exit(58);
211
}
212
tmp[i] = mat[k];
213
i++;
214
}
215
else
216
free_mat(mat[k]);
217
}
218
if (i != anzahl[0]){
219
fprintf(stderr, "ERROR in get_words!\n");
220
exit(57);
221
}
222
free(mat);
223
mat = tmp;
224
tmp = NULL;
225
free(woerter);
226
}
227
else{
228
anzahl[0] = anz;
229
}
230
231
fclose(infile);
232
233
return(mat);
234
}
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255