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

563516 views
1
#include "ZZ.h"
2
#include "bravais.h"
3
4
int INFO_LEVEL;
5
extern int SFLAG;
6
int IDEM_NO;
7
boolean GRAPH = FALSE;
8
9
extern char *optarg;
10
extern int optind;
11
FILE *outputfile;
12
13
void ZZ_usage (progname)
14
char *progname;
15
{
16
printf("Usage: %s 'file1' ['file2'] [-b] [-g] [-h] [-l=<#level>] \n"
17
,progname);
18
printf(" [-m] [-n=<#number>] [-p] [-q] [-r] [-s] [-t=out] [-u]\n");
19
printf("\n");
20
printf("file1: bravais_TYP containing a finite unimodular group G,\n");
21
printf(" ending with the order of G.\n");
22
printf("file2: (OPTIONAL) matrix_TYP containing the Gram matrix of a symmetric \n");
23
printf(" positive definite G-invariant bilinear form. This form is\n");
24
printf(" used for reduction purposes only. If this file is not\n");
25
printf(" given, the program computes such a form. In particular\n");
26
printf(" the forms possibly given in 'file1' are ignored.\n");
27
printf("\n");
28
printf("Calculates the the G-sublattices of the natural lattice Z^n of\n");
29
printf("finite index, the prime divisors of which divide the order of G\n");
30
printf("as given in 'file1'. Sublattices of proper multiples of Z^n are\n");
31
printf("ignored.\n");
32
printf("\n");
33
printf("Options:\n");
34
printf("-b : Print only the matrices of change of base and their inverse.\n");
35
printf("-g : Do not compute elementary divisors of the gram matrix.\n");
36
printf("-l=# : Stop after reaching level #level (default #=500).\n");
37
printf("-n=# : Stop after computation of #number \"sublattices\" (default #=1000).\n");
38
printf("-q : Quiet mode. Suppress any messages to stderr.\n");
39
printf("-r : With LLL-reduction for the bases, cf. 'file2'.\n");
40
printf("-s : Print less information.\n");
41
printf("-t='out': Create an output file with additional information. The name \n");
42
printf(" of the output file defaults to stdout. Specifying \"none\" \n");
43
printf(" disables writing to the output file\n");
44
printf("-u : Do not compute elementary divisors of the basis\n");
45
printf(" transformations.\n");
46
printf("\n");
47
printf("Options for experts:\n");
48
printf("-p<N>/<d1>/<d2>...<dN> : treat the lattice as a direct sum of <N> \n");
49
printf(" sublattices of dimensions <d1>, <d2> etc. \n");
50
printf(" (1 <= N, di <= 6) and compute only those\n");
51
printf(" sublattices that have surjective projections \n");
52
printf(" onto each of the N component lattices.\n");
53
printf("\n");
54
printf("Cf. Order, QtoZ, Z_equiv, Q_equiv\n");
55
56
}
57
58
int parse_options(int argc,
59
char *argv[],
60
char *option)
61
{
62
63
int i,
64
errflag = 0;
65
66
*option++ = 't';
67
outputfile = stdout;
68
69
if (is_option('b')){
70
*option='b';
71
option++;
72
}
73
if (is_option('g')){
74
*option='g';
75
option++;
76
}
77
if (is_option('q')){
78
*option='q';
79
option++;
80
}
81
if (is_option('r')){
82
*option='r';
83
option++;
84
}
85
if (is_option('s')){
86
*option='s';
87
option++;
88
}
89
if (is_option('m')){
90
*option='m';
91
option++;
92
}
93
if (is_option('u')){
94
*option='u';
95
option++;
96
}
97
if (is_option('z')){
98
*option='z';
99
option++;
100
}
101
if (is_option('Z')){
102
*option='Z';
103
option++;
104
}
105
106
if (is_option('l')){
107
*option='l';
108
option++;
109
sprintf(option,"%d ",optionnumber('l'));
110
option=strchr(option,' ');
111
}
112
if (is_option('n')){
113
*option='n';
114
option++;
115
sprintf(option,"%d ",optionnumber('n'));
116
option=strchr(option,' ');
117
}
118
119
if (is_option('p')){
120
*option='p';
121
option++;
122
for (i=1;i<argc && strstr(argv[i],"-p") != argv[i];i++);
123
sprintf(option,"%s ",argv[i]+2);
124
option=strchr(option,' ');
125
}
126
if (is_option('t')){
127
*option='t';
128
option++;
129
for (i=1;i<argc && strstr(argv[i],"-t") != argv[i];i++);
130
outputfile = fopen(argv[i]+3, "w+");
131
if (outputfile == NULL) {
132
fprintf(stderr,"ZZprog: Error, could not open temporary file %s\n",
133
argv[i]+3);
134
errflag = 1;
135
}
136
}
137
138
return errflag == 0;
139
}
140
141
int main (argc, argv)
142
int argc;
143
char *argv[];
144
{
145
bravais_TYP *group;
146
matrix_TYP *gram = NULL,
147
*ID;
148
char *prog_name = argv[0];
149
char options[256];
150
151
/* for somewhat obscure carat option handling. Why not use the well
152
* ANSI standard, i.e. getopt() :-(
153
*/
154
read_header(argc, argv);
155
IDEM_NO = 0;
156
157
if (is_option('D') && optionnumber('D') == 8){
158
SFLAG = 1;
159
INFO_LEVEL = optionnumber('D');
160
}
161
162
if (!parse_options(argc, argv, options)) {
163
ZZ_usage (prog_name);
164
exit(31);
165
}
166
167
#if DEBUG
168
printf("Options: %s\n", options);
169
{
170
int i;
171
172
for ( i = optind; i < argc; i++) {
173
printf("argv[%d] = %s\n", i, argv[i]);
174
}
175
}
176
#endif
177
switch (FILEANZ) {
178
case 1:
179
group = get_bravais (FILENAMES[0]);
180
ID = init_mat(group->dim,group->dim,"i1");
181
gram = rform(group->gen,group->gen_no,ID,101);
182
free_mat(ID);
183
break;
184
case 2:
185
group = get_bravais (FILENAMES[0]);
186
gram = get_mat(FILENAMES[1]);
187
break;
188
default:
189
ZZ_usage (prog_name);
190
exit(0);
191
}
192
193
194
#if DEBUG
195
fput_mat( stderr, gram, "Form", 0);
196
#endif
197
198
ZZ (group, gram, group->divisors, NULL, options, outputfile, 0, 0);
199
200
#if DEBUG
201
fprintf (stderr, "num_zentr: %d\n", group->zentr_no);
202
#endif
203
/* the following is not exactly needed as we do an exit() anyways.
204
* It's useful, however, for debugging.
205
*/
206
cleanup_prime();
207
free_bravais(group);
208
if (gram != NULL) free_mat(gram);
209
210
if (INFO_LEVEL == 8){
211
pointer_statistics(0,0);
212
}
213
214
return 0;
215
}
216
217