Orbiter 2022
Combinatorial Objects
permutation_representation_domain.cpp
Go to the documentation of this file.
1// permutation_representation_domain.cpp
2//
3// Anton Betten
4//
5// started: May 25, 2006
6
7
8
9
11#include "group_actions.h"
12
13using namespace std;
14
15
16
17namespace orbiter {
18namespace layer3_group_actions {
19namespace groups {
20
21
23{
24 null();
25}
26
28{
29 free();
30}
31
33{
34 Elt1 = NULL;
35 Elt2 = NULL;
36 Elt3 = NULL;
37 Elt4 = NULL;
38 elt1 = NULL;
39 elt2 = NULL;
40 elt3 = NULL;
41 Elts = NULL;
42 Eltrk1 = NULL;
43 Eltrk2 = NULL;
44 Eltrk3 = NULL;
45}
46
48{
49 //cout << "permutation_representation_domain::free" << endl;
50 if (Elt1)
52 if (Elt2)
54 if (Elt3)
56 if (Elt4)
58 //cout << "permutation_representation_domain::free before elt1" << endl;
59 if (elt1)
61 if (elt2)
63 if (elt3)
65 //cout << "permutation_representation_domain::free before Elts" << endl;
66 if (Elts) {
68 }
69 if (Eltrk1)
71 if (Eltrk2)
73 if (Eltrk3)
75 null();
76 //cout << "permutation_representation_domain::free finished" << endl;
77}
78
80{
91
93}
94
96 int page_length_log, int verbose_level)
97{
98 int f_v = (verbose_level >= 1);
99 //int f_vv = (verbose_level >= 2);
100
101 if (f_v) {
102 cout << "permutation_representation_domain::init_product_action "
103 "m=" << m << " n=" << n << endl;
104 }
108 mn = m * n;
109 offset = m + n;
110
111 degree = m + n + m * n;
112 elt_size_int = m + n;
114
115 init_data(page_length_log, verbose_level);
116 if (f_v) {
117 cout << "permutation_representation_domain::init_product_action done" << endl;
118 }
119}
120
121
123 int page_length_log, int verbose_level)
124{
125 int f_v = (verbose_level >= 1);
126 //int f_vv = (verbose_level >= 2);
127
128 if (f_v) {
129 cout << "permutation_representation_domain::init" << endl;
130 }
133
135 char_per_elt = elt_size_int * sizeof(int);
136
137 init_data(page_length_log, verbose_level);
138 if (f_v) {
139 cout << "permutation_representation_domain::init done" << endl;
140 }
141}
142
143void permutation_representation_domain::init_data(int page_length_log, int verbose_level)
144{
145 int f_v = (verbose_level >= 1);
146 int f_vv = (verbose_level >= 2);
147 int hdl;
148
149 if (f_v) {
150 cout << "permutation_representation_domain::init_data" << endl;
151 cout << "degree=" << degree << endl;
152 cout << "elt_size_int=" << elt_size_int << endl;
153 cout << "page_length_log=" << page_length_log << endl;
154 //cout << "base_len=" << A.base_len << endl;
155 }
156
157 allocate();
158
159 int *tmp1 = NEW_int(elt_size_int);
160 int *tmp2 = NEW_int(elt_size_int);
161 int *tmp3 = NEW_int(elt_size_int);
162
163
164
165 if (f_vv) {
166 cout << "permutation_representation_domain::init_data "
167 "calling Elts->init()" << endl;
168 }
169 Elts->init(char_per_elt /* entry_size */,
170 page_length_log, verbose_level - 2);
171 //Elts->add_elt_print_function(perm_group_elt_print, (void *) this);
172
173
174 if (f_vv) {
175 cout << "permutation_representation_domain::init_data "
176 "calling one()" << endl;
177 }
178 one(tmp1);
179 //print(tmp1, cout);
180 pack(tmp1, elt1);
181 if (f_vv) {
182 cout << "permutation_representation_domain::init_data "
183 "calling Elts->store()" << endl;
184 }
185 hdl = Elts->store(elt1);
186 if (f_vv) {
187 cout << "identity element stored, "
188 "hdl = " << hdl << endl;
189 }
190
191
192 if (f_vv) {
193 cout << "permutation_representation_domain::init_data "
194 "finished" << endl;
195 }
196
197 FREE_int(tmp1);
198 FREE_int(tmp2);
199 FREE_int(tmp3);
200}
201
203 int base_length, int *base, int page_length_log,
204 actions::action &A, int verbose_level)
205{
206 int f_v = (verbose_level >= 1);
207 int f_vv = (verbose_level >= 2);
208 int i, hdl;
209
212
213 //A.base_len = base_length;
214 A.degree = degree;
217
218
219 allocate();
220
221 int *tmp1 = NEW_int(elt_size_int);
222 int *tmp2 = NEW_int(elt_size_int);
223 int *tmp3 = NEW_int(elt_size_int);
224
225
226
227 if (f_v) {
228 cout << "permutation_representation_domain::init" << endl;
229 cout << "degree=" << A.degree << endl;
230 cout << "base_len=" << base_length << endl;
231 }
232 if (f_vv) {
233 cout << "perm_group::init "
234 "calling Elts->init" << endl;
235 }
236 Elts->init(char_per_elt /* entry_size */,
237 page_length_log, verbose_level - 2);
238 //Elts->add_elt_print_function(
239 //perm_group_elt_print, (void *) this);
240
241
242 if (f_vv) {
243 cout << "permutation_representation_domain::init "
244 "calling one()" << endl;
245 }
246 one(tmp1);
247 //print(tmp1, cout);
248 pack(tmp1, elt1);
249 if (f_vv) {
250 cout << "permutation_representation_domain::init "
251 "calling Elts->store" << endl;
252 }
253 hdl = Elts->store(elt1);
254 if (f_vv) {
255 cout << "identity element stored, "
256 "hdl = " << hdl << endl;
257 }
258
259 if (f_vv) {
260 cout << "permutation_representation_domain::init "
261 "initializing base, and transversal_length" << endl;
262 }
264 A.G.perm_grp = this;
265
267 A.Stabilizer_chain->allocate_base_data(&A, base_length, verbose_level);
268 //A.Stabilizer_chain->base_len = base_length;
269 //A.allocate_base_data(A.base_len);
270
271 // init base:
272 for (i = 0; i < A.base_len(); i++) {
273 A.base_i(i) = base[i];
274 }
275
276
277 if (f_v) {
278 cout << "base: ";
279 Lint_vec_print(cout, A.get_base(), A.base_len());
280 cout << endl;
281 //cout << "transversal_length: ";
282 //print_set(cout, A.base_len, A.transversal_length);
283 //cout << endl;
284 }
285
288
291
293
294 char str1[1000];
295 char str2[1000];
296
297 sprintf(str1, "Sym%d", degree);
298 sprintf(str2, "{\\rm Sym}_{%d}", degree);
299 A.label.assign(str1);
300 A.label_tex.assign(str2);
301
302 if (f_vv) {
303 cout << "permutation_representation_domain::init finished" << endl;
304 }
305
306 FREE_int(tmp1);
307 FREE_int(tmp2);
308 FREE_int(tmp3);
309}
310
312 int *Elt, int verbose_level)
313{
314 int j1, j2;
315
316 one(Elt);
317 j1 = i;
318 j2 = i + j;
319 Elt[j1] = j2;
320 Elt[j2] = j1;
321}
322
324{
325 int i;
326
327 for (i = 0; i < degree; i++) {
328 Elt[i] = i;
329 }
330}
331
333{
334 int i;
335
336 for (i = 0; i < degree; i++) {
337 if (Elt[i] != i) {
338 return FALSE;
339 }
340 }
341 return TRUE;
342}
343
344void permutation_representation_domain::mult(int *A, int *B, int *AB)
345{
347
348 //cout << "in perm_group::mult()" << endl;
349 Combi.perm_mult(A, B, AB, degree);
350 //cout << "in perm_group::mult()
351 // finished with perm_mult" << endl;
352}
353
355{
356 int i;
357
358 for (i = 0; i < degree; i++) {
359 B[i] = A[i];
360 }
361}
362
364{
366
367 Combi.perm_inverse(A, Ainv, degree);
368}
369
371{
372 int i, j;
373
374 for (i = 0; i < degree; i++) {
375 uchar *p;
376
377 p = (uchar *)(Elt + i);
378 for (j = 0; j < (int) sizeof(int); j++) {
379 *p++ = *elt++;
380 }
381 }
382}
383
385{
386 int i, j;
387
388 for (i = 0; i < degree; i++) {
389 uchar *p;
390
391 p = (uchar *)(Elt + i);
392 for (j = 0; j < (int) sizeof(int); j++) {
393 *elt++ = *p++;
394 }
395 }
396}
397
399{
401
402 //cout << "perm_group::print before perm_print" << endl;
403 Combi.perm_print(ost, Elt, degree);
404 //ost << endl;
405 //cout << "perm_group::print done" << endl;
406}
407
409 ostream &ost,
410 void (*point_label)(std::stringstream &sstr, long int pt, void *data),
411 void *point_label_data)
412{
414
415 //cout << "perm_group::print before perm_print" << endl;
416 Combi.perm_print_with_print_point_function(ost, Elt, degree, point_label, point_label_data);
417 //ost << endl;
418 //cout << "perm_group::print done" << endl;
419}
420
422{
423 Int_vec_copy(Elt, data, degree);
424}
425
427{
428 int i;
429
430 for (i = 0; i < degree; i++) {
431 ost << Elt[i] << ", ";
432 }
433}
434
436 int *Elt, ostream &ost)
437{
438 int i;
439
440 for (i = 0; i < degree; i++) {
441 ost << Elt[i] << " ";
442 }
443}
444
446{
447 //perm_print(ost, Elt, degree);
448 //ost << endl;
449 int i, bi, a;
450 int x1, y1, x2, y2; // if in product action
452
453 if (A->base_len() < A->degree) {
454 for (i = 0; i < A->base_len(); i++) {
455 bi = A->base_i(i);
456 a = Elt[bi];
457 if (f_product_action) {
458 cout << "bi=" << bi << "a=" << a << endl;
459 if (bi < m) {
460 ost << "(x=" << bi << ") -> (x=" << a << ")" << endl;
461 }
462 else if (bi < m + n) {
463 ost << "(y=" << bi - m
464 << ") -> (y=" << a - m << ")" << endl;
465 }
466 else {
467 bi -= m + n;
468 a -= m + n;
469 x1 = bi / n;
470 y1 = bi % n;
471 x2 = a / n;
472 y2 = a % n;
473 ost << bi << "=(" << x1 << "," << y1 << ")"
474 << " -> "
475 << a << "=(" << x2 << "," << y2 << ")";
476 }
477 }
478 else {
479 ost << bi << " -> " << a;
480 }
481 if (i < A->base_len() - 1) {
482 ost << ", ";
483 }
484 }
485 }
486 //perm_print(ost, Elt, degree);
487 ost << " : ";
488 Combi.perm_print_offset(ost, Elt, degree, 0 /* offset */,
489 FALSE /* f_print_cycles_of_length_one */,
490 FALSE /* f_cycle_length */, FALSE, 0,
491 FALSE /* f_orbit_structure */,
492 NULL, NULL);
493 ost << " : ";
494 Combi.perm_print_list_offset(ost, Elt, degree, 1);
495 ost << endl;
496}
497
498void permutation_representation_domain::make_element(int *Elt, int *data, int verbose_level)
499{
500 int f_v = (verbose_level >= 1);
501 int f_vv = (verbose_level >= 2);
502 int i, a;
503 int *my_data;
505
506
507 if (f_v) {
508 cout << "permutation_representation_domain::make_element" << endl;
509 }
510 if (f_vv) {
511 cout << "data: ";
512 Int_vec_print(cout, data, elt_size_int);
513 cout << endl;
514 }
515
516 my_data = NEW_int(elt_size_int);
517
518 for (i = 0; i < elt_size_int; i++) {
519 a = data[i];
520 my_data[i] = a;
521 Elt[i] = a;
522 }
523
524 if (!Combi.is_permutation(my_data, elt_size_int)) {
525 cout << "permutation_representation_domain::make_element "
526 "The input is not a permutation" << endl;
527 exit(1);
528 }
529
530 FREE_int(my_data);
531
532 if (f_v) {
533 cout << "permutation_representation_domain::make_element done" << endl;
534 }
535}
536
537
538}}}
539
void perm_print_with_print_point_function(std::ostream &ost, int *a, int n, void(*point_label)(std::stringstream &sstr, long int pt, void *data), void *point_label_data)
void perm_print_offset(std::ostream &ost, int *a, int n, int offset, int f_print_cycles_of_length_one, int f_cycle_length, int f_max_cycle_length, int max_cycle_length, int f_orbit_structure, void(*point_label)(std::stringstream &sstr, long int pt, void *data), void *point_label_data)
void perm_print_list_offset(std::ostream &ost, int *a, int n, int offset)
bulk storage of group elements in compressed form
void init(int entry_size, int page_length_log, int verbose_level)
interface to the implementation functions for group actions
Definition: actions.h:1081
a permutation group in a fixed action.
Definition: actions.h:99
stabilizer_chain_base_data * Stabilizer_chain
Definition: actions.h:178
the transversals in the stabilizer subgroup chain (Sims chain)
Definition: actions.h:1214
void init_product_action(int m, int n, int page_length_log, int verbose_level)
void init_with_base(int degree, int base_length, int *base, int page_length_log, actions::action &A, int verbose_level)
void print_with_print_point_function(int *Elt, std::ostream &ost, void(*point_label)(std::stringstream &sstr, long int pt, void *data), void *point_label_data)
#define NEW_uchar(n)
Definition: foundations.h:634
#define FREE_uchar(p)
Definition: foundations.h:647
#define FREE_int(p)
Definition: foundations.h:640
unsigned char uchar
Definition: foundations.h:204
#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 TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define Int_vec_copy(A, B, C)
Definition: foundations.h:693
#define Int_vec_print(A, B, C)
Definition: foundations.h:685
the orbiter library for the classification of combinatorial objects
groups::permutation_representation_domain * perm_grp