Orbiter 2022
Combinatorial Objects
object_with_canonical_form.cpp
Go to the documentation of this file.
1// object_with_canonical_form.cpp
2//
3// Anton Betten
4//
5// December 23, 2017
6//
7//
8//
9//
10//
11
12#include "foundations.h"
13
14using namespace std;
15
16
17
18namespace orbiter {
19namespace layer1_foundations {
20namespace geometry {
21
22
24{
25 P = NULL;
26 type = t_PTS;
27 //input_fname = NULL;
28 input_idx = 0;
30 known_ago = 0;
31 //set_as_string = NULL;
32
33 set = NULL;
34 sz = 0;
35
36 set2 = NULL;
37 sz2 = 0;
38
39 v = 0;
40 b = 0;
41
43 partition = NULL;
44
45 design_k = 0;
46 design_sz = 0;
47 SoS = NULL;
48 C = NULL;
49}
50
52{
53 if (set) {
55 }
56 if (set2) {
58 }
59#if 0
60 if (partition) {
62 }
63#endif
64 if (SoS) {
66 }
67 if (C) {
69 }
70}
71
73{
74
75 cout << "set_as_string: " << set_as_string << endl;
76 if (type == t_PTS) {
77 ost << "set of points of size " << sz << ": ";
78 Lint_vec_print(ost, set, sz);
79 ost << endl;
80 }
81 else if (type == t_LNS) {
82 ost << "set of lines of size " << sz << ": ";
83 Lint_vec_print(ost, set, sz);
84 ost << endl;
85 }
86 else if (type == t_PNL) {
87 ost << "set of points of size " << sz
88 << " and a set of lines of size " << sz2 << ": ";
89 Lint_vec_print(ost, set, sz);
90 ost << ", ";
91 Lint_vec_print(ost, set2, sz2);
92 ost << endl;
93 }
94 else if (type == t_PAC) {
95 ost << "packing:" << endl;
96 SoS->print_table_tex(ost);
97 ost << endl;
98 }
99 else if (type == t_INC) {
100 ost << "incidence structure:" << endl;
101 //SoS->print_table_tex(ost);
102 //ost << endl;
103 }
104 else if (type == t_LS) {
105 ost << "large set:" << endl;
106 //SoS->print_table_tex(ost);
107 //ost << endl;
108 }
109}
110
112 int f_show_incma, int verbose_level)
113{
114 int f_v = (verbose_level >= 1);
115
116 if (f_v) {
117 cout << "object_with_canonical_form::print_rows" << endl;
118 }
119
120 //print_tex(ost);
121
122 if (f_show_incma) {
123
125
126 encode_incma(Enc, verbose_level);
127
128 //Enc->latex_set_system_by_columns(ost, verbose_level);
129
130 Enc->latex_set_system_by_rows(ost, verbose_level);
131
132 //Enc->latex_incma(ost, verbose_level);
133
134 FREE_OBJECT(Enc);
135 }
136
137 if (f_v) {
138 cout << "object_with_canonical_form::print_rows done" << endl;
139 }
140}
141
143 int f_show_incma, int verbose_level)
144{
145 int f_v = (verbose_level >= 1);
146
147 if (f_v) {
148 cout << "object_with_canonical_form::print_tex_detailed" << endl;
149 }
150
151 print_tex(ost);
152
153 if (f_show_incma) {
154
156
157 encode_incma(Enc, verbose_level);
158
159 Enc->latex_set_system_by_columns(ost, verbose_level);
160
161 Enc->latex_set_system_by_rows(ost, verbose_level);
162
163 Enc->latex_incma(ost, verbose_level);
164 ost << "\\\\" << endl;
165
166 FREE_OBJECT(Enc);
167 }
168
169 if (f_v) {
170 cout << "object_with_canonical_form::print_tex_detailed done" << endl;
171 }
172}
173
175{
176 if (type == t_PTS) {
177 ost << "set of points of size " << sz << ": ";
178 Lint_vec_print(ost, set, sz);
179 ost << "\\\\" << endl;
180 //P->print_set_numerical(ost, set, sz);
181 P->print_set_of_points(ost, set, sz);
182 }
183 else if (type == t_LNS) {
184 ost << "set of lines of size " << sz << ": ";
185 Lint_vec_print(ost, set, sz);
186 ost << "\\\\" << endl;
187 }
188 else if (type == t_PNL) {
189 ost << "set of points of size " << sz << ": ";
190 Lint_vec_print(ost, set, sz);
191 ost << "\\\\" << endl;
192 ost << "and a set of lines of size " << sz2 << ": ";
193 Lint_vec_print(ost, set2, sz2);
194 ost << "\\\\" << endl;
195 }
196 else if (type == t_PAC) {
197 ost << "packing: \\\\" << endl;
198 SoS->print_table_tex(ost);
199 ost << endl;
200 }
201 else if (type == t_INC) {
202 ost << "incidence structure: \\\\" << endl;
203 //SoS->print_table_tex(ost);
204 //ost << endl;
205 Lint_vec_print(ost, set, sz);
206 ost << "\\\\" << endl;
207#if 0
213#endif
214 }
215 else if (type == t_LS) {
216 ost << "large set: \\\\" << endl;
217 //SoS->print_table_tex(ost);
218 //ost << endl;
219
220 int nb_designs = b / design_sz;
221 int i;
222
223 for (i = 0; i < nb_designs; i++) {
225 ost << "\\\\" << endl;
226 }
227#if 0
235#endif
236
237 }
238}
239
241 int &nb_sets, int &set_size, int verbose_level)
242{
243 int f_v = (verbose_level >= 1);
244 int i, j;
245
246 if (f_v) {
247 cout << "object_with_canonical_form::get_packing_as_set_system" << endl;
248 }
249 nb_sets = SoS->nb_sets;
250 set_size = SoS->Set_size[0];
251 Sets = NEW_lint(nb_sets * set_size);
252 for (i = 0; i < nb_sets; i++) {
253 for (j = 0; j < set_size; j++) {
254 Sets[i * set_size + j] = SoS->Sets[i][j];
255 }
256 }
257 if (f_v) {
258 cout << "object_with_canonical_form::get_packing_as_set_system done" << endl;
259 }
260}
261
262
264 long int *set, int sz,
265 int verbose_level)
266{
267 int f_v = (verbose_level >= 1);
268
269 if (f_v) {
270 cout << "object_with_canonical_form::init_point_set" << endl;
271 }
272 //object_with_canonical_form::P = P;
273 type = t_PTS;
277 if (f_v) {
278 cout << "object_with_canonical_form::init_point_set done" << endl;
279 }
280}
281
283 std::string &set_text,
284 int verbose_level)
285{
286 int f_v = (verbose_level >= 1);
287
288 if (f_v) {
289 cout << "object_with_canonical_form::init_point_set_from_string" << endl;
290 }
291
292 type = t_PTS;
293
295
296 if (f_v) {
297 cout << "object_with_canonical_form::init_point_set_from_string done" << endl;
298 }
299}
300
301
303 long int *set, int sz,
304 int verbose_level)
305{
306 int f_v = (verbose_level >= 1);
307
308 if (f_v) {
309 cout << "object_with_canonical_form::init_line_set" << endl;
310 }
311 //object_with_canonical_form::P = P;
312 type = t_LNS;
316 if (f_v) {
317 cout << "object_with_canonical_form::init_line_set done" << endl;
318 }
319}
320
322 std::string &set_text,
323 int verbose_level)
324{
325 int f_v = (verbose_level >= 1);
326
327 if (f_v) {
328 cout << "object_with_canonical_form::init_line_set_from_string" << endl;
329 }
330
331 type = t_LNS;
332
333 Lint_vec_scan(set_text, set, sz);
334
335 if (f_v) {
336 cout << "object_with_canonical_form::init_line_set_from_string done" << endl;
337 }
338}
339
341 long int *set, int sz,
342 long int *set2, int sz2,
343 int verbose_level)
344{
345 int f_v = (verbose_level >= 1);
346
347 if (f_v) {
348 cout << "object_with_canonical_form::init_points_and_lines" << endl;
349 }
350 //object_with_canonical_form::P = P;
351 type = t_PNL;
352
356
360
361 if (f_v) {
362 cout << "object_with_canonical_form::init_points_and_lines done" << endl;
363 }
364}
365
367 std::string &set_text,
368 std::string &set2_text,
369 int verbose_level)
370{
371 int f_v = (verbose_level >= 1);
372
373 if (f_v) {
374 cout << "object_with_canonical_form::init_points_and_lines_from_string" << endl;
375 }
376
377 type = t_PNL;
378
379 Lint_vec_scan(set_text, set, sz);
380
381 Lint_vec_scan(set2_text, set2, sz2);
382
383 if (f_v) {
384 cout << "object_with_canonical_form::init_points_and_lines_from_string done" << endl;
385 }
386}
387
389 long int *packing, int sz,
390 int verbose_level)
391{
392 int f_v = (verbose_level >= 1);
393 int i, q, size_of_spread, size_of_packing;
394
395 if (f_v) {
396 cout << "object_with_canonical_form::init_packing_from_set" << endl;
397 }
398 //object_with_canonical_form::P = P;
399 type = t_PAC;
400 q = P->q;
401 size_of_spread = q * q + 1;
402 size_of_packing = q * q + q + 1;
403 if (sz != size_of_packing * size_of_spread) {
404 cout << "object_with_canonical_form::init_packing_from_set "
405 "sz != size_of_packing * size_of_spread" << endl;
406 exit(1);
407 }
409
411 size_of_packing /* nb_sets */,
412 size_of_spread /* constant_size */,
413 0 /* verbose_level */);
414
415 for (i = 0; i < size_of_packing; i++) {
416 Lint_vec_copy(packing + i * size_of_spread,
417 SoS->Sets[i], size_of_spread);
418 }
419#if 0
420 if (f_v) {
421 cout << "object_with_canonical_form::init_packing_from_set it is" << endl;
422 SoS->print_table();
423 }
424#endif
425
426
427 if (f_v) {
428 cout << "object_with_canonical_form::init_packing_from_set done" << endl;
429 }
430}
431
432
434 std::string &packing_text,
435 int q,
436 int verbose_level)
437{
438 int f_v = (verbose_level >= 1);
439 int i, size_of_spread, size_of_packing;
440
441 if (f_v) {
442 cout << "object_with_canonical_form::init_packing_from_string" << endl;
443 }
444 type = t_PAC;
445
446 long int *packing;
447 int sz;
448 int N_lines;
449
450
451
452 Lint_vec_scan(packing_text, packing, sz);
453
454 size_of_spread = q * q + 1;
455 size_of_packing = q * q + q + 1;
456 N_lines = size_of_spread * size_of_packing;
457 if (sz != N_lines) {
458 cout << "object_with_canonical_form::init_packing_from_string "
459 "sz != N_lines" << endl;
460 exit(1);
461 }
463
465 size_of_packing /* nb_sets */,
466 size_of_spread /* constant_size */,
467 0 /* verbose_level */);
468
469 for (i = 0; i < size_of_packing; i++) {
470 Lint_vec_copy(packing + i * size_of_spread,
471 SoS->Sets[i], size_of_spread);
472 }
473#if 0
474 if (f_v) {
475 cout << "object_with_canonical_form::init_packing_from_string it is" << endl;
476 SoS->print_table();
477 }
478#endif
479
480
481 FREE_lint(packing);
482
483 if (f_v) {
484 cout << "object_with_canonical_form::init_packing_from_string done" << endl;
485 }
486}
487
489 data_structures::set_of_sets *SoS, int verbose_level)
490{
491 int f_v = (verbose_level >= 1);
492
493 if (f_v) {
494 cout << "object_with_canonical_form::init_packing_from_set_of_sets" << endl;
495 }
496 //object_with_canonical_form::P = P;
497 type = t_PAC;
498 //object_in_projective_space::set = NEW_int(sz);
499 //int_vec_copy(set, object_in_projective_space::set, sz);
500 //object_in_projective_space::sz = sz;
501
503
504 if (f_v) {
505 cout << "object_with_canonical_form::init_packing_from_set_of_sets done" << endl;
506 }
507}
508
509
511 long int *data,
512 long int *Spread_table, int nb_spreads, int spread_size,
513 int q,
514 int verbose_level)
515{
516 int f_v = (verbose_level >= 1);
517 int a, i, size_of_spread, size_of_packing;
518 int N_lines;
519
520 if (f_v) {
521 cout << "object_with_canonical_form::init_packing_from_spread_table" << endl;
522 }
523 //object_with_canonical_form::P = P;
524 type = t_PAC;
525 //q = P->q;
526 size_of_spread = q * q + 1;
527 size_of_packing = q * q + q + 1;
528 if (spread_size != size_of_spread) {
529 cout << "object_with_canonical_form::init_packing_from_spread_table "
530 "spread_size != size_of_spread" << endl;
531 exit(1);
532 }
533 N_lines = size_of_spread * size_of_packing;
534
536
538 size_of_packing /* nb_sets */,
539 size_of_spread /* constant_size */,
540 0 /* verbose_level */);
541
542 for (i = 0; i < size_of_packing; i++) {
543 a = data[i];
544 Lint_vec_copy(Spread_table + a * size_of_spread,
545 SoS->Sets[i], size_of_spread);
546 }
547 if (verbose_level >= 5) {
548 cout << "object_with_canonical_form::init_packing_from_spread_table Sos:" << endl;
549 SoS->print_table();
550 }
551
552 // test if the object is a packing:
553 SoS->sort_all(FALSE /*verbose_level*/);
554 int *M;
555 int j;
556 SoS->pairwise_intersection_matrix(M, 0 /*verbose_level*/);
557 for (i = 0; i < SoS->nb_sets; i++) {
558 for (j = i + 1; j < SoS->nb_sets; j++) {
559 if (M[i * SoS->nb_sets + j]) {
560 cout << "object_with_canonical_form::init_packing_from_spread_table not a packing, spreads "
561 << i << " and " << j << " meet in "
562 << M[i * SoS->nb_sets + j] << " lines" << endl;
563 cout << "object_with_canonical_form::init_packing_from_spread_table Sos:" << endl;
564 SoS->print_table();
565 exit(1);
566
567 }
568 }
569 }
570 FREE_int(M);
571
572 if (f_v) {
573 cout << "object_with_canonical_form::init_packing_from_spread_table done" << endl;
574 }
575}
576
578 long int *data, int data_sz, int v, int b, int nb_flags,
579 int verbose_level)
580{
581 int f_v = (verbose_level >= 1);
582
583 if (f_v) {
584 cout << "object_with_canonical_form::init_incidence_geometry" << endl;
585 }
586 if (nb_flags != data_sz) {
587 cout << "object_with_canonical_form::init_incidence_geometry nb_flags != data_sz" << endl;
588 }
590 type = t_INC;
596 if (f_v) {
597 cout << "object_with_canonical_form::init_incidence_geometry done" << endl;
598 }
599}
600
602 std::vector<int> &Flags, int v, int b, int nb_flags,
603 int verbose_level)
604{
605 int f_v = (verbose_level >= 1);
606
607 if (f_v) {
608 cout << "object_with_canonical_form::init_incidence_geometry" << endl;
609 }
610 if (nb_flags != Flags.size()) {
611 cout << "object_with_canonical_form::init_incidence_geometry nb_flags != Flags.size()" << endl;
612 }
613
615
616 type = t_INC;
617
619
620 int i;
621
622 for (i = 0; i < Flags.size(); i++) {
623 set[i] = Flags[i];
624 }
625 object_with_canonical_form::sz = Flags.size();
628 if (f_v) {
629 cout << "object_with_canonical_form::init_incidence_geometry done" << endl;
630 }
631}
632
634 std::string &data,
635 int v, int b, int nb_flags,
636 int verbose_level)
637{
638 int f_v = (verbose_level >= 1);
639
640 if (f_v) {
641 cout << "object_with_canonical_form::init_incidence_geometry_from_string" << endl;
642 }
643 long int *flags;
644 int data_sz;
645
646 Lint_vec_scan(data, flags, data_sz);
647
648 if (nb_flags != data_sz) {
649 cout << "object_with_canonical_form::init_incidence_geometry_from_string nb_flags != data_sz" << endl;
650 }
652 type = t_INC;
658
659 FREE_lint(flags);
660
661 if (f_v) {
662 cout << "object_with_canonical_form::init_incidence_geometry_from_string done" << endl;
663 }
664}
665
667 std::string &data,
668 int v, int b, int r,
669 int verbose_level)
670{
671 int f_v = (verbose_level >= 1);
672
673 if (f_v) {
674 cout << "object_with_canonical_form::init_incidence_geometry_from_string" << endl;
675 }
676 long int *row_ranks;
677 long int *flags;
678 int *row_set;
679 int data_sz;
680 int nb_flags;
681 int i, h, a;
683
684 Lint_vec_scan(data, row_ranks, data_sz);
685
686 if (v != data_sz) {
687 cout << "object_with_canonical_form::init_incidence_geometry_from_string v != data_sz" << endl;
688 }
689
690 flags = NEW_lint(v * r);
691 row_set = NEW_int(r);
692 nb_flags = 0;
693 for (i = 0; i < v; i++) {
694 Combi.unrank_k_subset(row_ranks[i], row_set, b, r);
695 for (h = 0; h < r; h++) {
696 a = i * b + row_set[h];
697 flags[nb_flags++] = a;
698 }
699
700 }
701
703 type = t_INC;
709
710 FREE_int(row_set);
711 FREE_lint(row_ranks);
712 FREE_lint(flags);
713
714 if (f_v) {
715 cout << "object_with_canonical_form::init_incidence_geometry_from_string done" << endl;
716 }
717}
718
719
721 long int *data, int data_sz, int v, int b, int k, int design_sz,
722 int verbose_level)
723{
724 int f_v = (verbose_level >= 1);
725
726 if (f_v) {
727 cout << "object_with_canonical_form::init_large_set" << endl;
728 }
729
730 if (data_sz != b) {
731 cout << "object_with_canonical_form::init_large_set data_sz != b" << endl;
732 exit(1);
733 }
735 type = t_LS;
743 if (f_v) {
744 cout << "object_with_canonical_form::init_large_set done" << endl;
745 }
746}
747
749 std::string &data_text, int v, int k, int design_sz,
750 int verbose_level)
751{
752 int f_v = (verbose_level >= 1);
753
754 if (f_v) {
755 cout << "object_with_canonical_form::init_large_set_from_string" << endl;
756 }
758
759 type = t_LS;
760
761 Lint_vec_scan(data_text, set, sz);
762
767 if (f_v) {
768 cout << "object_with_canonical_form::init_large_set_from_string done" << endl;
769 }
770}
771
772
774 int &nb_rows, int &nb_cols,
775 int verbose_level)
776{
777 int f_v = (verbose_level >= 1);
778
779 if (f_v) {
780 cout << "object_with_canonical_form::encoding_size" << endl;
781 }
782 if (type == t_PTS) {
783
784 if (f_v) {
785 cout << "object_with_canonical_form::encoding_size "
786 "before encoding_size_point_set" << endl;
787 }
789 nb_rows, nb_cols, verbose_level);
790
791 }
792 else if (type == t_LNS) {
793
794 if (f_v) {
795 cout << "object_with_canonical_form::encoding_size "
796 "before encoding_size_line_set" << endl;
797 }
799 nb_rows, nb_cols, verbose_level);
800
801 }
802 else if (type == t_PNL) {
803
804 if (f_v) {
805 cout << "object_with_canonical_form::encoding_size "
806 "before encoding_size_points_and_lines" << endl;
807 }
809 nb_rows, nb_cols, verbose_level);
810
811 }
812 else if (type == t_PAC) {
813
814 if (f_v) {
815 cout << "object_with_canonical_form::encoding_size "
816 "before encoding_size_packing" << endl;
817 }
819 nb_rows, nb_cols, verbose_level);
820
821 }
822 else if (type == t_INC) {
823
824 if (f_v) {
825 cout << "object_with_canonical_form::encoding_size "
826 "before encoding_size_packing" << endl;
827 }
829 nb_rows, nb_cols, verbose_level);
830
831 }
832 else if (type == t_LS) {
833
834 if (f_v) {
835 cout << "object_with_canonical_form::encoding_size "
836 "before encoding_size_large_set" << endl;
837 }
839 nb_rows, nb_cols, verbose_level);
840
841 }
842 else {
843 cout << "object_with_canonical_form::encoding_size "
844 "unknown type" << endl;
845 exit(1);
846 }
847 if (f_v) {
848 cout << "object_in_projective_space::encoding_size done" << endl;
849 }
850}
851
853 int &nb_rows, int &nb_cols,
854 int verbose_level)
855{
856 int f_v = (verbose_level >= 1);
857
858 if (f_v) {
859 cout << "object_with_canonical_form::encoding_size_point_set" << endl;
860 }
861
862
864
865 C->init_lint(set, sz, TRUE, 0);
866 if (C->second_nb_types > 1) {
867 cout << "object_with_canonical_form::encoding_size_point_set "
868 "The set is a multiset:" << endl;
869 C->print(FALSE /*f_backwards*/);
870 }
871
872
873 if (f_v) {
874 cout << "The type of the set is:" << endl;
875 C->print(FALSE /*f_backwards*/);
876 cout << "C->second_nb_types = " << C->second_nb_types << endl;
877 }
878
879 int nb_rows0, nb_cols0;
880
881 nb_rows0 = P->N_points;
882 nb_cols0 = P->N_lines;
883
884 nb_rows0 += P->N_lines;
885 nb_cols0 += P->Nb_subspaces[2];
886
887
888 nb_rows = nb_rows0 + 1;
889 if (f_v) {
890 cout << "object_with_canonical_form::encoding_size_point_set "
891 "nb_rows=" << nb_rows << endl;
892 }
893 nb_cols = nb_cols0 + C->second_nb_types;
894 if (f_v) {
895 cout << "object_with_canonical_form::encoding_size_point_set "
896 "nb_cols=" << nb_cols << endl;
897 }
898 if (f_v) {
899 cout << "object_with_canonical_form::encoding_size_point_set "
900 "before FREE_OBJECT(C)" << endl;
901 }
902 FREE_OBJECT(C);
903 C = NULL;
904 if (f_v) {
905 cout << "object_with_canonical_form::encoding_size_point_set "
906 "done" << endl;
907 }
908
909}
910
912 int &nb_rows, int &nb_cols,
913 int verbose_level)
914{
915 int f_v = (verbose_level >= 1);
916
917 if (f_v) {
918 cout << "object_with_canonical_form::encoding_size_line_set" << endl;
919 }
920
921
922 nb_rows = P->N_points + 1;
923 nb_cols = P->N_lines + 1;
924
925}
926
928 int &nb_rows, int &nb_cols,
929 int verbose_level)
930{
931 int f_v = (verbose_level >= 1);
932
933 if (f_v) {
934 cout << "object_with_canonical_form::encoding_size_points_and_lines" << endl;
935 }
936
937
938 nb_rows = P->N_points + 1;
939 nb_cols = P->N_lines + 1;
940
941}
942
944 int &nb_rows, int &nb_cols,
945 int verbose_level)
946{
947 int f_v = (verbose_level >= 1);
948
949 if (f_v) {
950 cout << "object_with_canonical_form::encoding_size_packing" << endl;
951 }
952
953 nb_rows = P->N_points + SoS->nb_sets;
954 nb_cols = P->N_lines + 1;
955
956}
957
959 int &nb_rows, int &nb_cols,
960 int verbose_level)
961{
962 int f_v = (verbose_level >= 1);
963 int nb_designs;
964
965 if (f_v) {
966 cout << "object_with_canonical_form::encoding_size_large_set" << endl;
967 }
968
969 nb_designs = b / design_sz;
970 if (nb_designs * design_sz != b) {
971 cout << "object_with_canonical_form::encoding_size_large_set "
972 "design_sz does not divide b" << endl;
973 exit(1);
974 }
975
976 nb_rows = v + nb_designs;
977 nb_cols = b + 1;
978
979}
980
982 int &nb_rows, int &nb_cols,
983 int verbose_level)
984{
985 int f_v = (verbose_level >= 1);
986
987 if (f_v) {
988 cout << "object_with_canonical_form::encoding_size_packing" << endl;
989 }
990
991 nb_rows = v;
992 nb_cols = b;
993
994}
995
997 int *canonical_labeling,
999 int verbose_level)
1000{
1001 int f_v = (verbose_level >= 1);
1002
1003 if (f_v) {
1004 cout << "object_with_canonical_form::canonical_form_given_canonical_labeling" << endl;
1005 }
1006
1008
1009 encode_incma(Enc, verbose_level - 1);
1010 if (f_v) {
1011 cout << "object_with_canonical_form::canonical_form_given_canonical_labeling "
1012 "after OiP->encode_incma" << endl;
1013 }
1014
1016 B,
1017 verbose_level);
1018
1019
1020 FREE_OBJECT(Enc);
1021
1022
1023 if (f_v) {
1024 cout << "object_with_canonical_form::canonical_form_given_canonical_labeling done" << endl;
1025 }
1026}
1027
1030 int verbose_level)
1031{
1032 int f_v = (verbose_level >= 1);
1033
1034 if (f_v) {
1035 cout << "object_with_canonical_form::encode_incma" << endl;
1036 }
1037 if (type == t_PTS) {
1038
1039 encode_point_set(Enc, verbose_level);
1040
1041 }
1042 else if (type == t_LNS) {
1043
1044 encode_line_set(Enc, verbose_level);
1045
1046 }
1047 else if (type == t_PNL) {
1048
1049 encode_points_and_lines(Enc, verbose_level);
1050
1051 }
1052 else if (type == t_PAC) {
1053
1054 encode_packing(Enc, verbose_level);
1055
1056 }
1057 else if (type == t_INC) {
1058
1059 encode_incidence_geometry(Enc, verbose_level);
1060
1061 }
1062 else if (type == t_LS) {
1063
1064 encode_large_set(Enc, verbose_level);
1065
1066 }
1067 else {
1068 cout << "object_with_canonical_form::encode_incma "
1069 "unknown type" << endl;
1070 exit(1);
1071 }
1072 if (f_v) {
1073 cout << "object_with_canonical_form::encode_incma done" << endl;
1074 }
1075}
1076
1079 int verbose_level)
1080{
1081 int f_v = (verbose_level >= 1);
1082
1083 if (f_v) {
1084 cout << "object_with_canonical_form::encode_point_set" << endl;
1085 }
1086 int i, j;
1087 int f_vvv = FALSE; // (verbose_level >= 3);
1088
1089
1091
1092 if (f_v) {
1093 cout << "object_with_canonical_form::encode_point_set set=";
1094 Lint_vec_print(cout, set, sz);
1095 cout << endl;
1096 }
1097 C->init_lint(set, sz, TRUE, 0);
1098 if (C->second_nb_types > 1) {
1099 cout << "object_with_canonical_form::encode_point_set "
1100 "The set is a multiset:" << endl;
1101 C->print(FALSE /*f_backwards*/);
1102 }
1103
1104
1105 if (f_v) {
1106 cout << "The type of the set is:" << endl;
1107 C->print(FALSE /*f_backwards*/);
1108 cout << "C->second_nb_types = " << C->second_nb_types << endl;
1109 }
1110
1111
1112 int nb_rows0, nb_cols0;
1113 int nb_rows, nb_cols;
1114
1115 nb_rows0 = P->N_points;
1116 nb_cols0 = P->N_lines;
1117
1118 nb_rows0 += P->N_lines;
1119 nb_cols0 += P->Nb_subspaces[2];
1120
1121 nb_rows = nb_rows0 + 1;
1122 nb_cols = nb_cols0 + C->second_nb_types;
1123
1125 Enc->init(nb_rows, nb_cols, verbose_level);
1126
1127
1128
1129 //Enc->incidence_matrix_projective_space_top_left(P, verbose_level);
1130
1132
1133
1134 // last columns:
1135 for (j = 0; j < C->second_nb_types; j++) {
1136
1137 int h, f2, l2, m, idx, f, l;
1138
1139 f2 = C->second_type_first[j];
1140 l2 = C->second_type_len[j];
1141 m = C->second_data_sorted[f2 + 0];
1142 if (f_vvv) {
1143 cout << "j=" << j << " f2=" << f2 << " l2=" << l2
1144 << " multiplicity=" << m << endl;
1145 }
1146 for (h = 0; h < l2; h++) {
1147 idx = C->second_sorting_perm_inv[f2 + h];
1148 f = C->type_first[idx];
1149 l = C->type_len[idx];
1150 i = C->data_sorted[f + 0];
1151 if (f_vvv) {
1152 cout << "h=" << h << " idx=" << idx << " f=" << f
1153 << " l=" << l << " i=" << i << endl;
1154 }
1155 if (i > P->N_points) {
1156 cout << "object_with_canonical_form::encode_point_set i > P->N_points" << endl;
1157 cout << "i = " << i << endl;
1158 cout << "P->N_points = " << P->N_points << endl;
1159 cout << "h=" << h << " idx=" << idx << " f=" << f
1160 << " l=" << l << " i=" << i << endl;
1161 exit(1);
1162 }
1163 Enc->set_incidence_ij(i, Enc->nb_cols0 + j);
1164 }
1165 }
1166
1167 if (f_v) {
1168 cout << "object_with_canonical_form::encode_point_set bottom right entries" << endl;
1169 }
1170 // bottom right entries:
1171 for (j = 0; j < C->second_nb_types; j++) {
1172 Enc->set_incidence_ij(Enc->nb_rows0, Enc->nb_cols0 + j);
1173 }
1174
1175 if (f_v) {
1176 cout << "object_with_canonical_form::encode_point_set partition" << endl;
1177 }
1178
1179
1180 Enc->partition[P->N_points - 1] = 0;
1181 Enc->partition[nb_rows0 - 1] = 0;
1182 Enc->partition[nb_rows - 1] = 0;
1183
1184 Enc->partition[nb_rows + P->N_lines - 1] = 0;
1185 Enc->partition[nb_rows + Enc->nb_cols0 - 1] = 0;
1186
1187 for (j = 0; j < C->second_nb_types; j++) {
1188 Enc->partition[nb_rows + Enc->nb_cols0 + j] = 0;
1189 }
1190 if (f_vvv) {
1191 cout << "object_with_canonical_form::encode_point_set "
1192 "partition:" << endl;
1193 Enc->print_partition();
1194 }
1195 if (f_v) {
1196 cout << "object_with_canonical_form::encode_point_set "
1197 "done" << endl;
1198 }
1199}
1200
1203 int verbose_level)
1204{
1205 int f_v = (verbose_level >= 1);
1206
1207 if (f_v) {
1208 cout << "object_with_canonical_form::encode_line_set" << endl;
1209 }
1210 int i, j;
1211 int f_vvv = (verbose_level >= 3);
1212
1213 int nb_rows0, nb_cols0;
1214 int nb_rows, nb_cols;
1215
1216 nb_rows0 = P->N_points;
1217 nb_cols0 = P->N_lines;
1218
1219 nb_rows = nb_rows0 + 1;
1220 nb_cols = nb_cols0 + 1;
1221
1222 int N;
1223
1224 N = nb_rows + nb_cols;
1225
1227 Enc->init(nb_rows, nb_cols, verbose_level);
1228
1229 Enc->incidence_matrix_projective_space_top_left(P, verbose_level);
1230
1231 // last rows:
1232 for (i = 0; i < 1; i++) {
1233 int h;
1234
1235 for (h = 0; h < sz; h++) {
1236 j = set[h];
1237 Enc->set_incidence_ij(nb_rows0 + i, j);
1238 }
1239 }
1240
1241 // bottom right entry:
1242 Enc->set_incidence_ij(nb_rows0, nb_cols0);
1243
1244 Enc->partition[nb_rows0 - 1] = 0;
1245 Enc->partition[nb_rows - 1] = 0;
1246 Enc->partition[nb_rows + nb_cols0 - 1] = 0;
1247 Enc->partition[nb_rows + nb_cols0 + 1 - 1] = 0;
1248
1249 if (f_vvv) {
1250 cout << "object_with_canonical_form::encode_line_set "
1251 "partition:" << endl;
1252 Enc->print_partition();
1253 }
1254 if (f_v) {
1255 cout << "object_with_canonical_form::encode_line_set "
1256 "done" << endl;
1257 }
1258}
1259
1262 int verbose_level)
1263{
1264 int f_v = (verbose_level >= 1);
1265
1266 if (f_v) {
1267 cout << "object_with_canonical_form::encode_points_and_lines" << endl;
1268 }
1269 int i, j;
1270 int f_vvv = (verbose_level >= 3);
1271
1272 int nb_rows0, nb_cols0;
1273 int nb_rows, nb_cols;
1274
1275 nb_rows0 = P->N_points;
1276 nb_cols0 = P->N_lines;
1277
1278 nb_rows = nb_rows0 + 1;
1279 nb_cols = nb_cols0 + 1;
1280
1281 int N;
1282
1283 N = nb_rows + nb_cols;
1284
1286 Enc->init(nb_rows, nb_cols, verbose_level);
1287
1288 Enc->incidence_matrix_projective_space_top_left(P, verbose_level);
1289
1290 // lines go in the last row:
1291 for (i = 0; i < 1; i++) {
1292 int h;
1293
1294 for (h = 0; h < sz2; h++) {
1295 j = set2[h];
1296 Enc->set_incidence_ij(nb_rows0 + i, j);
1297 }
1298 }
1299
1300 // points go in the last column:
1301 int h;
1302
1303 for (h = 0; h < sz; h++) {
1304 i = set[h];
1305 Enc->set_incidence_ij(i, nb_cols0);
1306 }
1307
1308 // bottom right entry:
1309 Enc->set_incidence_ij(nb_rows0, nb_cols0);
1310
1311 Enc->partition[nb_rows0 - 1] = 0;
1312 Enc->partition[nb_rows - 1] = 0;
1313 Enc->partition[nb_rows + nb_cols0 - 1] = 0;
1314 Enc->partition[nb_rows + nb_cols0 + 1 - 1] = 0;
1315 if (f_vvv) {
1316 cout << "object_with_canonical_form::encode_points_and_lines "
1317 "partition:" << endl;
1318 Enc->print_partition();
1319 }
1320 if (f_v) {
1321 cout << "object_with_canonical_form::encode_points_and_lines "
1322 "done" << endl;
1323 }
1324}
1325
1326
1329 int verbose_level)
1330{
1331 int f_v = (verbose_level >= 1);
1332
1333 if (f_v) {
1334 cout << "object_with_canonical_form::encode_packing" << endl;
1335 }
1336 int i, j;
1337 int f_vvv = (verbose_level >= 3);
1338
1339
1340 int nb_rows0, nb_cols0;
1341 int nb_rows, nb_cols;
1342
1343 nb_rows0 = P->N_points;
1344 nb_cols0 = P->N_lines;
1345
1346 nb_rows = nb_rows0 + SoS->nb_sets;
1347 nb_cols = nb_cols0 + 1;
1348
1350 Enc->init(nb_rows, nb_cols, verbose_level);
1351
1352 Enc->incidence_matrix_projective_space_top_left(P, verbose_level);
1353
1354 // last rows:
1355 for (i = 0; i < SoS->nb_sets; i++) {
1356 int h;
1357
1358 for (h = 0; h < SoS->Set_size[i]; h++) {
1359 j = SoS->Sets[i][h];
1360 Enc->set_incidence_ij(nb_rows0 + i, j);
1361 }
1362 }
1363 // bottom right entries:
1364 for (i = 0; i < SoS->nb_sets; i++) {
1365 Enc->set_incidence_ij(nb_rows0 + i, nb_cols0);
1366 }
1367
1368 Enc->partition[nb_rows0 - 1] = 0;
1369 Enc->partition[nb_rows - 1] = 0;
1370 Enc->partition[nb_rows + nb_cols0 - 1] = 0;
1371 Enc->partition[nb_rows + nb_cols0 + 1 - 1] = 0;
1372 if (f_vvv) {
1373 cout << "object_with_canonical_form::encode_packing "
1374 "partition:" << endl;
1375 Enc->print_partition();
1376 }
1377 if (f_v) {
1378 cout << "object_with_canonical_form::encode_packing "
1379 "done" << endl;
1380 }
1381}
1382
1385 int verbose_level)
1386{
1387 int f_v = (verbose_level >= 1);
1388
1389 if (f_v) {
1390 cout << "object_with_canonical_form::encode_large_set" << endl;
1391 }
1392 int i, j, a, h;
1393 int f_vvv = (verbose_level >= 3);
1394
1395
1396 int nb_rows, nb_cols;
1397 int nb_designs;
1398
1399 nb_designs = b / design_sz;
1400
1401 nb_rows = v + nb_designs;
1402 nb_cols = b + 1;
1403
1404 int N, L;
1405
1406 N = nb_rows + nb_cols;
1407 L = nb_rows * nb_cols;
1408
1410 Enc->init(nb_rows, nb_cols, verbose_level);
1411
1412
1414
1415 int *block;
1416
1417 block = NEW_int(design_k);
1418
1419 for (j = 0; j < sz; j++) {
1420 a = set[j];
1421 Combi.unrank_k_subset(a, block, v, design_k);
1422 for (h = 0; h < design_k; h++) {
1423 i = block[h];
1424 Enc->set_incidence_ij(i, j);
1425 }
1426 }
1427
1428 // last rows:
1429 for (i = 0; i < nb_designs; i++) {
1430
1431 for (h = 0; h < design_sz; h++) {
1432 Enc->set_incidence_ij(v + i, i * design_sz + h);
1433 }
1434 }
1435 // bottom right entries:
1436 for (i = 0; i < nb_designs; i++) {
1437 Enc->set_incidence_ij(v + i, b);
1438 }
1439
1440 Enc->partition[v - 1] = 0;
1441 Enc->partition[nb_rows - 1] = 0;
1442 Enc->partition[nb_rows + b - 1] = 0;
1443 Enc->partition[nb_rows + b + 1 - 1] = 0;
1444 if (f_vvv) {
1445 cout << "object_with_canonical_form::encode_large_set "
1446 "partition:" << endl;
1447 Enc->print_partition();
1448 }
1449
1450 FREE_int(block);
1451
1452 if (f_v) {
1453 cout << "object_with_canonical_form::encode_large_set "
1454 "done" << endl;
1455 }
1456}
1457
1460 int verbose_level)
1461{
1462 int f_v = (verbose_level >= 1);
1463
1464 if (f_v) {
1465 cout << "object_with_canonical_form::encode_incidence_geometry" << endl;
1466 }
1467 int i, a;
1468 int f_vvv = (verbose_level >= 3);
1469
1470
1471 int nb_rows, nb_cols;
1472 nb_rows = v;
1473 nb_cols = b;
1474
1475 int N;
1476
1477 N = nb_rows + nb_cols;
1478
1480 Enc->init(nb_rows, nb_cols, verbose_level);
1481
1482 for (i = 0; i < sz; i++) {
1483 a = set[i];
1484 if (a >= nb_rows * nb_cols) {
1485 cout << "object_with_canonical_form::encode_incidence_geometry a >= nb_rows* nb_cols" << endl;
1486 cout << "nb_rows = " << nb_rows << endl;
1487 cout << "nb_cols = " << nb_cols << endl;
1488 cout << "a = " << a << endl;
1489 exit(1);
1490 }
1491 Enc->set_incidence(a);
1492 }
1493
1494
1495 if (f_partition) {
1497 }
1498 else {
1499 Enc->partition[nb_rows - 1] = 0;
1500 Enc->partition[N - 1] = 0;
1501 }
1502
1503 if (f_vvv) {
1504 cout << "object_with_canonical_form::encode_incidence_geometry "
1505 "partition:" << endl;
1506 Enc->print_partition();
1507 }
1508 if (f_v) {
1509 cout << "object_with_canonical_form::encode_incidence_geometry "
1510 "done" << endl;
1511 }
1512}
1513
1516 incidence_structure *&Inc,
1518 int verbose_level)
1519{
1520 int f_v = (verbose_level >= 1);
1521
1522 if (f_v) {
1523 cout << "object_with_canonical_form::encode_incma_and_make_decomposition" << endl;
1524 }
1525 if (type == t_PTS) {
1526
1527 encode_point_set(Enc, verbose_level);
1528
1529 }
1530 else if (type == t_LNS) {
1531
1532 encode_line_set(Enc, verbose_level);
1533
1534 }
1535 else if (type == t_PNL) {
1536
1537 encode_points_and_lines(Enc, verbose_level);
1538
1539 }
1540 else if (type == t_PAC) {
1541
1542 encode_packing(Enc, verbose_level);
1543
1544 }
1545 else if (type == t_INC) {
1546
1547 encode_incidence_geometry(Enc, verbose_level);
1548
1549 }
1550 else if (type == t_LS) {
1551
1552 encode_large_set(Enc, verbose_level);
1553
1554 }
1555 else {
1556 cout << "object_with_canonical_form::encode_incma_and_make_decomposition unknown type" << endl;
1557 exit(1);
1558 }
1559
1561 Inc->init_by_matrix(Enc->nb_rows, Enc->nb_cols,
1562 Enc->get_Incma(), verbose_level - 2);
1563
1564
1565
1566
1568 Stack->allocate(Enc->nb_rows + Enc->nb_cols, 0);
1569 Stack->subset_continguous(Inc->nb_points(), Inc->nb_lines());
1570 Stack->split_cell(0);
1571
1572 if (type == t_PTS) {
1573
1574 if (f_v) {
1575 cout << "object_with_canonical_form::encode_incma_and_make_decomposition t_PTS split1" << endl;
1576 }
1577 Stack->subset_continguous(
1578 Inc->nb_points() + P->N_lines,
1579 Enc->nb_cols - P->N_lines);
1580 Stack->split_cell(0);
1581 if (f_v) {
1582 cout << "object_with_canonical_form::encode_incma_and_make_decomposition t_PTS split2" << endl;
1583 }
1584 if (Enc->nb_rows - Inc->nb_points()) {
1585 Stack->subset_continguous(
1586 Inc->nb_points(),
1587 Enc->nb_rows - Inc->nb_points());
1588 Stack->split_cell(0);
1589 }
1590
1591 }
1592
1593 else if (type == t_LNS) {
1594
1595 if (f_v) {
1596 cout << "object_with_canonical_form::encode_incma_and_make_decomposition t_LNS" << endl;
1597 }
1598 Stack->subset_continguous(P->N_points, 1);
1599 Stack->split_cell(0);
1600 Stack->subset_continguous(
1601 Inc->nb_points() + P->N_lines,
1602 Enc->nb_cols - P->N_lines);
1603 Stack->split_cell(0);
1604
1605 }
1606
1607 else if (type == t_PNL) {
1608
1609 if (f_v) {
1610 cout << "object_with_canonical_form::encode_incma_and_make_decomposition t_PNL" << endl;
1611 }
1612 Stack->subset_continguous(P->N_points, 1);
1613 Stack->split_cell(0);
1614 Stack->subset_continguous(
1615 Inc->nb_points() + P->N_lines,
1616 Enc->nb_cols - P->N_lines);
1617 Stack->split_cell(0);
1618
1619 }
1620
1621 else if (type == t_PAC) {
1622
1623 if (f_v) {
1624 cout << "object_with_canonical_form::encode_incma_and_make_decomposition t_PAC" << endl;
1625 }
1626 Stack->subset_continguous(P->N_points, Enc->nb_rows - P->N_points);
1627 Stack->split_cell(0);
1628 Stack->subset_continguous(
1629 Inc->nb_points() + P->N_lines,
1630 Enc->nb_cols - P->N_lines);
1631 Stack->split_cell(0);
1632
1633 }
1634 else if (type == t_INC) {
1635
1636 if (f_v) {
1637 cout << "object_with_canonical_form::encode_incma_and_make_decomposition t_INC" << endl;
1638 }
1639 Stack->subset_continguous(v, b);
1640 Stack->split_cell(0);
1641
1642 }
1643 else if (type == t_LS) {
1644
1645 if (f_v) {
1646 cout << "object_with_canonical_form::encode_incma_and_make_decomposition t_LS" << endl;
1647 }
1648 Stack->subset_continguous(v, Enc->nb_rows - v);
1649 Stack->split_cell(0);
1650 Stack->subset_continguous(
1651 v + b,
1652 Enc->nb_cols - b);
1653 Stack->split_cell(0);
1654
1655 }
1656 else {
1657 cout << "object_with_canonical_form::encode_incma_and_make_decomposition "
1658 "unknown type " << type << endl;
1659 exit(1);
1660 }
1661
1662 if (f_v) {
1663 cout << "object_with_canonical_form::encode_incma_and_make_decomposition done" << endl;
1664 }
1665}
1666
1668 long int *&encoding, int &encoding_sz, int verbose_level)
1669{
1670 int f_v = (verbose_level >= 1);
1671
1672 if (f_v) {
1673 cout << "object_with_canonical_form::encode_object" << endl;
1674 }
1675 if (type == t_PTS) {
1676
1677 encode_object_points(encoding, encoding_sz, verbose_level);
1678
1679 }
1680 else if (type == t_LNS) {
1681
1682 encode_object_lines(encoding, encoding_sz, verbose_level);
1683
1684 }
1685 else if (type == t_PNL) {
1686
1687 encode_object_points_and_lines(encoding, encoding_sz, verbose_level);
1688
1689 }
1690 else if (type == t_PAC) {
1691
1692 encode_object_packing(encoding, encoding_sz, verbose_level);
1693
1694 }
1695 else if (type == t_INC) {
1696
1697 encode_object_incidence_geometry(encoding, encoding_sz, verbose_level);
1698
1699 }
1700 else if (type == t_LS) {
1701
1702 encode_object_large_set(encoding, encoding_sz, verbose_level);
1703
1704 }
1705 else {
1706 cout << "object_with_canonical_form::encode_object "
1707 "unknown type" << endl;
1708 exit(1);
1709 }
1710 if (f_v) {
1711 cout << "object_with_canonical_form::encode_object "
1712 "encoding_sz=" << encoding_sz << endl;
1713 }
1714 if (f_v) {
1715 cout << "object_with_canonical_form::encode_object "
1716 "done" << endl;
1717 }
1718}
1719
1721 long int *&encoding, int &encoding_sz, int verbose_level)
1722{
1723 int f_v = (verbose_level >= 1);
1724
1725 if (f_v) {
1726 cout << "object_with_canonical_form::encode_object_points" << endl;
1727 }
1728 encoding_sz = sz;
1729 encoding = NEW_lint(sz);
1730 Lint_vec_copy(set, encoding, sz);
1731}
1732
1734 long int *&encoding, int &encoding_sz,
1735 int verbose_level)
1736{
1737 int f_v = (verbose_level >= 1);
1738
1739 if (f_v) {
1740 cout << "object_with_canonical_form::encode_object_lines" << endl;
1741 }
1742 encoding_sz = sz;
1743 encoding = NEW_lint(sz);
1744 Lint_vec_copy(set, encoding, sz);
1745}
1746
1748 long int *&encoding, int &encoding_sz,
1749 int verbose_level)
1750{
1751 int f_v = (verbose_level >= 1);
1752
1753 if (f_v) {
1754 cout << "object_with_canonical_form::encode_object_points_and_lines" << endl;
1755 }
1756 encoding_sz = sz;
1757 encoding = NEW_lint(sz);
1758 Lint_vec_copy(set, encoding, sz);
1759}
1760
1762 long int *&encoding, int &encoding_sz,
1763 int verbose_level)
1764{
1765 int f_v = (verbose_level >= 1);
1766
1767 if (f_v) {
1768 cout << "object_with_canonical_form::encode_object_packing" << endl;
1769 }
1770 int i, h;
1771
1772 encoding_sz = SoS->total_size();
1773 encoding = NEW_lint(encoding_sz);
1774 h = 0;
1775 for (i = 0; i < SoS->nb_sets; i++) {
1776 Lint_vec_copy(SoS->Sets[i], encoding + h, SoS->Set_size[i]);
1777 h += SoS->Set_size[i];
1778 }
1779 if (h != encoding_sz) {
1780 cout << "object_with_canonical_form::encode_object_packing "
1781 "h != encoding_sz" << endl;
1782 exit(1);
1783 }
1784}
1785
1787 long int *&encoding, int &encoding_sz, int verbose_level)
1788{
1789 int f_v = (verbose_level >= 1);
1790
1791 if (f_v) {
1792 cout << "object_with_canonical_form::encode_object_incidence_geometry" << endl;
1793 }
1794 encoding_sz = sz;
1795 encoding = NEW_lint(sz);
1796 Lint_vec_copy(set, encoding, sz);
1797}
1798
1800 long int *&encoding, int &encoding_sz, int verbose_level)
1801{
1802 int f_v = (verbose_level >= 1);
1803
1804 if (f_v) {
1805 cout << "object_with_canonical_form::encode_object_large_set" << endl;
1806 }
1807 encoding_sz = sz;
1808 encoding = NEW_lint(sz);
1809 Lint_vec_copy(set, encoding, sz);
1810}
1811
1812#if 0
1813void object_with_canonical_form::klein(int verbose_level)
1814{
1815 int f_v = (verbose_level >= 1);
1816
1817 if (f_v) {
1818 cout << "object_with_canonical_form::klein" << endl;
1819 }
1820 if (type != t_LNS) {
1821 if (f_v) {
1822 cout << "object_with_canonical_form::klein "
1823 "not of type t_LNS" << endl;
1824 }
1825 return;
1826 }
1827 if (P->n != 3) {
1828 if (f_v) {
1829 cout << "object_with_canonical_form::klein "
1830 "not in three space" << endl;
1831 }
1832 return;
1833 }
1834
1835
1836 projective_space *P5;
1837 grassmann *Gr;
1838 long int *pts_klein;
1839 long int i, N;
1840
1841 ring_theory::longinteger_object *R;
1842 long int **Pts_on_plane;
1843 int *nb_pts_on_plane;
1844 int nb_planes;
1845
1846
1847
1848 P5 = NEW_OBJECT(projective_space);
1849
1850 P5->init(5, P->F,
1851 FALSE /* f_init_incidence_structure */,
1852 0 /* verbose_level - 2 */);
1853
1854 pts_klein = NEW_lint(sz);
1855
1856 if (f_v) {
1857 cout << "object_with_canonical_form::klein "
1858 "before P3->klein_correspondence" << endl;
1859 }
1861 set, sz, pts_klein, 0/*verbose_level*/);
1862
1863
1864 N = P5->nb_rk_k_subspaces_as_lint(3);
1865 if (f_v) {
1866 cout << "object_with_canonical_form::klein N = " << N << endl;
1867 }
1868
1869
1870
1871 Gr = NEW_OBJECT(grassmann);
1872
1873 Gr->init(6, 3, P->F, 0 /* verbose_level */);
1874
1875 if (f_v) {
1876 cout << "object_with_canonical_form::klein "
1877 "before plane_intersection_type_fast" << endl;
1878 }
1879 P5->plane_intersection_type_slow(Gr, pts_klein, sz,
1880 R, Pts_on_plane, nb_pts_on_plane, nb_planes,
1881 verbose_level /*- 3*/);
1882
1883 if (f_v) {
1884 cout << "object_with_canonical_form::klein "
1885 "We found " << nb_planes << " planes." << endl;
1886
1887 tally C;
1888
1889 C.init(nb_pts_on_plane, nb_planes, FALSE, 0);
1890 cout << "plane types are: ";
1891 C.print(TRUE /* f_backwards*/);
1892 cout << endl;
1893#if 0
1894 for (i = 0; i < nb_planes; i++) {
1895 if (nb_pts_on_plane[i] >= 3) {
1896 cout << setw(3) << i << " / " << nb_planes << " : " << R[i]
1897 << " : " << setw(5) << nb_pts_on_plane[i] << " : ";
1898 int_vec_print(cout, Pts_on_plane[i], nb_pts_on_plane[i]);
1899 cout << endl;
1900 }
1901 }
1902#endif
1903 }
1904 if (f_v) {
1905 cout << "before FREE_OBJECTS(R);" << endl;
1906 }
1907 FREE_OBJECTS(R);
1908 if (f_v) {
1909 cout << "before FREE_int(Pts_on_plane[i]);" << endl;
1910 }
1911 for (i = 0; i < nb_planes; i++) {
1912 FREE_lint(Pts_on_plane[i]);
1913 }
1914 if (f_v) {
1915 cout << "before FREE_pint(Pts_on_plane);" << endl;
1916 }
1917 FREE_plint(Pts_on_plane);
1918 if (f_v) {
1919 cout << "before FREE_int(nb_pts_on_plane);" << endl;
1920 }
1921 FREE_int(nb_pts_on_plane);
1922
1923
1924
1925 FREE_lint(pts_klein);
1926 FREE_OBJECT(P5);
1927 FREE_OBJECT(Gr);
1928 if (f_v) {
1929 cout << "object_with_canonical_form::klein done" << endl;
1930 }
1931}
1932#endif
1933
1935 int f_compute_canonical_form,
1936 data_structures::bitvector *&Canonical_form,
1938 int verbose_level)
1939{
1940 int f_v = (verbose_level >= 1);
1941
1942 if (f_v) {
1943 cout << "object_with_canonical_form::run_nauty" << endl;
1944 }
1945 int L;
1948 nauty_interface Nau;
1950
1951 if (f_v) {
1952 cout << "object_with_canonical_form::run_nauty" << endl;
1953 cout << "verbose_level = " << verbose_level << endl;
1954 }
1955
1956
1957 if (f_v) {
1958 cout << "object_with_canonical_form::run_nauty "
1959 "before encode_incma" << endl;
1960 }
1961 encode_incma(Enc, verbose_level - 1);
1962 if (f_v) {
1963 cout << "object_with_canonical_form::run_nauty "
1964 "after encode_incma" << endl;
1965 }
1966 if (verbose_level > 5) {
1967 cout << "object_with_canonical_form::run_nauty Incma:" << endl;
1968 //int_matrix_print_tight(Incma, nb_rows, nb_cols);
1969 }
1970
1971
1972
1974
1975
1976 L = Enc->nb_rows * Enc->nb_cols;
1977
1978 if (verbose_level > 5) {
1979 cout << "object_with_canonical_form::run_nauty "
1980 "before NO->allocate" << endl;
1981 }
1982
1983 NO->allocate(Enc->canonical_labeling_len, verbose_level - 2);
1984
1985 if (f_v) {
1986 cout << "object_with_canonical_form::run_nauty "
1987 "before Nau.nauty_interface_matrix_int" << endl;
1988 }
1989 int t0, t1, dt, tps;
1990 double delta_t_in_sec;
1992
1993 tps = Os.os_ticks_per_second();
1994 t0 = Os.os_ticks();
1995
1996
1997 Nau.nauty_interface_matrix_int(
1998 Enc,
1999 NO,
2000 verbose_level - 3);
2001
2003
2004 t1 = Os.os_ticks();
2005 dt = t1 - t0;
2006 delta_t_in_sec = (double) dt / (double) tps;
2007
2008 if (f_v) {
2009 cout << "object_with_canonical_form::run_nauty "
2010 "after Nau.nauty_interface_matrix_int, "
2011 "Ago=" << *NO->Ago << " dt=" << dt
2012 << " delta_t_in_sec=" << delta_t_in_sec << endl;
2013 }
2014 if (verbose_level > 5) {
2015 int h;
2016 //int degree = nb_rows + nb_cols;
2017
2018 for (h = 0; h < NO->Aut_counter; h++) {
2019 cout << "aut generator " << h << " / " << NO->Aut_counter << " : " << endl;
2020 //Combi.perm_print(cout, Aut + h * degree, degree);
2021 cout << endl;
2022 }
2023 }
2024
2025
2026
2027
2028 if (f_compute_canonical_form) {
2029
2030
2031 Enc->compute_canonical_form(Canonical_form,
2032 NO->canonical_labeling, verbose_level);
2033
2034 }
2035
2036
2037 if (f_v) {
2038 cout << "object_with_canonical_form::run_nauty before FREE_OBJECT(Enc)" << endl;
2039 }
2040 FREE_OBJECT(Enc);
2041
2042
2043 if (f_v) {
2044 cout << "object_with_canonical_form::run_nauty done" << endl;
2045 }
2046
2047
2048}
2049
2050
2053 int verbose_level)
2054{
2055 int f_v = (verbose_level >= 1);
2056 int f_vv = (verbose_level >= 2);
2057
2059 nauty_interface Nau;
2060
2061
2062 if (f_v) {
2063 cout << "object_with_canonical_form::canonical_labeling"
2064 << endl;
2065 cout << "verbose_level = " << verbose_level << endl;
2066 }
2067
2068 if (f_v) {
2069 cout << "object_with_canonical_form::canonical_labeling "
2070 "before encode_incma" << endl;
2071 }
2072 encode_incma(Enc, verbose_level - 1);
2073 if (f_v) {
2074 cout << "object_with_canonical_form::canonical_labeling "
2075 "after encode_incma" << endl;
2076 }
2077 if (verbose_level > 5) {
2078 cout << "object_with_canonical_form::canonical_labeling "
2079 "Incma:" << endl;
2080 Enc->print_incma();
2081 }
2082
2083 if (f_vv) {
2084 cout << "object_with_canonical_form::canonical_labeling "
2085 "initializing Aut, Base, "
2086 "Transversal_length" << endl;
2087 }
2088
2089
2090
2091 if (f_v) {
2092 cout << "object_with_canonical_form::canonical_labeling "
2093 "calling nauty_interface_matrix_int" << endl;
2094 }
2095
2096
2097 int t0, t1, dt;
2098 double delta_t_in_sec;
2100
2101 t0 = Os.os_ticks();
2102
2103 Nau.nauty_interface_matrix_int(
2104 Enc,
2105 NO,
2106 verbose_level - 3);
2107
2108 t1 = Os.os_ticks();
2109 dt = t1 - t0;
2110 delta_t_in_sec = (double) t1 / (double) dt;
2111
2112 if (f_v) {
2113 cout << "object_with_canonical_form::canonical_labeling "
2114 "done with nauty_interface_matrix_int, "
2115 "Ago=" << NO->Ago << " dt=" << dt
2116 << " delta_t_in_sec=" << delta_t_in_sec << endl;
2117 }
2118
2119
2120 if (f_v) {
2121 cout << "object_with_canonical_form::canonical_labeling "
2122 "done with nauty_interface_matrix_int, "
2123 "Ago=" << NO->Ago << endl;
2124 }
2125 FREE_OBJECT(Enc);
2126 if (f_v) {
2127 cout << "object_with_canonical_form::canonical_labeling done"
2128 << endl;
2129 }
2130}
2131
2134 int verbose_level)
2135{
2136 int f_v = (verbose_level >= 1);
2137
2138
2139 if (f_v) {
2140 cout << "object_with_canonical_form::run_nauty_basic"
2141 << endl;
2142 cout << "verbose_level = " << verbose_level << endl;
2143 }
2144
2145 int nb_rows, nb_cols;
2146
2147
2148 if (f_v) {
2149 cout << "object_with_canonical_form::run_nauty_basic before OiP->encoding_size" << endl;
2150 }
2151 encoding_size(nb_rows, nb_cols, 0 /*verbose_level*/);
2152 if (f_v) {
2153 cout << "object_with_canonical_form::run_nauty_basic after OiP->encoding_size" << endl;
2154 cout << "object_with_canonical_form::run_nauty_basic nb_rows=" << nb_rows << endl;
2155 cout << "object_with_canonical_form::run_nauty_basic nb_cols=" << nb_cols << endl;
2156 }
2157
2158 data_structures::bitvector *Canonical_form;
2159
2160
2161 if (f_v) {
2162 cout << "object_with_canonical_form::run_nauty_basic "
2163 "before OwCF->run_nauty" << endl;
2164 }
2165 run_nauty(
2166 FALSE /* f_compute_canonical_form */, Canonical_form,
2167 NO,
2168 verbose_level);
2169 if (f_v) {
2170 cout << "object_with_canonical_form::run_nauty_basic "
2171 "after OwCF->run_nauty" << endl;
2172 }
2173
2174 if (f_v) {
2175 cout << "object_with_canonical_form::run_nauty_basic done" << endl;
2176 }
2177}
2178
2179
2180
2181
2182}}}
2183
2184
2185
encoding of combinatorial object for use with nauty
void compute_canonical_form(data_structures::bitvector *&Canonical_form, int *canonical_labeling, int verbose_level)
void canonical_form_given_canonical_labeling(int *canonical_labeling, data_structures::bitvector *&B, int verbose_level)
void incidence_matrix_projective_space_top_left(geometry::projective_space *P, int verbose_level)
void extended_incidence_matrix_projective_space_top_left(geometry::projective_space *P, int verbose_level)
compact storage of 0/1-data as bitvectors
void copy(long int *from, long int *to, long int len)
Definition: lint_vec.cpp:80
data structure for set partitions following Jeffrey Leon
void init_basic_constant_size(int underlying_set_size, int nb_sets, int constant_size, int verbose_level)
void pairwise_intersection_matrix(int *&M, int verbose_level)
a statistical analysis of data consisting of single integers
void init(int *data, int data_length, int f_second, int verbose_level)
Definition: tally.cpp:72
void init_lint(long int *data, int data_length, int f_second, int verbose_level)
Definition: tally.cpp:123
interface for various incidence geometries
Definition: geometry.h:1099
void init_by_matrix(int m, int n, int *M, int verbose_level)
void init_large_set_from_string(std::string &data_text, int v, int k, int design_sz, int verbose_level)
void encode_object(long int *&encoding, int &encoding_sz, int verbose_level)
void encode_incma(combinatorics::encoded_combinatorial_object *&Enc, int verbose_level)
void encoding_size_points_and_lines(int &nb_rows, int &nb_cols, int verbose_level)
void init_packing_from_string(std::string &packing_text, int q, int verbose_level)
void init_packing_from_set(long int *packing, int sz, int verbose_level)
void encode_incidence_geometry(combinatorics::encoded_combinatorial_object *&Enc, int verbose_level)
void encode_incma_and_make_decomposition(combinatorics::encoded_combinatorial_object *&Enc, incidence_structure *&Inc, data_structures::partitionstack *&Stack, int verbose_level)
void init_point_set_from_string(std::string &set_text, int verbose_level)
void encoding_size_incidence_geometry(int &nb_rows, int &nb_cols, int verbose_level)
void encoding_size_point_set(int &nb_rows, int &nb_cols, int verbose_level)
void encoding_size_line_set(int &nb_rows, int &nb_cols, int verbose_level)
void init_points_and_lines(long int *set, int sz, long int *set2, int sz2, int verbose_level)
void encode_object_large_set(long int *&encoding, int &encoding_sz, int verbose_level)
void encoding_size(int &nb_rows, int &nb_cols, int verbose_level)
void run_nauty(int f_compute_canonical_form, data_structures::bitvector *&Canonical_form, data_structures::nauty_output *&NO, int verbose_level)
void encode_points_and_lines(combinatorics::encoded_combinatorial_object *&Enc, int verbose_level)
void init_incidence_geometry_from_vector(std::vector< int > &Flags, int v, int b, int nb_flags, int verbose_level)
void get_packing_as_set_system(long int *&Sets, int &nb_sets, int &set_size, int verbose_level)
void encoding_size_large_set(int &nb_rows, int &nb_cols, int verbose_level)
void print_tex_detailed(std::ostream &ost, int f_show_incma, int verbose_level)
void canonical_labeling(data_structures::nauty_output *NO, int verbose_level)
void encode_line_set(combinatorics::encoded_combinatorial_object *&Enc, int verbose_level)
void init_line_set_from_string(std::string &set_text, int verbose_level)
void init_incidence_geometry(long int *data, int data_sz, int v, int b, int nb_flags, int verbose_level)
void init_points_and_lines_from_string(std::string &set_text, std::string &set2_text, int verbose_level)
void encode_point_set(combinatorics::encoded_combinatorial_object *&Enc, int verbose_level)
void encoding_size_packing(int &nb_rows, int &nb_cols, int verbose_level)
void init_large_set(long int *data, int data_sz, int v, int b, int k, int design_sz, int verbose_level)
void init_packing_from_set_of_sets(data_structures::set_of_sets *SoS, int verbose_level)
void init_incidence_geometry_from_string_of_row_ranks(std::string &data, int v, int b, int r, int verbose_level)
void encode_object_packing(long int *&encoding, int &encoding_sz, int verbose_level)
void run_nauty_basic(data_structures::nauty_output *&NO, int verbose_level)
void init_incidence_geometry_from_string(std::string &data, int v, int b, int nb_flags, int verbose_level)
void canonical_form_given_canonical_labeling(int *canonical_labeling, data_structures::bitvector *&B, int verbose_level)
void encode_object_points(long int *&encoding, int &encoding_sz, int verbose_level)
void encode_object_lines(long int *&encoding, int &encoding_sz, int verbose_level)
void init_packing_from_spread_table(long int *data, long int *Spread_table, int nb_spreads, int spread_size, int q, int verbose_level)
void encode_packing(combinatorics::encoded_combinatorial_object *&Enc, int verbose_level)
void encode_object_points_and_lines(long int *&encoding, int &encoding_sz, int verbose_level)
void encode_object_incidence_geometry(long int *&encoding, int &encoding_sz, int verbose_level)
void print_rows(std::ostream &ost, int f_show_incma, int verbose_level)
void encode_large_set(combinatorics::encoded_combinatorial_object *&Enc, int verbose_level)
void klein_correspondence(projective_space *P5, long int *set_in, int set_size, long int *set_out, int verbose_level)
void print_set_of_points(std::ostream &ost, long int *Pts, int nb_pts)
void get_lint_vector_from_label(std::string &label, long int *&v, int &sz, int verbose_level)
#define Lint_vec_copy(A, B, C)
Definition: foundations.h:694
#define FREE_OBJECTS(p)
Definition: foundations.h:652
#define FREE_int(p)
Definition: foundations.h:640
#define Lint_vec_scan(A, B, C)
Definition: foundations.h:717
#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 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_copy_to_lint(A, B, C)
Definition: foundations.h:722
#define FREE_lint(p)
Definition: foundations.h:642
#define NEW_lint(n)
Definition: foundations.h:628
orbiter_kernel_system::orbiter_session * Orbiter
global Orbiter session
the orbiter library for the classification of combinatorial objects