Orbiter 2022
Combinatorial Objects
orbit_of_subspaces.cpp
Go to the documentation of this file.
1// orbit_of_subspaces.cpp
2//
3// Anton Betten
4// April 9, 2014
5//
6//
7//
8//
9//
10
12#include "discreta/discreta.h"
15
16
17using namespace std;
18
19namespace orbiter {
20namespace layer4_classification {
21
23{
24 A = NULL;
25 A2 = NULL;
26 F = NULL;
27 gens = NULL;
28 f_lint = FALSE;
29 k = n = kn = sz = 0; // sz_for_compare = 0;
31 desired_pivots = NULL;
32 subspace_by_rank = NULL;
34 data_tmp = NULL;
35 Mtx1 = NULL;
36 Mtx2 = NULL;
37 Mtx3 = NULL;
38
40 rank_unrank_data = NULL;
47
50 old_length = 0;
51 used_length = 0;
52 Subspaces = NULL;
53 Subspaces_lint = NULL;
54 prev = NULL;
55 label = NULL;
56 //null();
57}
58
60{
61 freeself();
62}
63
65{
66}
67
69{
70 int i;
71
72 if (subspace_by_rank) {
74 }
77 }
78 if (Subspaces) {
79 for (i = 0; i < used_length; i++) {
81 }
83 }
84 if (Subspaces_lint) {
85 for (i = 0; i < used_length; i++) {
87 }
89 }
90 if (prev) {
92 }
93 if (label) {
95 }
96 if (data_tmp) {
98 }
99 if (Mtx1) {
100 FREE_int(Mtx1);
101 }
102 if (Mtx2) {
103 FREE_int(Mtx2);
104 }
105 if (Mtx3) {
106 FREE_int(Mtx3);
107 }
108 null();
109}
110
113 actions::action *A2,
115 int *subspace_by_rank, int k, int n,
116 int f_has_desired_pivots, int *desired_pivots,
117 int f_has_rank_functions, void *rank_unrank_data,
118 int (*rank_vector_callback)(int *v, int n,
119 void *data, int verbose_level),
120 void (*unrank_vector_callback)(int rk, int *v, int n,
121 void *data, int verbose_level),
122 void (*compute_image_of_vector_callback)(int *v, int *w,
123 int *Elt, void *data, int verbose_level),
124 void *compute_image_of_vector_callback_data,
126 int verbose_level)
127{
128 int f_v = (verbose_level >= 1);
129
130 if (f_v) {
131 cout << "orbit_of_subspaces::init" << endl;
132 }
133 f_lint = FALSE;
152 kn = k * n;
153 sz = k; // 1 + k + kn;
154 //sz_for_compare = 1 + k + kn;
155
157 Mtx1 = NEW_int(kn);
158 Mtx2 = NEW_int(kn);
159 Mtx3 = NEW_int(kn);
160
161 if (f_v) {
162 cout << "orbit_of_subspaces::init before compute" << endl;
163 }
164 compute(verbose_level - 1);
165 if (f_v) {
166 cout << "orbit_of_subspaces::init after compute" << endl;
167 }
168
169 if (f_v) {
170 cout << "orbit_of_subspaces::init printing the orbit" << endl;
171 print_orbit();
172 }
173
174 if (f_v) {
175 cout << "orbit_of_subspaces::init done" << endl;
176 }
177}
178
181 actions::action *A2,
183 long int *subspace_by_rank, int k, int n,
184 int f_has_desired_pivots, int *desired_pivots,
185 int f_has_rank_functions, void *rank_unrank_data,
186 long int (*rank_vector_lint_callback)(int *v, int n,
187 void *data, int verbose_level),
188 void (*unrank_vector_lint_callback)(long int rk, int *v, int n,
189 void *data, int verbose_level),
190 void (*compute_image_of_vector_callback)(int *v, int *w,
191 int *Elt, void *data, int verbose_level),
192 void *compute_image_of_vector_callback_data,
194 int verbose_level)
195{
196 int f_v = (verbose_level >= 1);
197
198 if (f_v) {
199 cout << "orbit_of_subspaces::init_lint" << endl;
200 }
201 f_lint = TRUE;
220 kn = k * n;
221 sz = k; //1 + k + kn;
222 //sz_for_compare = 1 + k + kn;
223
225 Mtx1 = NEW_int(kn);
226 Mtx2 = NEW_int(kn);
227 Mtx3 = NEW_int(kn);
228
229 if (f_v) {
230 cout << "orbit_of_subspaces::init_lint before compute" << endl;
231 }
232 compute(verbose_level - 1);
233 if (f_v) {
234 cout << "orbit_of_subspaces::init_lint after compute" << endl;
235 }
236
237 if (f_v) {
238 cout << "orbit_of_subspaces::init_lint printing the orbit" << endl;
239 print_orbit();
240 }
241
242 if (f_v) {
243 cout << "orbit_of_subspaces::init_lint done" << endl;
244 }
245}
246
247
248int orbit_of_subspaces::rank_vector(int *v, int verbose_level)
249{
250 int f_v = (verbose_level >= 1);
251 int r;
252
253 if (f_v) {
254 cout << "orbit_of_subspaces::rank_vector" << endl;
255 }
257 cout << "orbit_of_subspaces::rank_vector "
258 "!f_has_rank_functions" << endl;
259 exit(1);
260 }
261 r = (*rank_vector_callback)(v, n,
262 rank_unrank_data, verbose_level - 1);
263 if (f_v) {
264 cout << "orbit_of_subspaces::rank_vector done" << endl;
265 }
266 return r;
267}
268
269long int orbit_of_subspaces::rank_vector_lint(int *v, int verbose_level)
270{
271 int f_v = (verbose_level >= 1);
272 long int r;
273
274 if (f_v) {
275 cout << "orbit_of_subspaces::rank_vector_lint" << endl;
276 }
278 cout << "orbit_of_subspaces::rank_vector_lint "
279 "!f_has_rank_functions" << endl;
280 exit(1);
281 }
282 r = (*rank_vector_lint_callback)(v, n,
283 rank_unrank_data, verbose_level - 1);
284 if (f_v) {
285 cout << "orbit_of_subspaces::rank_vector_lint done" << endl;
286 }
287 return r;
288}
289
290void orbit_of_subspaces::unrank_vector(int rk, int *v, int verbose_level)
291{
292 int f_v = (verbose_level >= 1);
293
294 if (f_v) {
295 cout << "orbit_of_subspaces::unrank_vector" << endl;
296 }
298 cout << "orbit_of_subspaces::unrank_vector "
299 "!f_has_rank_functions" << endl;
300 exit(1);
301 }
302 (*unrank_vector_callback)(rk, v, n,
303 rank_unrank_data, verbose_level - 1);
304 if (f_v) {
305 cout << "orbit_of_subspaces::unrank_vector done" << endl;
306 }
307}
308
309void orbit_of_subspaces::unrank_vector_lint(long int rk, int *v, int verbose_level)
310{
311 int f_v = (verbose_level >= 1);
312
313 if (f_v) {
314 cout << "orbit_of_subspaces::unrank_vector_lint" << endl;
315 }
317 cout << "orbit_of_subspaces::unrank_vector_lint "
318 "!f_has_rank_functions" << endl;
319 exit(1);
320 }
321 (*unrank_vector_lint_callback)(rk, v, n,
322 rank_unrank_data, verbose_level - 1);
323 if (f_v) {
324 cout << "orbit_of_subspaces::unrank_vector_lint done" << endl;
325 }
326}
327
329 int subspace_idx, int *subspace_basis, int verbose_level)
330{
331 if (f_lint) {
332 unrank_lint(Subspaces_lint[subspace_idx],
333 subspace_basis,
334 verbose_level - 2);
335 }
336 else {
337 unrank(Subspaces[subspace_idx],
338 subspace_basis,
339 verbose_level - 2);
340 }
341}
342
344 int *subspace_basis, int verbose_level)
345{
346 if (f_lint) {
348 subspace_basis,
349 verbose_level - 2);
350 }
351 else {
353 subspace_basis,
354 verbose_level - 2);
355 }
356}
357
359{
360 uint32_t h;
362
363 if (f_lint) {
365 }
366 else {
368 }
369 return h;
370}
371
373 int *rk, int *subspace_basis, int verbose_level)
374{
375 int i;
376
377 for (i = 0; i < k; i++) {
378 unrank_vector(rk[i], subspace_basis + i * n,
379 verbose_level - 2);
380 }
381}
382
384 long int *rk, int *subspace_basis, int verbose_level)
385{
386 int i;
387
388 for (i = 0; i < k; i++) {
389 unrank_vector_lint(rk[i], subspace_basis + i * n,
390 verbose_level - 2);
391 }
392}
393
395 int *rk, int *subspace_basis, int verbose_level)
396{
397 int i;
398
399 for (i = 0; i < k; i++) {
400 rk[i] = rank_vector(subspace_basis + i * n,
401 verbose_level - 2);
402 }
403}
404
406 long int *rk, int *subspace_basis, int verbose_level)
407{
408 int i;
409
410 for (i = 0; i < k; i++) {
411 rk[i] = rank_vector_lint(subspace_basis + i * n,
412 verbose_level - 2);
413 }
414}
415
416
417void orbit_of_subspaces::rref(int *subspace, int verbose_level)
418{
419 int f_v = (verbose_level >= 1);
420 int f_vv = (verbose_level >= 2);
421
422 if (f_v) {
423 cout << "orbit_of_subspaces::rref" << endl;
424 }
426 if (f_vv) {
427 cout << "orbit_of_subspaces::rref before:" << endl;
428 Int_matrix_print(subspace, k, n);
429 cout << "desired_pivots:";
431 cout << endl;
432 }
434 subspace,
435 FALSE /* f_special */,
436 TRUE /* f_complete */,
438 k /* nb_pivots */,
439 k, n,
440 0 /*verbose_level - 2*/);
441 if (f_vv) {
442 cout << "orbit_of_subspaces::rref after:" << endl;
443 Int_matrix_print(subspace, k, n);
444 }
445 }
446 else {
447 if (f_vv) {
448 cout << "orbit_of_subspaces::rref "
449 "before Gauss_easy" << endl;
450 }
451 F->Linear_algebra->Gauss_easy(subspace, k, n);
452 }
453 if (f_v) {
454 cout << "orbit_of_subspaces::rref done" << endl;
455 }
456}
457
459 int *subspace, int *rk, int verbose_level)
460{
461 int f_v = (verbose_level >= 1);
462
463 if (f_v) {
464 cout << "orbit_of_subspaces::rref_and_rank" << endl;
465 }
466 rref(subspace, verbose_level - 1);
467 rank(rk, subspace, verbose_level - 1);
468 if (f_v) {
469 cout << "orbit_of_subspaces::rref_and_rank done" << endl;
470 }
471}
472
474 int *subspace, long int *rk, int verbose_level)
475{
476 int f_v = (verbose_level >= 1);
477
478 if (f_v) {
479 cout << "orbit_of_subspaces::rref_and_rank_lint" << endl;
480 }
481 rref(subspace, verbose_level - 1);
482 rank_lint(rk, subspace, verbose_level - 1);
483 if (f_v) {
484 cout << "orbit_of_subspaces::rref_and_rank_lint done" << endl;
485 }
486}
487
488
489#if 0
490void orbit_of_subspaces::map_a_subspace(int *subspace,
491 int *image_subspace, int *Elt, int verbose_level)
492{
493 int f_v = (verbose_level >= 1);
494
495 if (f_v) {
496 cout << "orbit_of_subspaces::map_a_subspace" << endl;
497 }
498 map_a_basis(subspace + 1 + k,
499 image_subspace + 1 + k, Elt, verbose_level - 1);
500 rref_and_rank_and_hash(image_subspace, verbose_level - 2);
501 if (f_v) {
502 cout << "orbit_of_subspaces::map_a_subspace done" << endl;
503 }
504}
505#endif
506
508 int *image_basis, int *Elt, int verbose_level)
509{
510 int f_v = (verbose_level >= 1);
511 int i;
512
513 if (f_v) {
514 cout << "orbit_of_subspaces::map_a_subspace" << endl;
515 }
516 for (i = 0; i < k; i++) {
517 (*compute_image_of_vector_callback)(basis + i * n,
518 image_basis + i * n, Elt,
520 verbose_level - 2);
521 }
522 if (f_v) {
523 cout << "orbit_of_subspaces::map_a_subspace done" << endl;
524 }
525}
526
528{
529 int i;
530 int *v;
531
532 v = NEW_int(n);
533 cout << "orbit_of_subspaces::print_orbit "
534 "We found an orbit of length " << used_length << endl;
535 for (i = 0; i < used_length; i++) {
536 cout << i << " : ";
537 if (f_lint) {
539 }
540 else {
541 Int_vec_print(cout, Subspaces[i], k);
542 }
543#if 0
544 cout << " : ";
545 for (j = 0; j < k; j++) {
546 unrank_vector(Subspaces[i][1 + j], v, 0);
547 int_vec_print(cout, v, n);
548 if (j < k - 1) {
549 cout << ", ";
550 }
551 }
552#endif
553 cout << endl;
554 }
555 FREE_int(v);
556}
557
559 int &idx, uint32_t &h, int verbose_level)
560{
561 int f_found;
563
564 rank_subspace(subspace, verbose_level - 2);
565
566
567 h = hash_subspace();
568
569 map<uint32_t, int>::iterator itr, itr1, itr2;
570
571 itr1 = Hashing.lower_bound(h);
572 itr2 = Hashing.upper_bound(h);
573 f_found = FALSE;
574 for (itr = itr1; itr != itr2; ++itr) {
575 idx = itr->second;
576 if (f_lint) {
577 if (Sorting.lint_vec_compare(subspace_by_rank_lint, Subspaces_lint[idx], sz) == 0) {
578 f_found = TRUE;
579 break;
580 }
581 }
582 else {
583 if (Sorting.int_vec_compare(subspace_by_rank, Subspaces[idx], sz) == 0) {
584 f_found = TRUE;
585 break;
586 }
587 }
588 }
589 return f_found;
590}
591
592void orbit_of_subspaces::compute(int verbose_level)
593{
594 int f_v = (verbose_level >= 1);
595 int f_vv = (verbose_level >= 2);
596 int i, cur, j, idx;
597 int *Q;
598 int Q_len;
599 uint32_t h;
600 int f_found;
601
602 if (f_v) {
603 cout << "orbit_of_subspaces::compute" << endl;
604 }
605 if (f_v) {
606 cout << "orbit_of_subspaces::compute "
607 "sz=" << sz << endl;
608 }
609 allocation_length = 1000;
611 if (f_lint) {
613 }
614 else {
616 }
619
620
621
622
623 if (f_v) {
624 cout << "orbit_of_subspaces::compute "
625 "init Subspaces[0]" << endl;
626 }
627 if (f_lint) {
629 Mtx1,
630 verbose_level - 2);
631 }
632 else {
634 Mtx1,
635 verbose_level - 2);
636 }
637 if (f_v) {
638 cout << "which equals" << endl;
640 }
641
642 rref(Mtx1, verbose_level - 1);
643 if (f_lint) {
645 Mtx1,
646 verbose_level - 2);
647 }
648 else {
650 Mtx1,
651 verbose_level - 2);
652 }
653 if (f_v) {
654 cout << "after RREF:" << endl;
656 }
657
658
659 if (f_lint) {
662 }
663 else {
664 Subspaces[0] = NEW_int(sz);
666 }
667 prev[0] = -1;
668 label[0] = -1;
669
670
671 h = hash_subspace();
672 Hashing.insert(pair<uint32_t, int>(h, 0));
673
674
676
677 used_length = 1;
679 Q[0] = 0;
680 Q_len = 1;
681 while (Q_len) {
682 if (f_vv) {
683 cout << "Q_len = " << Q_len
684 << " : used_length="
685 << used_length << " : ";
686 Int_vec_print(cout, Q, Q_len);
687 cout << endl;
688 }
689 cur = Q[0];
690 for (i = 1; i < Q_len; i++) {
691 Q[i - 1] = Q[i];
692 }
693 Q_len--;
694
695 unrank_subspace(cur, Mtx1, verbose_level - 1);
696
697
698 for (j = 0; j < gens->len; j++) {
699 if (f_vv) {
700 cout << "applying generator " << j << endl;
701 }
702
704 verbose_level - 1);
705
706 rref(Mtx2, verbose_level - 1);
707
708 f_found = rank_hash_and_find(Mtx2, idx, h, 0 /*verbose_level - 1*/);
709
710
711 if (!f_found) {
712
714 int al2 = allocation_length + old_length;
715 if (f_vv) {
716 cout << "reallocating to length " << al2 << endl;
717 }
718
719 // reallocate Sets:
720 if (f_lint) {
721 long int **Subspaces2;
722 Subspaces2 = NEW_plint(al2);
723 for (i = 0; i < allocation_length; i++) {
724 Subspaces2[i] = Subspaces_lint[i];
725 }
727 Subspaces_lint = Subspaces2;
728
729 }
730 else {
731 int **Subspaces2;
732 Subspaces2 = NEW_pint(al2);
733 for (i = 0; i < allocation_length; i++) {
734 Subspaces2[i] = Subspaces[i];
735 }
737 Subspaces = Subspaces2;
738 }
739
740 // reallocate prev:
741 int *prev2;
742 prev2 = NEW_int(al2);
743 Int_vec_copy(prev, prev2, al2);
744 FREE_int(prev);
745 prev = prev2;
746
747 // reallocate label:
748 int *label2;
749 label2 = NEW_int(al2);
750 Int_vec_copy(label, label2, al2);
752 label = label2;
753
754 // reallocate Q2:
755 int *Q2;
756 Q2 = NEW_int(al2);
757 Int_vec_copy(Q, Q2, Q_len);
758 FREE_int(Q);
759 Q = Q2;
760
762 allocation_length = al2;
763 }
764
765 if (f_lint) {
768 }
769 else {
772 }
773 prev[used_length] = cur;
774 label[used_length] = j;
775 used_length++;
776
777 if ((used_length % 10000) == 0) {
778 cout << "orbit_of_sets::compute " << used_length
779 << " Q_len=" << Q_len
780 << " allocation_length=" << allocation_length
781 << endl;
782 }
783
784 Q[Q_len++] = used_length - 1;
785 Hashing.insert(pair<uint32_t, int>(h, used_length - 1));
786
787 } // if (!f_found)
788
789
790
791
792
793 } // next generator j
794
795 } // next element in the orbit
796
797 if (f_v) {
798 cout << "orbit_of_subspaces::compute found an orbit of length "
799 << used_length << endl;
800 }
801
802
803 FREE_int(Q);
804 if (f_v) {
805 cout << "orbit_of_subspaces::compute done" << endl;
806 }
807}
808
810 int *transporter, int verbose_level)
811// transporter is an element which maps the orbit
812// representative to the given subspace.
813{
814 int f_v = (verbose_level >= 1);
815 int *Elt1, *Elt2;
816 int idx0, idx1, l;
817
818 if (f_v) {
819 cout << "orbit_of_subspaces::get_transporter" << endl;
820 }
821 Elt1 = NEW_int(A->elt_size_in_int);
822 Elt2 = NEW_int(A->elt_size_in_int);
823
824 A->element_one(Elt1, 0);
825 idx1 = idx;
826 idx0 = prev[idx1];
827 while (idx0 >= 0) {
828 l = label[idx1];
829 A->element_mult(gens->ith(l), Elt1, Elt2, 0);
830 A->element_move(Elt2, Elt1, 0);
831 idx1 = idx0;
832 idx0 = prev[idx1];
833 }
834 if (idx1 != position_of_original_subspace) {
835 cout << "orbit_of_subspaces::get_transporter "
836 "idx1 != position_of_original_subspace" << endl;
837 exit(1);
838 }
839 A->element_move(Elt1, transporter, 0);
840
841 FREE_int(Elt1);
842 FREE_int(Elt2);
843 if (f_v) {
844 cout << "orbit_of_subspaces::get_transporter done" << endl;
845 }
846}
847
849 int *subspace_ranks, int &idx, int verbose_level)
850{
851 int f_v = (verbose_level >= 1);
852 int f_found;
853 uint32_t h;
854
855 if (f_v) {
856 cout << "orbit_of_subspaces::find_subspace" << endl;
857 }
858
859 unrank(subspace_ranks, Mtx3, verbose_level - 2);
860
861 rref(Mtx3, verbose_level - 1);
862
863 f_found = rank_hash_and_find(Mtx3, idx, h, verbose_level - 1);
864
865 if (!f_found) {
866 cout << "orbit_of_subspaces::find_subspace "
867 "not found" << endl;
868 }
869 if (f_v) {
870 cout << "orbit_of_subspaces::find_subspace done" << endl;
871 }
872 return f_found;
873}
874
876 long int *subspace_ranks, int &idx, int verbose_level)
877{
878 int f_v = (verbose_level >= 1);
879 int f_found;
880 uint32_t h;
881
882 if (f_v) {
883 cout << "orbit_of_subspaces::find_subspace_lint" << endl;
884 }
885
886 unrank_lint(subspace_ranks, Mtx3, verbose_level - 2);
887
888 rref(Mtx3, verbose_level - 1);
889
890 f_found = rank_hash_and_find(Mtx3, idx, h, verbose_level - 2);
891
892 if (!f_found) {
893 if (f_v) {
894 cout << "orbit_of_subspaces::find_subspace_lint "
895 "not found" << endl;
896 }
897 }
898 if (f_v) {
899 cout << "orbit_of_subspaces::find_subspace_lint done" << endl;
900 }
901 return f_found;
902}
903
905 int *Elt, int verbose_level)
906{
907 int f_v = (verbose_level >= 1);
908 int f_vv = FALSE; //(verbose_level >= 2);
909 int len, r1, r2, pt1, pt2;
910 int *E1, *E2, *E3, *E4, *E5;
911 int f_found, idx;
912 uint32_t h;
913 //int *cur_basis;
914 //int *new_basis;
916
917 if (f_v) {
918 cout << "orbit_of_subspaces::get_random_schreier_generator" << endl;
919 }
925 //cur_basis = NEW_int(sz);
926 //new_basis = NEW_int(sz);
927 len = used_length;
929
930 // get a random coset:
931 r1 = Os.random_integer(len);
932 get_transporter(r1, E1, 0);
933
934 // get a random generator:
935 r2 = Os.random_integer(gens->len);
936 if (f_vv) {
937 cout << "r2=" << r2 << endl;
938 }
939 if (f_vv) {
940 cout << "random coset " << r1 << ", random generator " << r2 << endl;
941 }
942
943 A->element_mult(E1, gens->ith(r2), E2, 0);
944
945 // compute image of original subspace under E2:
946 unrank_subspace(pt1, Mtx1, verbose_level - 1);
947 //int_vec_copy(Subspaces[pt1], cur_basis, sz);
948
949 map_a_subspace(Mtx1, Mtx2, E2, 0 /* verbose_level*/);
950
951 rref(Mtx2, verbose_level - 1);
952
953 f_found = rank_hash_and_find(Mtx2, idx, h, verbose_level - 1);
954
955 if (!f_found) {
956 cout << "orbit_of_subspaces::get_random_schreier_generator "
957 "image space is not found in the orbit" << endl;
958 exit(1);
959 }
960 pt2 = idx;
961
962 get_transporter(pt2, E3, 0);
963 A->element_invert(E3, E4, 0);
964 A->element_mult(E2, E4, E5, 0);
965
966#if 0
967 // test:
968 int pt3;
969 map_a_subspace(cur_basis, new_basis, E5, 0 /* verbose_level*/);
970 if (search_data(new_basis, pt3)) {
971 //if (vec_search((void **)Subspaces,
972 //orbit_of_subspaces_compare_func, (void *) (sz_for_compare),
973 // used_length, new_basis, pt3, 0 /* verbose_level */)) {
974 if (f_vv) {
975 cout << "testing: n e w subspace is at position " << pt3 << endl;
976 }
977 }
978 else {
979 cout << "orbit_of_subspaces::get_random_schreier_generator "
980 "(testing) image space is not found in the orbit" << endl;
981 exit(1);
982 }
983
985 cout << "orbit_of_subspaces::get_random_schreier_generator "
986 "pt3 != position_of_original_subspace" << endl;
987 exit(1);
988 }
989#endif
990
991
992 A->element_move(E5, Elt, 0);
993
994
995 FREE_int(E1);
996 FREE_int(E2);
997 FREE_int(E3);
998 FREE_int(E4);
999 FREE_int(E5);
1000 //FREE_int(cur_basis);
1001 //FREE_int(new_basis);
1002 if (f_v) {
1003 cout << "orbit_of_subspaces::get_random_schreier_generator "
1004 "done" << endl;
1005 }
1006}
1007
1010 ring_theory::longinteger_object &full_group_order,
1011 int verbose_level)
1012{
1013 int f_v = (verbose_level >= 1);
1015 groups::sims *Stab;
1016
1017 if (f_v) {
1018 cout << "orbit_of_subspaces::generators_for_stabilizer_"
1019 "of_orbit_rep" << endl;
1020 }
1021
1022 compute_stabilizer(A /* default_action */, full_group_order,
1023 Stab, 0 /*verbose_level*/);
1024
1026
1027 Stab->group_order(stab_order);
1028 if (f_v) {
1029 cout << "orbit_of_subspaces::generators_for_stabilizer_of_"
1030 "orbit_rep found a stabilizer group of order "
1031 << stab_order << endl;
1032 }
1033
1035 gens->init(A);
1036 gens->init_from_sims(Stab, verbose_level);
1037
1038 FREE_OBJECT(Stab);
1039 if (f_v) {
1040 cout << "orbit_of_subspaces::generators_for_stabilizer_of_"
1041 "orbit_rep done" << endl;
1042 }
1043 return gens;
1044}
1045
1047 actions::action *default_action,
1049 groups::sims *&Stab, int verbose_level)
1050// this function allocates a sims structure into Stab.
1051{
1052 int f_v = (verbose_level >= 1);
1053 int f_vv = (verbose_level >= 2);
1054 int f_vvv = (verbose_level >= 3);
1055 int f_v4 = (verbose_level >= 4);
1056
1057
1058 if (f_v) {
1059 cout << "orbit_of_subspaces::compute_stabilizer" << endl;
1060 }
1061
1062 Stab = NEW_OBJECT(groups::sims);
1063 ring_theory::longinteger_object cur_go, target_go;
1065 int len, r, cnt = 0, f_added, drop_out_level, image;
1066 int *residue;
1067 int *E1;
1068
1069
1070 if (f_v) {
1071 cout << "orbit_of_subspaces::compute_stabilizer computing "
1072 "stabilizer inside a group of order " << go
1073 << " in action ";
1074 default_action->print_info();
1075 cout << endl;
1076 }
1077 E1 = NEW_int(default_action->elt_size_in_int);
1078 residue = NEW_int(default_action->elt_size_in_int);
1079 len = used_length;
1080 D.integral_division_by_int(go, len, target_go, r);
1081 if (r) {
1082 cout << "orbit_of_subspaces::compute_stabilizer orbit length "
1083 "does not divide group order" << endl;
1084 exit(1);
1085 }
1086 if (f_vv) {
1087 cout << "orbit_of_subspaces::compute_stabilizer expecting group "
1088 "of order " << target_go << endl;
1089 }
1090
1091 Stab->init(default_action, verbose_level - 2);
1092 Stab->init_trivial_group(verbose_level - 1);
1093 while (TRUE) {
1094 Stab->group_order(cur_go);
1095 if (D.compare(cur_go, target_go) == 0) {
1096 break;
1097 }
1098 if (cnt % 2 || Stab->nb_gen[0] == 0) {
1099 get_random_schreier_generator(E1, 0 /* verbose_level */);
1100 if (f_vvv) {
1101 cout << "orbit_of_subspaces::compute_stabilizer created "
1102 "random Schreier generator" << endl;
1103 //default_action->element_print(E1, cout);
1104 }
1105 }
1106 else {
1107 Stab->random_schreier_generator(E1, 0 /* verbose_level */);
1108 //A->element_move(Stab->schreier_gen, E1, 0);
1109 if (f_v4) {
1110 cout << "orbit_of_subspaces::compute_stabilizer created "
1111 "random schreier generator from sims" << endl;
1112 //default_action->element_print(E1, cout);
1113 }
1114 }
1115
1116
1117
1118 if (Stab->strip(E1, residue, drop_out_level, image,
1119 0 /*verbose_level - 3*/)) {
1120 if (f_vvv) {
1121 cout << "orbit_of_subspaces::compute_stabilizer "
1122 "element strips through" << endl;
1123 if (FALSE) {
1124 cout << "residue:" << endl;
1125 A->element_print(residue, cout);
1126 cout << endl;
1127 }
1128 }
1129 f_added = FALSE;
1130 }
1131 else {
1132 f_added = TRUE;
1133 if (f_vvv) {
1134 cout << "orbit_of_subspaces::compute_stabilizer "
1135 "element needs to be inserted at level = "
1136 << drop_out_level << " with image " << image << endl;
1137 if (FALSE) {
1138 A->element_print(residue, cout);
1139 cout << endl;
1140 }
1141 }
1142 Stab->add_generator_at_level(residue, drop_out_level,
1143 verbose_level - 4);
1144 }
1145 Stab->group_order(cur_go);
1146 if ((f_vv && f_added) || f_vvv) {
1147 cout << "iteration " << cnt
1148 << " the n e w group order is " << cur_go
1149 << " expecting a group of order " << target_go << endl;
1150 }
1151 cnt++;
1152 }
1153 FREE_int(E1);
1154 FREE_int(residue);
1155 if (f_v) {
1156 cout << "orbit_of_subspaces::compute_stabilizer finished" << endl;
1157 }
1158}
1159
1160
1161
1162}}
1163
1164
1165
a catch-all container class for everything related to data structures
a collection of functions related to sorted vectors
int lint_vec_compare(long int *p, long int *q, int len)
Definition: sorting.cpp:2326
int Gauss_int_with_given_pivots(int *A, int f_special, int f_complete, int *pivots, int nb_pivots, int m, int n, int verbose_level)
domain to compute with objects of type longinteger
Definition: ring_theory.h:240
int compare(longinteger_object &a, longinteger_object &b)
void integral_division_by_int(longinteger_object &a, int b, longinteger_object &q, int &r)
a class to represent arbitrary precision integers
Definition: ring_theory.h:366
a permutation group in a fixed action.
Definition: actions.h:99
void element_print(void *elt, std::ostream &ost)
Definition: action_cb.cpp:347
void element_mult(void *a, void *b, void *ab, int verbose_level)
Definition: action_cb.cpp:315
void element_invert(void *a, void *av, int verbose_level)
Definition: action_cb.cpp:322
void element_one(void *elt, int verbose_level)
Definition: action_cb.cpp:224
void element_move(void *a, void *b, int verbose_level)
Definition: action_cb.cpp:335
void init(actions::action *A, int verbose_level)
Definition: vector_ge.cpp:55
a permutation group represented via a stabilizer chain
Definition: groups.h:1273
void init(actions::action *A, int verbose_level)
Definition: sims.cpp:289
void group_order(ring_theory::longinteger_object &go)
Definition: sims.cpp:951
void init_trivial_group(int verbose_level)
Definition: sims.cpp:584
void add_generator_at_level(int *elt, int lvl, int verbose_level)
Definition: sims_main.cpp:543
void random_schreier_generator(int *Elt, int verbose_level)
Definition: sims.cpp:1803
int strip(int *elt, int *residue, int &drop_out_level, int &image, int verbose_level)
Definition: sims_main.cpp:433
a strong generating set for a permutation group with respect to a fixed action
Definition: groups.h:1703
void(* unrank_vector_lint_callback)(long int rk, int *v, int n, void *data, int verbose_level)
Definition: orbits.h:204
void(* unrank_vector_callback)(int rk, int *v, int n, void *data, int verbose_level)
Definition: orbits.h:202
long int(* rank_vector_lint_callback)(int *v, int n, void *data, int verbose_level)
Definition: orbits.h:200
int find_subspace(int *subspace_ranks, int &idx, int verbose_level)
void rank_subspace(int *subspace_basis, int verbose_level)
void init_lint(actions::action *A, actions::action *A2, field_theory::finite_field *F, long int *subspace_by_rank, int k, int n, int f_has_desired_pivots, int *desired_pivots, int f_has_rank_functions, void *rank_unrank_data, long int(*rank_vector_lint_callback)(int *v, int n, void *data, int verbose_level), void(*unrank_vector_lint_callback)(long int rk, int *v, int n, void *data, int verbose_level), void(*compute_image_of_vector_callback)(int *v, int *w, int *Elt, void *data, int verbose_level), void *compute_image_of_vector_callback_data, data_structures_groups::vector_ge *gens, int verbose_level)
int(* rank_vector_callback)(int *v, int n, void *data, int verbose_level)
Definition: orbits.h:198
groups::strong_generators * stabilizer_orbit_rep(ring_theory::longinteger_object &full_group_order, int verbose_level)
int find_subspace_lint(long int *subspace_ranks, int &idx, int verbose_level)
void unrank_subspace(int subspace_idx, int *subspace_basis, int verbose_level)
void rank(int *rk, int *subspace_basis, int verbose_level)
void unrank_lint(long int *rk, int *subspace_basis, int verbose_level)
void(* compute_image_of_vector_callback)(int *v, int *w, int *Elt, void *data, int verbose_level)
Definition: orbits.h:206
void compute_stabilizer(actions::action *default_action, ring_theory::longinteger_object &go, groups::sims *&Stab, int verbose_level)
void init(actions::action *A, actions::action *A2, field_theory::finite_field *F, int *subspace, int k, int n, int f_has_desired_pivots, int *desired_pivots, int f_has_rank_functions, void *rank_unrank_data, int(*rank_vector_callback)(int *v, int n, void *data, int verbose_level), void(*unrank_vector_callback)(int rk, int *v, int n, void *data, int verbose_level), void(*compute_image_of_vector_callback)(int *v, int *w, int *Elt, void *data, int verbose_level), void *compute_image_of_vector_callback_data, data_structures_groups::vector_ge *gens, int verbose_level)
void unrank(int *rk, int *subspace_basis, int verbose_level)
int rank_hash_and_find(int *subspace, int &idx, uint32_t &h, int verbose_level)
void rref_and_rank(int *subspace, int *rk, int verbose_level)
void map_a_subspace(int *basis, int *image_basis, int *Elt, int verbose_level)
void get_transporter(int idx, int *transporter, int verbose_level)
void get_random_schreier_generator(int *Elt, int verbose_level)
void unrank_vector(int rk, int *v, int verbose_level)
void rank_lint(long int *rk, int *subspace_basis, int verbose_level)
void rref_and_rank_lint(int *subspace, long int *rk, int verbose_level)
std::multimap< uint32_t, int > Hashing
Definition: orbits.h:219
void unrank_vector_lint(long int rk, int *v, int verbose_level)
data_structures_groups::vector_ge * gens
Definition: orbits.h:180
long int rank_vector_lint(int *v, int verbose_level)
void rref(int *subspace, int verbose_level)
#define Lint_vec_copy(A, B, C)
Definition: foundations.h:694
#define NEW_plint(n)
Definition: foundations.h:629
#define FREE_int(p)
Definition: foundations.h:640
#define NEW_pint(n)
Definition: foundations.h:627
#define FREE_plint(p)
Definition: foundations.h:643
#define NEW_OBJECT(type)
Definition: foundations.h:638
#define Lint_vec_print(A, B, C)
Definition: foundations.h:686
#define FREE_OBJECT(p)
Definition: foundations.h:651
#define NEW_int(n)
Definition: foundations.h:625
#define Int_matrix_print(A, B, C)
Definition: foundations.h:707
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define Int_vec_copy(A, B, C)
Definition: foundations.h:693
#define FREE_lint(p)
Definition: foundations.h:642
#define NEW_lint(n)
Definition: foundations.h:628
#define FREE_pint(p)
Definition: foundations.h:641
#define Int_vec_print(A, B, C)
Definition: foundations.h:685
the orbiter library for the classification of combinatorial objects