CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418346
1
#include "typedef.h"
2
#include "matrix.h"
3
4
5
6
main (int argc, char *argv[])
7
{
8
9
matrix_TYP **F1, **F2, **Erz, *SV1, *SV2, *Iso, *tmp;
10
int i, Fanz, F2anz, Erzanz, options[6];
11
FILE *infile;
12
int Fmax;
13
14
extern char **FILENAMES;
15
extern int FILEANZ;
16
17
extern matrix_TYP *fget_mat ();
18
extern matrix_TYP **fmget_mat ();
19
extern matrix_TYP *short_vectors();
20
extern matrix_TYP *isometry();
21
22
read_header(argc, argv);
23
if(FILEANZ != 2)
24
{
25
printf("Usage: %s 'file1' 'file2 [-d=n] [-s=n] [-b] [-b=n] [-B=n] [-g] [-v] [-p]\n",argv[0]);
26
printf("\n");
27
printf("file1: matrix_TYP containing a set of m NxN-matrices, the first of which,\n");
28
printf(" must be symmetric and positive definite.\n");
29
printf("file2: matrix_TYP containing a set of m NxN-matrices, the first of which,\n");
30
printf(" must be symmetric and positive definite.\n");
31
printf("\n");
32
printf("Computes a single g in GL_n(Z) with the property g^Tr * F_i_1 * g = F_i_2 for all\n");
33
printf("F_i_1 in 'file1' and F_i_2 in 'file2'.\n");
34
printf("\n");
35
printf("Options:\n");
36
printf("-d=n : Depth up to which scalar products are calculated. The value\n");
37
printf(" should be small.\n");
38
printf("-s=n : The n-point stabilizer with respect to different basis will be\n");
39
printf(" calculated.\n");
40
printf("-b=n : Use Bacher polynomials up to deepth n.\n");
41
printf("-B=n : Use Bacher polynomials with vectors having scalar product n\n");
42
printf("-v,-g : Read additional data from 'file'. If -v is given the program\n");
43
printf(" assumes that the short vectors of the first form in 'file'\n");
44
printf(" are given below the forms.\n");
45
printf(" If -g is given, the program assumes known generators for\n");
46
printf(" the automorphism group to be given below any other information in\n");
47
printf(" 'file'.\n");
48
printf("-p : Write additional output to the file ISOM.tmp\n");
49
printf("\n");
50
printf("Cf. Short, Shortest, Aut_grp\n");
51
if (is_option('h')){
52
exit(0);
53
}
54
else{
55
exit(31);
56
}
57
}
58
/*------------------------------------------------------------*\
59
| Open input file1
60
\*------------------------------------------------------------*/
61
if ( (infile = fopen (FILENAMES[0], "r")) == NULL )
62
{
63
fprintf (stderr, "Could not open input-file %s\n", FILENAMES[0]);
64
exit (4);
65
}
66
/*------------------------------------------------------------*\
67
| Read the input
68
\*------------------------------------------------------------*/
69
F1 = fmget_mat(infile, &Fanz);
70
if(is_option('v') == TRUE)
71
SV1 = fget_mat(infile);
72
else
73
{
74
Fmax = F1[0]->array.SZ[0][0];
75
for(i=1;i<F1[0]->cols;i++)
76
{
77
if(F1[0]->array.SZ[i][i] > Fmax)
78
Fmax = F1[0]->array.SZ[i][i];
79
}
80
SV1 = short_vectors(F1[0], Fmax, 0, 0, 0, &i);
81
82
}
83
/*------------------------------------------------------------*\
84
| Close input file
85
\*------------------------------------------------------------*/
86
if ( infile != stdin )
87
fclose (infile);
88
89
/*------------------------------------------------------------*\
90
| Open input file2
91
\*------------------------------------------------------------*/
92
if ( (infile = fopen (FILENAMES[1], "r")) == NULL )
93
{
94
fprintf (stderr, "Could not open input-file %s\n", FILENAMES[1]);
95
exit (4);
96
}
97
/*------------------------------------------------------------*\
98
| Read the input
99
\*------------------------------------------------------------*/
100
F2 = fmget_mat(infile, &F2anz);
101
if(F2anz != Fanz)
102
{
103
printf("Error: different number of matrices in 'isometry'\n");
104
exit(3);
105
}
106
if(is_option('v') == TRUE)
107
SV2 = fget_mat(infile);
108
else
109
SV2 = short_vectors(F2[0], Fmax, 0, 0, 0, &i);
110
if(is_option('g') == TRUE)
111
Erz = fmget_mat(infile, &Erzanz);
112
else
113
{ Erz = NULL, Erzanz = 0;}
114
/*------------------------------------------------------------*\
115
| Close input file
116
\*------------------------------------------------------------*/
117
if ( infile != stdin )
118
fclose (infile);
119
120
/*------------------------------------------------------------*\
121
| Read the options
122
\*------------------------------------------------------------*/
123
124
/*-------------------------------------------------------------------*\
125
| options is a pointer to integer (of length 6)
126
| The possible options are encoded in the following way:
127
| options[0]: The depth, up to wich scalar product combinations
128
| shall be calculated. The value should be small.
129
| options[0] > 0 should be used only, if the automorphismn
130
| group is expected to be small (with respect to the number
131
| of shortest vectors).
132
| options[1]: The n-point stabiliser with respect to different basis
133
| will be calculated.
134
| options[2]: If options[2] = 1, additional output is written to the
135
| file AUTO.tmp
136
| options[3]: If options[3] = 1, Bacher polynomials are used.
137
| If options[3] = 2, Bacher polynomial are used up to a deepth
138
| specified in options[4].
139
| If options[3] = 3, Bacher polynomials are used, using
140
| combinations of vectors having the scalar
141
| product specified in options[5]
142
| options[3] = 4 is the combination of options[3] = 2 and
143
| options[3] = 3.
144
| options[4]: A natural number number or zero (if options[3] = 2 or 4)
145
| options[5]: An integral number (if options[3] = 3 or 4)
146
|
147
| It is possible to use NULL for options,
148
| in this case option is assumed to be [0,0,0,0,0,0]
149
\*************************************************************************/
150
151
for(i=0;i<6;i++)
152
options[i] = 0;
153
if(is_option('d') == TRUE)
154
options[0] = optionnumber('d');
155
if(is_option('s') == TRUE)
156
options[1] = optionnumber('s');
157
if(is_option('p'))
158
options[2] = 1;
159
if(is_option('B') || is_option('b'))
160
options[3] = TRUE;
161
if(optionnumber('b') > 0)
162
{
163
options[4] = optionnumber('b');
164
options[3] = 2;
165
}
166
if(optionnumber('B') > 0)
167
{
168
options[5] = optionnumber('4');
169
options[3] = 3;
170
}
171
if(optionnumber('B') > 0 && optionnumber('b') > 0)
172
options[3] = 4;
173
174
175
Iso = isometry(F1, F2, Fanz, SV1, SV2, Erz, Erzanz, options);
176
if(Iso != NULL) {
177
tmp = tr_pose(Iso);
178
put_mat(tmp, NULL, "isometry", 0);
179
free_mat(tmp);
180
}
181
else
182
printf("The forms are not isometric\n");
183
184
185
exit(0);
186
}
187
188