Orbiter 2022
Combinatorial Objects
classification_step.cpp
Go to the documentation of this file.
1// classification.cpp
2//
3// Anton Betten
4// September 23, 2017
5//
6//
7//
8//
9//
10
12#include "discreta/discreta.h"
15
16using namespace std;
17
18namespace orbiter {
19namespace layer4_classification {
20namespace invariant_relations {
21
23{
24 A = NULL;
25 A2 = NULL;
26 //f_lint = FALSE;
27 max_orbits = 0;
28 nb_orbits = 0;
29 Orbit = NULL;
31 Rep = NULL;
32 //Rep_lint = NULL;
33 //null();
34}
35
37{
38 freeself();
39}
40
42{
43}
44
46{
47 if (Orbit) {
49 }
50 if (Rep) {
52 }
53 null();
54}
55
57 int max_orbits, int representation_sz,
58 ring_theory::longinteger_object &go, int verbose_level)
59{
60 int f_v = (verbose_level >= 1);
61
62 if (f_v) {
63 cout << "classification_step::init "
64 "group order = " << go
65 << " representation_sz = " << representation_sz
66 << " max_orbits = " << max_orbits << endl;
67 }
70 //f_lint = FALSE;
76 if (f_v) {
77 cout << "classification_step::init done" << endl;
78 }
79}
80
82 int orbit_index, int verbose_level)
83{
84 int f_v = (verbose_level >= 1);
86 long int *data;
87 groups::strong_generators *Strong_gens;
88
89 if (f_v) {
90 cout << "classification_step::get_set_and_stabilizer" << endl;
91 }
92
94
97 Rep_ith(orbit_index),
98 data, representation_sz);
99
100 if (f_v) {
101 cout << "classification_step::get_set_and_stabilizer "
102 "before Orbit[orbit_index].gens->create_copy" << endl;
103 }
104
105 Strong_gens = Orbit[orbit_index].gens->create_copy();
106
107 if (f_v) {
108 cout << "classification_step::get_set_and_stabilizer "
109 "before SaS->init_everything" << endl;
110 }
111
112 SaS->init_everything(
113 A, A2, data, representation_sz,
114 Strong_gens, 0 /* verbose_level */);
115
116 if (f_v) {
117 cout << "classification_step::get_set_and_stabilizer done" << endl;
118 }
119
120 return SaS;
121}
122
123
124void classification_step::write_file(ofstream &fp, int verbose_level)
125{
126 int f_v = (verbose_level >= 1);
127 int f_vv = FALSE; //(verbose_level >= 1);
128 int i;
129
130 if (f_v) {
131 cout << "classification_step::write_file" << endl;
132 }
133 if (f_v) {
134 cout << "classification_step::write_file nb_orbits=" << nb_orbits << endl;
135 cout << "classification_step::write_file representation_sz=" << representation_sz << endl;
136 }
137 fp.write((char *) &nb_orbits, sizeof(int));
138 fp.write((char *) &representation_sz, sizeof(int));
139
140
141 if (f_vv) {
142 cout << "classification_step::write_file Rep matrix:" << endl;
144 }
145
146 for (i = 0; i < nb_orbits * representation_sz; i++) {
147 fp.write((char *) &Rep[i], sizeof(long int));
148 }
149
150 if (f_v) {
151 cout << "classification_step::write_file writing " << nb_orbits << " orbits" << endl;
152 }
153 for (i = 0; i < nb_orbits; i++) {
154 Orbit[i].write_file(fp, 0 /*verbose_level*/);
155 }
156
157 if (f_v) {
158 cout << "classification_step::write_file finished" << endl;
159 }
160}
161
164 int verbose_level)
165{
166 int f_v = (verbose_level >= 1);
167 int f_vv = FALSE; //(verbose_level >= 1);
168 int i;
169
170 if (f_v) {
171 cout << "classification_step::read_file" << endl;
172 }
176 fp.read((char *) &nb_orbits, sizeof(int));
177 fp.read((char *) &representation_sz, sizeof(int));
178
179 if (f_v) {
180 cout << "classification_step::read_file nb_orbits=" << nb_orbits << endl;
181 cout << "classification_step::read_file representation_sz=" << representation_sz << endl;
182 }
183
185 for (i = 0; i < nb_orbits * representation_sz; i++) {
186 fp.read((char *) &Rep[i], sizeof(long int));
187 }
188
189 if (f_vv) {
190 cout << "classification_step::read_file Rep matrix:" << endl;
192 }
193
196 if (f_v) {
197 cout << "classification_step::read_file reading " << nb_orbits << " orbits" << endl;
198 }
199 for (i = 0; i < nb_orbits; i++) {
200 Orbit[i].C = this;
201 Orbit[i].orbit_index = i;
202 Orbit[i].read_file(fp, 0 /*verbose_level*/);
203 }
204
205 if (f_v) {
206 cout << "classification_step::read_file finished" << endl;
207 }
208}
209
210void classification_step::generate_source_code(std::string &fname_base,
211 int verbose_level)
212{
213 int f_v = (verbose_level >= 1);
214 string fname;
215 string prefix;
216 int orbit_index;
217
218 if (f_v) {
219 cout << "classification_step::generate_source_code" << endl;
220 }
221 fname.assign(fname_base);
222 fname.append(".cpp");
223
224 prefix.assign(fname_base);
225
226 {
227 ofstream f(fname);
228
229 f << "static int " << prefix << "_nb_reps = "
230 << nb_orbits << ";" << endl;
231 f << "static int " << prefix << "_size = "
232 << representation_sz << ";" << endl;
233
234
235
236 if (f_v) {
237 cout << "classification_step::generate_source_code "
238 "preparing reps" << endl;
239 }
240
241
242#if 0
243 if (f_lint) {
244
245 f << "static long int " << prefix << "_reps[] = {" << endl;
246 for (orbit_index = 0;
247 orbit_index < nb_orbits;
248 orbit_index++) {
249
250
251 if (f_vv) {
252 cout << "classification_step::generate_source_code orbit_index = " << orbit_index << endl;
253 }
254
255 f << "\t";
256 for (i = 0; i < representation_sz; i++) {
257 f << Rep_lint_ith(orbit_index)[i];
258 f << ", ";
259 }
260 f << endl;
261
262
263 }
264 f << "};" << endl;
265 }
266#endif
267
268
269
270
271 if (f_v) {
272 cout << "classification_step::generate_source_code preparing stab_order" << endl;
273 }
274 f << "// the stabilizer orders:" << endl;
275 f << "static const char *" << prefix << "_stab_order[] = {" << endl;
276 for (orbit_index = 0;
277 orbit_index < nb_orbits;
278 orbit_index++) {
279
281
282 Orbit[orbit_index].gens->group_order(ago);
283
284 f << "\t\"";
285
287 f << "\"," << endl;
288
289 }
290 f << "};" << endl;
291
292
293
294
295 f << "static int " << prefix << "_make_element_size = "
296 << A->make_element_size << ";" << endl;
297
298 {
299 int *stab_gens_first;
300 int *stab_gens_len;
301 int fst;
302
303 stab_gens_first = NEW_int(nb_orbits);
304 stab_gens_len = NEW_int(nb_orbits);
305 fst = 0;
306 for (orbit_index = 0;
307 orbit_index < nb_orbits;
308 orbit_index++) {
309 stab_gens_first[orbit_index] = fst;
310 stab_gens_len[orbit_index] =
311 Orbit[orbit_index].gens->gens->len;
312 //stab_gens_len[orbit_index] =
313 //The_surface[iso_type]->stab_gens->gens->len;
314 fst += stab_gens_len[orbit_index];
315 }
316
317
318 if (f_v) {
319 cout << "classification_step::generate_source_code preparing stab_gens_fst" << endl;
320 }
321 f << "static int " << prefix << "_stab_gens_fst[] = { " << endl << "\t";
322 for (orbit_index = 0;
323 orbit_index < nb_orbits;
324 orbit_index++) {
325 f << stab_gens_first[orbit_index];
326 if (orbit_index < nb_orbits - 1) {
327 f << ", ";
328 }
329 if (((orbit_index + 1) % 10) == 0) {
330 f << endl << "\t";
331 }
332 }
333 f << "};" << endl;
334
335 if (f_v) {
336 cout << "classification_step::generate_source_code preparing stab_gens_len" << endl;
337 }
338 f << "static int " << prefix << "_stab_gens_len[] = { " << endl << "\t";
339 for (orbit_index = 0;
340 orbit_index < nb_orbits;
341 orbit_index++) {
342 f << stab_gens_len[orbit_index];
343 if (orbit_index < nb_orbits - 1) {
344 f << ", ";
345 }
346 if (((orbit_index + 1) % 10) == 0) {
347 f << endl << "\t";
348 }
349 }
350 f << "};" << endl;
351
352
353 if (f_v) {
354 cout << "classification_step::generate_source_code preparing stab_gens" << endl;
355 }
356 f << "static int " << prefix << "_stab_gens[] = {" << endl;
357 for (orbit_index = 0;
358 orbit_index < nb_orbits;
359 orbit_index++) {
360 int j;
361
362 for (j = 0; j < stab_gens_len[orbit_index]; j++) {
363 if (FALSE) {
364 cout << "classification_step::generate_source_code "
365 "before extract_strong_generators_in_order generator " << j << " / "
366 << stab_gens_len[orbit_index] << endl;
367 }
368 f << "\t";
370 Orbit[orbit_index].gens->gens->ith(j), f);
371 //A->element_print_for_make_element(
372 //The_surface[iso_type]->stab_gens->gens->ith(j), f);
373 f << endl;
374 }
375 }
376 f << "};" << endl;
377
378
379 FREE_int(stab_gens_first);
380 FREE_int(stab_gens_len);
381 }
382 }
383
385
386 cout << "written file " << fname << " of size "
387 << Fio.file_size(fname) << endl;
388 if (f_v) {
389 cout << "classification_step::generate_source_"
390 "code done" << endl;
391 }
392}
393
395{
396 return Rep + i * representation_sz;
397}
398
399#if 0
400long int *classification_step::Rep_lint_ith(int i)
401{
402 return Rep_lint + i * representation_sz;
403}
404#endif
405
406
408{
409 int i;
412
413 cout << "i : stab order : orbit length" << endl;
414 for (i = 0; i < nb_orbits; i++) {
415 Orbit[i].gens->group_order(go1);
416
417 D.integral_division_exact(go, go1, ol);
418
419
420 cout << i << " : " << go1 << " : " << ol << endl;
421
422 }
423}
424
426{
427 int verbose_level = 0;
428 int f_v = (verbose_level >= 1);
430
431 if (f_v) {
432 cout << "classification_step::print_summary" << endl;
433 }
434
435
436 ost << "The order of the group is ";
438 ost << "\\\\" << endl;
439
440 ost << "\\bigskip" << endl;
441
442 ost << "The group has " << nb_orbits << " orbits. \\\\" << endl;
443
444}
445
446
448 std::string &title, int f_print_stabilizer_gens,
449 int f_has_print_function,
450 void (*print_function)(ostream &ost, int i,
451 classification_step *Step, void *print_function_data),
452 void *print_function_data)
453{
454 int verbose_level = 0;
455 int f_v = (verbose_level >= 1);
457
458 if (f_v) {
459 cout << "classification_step::print_latex" << endl;
460 }
461
462 //ost << "\\clearpage" << endl;
463 ost << "\\subsection*{" << title << "}" << endl;
464
465
466
467 {
468
469 ost << "The order of the group is ";
471 ost << "\\\\" << endl;
472
473 ost << "\\bigskip" << endl;
474 }
475
476 ost << "The group has " << nb_orbits << " orbits: \\\\" << endl;
477
478 int i;
481 Ol.create(0, __FILE__, __LINE__);
482
483 ost << "The orbits are:" << endl;
484 ost << "\\begin{enumerate}[(1)]" << endl;
485 for (i = 0; i < nb_orbits; i++) {
486
487 if (f_v) {
488 cout << "orbit " << i << " / " << nb_orbits << ":" << endl;
489 }
490
491 Orbit[i].gens->group_order(go1);
492
493 if (f_v) {
494 cout << "stab order " << go1 << endl;
495 }
496
497 D.integral_division_exact(go, go1, ol);
498
499 if (f_v) {
500 cout << "orbit length " << ol << endl;
501 }
502
503 ost << "\\item" << endl;
504 ost << "$" << i << " / " << nb_orbits << "$ " << endl;
505
506
507 if (f_has_print_function) {
508 (*print_function)(ost, i, this, print_function_data);
509 }
510
511
512 ost << "$" << endl;
513
515 Rep_ith(i),
517
518 ost << "_{";
519 go1.print_not_scientific(ost);
520 ost << "}$ orbit length $";
521 ol.print_not_scientific(ost);
522 ost << "$\\\\" << endl;
523
524 if (f_print_stabilizer_gens) {
525 //ost << "Strong generators are:" << endl;
527 }
528
529
530
531
532 D.add_in_place(Ol, ol);
533
534
535 }
536 ost << "\\end{enumerate}" << endl;
537
538 ost << "The overall number of objects is: " << Ol << "\\\\" << endl;
539
540 if (f_v) {
541 cout << "classification_step::print_latex done" << endl;
542 }
543
544}
545
546
547
548}}}
549
550
void lint_set_print_tex_for_inline_text(std::ostream &ost, long int *v, int len)
domain to compute with objects of type longinteger
Definition: ring_theory.h:240
void integral_division_exact(longinteger_object &a, longinteger_object &b, longinteger_object &a_over_b)
void add_in_place(longinteger_object &a, longinteger_object &b)
a class to represent arbitrary precision integers
Definition: ring_theory.h:366
void create(long int i, const char *file, int line)
a permutation group in a fixed action.
Definition: actions.h:99
void element_print_for_make_element(void *elt, std::ostream &ost)
Definition: action_cb.cpp:409
void init_everything(actions::action *A, actions::action *A2, long int *Set, int set_sz, groups::strong_generators *gens, int verbose_level)
a strong generating set for a permutation group with respect to a fixed action
Definition: groups.h:1703
data_structures_groups::vector_ge * gens
Definition: groups.h:1708
void group_order(ring_theory::longinteger_object &go)
a single step classification of combinatorial objects
Definition: classify.h:29
void generate_source_code(std::string &fname_base, int verbose_level)
void print_latex(std::ostream &ost, std::string &title, int f_print_stabilizer_gens, int f_has_print_function, void(*print_function)(std::ostream &ost, int i, classification_step *Step, void *print_function_data), void *print_function_data)
void init(actions::action *A, actions::action *A2, int max_orbits, int representation_sz, ring_theory::longinteger_object &go, int verbose_level)
void read_file(std::ifstream &fp, actions::action *A, actions::action *A2, ring_theory::longinteger_object &go, int verbose_level)
data_structures_groups::set_and_stabilizer * get_set_and_stabilizer(int orbit_index, int verbose_level)
to encode one group orbit, associated to the class classification_step
Definition: classify.h:168
void read_file(std::ifstream &fp, int verbose_level)
Definition: orbit_node.cpp:77
void write_file(std::ofstream &fp, int verbose_level)
Definition: orbit_node.cpp:63
#define Lint_vec_copy(A, B, C)
Definition: foundations.h:694
#define FREE_OBJECTS(p)
Definition: foundations.h:652
#define Lint_matrix_print(A, B, C)
Definition: foundations.h:708
#define FREE_int(p)
Definition: foundations.h:640
#define NEW_OBJECT(type)
Definition: foundations.h:638
#define NEW_int(n)
Definition: foundations.h:625
#define NEW_OBJECTS(type, n)
Definition: foundations.h:639
#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