Orbiter 2022
Combinatorial Objects
action_on_sets.cpp
Go to the documentation of this file.
1// action_on_sets.cpp
2//
3// Anton Betten
4// November 13, 2007
5
7#include "group_actions.h"
8
9using namespace std;
10
11
12namespace orbiter {
13namespace layer3_group_actions {
14namespace induced_actions {
15
16
18{
19 null();
20}
21
23{
24 free();
25}
26
28{
29 sets = NULL;
30 image_set = NULL;
31 perm = NULL;
32 perm_inv = NULL;
33}
34
36{
37 int i;
38
39 if (sets) {
40 for (i = 0; i < nb_sets; i++) {
41 FREE_lint(sets[i]);
42 }
44 }
45 if (image_set) {
47 }
48 if (perm) {
50 }
51 if (perm_inv) {
53 }
54 null();
55}
56
57
58void action_on_sets::init(int nb_sets,
59 int set_size, long int *input_sets,
60 int verbose_level)
61{
62 int i, j;
63 int f_v = (verbose_level >= 1);
64 int f_vv = FALSE; //(verbose_level >= 5);
67
68 if (f_v) {
69 cout << "action_on_sets::init "
70 "nb_sets=" << nb_sets
71 << " set_size=" << set_size << endl;
72 }
79 for (i = 0; i < nb_sets; i++) {
80 perm[i] = i;
81 perm_inv[i] = i;
82 }
83 for (i = 0; i < nb_sets; i++) {
85 for (j = 0; j < set_size; j++) {
86 sets[i][j] = input_sets[i * set_size + j];
87 }
89 if (f_vv) {
90 cout << "set " << setw(3) << i << " is ";
91 Lint_vec_print(cout, sets[i], set_size);
92 cout << endl;
93 }
94 }
96 (void **) sets, perm_inv,
98 this);
100
101 test_sets();
102
103
104 if (f_vv) {
105 cout << "after quicksort_array_with_perm" << endl;
106#if 0
107 cout << "i : perm[i] : perm_inv[i]" << endl;
108 for (i = 0; i < nb_sets; i++) {
109 cout << i << " : " << perm[i] << " : " << perm_inv[i] << endl;
110 }
111#endif
112
114
116
117#if 0
118 cout << "the sets in the perm_inv ordering:" << endl;
119 for (i = 0; i < nb_sets; i++) {
120 j = perm_inv[i];
121 cout << "set " << i << " is set " << j << " : ";
122 int_vec_print(cout, sets[j], set_size);
123 cout << endl;
124 }
125#endif
126 }
127 if (f_v) {
128 cout << "action_on_sets::init finished" << endl;
129 }
130}
131
132int action_on_sets::find_set(long int *set, int verbose_level)
133{
134 int f_v = (verbose_level >= 1);
136 int idx, j;
137
138 if (f_v) {
139 cout << "action_on_sets::find_set, nb_sets=" << nb_sets << endl;
140 }
141 if (!Sorting.vec_search(
142 (void **)sets,
144 this,
145 nb_sets,
146 set,
147 idx,
148 verbose_level)) {
149 cout << "action_on_sets::find_set could not find the given set" << endl;
150 exit(1);
151 }
152 j = perm_inv[idx];
153 if (f_v) {
154 cout << "action_on_sets::find_set done" << endl;
155 }
156 return j;
157}
158
160 int *Elt, long int i, int verbose_level)
161{
162 int f_v = (verbose_level >= 1);
163 int f_vv = (verbose_level >= 2);
164 int idx, res;
165 long int j;
167
168 if (f_v) {
169 cout << "action_on_sets::compute_image "
170 "i = " << i << endl;
171 cout << "action_on_sets::compute_image "
172 "perm[i] = " << perm[i] << endl;
173 }
174 if (i < 0 || i >= nb_sets) {
175 cout << "action_on_sets::compute_image "
176 "i = " << i << " out of range" << endl;
177 exit(1);
178 }
179 if (f_vv) {
180 cout << "the element " << endl;
181 A->print(cout, Elt);
182 cout << endl;
183 cout << "as permutation:" << endl;
184 A->print_as_permutation(cout, Elt);
185 cout << endl;
186 }
187 if (f_vv) {
188 cout << "sets[perm[i]]:" << endl;
189 Lint_vec_print(cout, sets[perm[i]], set_size);
190 cout << endl;
191 for (j = 0; j < set_size; j++) {
192 cout << j << " : " << sets[perm[i]][j] << " : " << endl;
193 A->print_point(sets[perm[i]][j], cout);
194 cout << endl;
195 }
196 }
198 sets[perm[i]],
199 image_set,
200 set_size,
201 Elt,
202 0);
203 if (f_vv) {
204 cout << "after map_a_set_and_reorder:" << endl;
206 cout << endl;
207 for (j = 0; j < set_size; j++) {
208 cout << j << " : " << image_set[j] << " : " << endl;
209 A->print_point(image_set[j], cout);
210 cout << endl;
211 }
212 }
213 if (!Sorting.vec_search(
214 (void **)sets,
216 this,
217 nb_sets,
218 image_set,
219 idx,
220 verbose_level)) {
221 int u, a, b;
222 cout << "action_on_sets::compute_image "
223 "image set not found" << endl;
224 cout << "action = " << A->label << endl;
225
226 cout << "the element " << endl;
227 A->print(cout, Elt);
228 cout << endl;
229 cout << "as permutation:" << endl;
230 A->print_as_permutation(cout, Elt);
231 cout << endl;
232
233 cout << "i=" << i << endl;
234 cout << "perm[i]=" << perm[i] << endl;
235 cout << "sets[perm[i]]:" << endl;
237 cout << endl;
238 cout << "image_set:" << endl;
240 cout << endl;
241 for (u = 0; u < nb_sets; u++) {
242 cout << u << " : ";
243 Lint_vec_print(cout, sets[u], set_size);
244 cout << endl;
245 }
246 for (u = 0; u < set_size; u++) {
247 a = sets[perm[i]][u];
248 b = A->image_of(Elt, a);
249 cout << setw(3) << u << " : " << setw(3) << a
250 << " : " << setw(3) << b << endl;
251 }
252 exit(1);
253 }
254 if (f_v) {
255 cout << "action_on_sets::compute_image "
256 "idx = " << idx << endl;
257 }
258 res = action_on_sets_compare(image_set, sets[idx], this);
259 if (res != 0) {
260 cout << "action_on_sets::compute_image "
261 "the set we found is not the right one" << endl;
262 }
263 j = perm_inv[idx];
264 if (f_v) {
265 cout << "action_on_sets::compute_image "
266 "j = perm_inv[idx] = " << j << endl;
267 }
268 if (j < 0 || j >= nb_sets) {
269 cout << "action_on_sets::compute_image "
270 "j=" << j << " out of range" << endl;
271 exit(1);
272 }
273 return j;
274}
275
277{
278 int i;
279
280 cout << "the sets in the sorted ordering:" << endl;
281 for (i = 0; i < nb_sets; i++) {
282 cout << "set " << i << " : is " << perm_inv[i] << " : ";
283 Lint_vec_print(cout, sets[i], set_size);
284 cout << endl;
285 }
286}
287
289{
290 int i;
291
292 cout << "the sets in the original ordering:" << endl;
293 for (i = 0; i < nb_sets; i++) {
294 cout << "set " << i << " : is " << perm[i] << " : ";
295 Lint_vec_print(cout, sets[perm[i]], set_size);
296 cout << endl;
297 }
298}
299
301{
302 int i, c;
303
304 for (i = 0; i < nb_sets - 1; i++) {
305 c = action_on_sets_compare(sets[i], sets[i + 1], this);
306 if (c == 0) {
307 cout << "action_on_sets::test_sets "
308 "sorted set " << i << " and sorted set "
309 << i + 1 << " are equal. This should not be" << endl;
310 cout << "The original set numbers are " << perm_inv[i]
311 << " and " << perm_inv[i + 1] << " respectively." << endl;
312 exit(1);
313 }
314 }
315}
316
317
318
319int action_on_sets_compare(void *a, void *b, void *data)
320{
321 action_on_sets *AOS = (action_on_sets *) data;
322 long int *A = (long int *)a;
323 long int *B = (long int *)b;
324 int c;
326
327 c = Sorting.lint_vec_compare(A, B, AOS->set_size);
328 return c;
329}
330
331int action_on_sets_compare_inverted(void *a, void *b, void *data)
332{
333 action_on_sets *AOS = (action_on_sets *) data;
334 long int *A = (long int *)a;
335 long int *B = (long int *)b;
336 int c;
338
339 c = Sorting.lint_vec_compare(B, A, AOS->set_size);
340 return c;
341}
342
343}}}
344
345
346
a collection of functions related to sorted vectors
void lint_vec_quicksort_increasingly(long int *v, int len)
Definition: sorting.cpp:918
int lint_vec_compare(long int *p, long int *q, int len)
Definition: sorting.cpp:2326
void quicksort_array_with_perm(int len, void **v, int *perm, int(*compare_func)(void *a, void *b, void *data), void *data)
Definition: sorting.cpp:937
int vec_search(void **v, int(*compare_func)(void *a, void *b, void *data), void *data_for_compare, int len, void *a, int &idx, int verbose_level)
Definition: sorting.cpp:945
a permutation group in a fixed action.
Definition: actions.h:99
void print_point(int a, std::ostream &ost)
Definition: action_cb.cpp:149
void map_a_set_and_reorder(long int *set, long int *image_set, int n, int *Elt, int verbose_level)
Definition: action.cpp:698
void print(std::ostream &ost, void *elt)
Definition: action_cb.cpp:131
void print_as_permutation(std::ostream &ost, void *elt)
Definition: action_cb.cpp:143
void init(int nb_sets, int set_size, long int *input_sets, int verbose_level)
long int compute_image(actions::action *A, int *Elt, long int i, int verbose_level)
#define NEW_plint(n)
Definition: foundations.h:629
#define FREE_int(p)
Definition: foundations.h:640
#define FREE_plint(p)
Definition: foundations.h:643
#define Lint_vec_print(A, B, C)
Definition: foundations.h:686
#define NEW_int(n)
Definition: foundations.h:625
#define FALSE
Definition: foundations.h:234
#define FREE_lint(p)
Definition: foundations.h:642
#define NEW_lint(n)
Definition: foundations.h:628
#define Lint_vec_print_fully(A, B, C)
Definition: foundations.h:688
int action_on_sets_compare_inverted(void *a, void *b, void *data)
int action_on_sets_compare(void *a, void *b, void *data)
the orbiter library for the classification of combinatorial objects