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

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