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

563640 views
1
#include "typedef.h"
2
#include "getput.h"
3
#include "matrix.h"
4
5
/**************************************************************************\
6
@---------------------------------------------------------------------------
7
@---------------------------------------------------------------------------
8
@ FILE: get_bravais.c
9
@---------------------------------------------------------------------------
10
@---------------------------------------------------------------------------
11
@
12
\**************************************************************************/
13
14
15
16
17
/**************************************************************************\
18
@---------------------------------------------------------------------------
19
@ bravais_TYP *get_bravais (file_name)
20
@ char *file_name;
21
@ reads a bravais_TYP from the file 'file_name'
22
@---------------------------------------------------------------------------
23
@
24
\**************************************************************************/
25
bravais_TYP *get_bravais (file_name)
26
char *file_name;
27
28
{
29
30
char string[1024];
31
char *str, *strin;
32
char merk[256];
33
bravais_TYP *grp;
34
boolean header = FALSE;
35
char st;
36
char **piece;
37
FILE *infile;
38
int anz, teile;
39
int i, j, k, l, m;
40
int gen_no, form_no, zentr_no, normal_no, cen_no;
41
42
/*------------------------------------------------------------*\
43
| Open input file |
44
\*------------------------------------------------------------*/
45
if ( file_name == NULL )
46
infile = stdin;
47
else
48
if ( (infile = fopen (file_name, "r")) == NULL ) {
49
fprintf (stderr, "get_bravais: Could not open input-file %s\n", file_name);
50
exit (4);
51
}
52
gen_no = 0;
53
form_no = 0;
54
zentr_no = 0;
55
normal_no = 0;
56
cen_no = 0;
57
58
/*--------------------------------------------------*\
59
| read header line |
60
\*--------------------------------------------------*/
61
fscanf (infile, "%*[ \t\n\r]");
62
st = getc(infile);
63
if ( st != '#' ) {
64
gen_no = 1;
65
ungetc(st,infile);
66
}
67
else
68
{
69
70
fscanf (infile, "%[ \t\n]", string);
71
if (fscanf (infile, "%[^\n]",string) == EOF) {
72
*string = '\0';
73
}
74
strtok (string, "%");
75
76
if ( (str = strpbrk (string, "gfznc")) == NULL )
77
sscanf(string, "%d", &gen_no);
78
else
79
{
80
while((str = strpbrk(str, "gfznc")) != NULL)
81
{
82
i = strcspn(str, "g");
83
j = strcspn(str, "f");
84
k = strcspn(str, "z");
85
l = strcspn(str, "n");
86
m = strcspn(str, "c");
87
88
if(i< j && i<k &&i<l && i<m)
89
sscanf ( ++str, "%d", &gen_no);
90
if(j<i && j<k && j<l && j<m)
91
sscanf ( ++str, "%d", &form_no);
92
if(k<i && k<j && k<l && k<m)
93
sscanf ( ++str, "%d", &zentr_no);
94
if(l<i && l<j && l<k && l<m)
95
sscanf ( ++str, "%d", &normal_no);
96
if(m<i && m<j && m<k && m<l)
97
sscanf ( ++str, "%d", &cen_no);
98
}
99
}
100
}
101
102
/*--------------------------------------------------*\
103
| read the matrices |
104
\*--------------------------------------------------*/
105
grp = (bravais_TYP *) malloc(sizeof(bravais_TYP));
106
grp->gen_no = gen_no;
107
grp->form_no = form_no;
108
grp->zentr_no = zentr_no;
109
grp->normal_no = normal_no;
110
grp->cen_no = cen_no;
111
if ( gen_no >0 ) {
112
grp->gen = (matrix_TYP **)malloc(gen_no *sizeof(matrix_TYP *));
113
} else {
114
grp->gen = NULL;
115
}
116
if ( form_no>0 ) {
117
grp->form = (matrix_TYP **)malloc(form_no *sizeof(matrix_TYP *));
118
} else {
119
grp->form = NULL;
120
}
121
if ( zentr_no >0 ) {
122
grp->zentr = (matrix_TYP **)malloc(zentr_no *sizeof(matrix_TYP *));
123
} else {
124
grp->zentr = NULL;
125
}
126
if ( normal_no>0 ) {
127
grp->normal = (matrix_TYP **)malloc(normal_no *sizeof(matrix_TYP *));
128
} else {
129
grp->normal = NULL;
130
}
131
if ( cen_no>0 ) {
132
grp->cen = (matrix_TYP **)malloc(cen_no *sizeof(matrix_TYP *));
133
} else {
134
grp->cen = NULL;
135
}
136
137
for ( k = 0; k < gen_no; k++)
138
grp->gen[k] = fget_mat(infile);
139
for ( k = 0; k < form_no; k++)
140
grp->form[k] = fget_mat(infile);
141
for ( k = 0; k < zentr_no; k++)
142
grp->zentr[k] = fget_mat(infile);
143
for ( k = 0; k < normal_no; k++)
144
grp->normal[k] = fget_mat(infile);
145
for ( k = 0; k < cen_no; k++)
146
grp->cen[k] = fget_mat(infile);
147
148
/*------------------------------------------------------------*\
149
| read group order |
150
\*------------------------------------------------------------*/
151
fscanf (infile, "%[ \t\n]", string);
152
if (fscanf (infile, "%[^\n]",string) == EOF) {
153
*string = '\0';
154
}
155
if ( *string == '%' )
156
strin= NULL;
157
else
158
strin= strtok (string, "%");
159
for(i=0; i<100; i++)
160
grp->divisors[i] = 0;
161
/* changed 15/5/97 tilman from
162
if( strin != NULL && (strlen(strin)) != 0 ) to */
163
if( strin != NULL && (strlen(strin)) != 1 )
164
{
165
i = strcspn(strin, "=");
166
while(i != 0)
167
{
168
while(strin[0] == ' ')
169
strin++;
170
if((strcspn(strin, "*")) == 0)
171
strin++;
172
while(strin[0] == ' ')
173
strin++;
174
sscanf(strin, "%d", &j);
175
itoa(j, merk);
176
k = strlen(merk);
177
strin = strin+k;
178
while(strin[0] == ' ')
179
strin++;
180
if((strcspn(strin, "^")) != 0)
181
grp->divisors[j] = 1;
182
else
183
{
184
strin++;
185
while(strin[0] == ' ')
186
strin++;
187
sscanf(strin, "%d", &k);
188
grp->divisors[j] = k;
189
itoa(k, merk);
190
k = strlen(merk);
191
strin = strin+k;
192
}
193
while(strin[0] == ' ')
194
strin++;
195
i = strcspn(strin, "=");
196
}
197
if ( (str = strpbrk (strin, "=")) != NULL )
198
sscanf ( ++str, "%d", &grp->order);
199
else
200
grp->order = 0;
201
}
202
else
203
{
204
grp->divisors[0] = 1;
205
grp->order = 0;
206
}
207
208
/*------------------------------------------------------------*\
209
| close input file |
210
\*------------------------------------------------------------*/
211
if ( infile != stdin )
212
fclose (infile);
213
if(grp->gen_no != 0)
214
grp->dim = grp->gen[0]->cols;
215
return ( grp );
216
}
217
/*{{{}}}*/
218
219