Orbiter 2022
Combinatorial Objects
set_and_stabilizer.cpp
Go to the documentation of this file.
1// set_and_stabilizer.cpp
2//
3// Anton Betten
4// September 18, 2016
5
7#include "group_actions.h"
8
9using namespace std;
10
11
12namespace orbiter {
13namespace layer3_group_actions {
14namespace data_structures_groups {
15
16
18{
19 null();
20}
21
23{
24 freeself();
25}
26
28{
29 A = NULL;
30 A2 = NULL;
31 data = NULL;
32 Strong_gens = NULL;
33 Stab = NULL;
34}
35
37{
38 if (data) {
40 }
41 if (Strong_gens) {
43 }
44 if (Stab) {
46 }
47 null();
48};
49
51{
52 int f_v = (verbose_level >= 1);
53
54 if (f_v) {
55 cout << "set_and_stabilizer::init" << endl;
56 }
59 if (f_v) {
60 cout << "set_and_stabilizer::init done" << endl;
61 }
62}
63
65{
66 if (Strong_gens == NULL) {
67 cout << "set_and_stabilizer::group_order "
68 "Strong_gens == NULL" << endl;
69 exit(1);
70 }
72}
73
75{
76 if (Strong_gens == NULL) {
77 cout << "set_and_stabilizer::group_order_as_int "
78 "Strong_gens == NULL" << endl;
79 exit(1);
80 }
82}
83
85 actions::action *A, actions::action *A2, long int *Set, int set_sz,
86 groups::strong_generators *gens, int verbose_level)
87{
88 int f_v = (verbose_level >= 1);
89
90 if (f_v) {
91 cout << "set_and_stabilizer::init_everything" << endl;
92 }
99 Stab = Strong_gens->create_sims(verbose_level);
100 if (f_v) {
101 cout << "set_and_stabilizer::init_everything done" << endl;
102 }
103}
104
106{
107 int f_v = (verbose_level >= 1);
109
110 if (f_v) {
111 cout << "set_and_stabilizer::create_copy" << endl;
112 }
113
115 SaS->A = A;
116 SaS->A2 = A2;
117 SaS->data = NEW_lint(sz);
118 Lint_vec_copy(data, SaS->data, sz);
119 SaS->sz = sz;
121
123 Strong_gens->init_copy(SaS->Strong_gens, 0 /* verbose_level*/);
124 SaS->Stab = SaS->Strong_gens->create_sims(verbose_level);
125
126 if (f_v) {
127 cout << "set_and_stabilizer::create_copy done" << endl;
128 }
129 return SaS;
130}
131
132void set_and_stabilizer::allocate_data(int sz, int verbose_level)
133{
134 int f_v = (verbose_level >= 1);
135
136 if (f_v) {
137 cout << "set_and_stabilizer::allocate_data" << endl;
138 }
141 if (f_v) {
142 cout << "set_and_stabilizer::allocate_data done" << endl;
143 }
144}
145
146void set_and_stabilizer::init_data(long int *data, int sz, int verbose_level)
147{
148 int f_v = (verbose_level >= 1);
149
150 if (f_v) {
151 cout << "set_and_stabilizer::init_data" << endl;
152 }
156 if (f_v) {
157 cout << "set_and_stabilizer::init_data done" << endl;
158 }
159}
160
162 int data_gens_size, int nb_gens, std::string &ascii_target_go,
163 int verbose_level)
164{
165 int f_v = (verbose_level >= 1);
166 int i;
167
168 if (f_v) {
169 cout << "set_and_stabilizer::init_stab_from_data" << endl;
170 }
171 vector_ge *gens;
172
173 gens = NEW_OBJECT(vector_ge);
174 gens->init(A, verbose_level - 2);
175 target_go.create_from_base_10_string(ascii_target_go);
176
177
178 gens->allocate(nb_gens, verbose_level - 2);
179 for (i = 0; i < nb_gens; i++) {
180 A->make_element(gens->ith(i), data_gens + i * data_gens_size, 0);
181 }
182
184 TRUE /* f_target_go */, target_go,
185 gens, Strong_gens,
186 0 /*verbose_level*/);
187
188 if (FALSE) {
189 cout << "strong generators are:" << endl;
191 }
192
193 Stab = Strong_gens->create_sims(verbose_level);
194
195 FREE_OBJECT(gens);
196
197 if (f_v) {
198 cout << "set_and_stabilizer::init_stab_from_data done" << endl;
199 }
200}
201
203 const char *fname_gens,
204 int verbose_level)
205{
206 int f_v = (verbose_level >= 1);
207 int i, j;
208 vector_ge *gens;
210
211 if (f_v) {
212 cout << "set_and_stabilizer::init_stab_from_file" << endl;
213 }
214
215 if (Fio.file_size(fname_gens) <= 0) {
216 cout << "set_and_stabilizer::init_stab_from_file "
217 "the file " << fname_gens
218 << " does not exist or is empty" << endl;
219 exit(1);
220 }
221
222 {
223 ifstream f(fname_gens);
224 int nb_gens;
225 int *data;
226 char target_go_ascii[1000];
227
228 f >> nb_gens;
229 f >> target_go_ascii;
230
231
232 target_go.create_from_base_10_string(target_go_ascii);
233
234
236
237
238 gens = NEW_OBJECT(vector_ge);
239 gens->init(A, verbose_level - 2);
240
241
242 gens->allocate(nb_gens, verbose_level - 2);
243 for (i = 0; i < nb_gens; i++) {
244 for (j = 0; j < A->make_element_size; j++) {
245 f >> data[j];
246 }
247 A->make_element(gens->ith(i), data, 0);
248 }
249
250 FREE_int(data);
251 }
252
254 TRUE /* f_target_go */, target_go,
255 gens, Strong_gens,
256 0 /*verbose_level*/);
257
258 if (FALSE) {
259 cout << "strong generators are:" << endl;
261 }
262
263 Stab = Strong_gens->create_sims(verbose_level);
264
265 FREE_OBJECT(gens);
266
267 if (f_v) {
268 cout << "set_and_stabilizer::init_stab_from_file done" << endl;
269 }
270}
271
273{
275
276 L.lint_set_print_tex(ost, data, sz);
277 ost << "_{";
279 ost << "}";
280}
281
283{
285
287 ost << "_{";
289 ost << "}";
290}
291
293{
295}
296
297void set_and_stabilizer::apply_to_self(int *Elt, int verbose_level)
298{
299 int f_v = (verbose_level >= 1);
300 long int *data2;
301 int i;
302 vector_ge *gens;
304
305 if (f_v) {
306 cout << "set_and_stabilizer::apply_to_self" << endl;
307 }
308 if (f_v) {
309 cout << "set_and_stabilizer::apply_to_self Elt=" << endl;
310 A->element_print_quick(Elt, cout);
311 }
312
313 data2 = NEW_lint(sz);
314 A2->map_a_set(data, data2, sz, Elt, 0 /* verbose_level */);
315 if (f_v) {
316 cout << "set_and_stabilizer::apply_to_self "
317 "mapping the set under action " << A2->label << ":" << endl;
318 for (i = 0; i < sz; i++) {
319 cout << i << " : " << data[i] << " : " << data2[i] << endl;
320 }
321 }
322
323 gens = NEW_OBJECT(vector_ge);
324 if (f_v) {
325 cout << "set_and_stabilizer::apply_to_self "
326 "before conjugating generators" << endl;
327 }
329 0 /* verbose_level */);
330 if (f_v) {
331 cout << "set_and_stabilizer::apply_to_self "
332 "before testing the n e w generators" << endl;
333 }
334 for (i = 0; i < Strong_gens->gens->len; i++) {
336 gens->ith(i), sz, data2, 0 /*verbose_level*/)) {
337 cout << "set_and_stabilizer::apply_to_self "
338 "conjugate element does not stabilize the set" << endl;
339 }
340 }
342 TRUE /* f_target_go */, target_go,
343 gens, sg,
344 0 /*verbose_level*/);
345 Lint_vec_copy(data2, data, sz);
346 FREE_OBJECT(gens);
348 Strong_gens = sg;
349 if (Stab) {
351 Stab = Strong_gens->create_sims(verbose_level);
352 }
353 FREE_lint(data2);
354 if (f_v) {
355 cout << "set_and_stabilizer::apply_to_self done" << endl;
356 }
357}
358
359void set_and_stabilizer::apply_to_self_inverse(int *Elt, int verbose_level)
360{
361 int f_v = (verbose_level >= 1);
362 int *Elt1;
363
364 if (f_v) {
365 cout << "set_and_stabilizer::apply_to_self_inverse" << endl;
366 }
367 Elt1 = NEW_int(A->elt_size_in_int);
368
369 A->element_invert(Elt, Elt1, 0);
370 apply_to_self(Elt1, verbose_level);
371
372 FREE_int(Elt1);
373 if (f_v) {
374 cout << "set_and_stabilizer::apply_to_self_inverse done" << endl;
375 }
376}
377
379 int *Elt_data, int verbose_level)
380{
381 int f_v = (verbose_level >= 1);
382 int *Elt;
383
384 if (f_v) {
385 cout << "set_and_stabilizer::apply_to_self_element_raw" << endl;
386 }
387
388 Elt = NEW_int(A->elt_size_in_int);
389 A->make_element(Elt, Elt_data, 0);
390 apply_to_self(Elt, verbose_level);
391 FREE_int(Elt);
392 if (f_v) {
393 cout << "set_and_stabilizer::apply_to_self_element_raw done" << endl;
394 }
395}
396
398 int *Elt_data, int verbose_level)
399{
400 int f_v = (verbose_level >= 1);
401 int *Elt;
402
403 if (f_v) {
404 cout << "set_and_stabilizer::apply_to_self_"
405 "inverse_element_raw" << endl;
406 }
407
408 Elt = NEW_int(A->elt_size_in_int);
409 A->make_element(Elt, Elt_data, 0);
410 apply_to_self_inverse(Elt, verbose_level);
411 FREE_int(Elt);
412 if (f_v) {
413 cout << "set_and_stabilizer::apply_to_self_"
414 "inverse_element_raw done" << endl;
415 }
416}
417
418
420 int *&orbit_first, int *&orbit_length,
421 int *&orbit, int &nb_orbits, int verbose_level)
422{
423 int f_v = (verbose_level >= 1);
424
425 if (f_v) {
426 cout << "set_and_stabilizer::rearrange_by_orbits" << endl;
427 }
428
429 actions::action *A_on_set;
430
431
432 if (f_v) {
433 cout << "set_and_stabilizer::rearrange_by_orbits "
434 "creating restricted action on the set "
435 "of lines" << endl;
436 }
437 A_on_set = A2->restricted_action(data, sz, verbose_level);
438 if (f_v) {
439 cout << "set_and_stabilizer::rearrange_by_orbits "
440 "creating restricted action on the set of "
441 "lines done" << endl;
442 }
443
444 groups::schreier *Orb;
445 long int *data2;
446 int f, l, h, cur, j, a, b;
447
448 if (f_v) {
449 cout << "set_and_stabilizer::rearrange_by_orbits "
450 "computing orbits on set:" << endl;
451 }
453 A_on_set, verbose_level);
454
455 data2 = NEW_lint(sz);
456
457 nb_orbits = Orb->nb_orbits;
458 orbit_first = NEW_int(nb_orbits);
459 orbit_length = NEW_int(nb_orbits);
460 orbit = NEW_int(sz);
461
462
463 cur = 0;
464 orbit_first[0] = 0;
465
466
468 int t, ff, c, d;
469 //int d;
470
471 d = 0;
472 C.init(Orb->orbit_len, Orb->nb_orbits, FALSE, 0);
473 for (t = 0; t < C.nb_types; t++) {
474 ff = C.type_first[t];
475 c = C.data_sorted[ff + 0];
476 for (h = 0; h < Orb->nb_orbits; h++) {
477 f = Orb->orbit_first[h];
478 l = Orb->orbit_len[h];
479#if 1
480 if (l != c) {
481 continue;
482 }
483#endif
484 orbit_length[d] = l;
485 for (j = 0; j < l; j++) {
486 a = Orb->orbit[f + j];
487 b = data[a];
488 orbit[cur] = a;
489 data2[cur++] = b;
490 }
491 if (d < Orb->nb_orbits - 1) {
492 orbit_first[d + 1] = orbit_first[d] + l;
493 }
494 d++;
495 }
496 }
497 Lint_vec_copy(data2, data, sz);
498
499 FREE_OBJECT(Orb);
500 FREE_OBJECT(A_on_set);
501
502 if (f_v) {
503 cout << "set_and_stabilizer::rearrange_by_orbits done" << endl;
504 }
505}
506
508 int verbose_level)
509{
510 int f_v = (verbose_level >= 1);
511
512 if (f_v) {
513 cout << "set_and_stabilizer::create_restricted_"
514 "action_on_the_set" << endl;
515 }
516
517 actions::action *A_on_set;
518
519
520 if (f_v) {
521 cout << "set_and_stabilizer::create_restricted_"
522 "action_on_the_set creating restricted "
523 "action on the set" << endl;
524 }
525 A_on_set = A2->restricted_action(data, sz, verbose_level);
526
527 Strong_gens->print_with_given_action(cout, A_on_set);
528
529 if (f_v) {
530 cout << "set_and_stabilizer::create_restricted_"
531 "action_on_the_set creating restricted "
532 "action on the set done" << endl;
533 }
534
535 return A_on_set;
536}
537
539 int verbose_level)
540{
541 int f_v = (verbose_level >= 1);
542
543 if (f_v) {
544 cout << "set_and_stabilizer::print_restricted_"
545 "action_on_the_set" << endl;
546 }
547
548 actions::action *A_on_set;
549
550
551 if (f_v) {
552 cout << "set_and_stabilizer::print_restricted_action_"
553 "on_the_set creating restricted action on the set" << endl;
554 }
555 A_on_set = A2->restricted_action(data, sz, verbose_level);
556
557 Strong_gens->print_with_given_action(cout, A_on_set);
558
559 if (f_v) {
560 cout << "set_and_stabilizer::print_restricted_action_"
561 "on_the_set creating restricted action "
562 "on the set done" << endl;
563 }
564
565 FREE_OBJECT(A_on_set);
566}
567
569{
570 int f_v = (verbose_level >= 1);
571
572 if (f_v) {
573 cout << "set_and_stabilizer::test_if_group_acts" << endl;
574 }
575
576 if (f_v) {
577 cout << "set_and_stabilizer::test_if_group_acts done" << endl;
578 }
579}
580
582{
584 int idx;
585
586 if (!Sorting.lint_vec_search(
587 data,
588 sz, pt, idx, 0)) {
589 cout << "set_and_stabilizer::find" << endl;
590 exit(1);
591 }
592 return idx;
593}
594
595
596}}}
597
598
599
a collection of functions related to sorted vectors
int lint_vec_search(long int *v, int len, long int a, int &idx, int verbose_level)
Definition: sorting.cpp:1157
a statistical analysis of data consisting of single integers
void init(int *data, int data_length, int f_second, int verbose_level)
Definition: tally.cpp:72
void lint_set_print_tex_for_inline_text(std::ostream &ost, long int *v, int len)
void lint_set_print_tex(std::ostream &ost, long int *v, int len)
a class to represent arbitrary precision integers
Definition: ring_theory.h:366
void create_from_base_10_string(const char *str, int verbose_level)
a permutation group in a fixed action.
Definition: actions.h:99
action * restricted_action(long int *points, int nb_points, int verbose_level)
void element_print_quick(void *elt, std::ostream &ost)
Definition: action_cb.cpp:353
void map_a_set(long int *set, long int *image_set, int n, int *Elt, int verbose_level)
Definition: action.cpp:668
void element_invert(void *a, void *av, int verbose_level)
Definition: action_cb.cpp:322
void make_element(int *Elt, int *data, int verbose_level)
Definition: action.cpp:1875
int check_if_in_set_stabilizer(int *Elt, int size, long int *set, int verbose_level)
Definition: action.cpp:1364
void generators_to_strong_generators(int f_target_go, ring_theory::longinteger_object &target_go, data_structures_groups::vector_ge *gens, groups::strong_generators *&Strong_gens, int verbose_level)
void init_stab_from_data(int *data_gens, int data_gens_size, int nb_gens, std::string &ascii_target_go, int verbose_level)
void init(actions::action *A, actions::action *A2, int verbose_level)
void init_everything(actions::action *A, actions::action *A2, long int *Set, int set_sz, groups::strong_generators *gens, int verbose_level)
void rearrange_by_orbits(int *&orbit_first, int *&orbit_length, int *&orbit, int &nb_orbits, int verbose_level)
void init_conjugate_svas_of(vector_ge *v, int *Elt, int verbose_level)
Definition: vector_ge.cpp:205
void init(actions::action *A, int verbose_level)
Definition: vector_ge.cpp:55
Schreier trees for orbits of groups on points.
Definition: groups.h:839
a strong generating set for a permutation group with respect to a fixed action
Definition: groups.h:1703
void init_copy(strong_generators *S, int verbose_level)
schreier * orbits_on_points_schreier(actions::action *A_given, int verbose_level)
void print_with_given_action(std::ostream &ost, actions::action *A2)
data_structures_groups::vector_ge * gens
Definition: groups.h:1708
void group_order(ring_theory::longinteger_object &go)
#define Lint_vec_copy(A, B, C)
Definition: foundations.h:694
#define FREE_int(p)
Definition: foundations.h:640
#define NEW_OBJECT(type)
Definition: foundations.h:638
#define FREE_OBJECT(p)
Definition: foundations.h:651
#define NEW_int(n)
Definition: foundations.h:625
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define FREE_lint(p)
Definition: foundations.h:642
#define NEW_lint(n)
Definition: foundations.h:628
the orbiter library for the classification of combinatorial objects