Orbiter 2022
Combinatorial Objects
tensor_classify.cpp
Go to the documentation of this file.
1/*
2 * tensor_classify.cpp
3 *
4 * Created on: Sep 14, 2019
5 * Author: betten
6 */
7
8
9
10#include "orbiter.h"
11
12using namespace std;
13
14
15namespace orbiter {
16namespace layer5_applications {
17namespace apps_geometry {
18
19
20//static int wreath_rank_point_func(int *v, void *data);
21//static void wreath_unrank_point_func(int *v, int rk, void *data);
22static void wreath_product_print_set(std::ostream &ost, int len, long int *S, void *data);
23static void wreath_product_rank_one_early_test_func_callback(long int *S, int len,
24 long int *candidates, int nb_candidates,
25 long int *good_candidates, int &nb_good_candidates,
26 void *data, int verbose_level);
27
28
30{
31 nb_factors = 0;
33 v = NULL;
34 n = 0;
35 q = 0;
36 SG = NULL;
37 F = NULL;
38 A = NULL;
39 A0 = NULL;
40 Ar = NULL;
41 nb_points = 0;
42 points = NULL;
43 W = NULL;
44 VS = NULL;
45 Control = NULL;
46 Poset = NULL;
47 Gen = NULL;
48 t0 = 0;
49}
50
52{
53
54}
55
58 int verbose_level)
59{
60 int f_v = (verbose_level >= 1);
62
63 if (f_v) {
64 cout << "tensor_classify::init" << endl;
65 }
66 t0 = Os.os_ticks();
67
68 q = F->q;
69
70 //A = NEW_OBJECT(action);
71 //A = LG->A_linear;
72 A = LG->A2;
73
74
75#if 0
76 F = NEW_OBJECT(finite_field);
77
78 F->init(q, 0);
79
80 if (f_v) {
81 cout << "tensor_classify::init before "
82 "A->init_wreath_product_group" << endl;
83 }
85 verbose_level);
86 if (f_v) {
87 cout << "tensor_classify::init after "
88 "A->init_wreath_product_group" << endl;
89 }
90#endif
91
92
93 A0 = LG->A_linear;
95
99
100
102 cout << "tensor_classify::init action A0 does not "
103 "have strong generators" << endl;
104 exit(1);
105 }
106
108
109 SG = A0->Strong_gens;
110 SG->group_order(go);
111
112 if (f_v) {
113 cout << "tensor_classify::init The group " << A->label
114 << " has order " << go
115 << " and permutation degree " << A->degree << endl;
116 }
117
118
119#if 0
120 i = SG->gens->len - 1;
121 cout << "generator " << i << " is: " << endl;
122
123
124 int h;
125
126 cout << "computing image of 2:" << endl;
127 h = A->element_image_of(2,
128 SG->gens->ith(i), 10 /*verbose_level - 2*/);
129
130
131 for (j = 0; j < A->degree; j++) {
132 h = A->element_image_of(j,
133 SG->gens->ith(i), verbose_level - 2);
134 cout << j << " -> " << h << endl;
135 }
136
138 cout << endl;
139#endif
140
141 if (f_v) {
142 SG->print_generators(cout);
143 }
144
145#if 0
146 cout << "tensor_classify::init Generators in ASCII format are:" << endl;
147 cout << SG->gens->len << endl;
148 for (i = 0; i < SG->gens->len; i++) {
150 SG->gens->ith(i), cout);
151 cout << endl;
152 }
153 cout << -1 << endl;
154#endif
155
156 if (f_v) {
158 }
159
160
161
162 if (f_v) {
163 cout << "tensor_classify::init done" << endl;
164 }
165
166}
167
168
171 int verbose_level)
172{
173 int f_v = (verbose_level >= 1);
174
175 if (f_v) {
176 cout << "tensor_classify::classify_poset" << endl;
177 }
178
179
180 if (f_v) {
181 cout << "tensor_classify::classify_poset "
182 "before create_restricted_action_on_rank_one_tensors" << endl;
183 }
185 if (f_v) {
186 cout << "tensor_classify::classify_poset "
187 "after create_restricted_action_on_rank_one_tensors" << endl;
188 }
189
192 SG,
193 verbose_level);
194
195 if (f_v) {
196 cout << "tensor_classify::classify_poset before "
197 "Poset->add_testing_without_group" << endl;
198 }
200 wreath_product_rank_one_early_test_func_callback,
201 this /* void *data */,
202 verbose_level);
203
205 Poset->print_function = wreath_product_print_set;
207
209 Control->depth = depth;
210
211 if (f_v) {
212 cout << "tensor_classify::classify_poset before "
213 "Gen->initialize_and_allocate_root_node" << endl;
214 }
216
218 Control, Poset,
219 depth /* sz */, verbose_level);
220 if (f_v) {
221 cout << "tensor_classify::classify_poset after "
222 "Gen->initialize_and_allocate_root_node" << endl;
223 }
224
225
226 //int schreier_depth;
227 int f_use_invariant_subset_if_available;
228 int f_debug;
229
230 //schreier_depth = Gen->depth;
231 f_use_invariant_subset_if_available = TRUE;
232 f_debug = FALSE;
233
234 //int t0 = os_ticks();
235
236 if (f_v) {
237 cout << "tensor_classify::classify_poset before Gen->main" << endl;
238 cout << "A=";
239 A->print_info();
240 cout << "A0=";
241 A0->print_info();
242 }
243
244
245 //Gen->f_allowed_to_show_group_elements = TRUE;
246
247 if (f_v) {
248 cout << "tensor_classify::classify_poset "
249 "before Gen->main, verbose_level=" << verbose_level << endl;
250 }
251 Gen->main(t0,
252 depth,
253 f_use_invariant_subset_if_available,
254 f_debug,
255 verbose_level);
256 if (f_v) {
257 cout << "tensor_classify::classify_poset "
258 "after Gen->main" << endl;
259 }
260 if (f_v) {
261 cout << "tensor_classify::classify_poset done" << endl;
262 }
263}
264
266 int verbose_level)
267{
268 int f_v = (verbose_level >= 1);
269 int i;
270
271 if (f_v) {
272 cout << "tensor_classify::create_restricted_action_on_rank_one_tensors" << endl;
273 }
274
277 for (i = 0; i < nb_points; i++) {
278 uint32_t a, b;
279
280 a = W->rank_one_tensors[i];
282
283 points[i] = /*W->perm_offset_i[nb_factors] +*/ b;
284 }
285
286 if (f_v) {
287 cout << "tensor_classify::create_restricted_action_on_rank_one_tensors "
288 "before A->restricted_action" << endl;
289 }
291 verbose_level);
293 if (f_v) {
294 cout << "tensor_classify::create_restricted_action_on_rank_one_tensors "
295 "after A->restricted_action" << endl;
296 }
297 if (f_v) {
298 cout << "tensor_classify::create_restricted_action_on_rank_one_tensors done" << endl;
299 }
300}
301
302
303void tensor_classify::early_test_func(long int *S, int len,
304 long int *candidates, int nb_candidates,
305 long int *good_candidates, int &nb_good_candidates,
306 int verbose_level)
307{
308 int f_v = (verbose_level >= 1);
309 int f_vv = (verbose_level >= 2);
310 int f_OK;
311 int i, j, c;
312
313 if (f_v) {
314 cout << "tensor_classify::early_test_func checking set ";
315 Lint_vec_print(cout, S, len);
316 cout << endl;
317 cout << "candidate set of size "
318 << nb_candidates << ":" << endl;
319 Lint_vec_print(cout, candidates, nb_candidates);
320 cout << endl;
321 }
322
323
324 if (len == 0) {
325 Lint_vec_copy(candidates, good_candidates, nb_candidates);
326 nb_good_candidates = nb_candidates;
327 }
328 else {
329 nb_good_candidates = 0;
330
331 if (f_vv) {
332 cout << "tensor_classify::early_test_func before testing" << endl;
333 }
334 for (j = 0; j < nb_candidates; j++) {
335
336
337 if (f_vv) {
338 cout << "tensor_classify::early_test_func "
339 "testing " << j << " / "
340 << nb_candidates << endl;
341 }
342
343 f_OK = TRUE;
344 c = candidates[j];
345
346 for (i = 0; i < len; i++) {
347 if (S[i] == c) {
348 f_OK = FALSE;
349 break;
350 }
351 }
352
353
354
355 if (f_OK) {
356 good_candidates[nb_good_candidates++] =
357 candidates[j];
358 }
359 } // next j
360 } // else
361 if (f_v) {
362 cout << "tensor_classify::early_test_func done" << endl;
363 }
364}
365
366
367
368void tensor_classify::report(int f_poset_classify, int poset_classify_depth,
370 int verbose_level)
371{
372 int f_v = (verbose_level >= 1);
373 //int f_vv = (verbose_level >= 2);
374 //int f_OK;
375 int i, j; //, c;
376
377 if (f_v) {
378 cout << "tensor_classify::report" << endl;
379 }
380
381
382
385
386 char fname[1000];
387 char title[1000];
388 char author[1000];
389 //int f_with_stabilizers = TRUE;
390
391 snprintf(title, 1000, "Wreath product $%s$", W->label_tex.c_str());
392 strcpy(author, "Orbiter");
393 snprintf(fname, 1000, "WreathProduct_q%d_n%d.tex", W->q, W->nb_factors);
394
395 {
396 ofstream fp(fname);
398
399 //latex_head_easy(fp);
400 L.head(fp,
401 FALSE /* f_book */,
402 TRUE /* f_title */,
403 title, author,
404 FALSE /*f_toc */,
405 FALSE /* f_landscape */,
406 FALSE /* f_12pt */,
407 TRUE /*f_enlarged_page */,
408 TRUE /* f_pagenumbers*/,
409 NULL /* extra_praeamble */);
410
411 fp << "\\section{The field of order " << q << "}" << endl;
412 fp << "\\noindent The field ${\\mathbb F}_{"
413 << W->q
414 << "}$ :\\\\" << endl;
415 W->F->cheat_sheet(fp, verbose_level);
416
417 if (f_v) {
418 cout << "tensor_classify::report before W->report" << endl;
419 }
420
421 W->report(fp, verbose_level);
422
423 if (f_v) {
424 cout << "tensor_classify::report after W->report" << endl;
425 }
426
427 fp << "\\section{Generators}" << endl;
428 for (i = 0; i < SG->gens->len; i++) {
429 fp << "$$" << endl;
430 A->element_print_latex(SG->gens->ith(i), fp);
431 if (i < SG->gens->len - 1) {
432 fp << ", " << endl;
433 }
434 fp << "$$" << endl;
435 }
436
437
438 fp << "\\section{The Group}" << endl;
440 draw_options,
441 verbose_level);
442
443 if (f_v) {
444 cout << "tensor_classify::report after A->report" << endl;
445 }
446
447
448 if (f_poset_classify) {
449
450
451
452#if 0
453 {
454 char fname_poset[1000];
455
456 Gen->draw_poset_fname_base_poset_lvl(fname_poset, poset_classify_depth);
457 Gen->draw_poset(fname_poset,
458 poset_classify_depth /*depth*/,
459 0 /* data1 */,
460 FALSE /* f_embedded */,
461 FALSE /* f_sideways */,
462 100 /* rad */,
463 verbose_level);
464 }
465#endif
466
467
468 fp << endl;
469 fp << "\\section{Poset Classification}" << endl;
470 fp << endl;
471
473
474 Gen->report(fp, &Opt, verbose_level);
475 fp << "\\subsection*{Orbits at level " << poset_classify_depth << "}" << endl;
476 int nb_orbits, orbit_idx;
477
478 nb_orbits = Gen->nb_orbits_at_level(poset_classify_depth);
479 for (orbit_idx = 0; orbit_idx < nb_orbits; orbit_idx++) {
480 fp << "\\subsubsection*{Orbit " << orbit_idx << " / " << nb_orbits << "}" << endl;
481
482 long int *Orbit; // orbit_length * depth
483 int orbit_length;
484
485 cout << "before get_whole_orbit orbit_idx=" << orbit_idx << endl;
486
488 poset_classify_depth, orbit_idx,
489 Orbit, orbit_length, verbose_level);
490
491 long int *data;
492
493 data = NEW_lint(orbit_length);
494
495 for (i = 0; i < orbit_length; i++) {
496
497 fp << "set " << i << " / " << orbit_length << " is: ";
498
499
500 uint32_t a, b;
501
502 a = 0;
503 for (j = 0; j < poset_classify_depth; j++) {
504 b = W->rank_one_tensors[Orbit[i * poset_classify_depth + j]];
505 a ^= b;
506 }
507
508 for (j = 0; j < poset_classify_depth; j++) {
509 fp << Orbit[i * poset_classify_depth + j];
510 if (j < poset_classify_depth - 1) {
511 fp << ", ";
512 }
513 }
514 fp << "= ";
515 for (j = 0; j < poset_classify_depth; j++) {
516 b = W->rank_one_tensors[Orbit[i * poset_classify_depth + j]];
517 fp << b;
518 if (j < poset_classify_depth - 1) {
519 fp << ", ";
520 }
521 }
522 fp << " = " << a;
523 data[i] = a;
524 fp << "\\\\" << endl;
525 }
527
528 Sorting.lint_vec_heapsort(data, orbit_length);
529
530 fp << "$$" << endl;
531 L.print_lint_matrix_tex(fp, data, (orbit_length + 9)/ 10, 10);
532 fp << "$$" << endl;
533
535
536 C.init_lint(data, orbit_length, TRUE, 0);
537 fp << "$$";
538 C.print_naked_tex(fp, TRUE /* f_backwards */);
539 fp << "$$";
540 FREE_lint(data);
541 }
542 }
543
544 L.foot(fp);
545 }
546 cout << "Written file " << fname << " of size "
547 << Fio.file_size(fname) << endl;
548
549 if (f_v) {
550 cout << "tensor_classify::report done" << endl;
551 }
552}
553
554
555
556
557#if 0
558static int wreath_rank_point_func(int *v, void *data)
559{
561 int rk;
562
563 T = (tensor_classify *) data;
564
565 rk = T->W->tensor_PG_rank(v);
566
567 return rk;
568}
569
570static void wreath_unrank_point_func(int *v, int rk, void *data)
571{
572 tensor_classify *T;
573
574 T = (tensor_classify *) data;
575
576 T->W->tensor_PG_unrank(v, rk);
577
578}
579#endif
580
581
582static void wreath_product_print_set(ostream &ost, int len, long int *S, void *data)
583{
584 tensor_classify *T;
585 int i;
586
587 T = (tensor_classify *) data;
588 cout << "set: ";
589 Lint_vec_print(cout, S, len);
590 cout << endl;
591 for (i = 0; i < len; i++) {
592 T->F->PG_element_unrank_modified(T->v,
593 1, T->vector_space_dimension, S[i]);
594 cout << S[i] << " : ";
595 Int_vec_print(cout, T->v, T->vector_space_dimension);
596 cout << endl;
597 }
598}
599
600
601
602
603static void wreath_product_rank_one_early_test_func_callback(long int *S, int len,
604 long int *candidates, int nb_candidates,
605 long int *good_candidates, int &nb_good_candidates,
606 void *data, int verbose_level)
607{
608 tensor_classify *T = (tensor_classify *) data;
609 int f_v = (verbose_level >= 1);
610
611 if (f_v) {
612 cout << "wreath_product_rank_one_early_test_func_callback for set ";
613 Lint_vec_print(cout, S, len);
614 cout << endl;
615 }
616 T->early_test_func(S, len,
617 candidates, nb_candidates,
618 good_candidates, nb_good_candidates,
619 verbose_level - 2);
620 if (f_v) {
621 cout << "wreath_product_rank_one_early_test_func_callback done" << endl;
622 }
623}
624
625
626}}}
627
628
a collection of functions related to sorted vectors
a statistical analysis of data consisting of single integers
void init_lint(long int *data, int data_length, int f_second, int verbose_level)
Definition: tally.cpp:123
void print_naked_tex(std::ostream &ost, int f_backwards)
Definition: tally.cpp:413
void init(finite_field_description *Descr, int verbose_level)
void cheat_sheet(std::ostream &f, int verbose_level)
options for drawing an object of type layered_graph
Definition: graphics.h:457
void print_lint_matrix_tex(std::ostream &ost, long int *p, int m, int n)
void head(std::ostream &ost, int f_book, int f_title, const char *title, const char *author, int f_toc, int f_landscape, int f_12pt, int f_enlarged_page, int f_pagenumbers, const char *extras_for_preamble)
void element_print_latex(void *elt, std::ostream &ost)
Definition: action_cb.cpp:364
action * restricted_action(long int *points, int nb_points, int verbose_level)
void element_print_for_make_element(void *elt, std::ostream &ost)
Definition: action_cb.cpp:409
void report(std::ostream &ost, int f_sims, groups::sims *S, int f_strong_gens, groups::strong_generators *SG, graphics::layered_graph_draw_options *LG_Draw_options, int verbose_level)
Definition: action_io.cpp:22
groups::strong_generators * Strong_gens
Definition: actions.h:130
void element_print_as_permutation(void *elt, std::ostream &ost)
Definition: action_cb.cpp:421
long int element_image_of(long int a, void *elt, int verbose_level)
Definition: action_cb.cpp:198
void init_wreath_product_group(int nb_factors, int n, field_theory::finite_field *F, data_structures_groups::vector_ge *&nice_gens, int verbose_level)
creates a linear group from command line arguments using linear_group_description
Definition: groups.h:244
data_structures_groups::vector_ge * gens
Definition: groups.h:1708
void group_order(ring_theory::longinteger_object &go)
void report(std::ostream &ost, int verbose_level)
to control the behavior of the poset classification algorithm
to control the behavior of the poset classification report function
void initialize_and_allocate_root_node(poset_classification_control *PC_control, poset_with_group_action *Poset, int depth, int verbose_level)
int main(int t0, int schreier_depth, int f_use_invariant_subset_if_available, int f_debug, int verbose_level)
void get_whole_orbit(int depth, int orbit_idx, long int *&Orbit, int &orbit_length, int verbose_level)
void draw_poset(std::string &fname_base, int depth, int data, graphics::layered_graph_draw_options *LG_Draw_options, int verbose_level)
void report(std::ostream &ost, poset_classification_report_options *Opt, int verbose_level)
void init_subset_lattice(actions::action *A, actions::action *A2, groups::strong_generators *Strong_gens, int verbose_level)
void add_testing_without_group(void(*func)(long int *S, int len, long int *candidates, int nb_candidates, long int *good_candidates, int &nb_good_candidates, void *data, int verbose_level), void *data, int verbose_level)
void(* print_function)(std::ostream &ost, int len, long int *S, void *data)
classification of tensors under the wreath product group
Definition: tl_geometry.h:899
void init(field_theory::finite_field *F, groups::linear_group *LG, int verbose_level)
poset_classification::poset_with_group_action * Poset
Definition: tl_geometry.h:921
void early_test_func(long int *S, int len, long int *candidates, int nb_candidates, long int *good_candidates, int &nb_good_candidates, int verbose_level)
void report(int f_poset_classify, int poset_classify_depth, graphics::layered_graph_draw_options *draw_options, int verbose_level)
poset_classification::poset_classification * Gen
Definition: tl_geometry.h:922
void classify_poset(int depth, poset_classification::poset_classification_control *Control, int verbose_level)
poset_classification::poset_classification_control * Control
Definition: tl_geometry.h:920
#define Lint_vec_copy(A, B, C)
Definition: foundations.h:694
#define NEW_OBJECT(type)
Definition: foundations.h:638
#define Lint_vec_print(A, B, C)
Definition: foundations.h:686
#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
#define Int_vec_print(A, B, C)
Definition: foundations.h:685
the orbiter library for the classification of combinatorial objects