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: 418386
1
#include"typedef.h"
2
#include"matrix.h"
3
#include"bravais.h"
4
#include"orbit.h"
5
#include"getput.h"
6
#include"sort.h"
7
8
int SFLAG;
9
int INFO_LEVEL;
10
11
main (int argc, char *argv[])
12
{
13
14
matrix_TYP **M,
15
*Mat,
16
**erg,
17
**representatives,
18
**tmp;
19
20
bravais_TYP *G,
21
*Stab,
22
*UNITY; /* the unity group */
23
24
int length,
25
l,
26
i,
27
j,
28
no_of_orbits=1,
29
Manz;
30
31
int *option;
32
33
extern char **FILENAMES;
34
extern int FILEANZ;
35
36
read_header(argc, argv);
37
38
if (is_option('h')){
39
INFO_LEVEL = optionnumber('h');
40
}
41
if (INFO_LEVEL == 8) SFLAG = 1;
42
43
if(FILEANZ != 2)
44
{
45
printf("Usage: %s 'file1' 'file2' [-i] [-r] [-l] [-k] [-t] [-L=n] [-S=n] [-p] [-u] [-g] [-R]\n",argv[0]);
46
printf("\n");
47
printf("file1: matrix_TYP, contains a matrix X whose orbit is to be calculated \n");
48
printf("file2: bravais_TYP, contains generators of a group G\n");
49
printf("\n");
50
printf("Calulates the orbit of the matrix X in file1 under the group G in file2,\n");
51
printf("where the action is specified by the options. Default option is action by\n");
52
printf("left multiplication.\n");
53
printf("\n");
54
printf("Options:\n");
55
printf("-i : Use the generators given in file2 and their\n");
56
printf(" inverses to calculate the orbit.\n");
57
printf("-r : Operate from the right.\n");
58
printf("-l : Operate from the left (default).\n");
59
printf("-k : Operate via conjugation, ie. x -> g x g^-1 \n");
60
printf("-L=n : Calculate at most n elements of the orbit.\n");
61
printf(" 0 means infinity.\n");
62
printf("-S=n : If given as -S or -S=0 a generating set for\n");
63
printf(" the stabilizer is calculated. If given as\n");
64
printf(" -S=n at most n matrices of the stabilizer\n");
65
printf(" are calculated.\n");
66
printf(" S=-1 means ONLY the stabilizer is calculated.\n");
67
printf("-p : Operate on pairs of the form {M,-M}.\n");
68
printf("-u : Operate on the set of rows of the matrix given\n");
69
printf(" in file1.\n");
70
printf("-f : Operates on quadratic forms via x -> g^-tr x g^-1\n");
71
printf("-g : Operate on sublattices of Z^n spanned by the columns\n");
72
73
printf(" (rows) of the matrices gX (Xg) with g in G. Brakets \n");
74
printf(" apply if given with the -r option.\n");
75
printf("-R : Give representatives of the G-orbits at the end of\n");
76
printf(" the output.\n");
77
printf("WARNING: If the orbit is infinite use option -L!\n");
78
printf("\n");
79
printf("Cf. Order, Is_finite.\n");
80
/* printf("Cf. Orbit_representatives, Order, Is_finite.\n"); */
81
if (is_option('h')){
82
exit(0);
83
}
84
else{
85
exit(31);
86
}
87
}
88
89
M = mget_mat(FILENAMES[0],&Manz);
90
Mat = M[0];
91
G = get_bravais(FILENAMES[1]);
92
option = make_orbit_options();
93
Stab = (bravais_TYP *)malloc(sizeof(bravais_TYP));
94
Stab->gen_no = Stab->form_no = Stab->zentr_no = 0;
95
Stab->normal_no = Stab->cen_no = 0;
96
UNITY = init_bravais(G->dim);
97
UNITY->gen = (matrix_TYP **) malloc(1 * sizeof(matrix_TYP *));
98
UNITY->gen[0] = init_mat(G->dim,G->dim,"1");
99
UNITY->gen_no = 1;
100
representatives = (matrix_TYP **) malloc(Manz * sizeof(matrix_TYP *));
101
102
if (is_option('S') && Manz > 1){
103
fprintf(stderr,"which matrix to you want to calculate the\n");
104
fprintf(stderr,"stabilizer of?");
105
exit(3);
106
}
107
108
erg = orbit_alg(Mat, G, Stab, option, &length);
109
representatives[0] = erg[0];
110
111
for (i=1;i<Manz;i++){
112
113
mat_quicksort(erg,0,length-1,mat_comp);
114
115
/* standartize M[i] (in a funny way) */
116
tmp = orbit_alg(M[i], UNITY, Stab, option, &l);
117
if (l != 1){
118
fprintf(stderr,"ERROR in orbit\n");
119
exit(3);
120
}
121
free_mat(M[i]);
122
M[i] = tmp[0];
123
free(tmp);
124
125
if (mat_search(M[i],erg,length,mat_comp) == -1){
126
tmp = orbit_alg(M[i],G, Stab, option, &l);
127
erg = (matrix_TYP **) realloc(erg,(length+l)*sizeof(matrix_TYP));
128
for (j=0;j<l;j++){
129
erg[length+j] = tmp[j];
130
}
131
length += l;
132
representatives[no_of_orbits] = tmp[0];
133
no_of_orbits++;
134
free(tmp);
135
}
136
}
137
138
if (!is_option('S') || optionnumber('S') >= 0){
139
printf("#%d\n", length);
140
for(i=0;i<length;i++)
141
put_mat(erg[i], NULL, "", 2);
142
}
143
if(is_option('S') == TRUE)
144
put_bravais(Stab, NULL, "Stabilizer of the operation");
145
146
if (is_option('R')){
147
printf("===== Number of orbits: \n#%d\n",no_of_orbits);
148
for (i=0;i<no_of_orbits;i++){
149
put_mat(representatives[i],0,"representative of orbit",2);
150
}
151
}
152
153
free_bravais(UNITY);
154
free_bravais(Stab);
155
free_bravais(G);
156
for(i=0;i<length;i++)
157
free_mat(erg[i]);
158
159
for (i=0;i<Manz;i++)
160
free_mat(M[i]);
161
free(M);
162
free(erg);
163
free(representatives);
164
if (option != NULL) free(option);
165
if (INFO_LEVEL == 8) pointer_statistics(0,0);
166
167
exit(0);
168
}
169
170