Orbiter 2022
Combinatorial Objects
union_find_on_k_subsets.cpp
Go to the documentation of this file.
1// union_find_on_k_subsets.cpp
2//
3// Anton Betten
4// February 2, 2010
5
7#include "group_actions.h"
8
9
10using namespace std;
11
12
13namespace orbiter {
14namespace layer3_group_actions {
15namespace data_structures_groups {
16
17
19{
20 null();
21}
22
24{
25 freeself();
26}
27
29{
30 if (Ar) {
32 }
33 if (Ar_perm) {
35 }
36 if (Ark) {
38 }
39 if (Arkr) {
41 }
42 if (gens_perm) {
44 }
45 if (UF) {
47 }
48 null();
49}
50
52{
53 set = NULL;
55 A_original = NULL;
56 Ar = NULL;
57 Ar_perm = NULL;
58 Ark = NULL;
59 Arkr = NULL;
60 gens_perm = NULL;
61 UF = NULL;
62
63}
64
66 actions::action *A_original, groups::sims *S,
67 long int *set, int set_sz, int k,
68 long int *interesting_k_subsets,
69 int nb_interesting_k_subsets,
70 int verbose_level)
71{
72 int f_v = (verbose_level >= 1);
73 int f_vv = (verbose_level >= 2);
75 int i, j, h, len;
76 int *data1;
77 int *data2;
78 int *Elt1;
79
80
81 if (f_v) {
82 cout << "union_find_on_k_subsets::init k=" << k << endl;
83 }
92
97
98
99 if (f_v) {
100 cout << "union_find_on_k_subsets::init "
101 "before induced_action_by_restriction" << endl;
102 }
104 S, set_sz, set, TRUE, 0/*verbose_level*/);
105 //action *create_induced_action_by_restriction(
106 // sims *S, int size, int *set, int f_induce,
107 // int verbose_level);
108#if 0
109 Ar->induced_action_by_restriction(*A_original,
110 TRUE, S, set_sz, set, 0/*verbose_level*/);
111#endif
112 if (f_v) {
113 cout << "union_find_on_k_subsets::init "
114 "after induced_action_by_restriction" << endl;
115 }
116 Ar->group_order(go);
117 Ar->Kernel->group_order(K_go);
118 if (f_v) {
119 cout << "union_find_on_k_subsets::init "
120 "induced action by restriction: "
121 "group order = " << go << endl;
122 cout << "union_find_on_k_subsets::init "
123 "kernel group order = " << K_go << endl;
124 }
125
126 if (f_vv) {
127 cout << "union_find_on_k_subsets::init "
128 "induced action:" << endl;
129 //Ar->Sims->print_generators();
130 //Ar->Sims->print_generators_as_permutations();
131 //Ar->Sims->print_basic_orbits();
132
134 Ar->Sims->group_order(go);
135 cout << "union_find_on_k_subsets::init "
136 "Ar->Sims go=" << go << endl;
137
138 //cout << "induced action, in the original action:" << endl;
139 //AA->Sims->print_generators_as_permutations_override_action(A);
140 }
141
142 //cout << "kernel:" << endl;
143 //K->print_generators();
144 //K->print_generators_as_permutations();
145
146 if (f_v) {
147 cout << "union_find_on_k_subsets::init "
148 "before init_permutation_group" << endl;
149 }
150
151 int f_no_base = FALSE;
152
153 Ar_perm->init_permutation_group(set_sz, f_no_base, 0/*verbose_level*/);
154 if (f_v) {
155 cout << "Ar_perm:" << endl;
157 }
158
159 if (f_v) {
160 cout << "union_find_on_k_subsets::init "
161 "before induced_action_on_k_subsets" << endl;
162 }
163 Ark->induced_action_on_k_subsets(*Ar_perm, k, 0/*verbose_level*/);
164 if (f_v) {
165 cout << "union_find_on_k_subsets::init Ar_on_k_subsets:" << endl;
166 Ark->print_info();
167 }
168
169 if (f_v) {
170 cout << "union_find_on_k_subsets::init "
171 "before induced_action_by_restriction, "
172 "creating Arkr" << endl;
173 }
176 FALSE, 0/*verbose_level*/);
177#if 0
178 Arkr->induced_action_by_restriction(*Ark, FALSE, NULL,
180 0/*verbose_level*/);
181#endif
182 if (f_v) {
183 cout << "union_find_on_k_subsets::init after "
184 "induced_action_by_restriction, Arkr "
185 "has been created" << endl;
186 }
187
188
189 if (f_v) {
190 cout << "union_find_on_k_subsets::init "
191 "creating gens_perm" << endl;
192 }
193
194 if (Ar->Strong_gens == NULL) {
195 cout << "Ar->Strong_gens == NULL" << endl;
196 exit(1);
197 }
198
199 vector_ge *gens = Ar->Strong_gens->gens;
200
201 len = gens->len;
203
204 gens_perm->init(Ar_perm, verbose_level - 2);
205 gens_perm->allocate(len, verbose_level - 2);
206
207 data1 = NEW_int(set_sz);
208 data2 = NEW_int(set_sz);
210
211 for (h = 0; h < len; h++) {
212 if (FALSE /*f_v*/) {
213 cout << "union_find_on_k_subsets::init "
214 "generator " << h << " / " << len << ":" << endl;
215 }
216 for (i = 0; i < set_sz; i++) {
217 j = Ar->image_of(gens->ith(h), i);
218 data1[i] = j;
219 }
220 if (FALSE /*f_v*/) {
221 cout << "union_find_on_k_subsets::init permutation: ";
222 Int_vec_print(cout, data1, set_sz);
223 cout << endl;
224 }
225 Ar_perm->make_element(Elt1, data1, 0 /* verbose_level */);
226 Ar_perm->element_move(Elt1,
227 gens_perm->ith(h), 0 /* verbose_level */);
228 }
229 if (f_v) {
230 cout << "union_find_on_k_subsets::init "
231 "created gens_perm" << endl;
232 }
233
235 UF->init(Arkr, verbose_level);
236 if (f_v) {
237 cout << "union_find_on_k_subsets::init "
238 "after UF->init" << endl;
239 }
240 UF->add_generators(gens_perm, 0 /* verbose_level */);
241 if (f_v) {
242 cout << "union_find_on_k_subsets::init "
243 "after UF->add_generators" << endl;
244 }
245 if (f_v) {
246 int nb, N;
247 double f;
248 nb = UF->count_ancestors();
249 N = Arkr->degree;
250 f = ((double)nb / (double)N) * 100;
251 cout << "union_find_on_k_subsets::init number of "
252 "ancestors = " << nb << " / " << N << " ("
253 << f << "%)" << endl;
254 }
255 if (f_v) {
256 cout << "union_find_on_k_subsets::init finished" << endl;
257 }
258
259 FREE_int(data1);
260 FREE_int(data2);
261 FREE_int(Elt1);
262
263
264 if (f_v) {
265 cout << "union_find_on_k_subsets::init done" << endl;
266 }
267}
268
269
270int union_find_on_k_subsets::is_minimal(int rk, int verbose_level)
271{
272 int rk0;
273
274 rk0 = UF->ancestor(rk);
275 if (rk0 == rk) {
276 return TRUE;
277 }
278 else {
279 return FALSE;
280 }
281}
282
283
284}}}
285
a class to represent arbitrary precision integers
Definition: ring_theory.h:366
a permutation group in a fixed action.
Definition: actions.h:99
groups::strong_generators * Strong_gens
Definition: actions.h:130
void make_element(int *Elt, int *data, int verbose_level)
Definition: action.cpp:1875
void induced_action_on_k_subsets(action &old_action, int k, int verbose_level)
void element_move(void *a, void *b, int verbose_level)
Definition: action_cb.cpp:335
void init_permutation_group(int degree, int f_no_base, int verbose_level)
void group_order(ring_theory::longinteger_object &go)
Definition: action.cpp:2223
action * create_induced_action_by_restriction(groups::sims *S, int size, long int *set, int f_induce, int verbose_level)
void init(actions::action *A_original, groups::sims *S, long int *set, int set_sz, int k, long int *interesting_k_subsets, int nb_interesting_k_subsets, int verbose_level)
a union find data structure (used in the poset classification algorithm)
void init(actions::action *A, int verbose_level)
Definition: union_find.cpp:41
void add_generators(vector_ge *gens, int verbose_level)
Definition: union_find.cpp:123
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 group_order(ring_theory::longinteger_object &go)
Definition: sims.cpp:951
data_structures_groups::vector_ge * gens
Definition: groups.h:1708
#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 Int_vec_print(A, B, C)
Definition: foundations.h:685
the orbiter library for the classification of combinatorial objects