Orbiter 2022
Combinatorial Objects
encoded_combinatorial_object.cpp
Go to the documentation of this file.
1/*
2 * encoded_combinatorial_object.cpp
3 *
4 * Created on: Aug 22, 2021
5 * Author: betten
6 */
7
8
9
10
11#include "foundations.h"
12
13using namespace std;
14
15
16namespace orbiter {
17namespace layer1_foundations {
18namespace combinatorics {
19
20
22{
23 Incma = NULL;
24 nb_rows0 = 0;
25 nb_cols0 = 0;
26 nb_flags = 0;
27 nb_rows = 0;
28 nb_cols = 0;
29 partition = NULL;
31}
32
34{
35 if (Incma) {
36 FREE_int(Incma);
37 }
38 if (partition) {
40 }
41}
42
44 int *Incma, int *partition,
45 int verbose_level)
46{
47 int f_v = (verbose_level >= 1);
48
49 if (f_v) {
50 cout << "encoded_combinatorial_object::init_everything" << endl;
51 }
54 encoded_combinatorial_object::Incma = Incma;
56 if (f_v) {
57 cout << "encoded_combinatorial_object::init_everything done" << endl;
58 }
59
60}
61
62
63void encoded_combinatorial_object::init(int nb_rows, int nb_cols,
64 int verbose_level)
65{
66 int f_v = (verbose_level >= 1);
67
68 if (f_v) {
69 cout << "encoded_combinatorial_object::init" << endl;
70 cout << "encoded_combinatorial_object::init "
71 "nb_rows=" << nb_rows << " nb_cols=" << nb_cols << endl;
72 }
73 int i, L;
74
77 L = nb_rows * nb_cols;
79
80 Incma = NEW_int(L);
81 Int_vec_zero(Incma, L);
82
84
85 nb_flags = 0;
86
87 Int_vec_zero(Incma, L);
88 for (i = 0; i < canonical_labeling_len; i++) {
89 partition[i] = 1;
90 }
91
92 if (f_v) {
93 cout << "encoded_combinatorial_object::init done" << endl;
94 }
95}
96
98{
99 return Incma;
100}
101
103{
104 if (Incma[i * nb_cols + j] == 0) {
105 Incma[i * nb_cols + j] = 1;
106 nb_flags++;
107 }
108}
109
111{
112 return Incma[i * nb_cols + j];
113}
114
116{
117 if (Incma[a] == 0) {
118 Incma[a] = 1;
119 nb_flags++;
120 }
121}
122
125 data_structures::nauty_output *NO, int verbose_level)
126{
127 int f_v = (verbose_level >= 1);
128
129 if (f_v) {
130 cout << "encoded_combinatorial_object::init_canonical_form" << endl;
131 }
132
135
136 Enc->apply_canonical_labeling(Incma, NO);
137
141
142 if (f_v) {
143 cout << "encoded_combinatorial_object::init_canonical_form done" << endl;
144 }
145}
146
148{
150
151}
152
154{
155 int i;
156
157 for (i = 0; i < canonical_labeling_len; i++) {
158 //cout << i << " : " << partition[i] << endl;
159 cout << partition[i];
160 }
161 cout << endl;
162
163}
164
166 int *&Incma_out, int verbose_level)
167{
168 int f_v = (verbose_level >= 1);
169
170 if (f_v) {
171 cout << "encoded_combinatorial_object::compute_canonical_incma" << endl;
172 }
173
174 int i, j, ii, jj;
175
176 Incma_out = NEW_int(nb_rows * nb_cols);
177 for (i = 0; i < nb_rows; i++) {
178 ii = canonical_labeling[i];
179 for (j = 0; j < nb_cols; j++) {
180 jj = canonical_labeling[nb_rows + j] - nb_rows;
181 //cout << "i=" << i << " j=" << j << " ii=" << ii
182 //<< " jj=" << jj << endl;
183 Incma_out[i * nb_cols + j] = Incma[ii * nb_cols + jj];
184 }
185 }
186 if (f_v) {
187 cout << "encoded_combinatorial_object::compute_canonical_incma done" << endl;
188 }
189}
190
192 int *canonical_labeling, int verbose_level)
193{
194 int f_v = (verbose_level >= 1);
195
196 if (f_v) {
197 cout << "encoded_combinatorial_object::compute_canonical_form" << endl;
198 }
199 int *Incma_out;
200 int L;
201 int i, j, a;
202
203 L = nb_rows * nb_cols;
204
205 compute_canonical_incma(canonical_labeling,
206 Incma_out, verbose_level);
207
208
209 Canonical_form = NEW_OBJECT(data_structures::bitvector);
210 Canonical_form->allocate(L);
211 for (i = 0; i < nb_rows; i++) {
212 for (j = 0; j < nb_cols; j++) {
213 if (Incma_out[i * nb_cols + j]) {
214 a = i * nb_cols + j;
215 Canonical_form->m_i(a, 1);
216 }
217 }
218 }
219 FREE_int(Incma_out);
220
221 if (f_v) {
222 cout << "encoded_combinatorial_object::compute_canonical_form done" << endl;
223 }
224}
225
227 geometry::projective_space *P, int verbose_level)
228{
229 int f_v = (verbose_level >= 1);
230
231 if (f_v) {
232 cout << "encoded_combinatorial_object::incidence_matrix_projective_space_top_left" << endl;
233 }
234 int i, j;
235
236 nb_rows0 = P->N_points;
237 nb_cols0 = P->N_lines;
238
239 for (i = 0; i < P->N_points; i++) {
240 for (j = 0; j < P->N_lines; j++) {
241 if (P->is_incident(i, j)) {
242 set_incidence_ij(i, j);
243 }
244 }
245 }
246 if (f_v) {
247 cout << "encoded_combinatorial_object::incidence_matrix_projective_space_top_left done" << endl;
248 }
249}
250
251
253 geometry::projective_space *P, int verbose_level)
254{
255 int f_v = (verbose_level >= 1);
256
257 if (f_v) {
258 cout << "encoded_combinatorial_object::extended_incidence_matrix_projective_space_top_left" << endl;
259 }
260
261 int i, j, h, k, l;
262
263 nb_rows0 = P->N_points + P->N_lines;
264 nb_cols0 = P->N_lines + P->Nb_subspaces[2]; // number of lines and planes
265
266 for (i = 0; i < P->N_points; i++) {
267 for (j = 0; j < P->N_lines; j++) {
268 if (P->is_incident(i, j)) {
269 set_incidence_ij(i, j);
270 }
271 }
272 }
273 for (j = 0; j < P->N_lines; j++) {
274 set_incidence_ij(P->N_points + j, j);
275 }
276
277
278 if (f_v) {
279 cout << "encoded_combinatorial_object::extended_incidence_matrix_projective_space_top_left computing points on lines" << endl;
280 }
281
282 long int *Pts_on_line;
283
284 Pts_on_line = NEW_lint(P->N_lines * P->k);
285
286 for (j = 0; j < P->N_lines; j++) {
288 j /* line_rk */, Pts_on_line + j * P->k,
289 0 /* verbose_level*/);
290 }
291
292 if (f_v) {
293 cout << "encoded_combinatorial_object::extended_incidence_matrix_projective_space_top_left computing planes through lines" << endl;
294 }
295
296 std::vector<std::vector<long int>> Plane_ranks;
297
298 for (j = 0; j < P->N_lines; j++) {
299
300 std::vector<long int> plane_ranks;
301
303 j /* line_rk */, plane_ranks, 0 /*verbose_level*/);
304
305 Plane_ranks.push_back(plane_ranks);
306
307 for (h = 0; h < plane_ranks.size(); h++) {
308
309 k = plane_ranks[h];
310
311 set_incidence_ij(P->N_points + j, P->N_lines + k);
312
313 for (l = 0; l < P->k; l++) {
314
315 i = Pts_on_line[j * P->k + l];
316
317 set_incidence_ij(i, P->N_lines + k);
318
319 }
320 }
321 }
322
323 FREE_lint(Pts_on_line);
324
325
326 if (f_v) {
327 cout << "encoded_combinatorial_object::extended_incidence_matrix_projective_space_top_left done" << endl;
328 }
329}
330
331
332
335 int verbose_level)
336{
337 int f_v = (verbose_level >= 1);
338
339 if (f_v) {
340 cout << "encoded_combinatorial_object::canonical_form_given_canonical_labeling" << endl;
341 }
342
343
344 int *Incma_out;
345 int i, j, a;
346
347 compute_canonical_incma(canonical_labeling, Incma_out, verbose_level);
348
349
351 for (i = 0; i < nb_rows; i++) {
352 for (j = 0; j < nb_cols; j++) {
353 if (Incma_out[i * nb_cols + j]) {
354 a = i * nb_cols + j;
355 B->m_i(a, 1);
356 }
357 }
358 }
359
360 FREE_int(Incma_out);
361
362
363 if (f_v) {
364 cout << "encoded_combinatorial_object::canonical_form_given_canonical_labeling done" << endl;
365 }
366}
367
369 int verbose_level)
370{
371 int f_v = (verbose_level >= 1);
372
373 if (f_v) {
374 cout << "encoded_combinatorial_object::latex_set_system_by_columns" << endl;
375 }
376
377 if (nb_rows >= 30) {
378 return;
379 }
380
382 int i, j;
383 int *B;
384 int sz;
385
386 B = NEW_int(nb_rows);
387
388 ost << "Column sets of the encoded object:\\\\" << endl;
389 for (j = 0; j < nb_cols; j++) {
390 sz = 0;
391 for (i = 0; i < nb_rows; i++) {
392 if (Incma[i * nb_cols + j]) {
393 B[sz++] = i;
394 }
395 }
396 L.int_set_print_tex(ost, B, sz);
397 ost << "\\\\" << endl;
398 }
399
400 FREE_int(B);
401
402}
403
405 int verbose_level)
406{
407 int f_v = (verbose_level >= 1);
408
409 if (f_v) {
410 cout << "encoded_combinatorial_object::latex_set_system_by_rows" << endl;
411 }
412 if (nb_cols >= 30) {
413 return;
414 }
415
417 int i, j;
418 int *B;
419 int sz;
420 long int rk;
422
423 B = NEW_int(nb_cols);
424
425 ost << "Row sets of the encoded object:\\\\" << endl;
426 for (i = 0; i < nb_rows; i++) {
427 sz = 0;
428 for (j = 0; j < nb_cols; j++) {
429 if (Incma[i * nb_cols + j]) {
430 B[sz++] = j;
431 }
432 }
433 rk = Combi.rank_k_subset(B, nb_cols, sz);
434 L.int_set_print_tex(ost, B, sz);
435 ost << " = " << rk;
436 ost << "\\\\" << endl;
437 }
438
439 FREE_int(B);
440
441}
442
444 int verbose_level)
445{
446 int f_v = (verbose_level >= 1);
447
448 if (f_v) {
449 cout << "encoded_combinatorial_object::latex_incma" << endl;
450 }
451
453
454 int *Vi;
455 int *Bj;
456 int V, B;
457 int i, j, i0, j0;
458
459 V = 0;
460 B = 0;
461 Vi = NEW_int(nb_rows);
462 Bj = NEW_int(nb_cols);
463
464 i0 = 0;
465 for (i = 0; i < nb_rows; i++) {
466 if (partition[i] == 0) {
467 Vi[V++] = i - i0 + 1;
468 i0 = i + 1;
469 }
470 }
471 if (f_v) {
472 cout << "encoded_combinatorial_object::latex_incma Vi=";
473 Int_vec_print(cout, Vi, V);
474 cout << endl;
475 }
476 j0 = 0;
477 for (j = 0; j < nb_cols; j++) {
478 if (partition[nb_rows + j] == 0) {
479 Bj[B++] = j - j0 + 1;
480 j0 = j + 1;
481 }
482 }
483 if (f_v) {
484 cout << "encoded_combinatorial_object::latex_incma Bj=";
485 Int_vec_print(cout, Bj, B);
486 cout << endl;
487 }
488
489 if (f_v) {
490 cout << "encoded_combinatorial_object::latex_incma before L.incma_latex" << endl;
491 }
492 L.incma_latex(ost,
493 nb_rows /*v */,
494 nb_cols /*b */,
495 V, B, Vi, Bj,
496 Incma,
497 verbose_level - 1);
498 if (f_v) {
499 cout << "encoded_combinatorial_object::latex_incma after L.incma_latex" << endl;
500 }
501
502
503 FREE_int(Vi);
504 FREE_int(Bj);
505
506 if (f_v) {
507 cout << "encoded_combinatorial_object::latex_incma done" << endl;
508 }
509}
510
511
512
513
514#if 0
515void projective_space_with_action::save_Levi_graph(std::string &prefix,
516 const char *mask,
517 int *Incma, int nb_rows, int nb_cols,
518 long int *canonical_labeling, int canonical_labeling_len,
519 int verbose_level)
520{
521 int f_v = (verbose_level >= 1);
522
523 if (f_v) {
524 cout << "projective_space_with_action::save_Levi_graph" << endl;
525 }
526 file_io Fio;
527 string fname_csv;
528 string fname_bin;
529 string fname_labeling;
530 char str[1000];
531
532 sprintf(str, mask, nb_rows, nb_cols);
533
534 fname_csv.assign(prefix);
535 fname_csv.append(str);
536 fname_csv.append(".csv");
537
538 fname_bin.assign(prefix);
539 fname_bin.append(str);
540 fname_bin.append(".graph");
541
542
543 fname_labeling.assign(prefix);
544 fname_labeling.append("_labeling");
545 fname_labeling.append(".csv");
546
547 latex_interface L;
548
549#if 0
550 cout << "labeling:" << endl;
551 L.lint_vec_print_as_matrix(cout,
552 canonical_labeling, N, 10 /* width */, TRUE /* f_tex */);
553#endif
554
555 Fio.lint_vec_write_csv(canonical_labeling, canonical_labeling_len,
556 fname_labeling, "can_lab");
557 Fio.int_matrix_write_csv(fname_csv, Incma, nb_rows, nb_cols);
558
559
560 colored_graph *CG;
561
562 CG = NEW_OBJECT(colored_graph);
563
564 CG->create_Levi_graph_from_incidence_matrix(
565 Incma, nb_rows, nb_cols,
566 TRUE, canonical_labeling, verbose_level);
567 CG->save(fname_bin, verbose_level);
568 FREE_OBJECT(CG);
569 if (f_v) {
570 cout << "projective_space_with_action::save_Levi_graph done" << endl;
571 }
572}
573#endif
574
575
577 int nb_orbits, int *orbit_first, int *orbit_len, int *orbit,
578 int verbose_level)
579{
580 int f_v = (verbose_level >= 1);
581
582 if (f_v) {
583 cout << "encoded_combinatorial_object::latex_TDA" << endl;
584 }
585
587
588 int *Vi;
589 int *Bj;
590 int V, B;
591 int i, j;
592 int fst, len;
593
594 V = 0;
595 B = 0;
596 Vi = NEW_int(nb_rows);
597 Bj = NEW_int(nb_cols);
598
599 for (i = 0; i < nb_orbits; i++) {
600 fst = orbit_first[i];
601 if (fst == nb_rows) {
602 break;
603 }
604 len = orbit_len[i];
605 Vi[V++] = len;
606 }
607 for (; i < nb_orbits; i++) {
608 fst = orbit_first[i];
609 len = orbit_len[i];
610 Bj[B++] = len;
611 }
612
613
614 if (f_v) {
615 cout << "encoded_combinatorial_object::latex_TDA Vi=";
616 Int_vec_print(cout, Vi, V);
617 cout << endl;
618 }
619 if (f_v) {
620 cout << "encoded_combinatorial_object::latex_TDA Bj=";
621 Int_vec_print(cout, Bj, B);
622 cout << endl;
623 }
624
625 int *Inc2;
626 int i0, j0;
627
628 Inc2 = NEW_int(nb_rows * nb_cols);
630
631 for (i = 0; i < nb_rows; i++) {
632 i0 = orbit[i];
633 for (j = 0; j < nb_cols; j++) {
634 j0 = orbit[nb_rows + j] - nb_rows;
635 if (Incma[i0 * nb_cols + j0]) {
636 Inc2[i * nb_cols + j] = 1;
637 }
638 }
639 }
640
641 if (f_v) {
642 cout << "encoded_combinatorial_object::latex_TDA "
643 "before L.incma_latex" << endl;
644 }
645 L.incma_latex(ost,
646 nb_rows /*v */,
647 nb_cols /*b */,
648 V, B, Vi, Bj,
649 Inc2,
650 verbose_level - 1);
651 if (f_v) {
652 cout << "encoded_combinatorial_object::latex_TDA "
653 "after L.incma_latex" << endl;
654 }
655
656
657 FREE_int(Inc2);
658 FREE_int(Vi);
659 FREE_int(Bj);
660
661 if (f_v) {
662 cout << "encoded_combinatorial_object::latex_TDA done" << endl;
663 }
664}
665
666
668 int nb_orbits, int *orbit_first, int *orbit_len, int *orbit,
669 int verbose_level)
670{
671 int f_v = (verbose_level >= 1);
672
673 if (f_v) {
674 cout << "encoded_combinatorial_object::latex_TDA_with_labels" << endl;
675 }
676
678
679 int *Vi;
680 int *Bj;
681 int V, B;
682 int i, j;
683 int fst, len;
684
685 V = 0;
686 B = 0;
687 Vi = NEW_int(nb_rows);
688 Bj = NEW_int(nb_cols);
689
690 for (i = 0; i < nb_orbits; i++) {
691 fst = orbit_first[i];
692 if (fst == nb_rows) {
693 break;
694 }
695 len = orbit_len[i];
696 Vi[V++] = len;
697 }
698 for (; i < nb_orbits; i++) {
699 fst = orbit_first[i];
700 len = orbit_len[i];
701 Bj[B++] = len;
702 }
703
704
705 if (f_v) {
706 cout << "encoded_combinatorial_object::latex_TDA_with_labels Vi=";
707 Int_vec_print(cout, Vi, V);
708 cout << endl;
709 }
710 if (f_v) {
711 cout << "encoded_combinatorial_object::latex_TDA_with_labels Bj=";
712 Int_vec_print(cout, Bj, B);
713 cout << endl;
714 }
715
716 int *Inc2;
717 int i0, j0;
718
719 Inc2 = NEW_int(nb_rows * nb_cols);
721
722 for (i = 0; i < nb_rows; i++) {
723 i0 = orbit[i];
724 for (j = 0; j < nb_cols; j++) {
725 j0 = orbit[nb_rows + j] - nb_rows;
726 if (Incma[i0 * nb_cols + j0]) {
727 Inc2[i * nb_cols + j] = 1;
728 }
729 }
730 }
731
732 int v = nb_rows;
733 int b = nb_cols;
734
735 std::string *point_labels;
736 std::string *block_labels;
737
738
739 point_labels = new string [v];
740 block_labels = new string [b];
741
742 for (i = 0; i < v; i++) {
743 char str[1000];
744
745 sprintf(str, "%d", orbit[i]);
746 point_labels[i].assign(str);
747 }
748
749
750 for (j = 0; j < b; j++) {
751 char str[1000];
752
753 sprintf(str, "%d", orbit[nb_rows + j]);
754 block_labels[j].assign(str);
755 }
756
758
760
761
762 if (f_v) {
763 cout << "encoded_combinatorial_object::latex_TDA_with_labels "
764 "before L.incma_latex_with_text_labels" << endl;
765 }
767 Descr,
768 nb_rows /*v */,
769 nb_cols /*b */,
770 V, B, Vi, Bj,
771 Inc2,
772 TRUE, point_labels,
773 TRUE, block_labels,
774 verbose_level - 1);
775 if (f_v) {
776 cout << "encoded_combinatorial_object::latex_TDA_with_labels "
777 "after L.incma_latex_with_text_labels" << endl;
778 }
779
780
781 delete [] point_labels;
782 delete [] block_labels;
783
784 FREE_int(Inc2);
785 FREE_int(Vi);
786 FREE_int(Bj);
787
788 if (f_v) {
789 cout << "encoded_combinatorial_object::latex_TDA_with_labels done" << endl;
790 }
791}
792
793
796 int verbose_level)
797{
798 int f_v = (verbose_level >= 1);
799
800 if (f_v) {
801 cout << "encoded_combinatorial_object::latex_canonical_form" << endl;
802 }
803
805
806 int *Vi;
807 int *Bj;
808 int V, B;
809 int i, j;
810 //int fst, len;
811
812 V = 0;
813 B = 0;
814 Vi = NEW_int(nb_rows);
815 Bj = NEW_int(nb_cols);
816
817 Vi[V++] = nb_rows;
818 Bj[B++] = nb_cols;
819#if 0
820 for (i = 0; i < nb_orbits; i++) {
821 fst = orbit_first[i];
822 if (fst == nb_rows) {
823 break;
824 }
825 len = orbit_len[i];
826 Vi[V++] = len;
827 }
828 for (; i < nb_orbits; i++) {
829 fst = orbit_first[i];
830 len = orbit_len[i];
831 Bj[B++] = len;
832 }
833#endif
834
835 if (f_v) {
836 cout << "encoded_combinatorial_object::latex_canonical_form Vi=";
837 Int_vec_print(cout, Vi, V);
838 cout << endl;
839 }
840 if (f_v) {
841 cout << "encoded_combinatorial_object::latex_canonical_form Bj=";
842 Int_vec_print(cout, Bj, B);
843 cout << endl;
844 }
845
846 int *Inc2;
847 int i0, j0;
848
849 Inc2 = NEW_int(nb_rows * nb_cols);
851
852 for (i = 0; i < nb_rows; i++) {
853 i0 = NO->canonical_labeling[i];
854 for (j = 0; j < nb_cols; j++) {
855 j0 = NO->canonical_labeling[nb_rows + j] - nb_rows;
856 if (Incma[i0 * nb_cols + j0]) {
857 Inc2[i * nb_cols + j] = 1;
858 }
859 }
860 }
861
862 ost << "Flags : ";
863
864 for (i = 0; i < nb_rows; i++) {
865 for (j = 0; j < nb_cols; j++) {
866 if (Inc2[i * nb_cols + j]) {
867 ost << i * nb_cols + j << ",";
868 }
869 }
870 }
871 ost << "\\\\" << endl;
872
873 int *row_labels_int;
874 int *col_labels_int;
875
876
877 row_labels_int = NEW_int(nb_rows);
878 col_labels_int = NEW_int(nb_cols);
879
880 for (i = 0; i < nb_rows; i++) {
881 row_labels_int[i] = NO->canonical_labeling[i];
882 }
883 for (j = 0; j < nb_cols; j++) {
884 //col_labels_int[j] = NO->canonical_labeling[nb_rows + j] - nb_rows;
885 col_labels_int[j] = NO->canonical_labeling[nb_rows + j];
886 }
887
888 if (f_v) {
889 cout << "encoded_combinatorial_object::latex_canonical_form "
890 "before L.incma_latex" << endl;
891 }
893 nb_rows /*v */,
894 nb_cols /*b */,
895 V, B, Vi, Bj,
896 row_labels_int,
897 col_labels_int,
898 Inc2,
899 verbose_level - 1);
900 if (f_v) {
901 cout << "encoded_combinatorial_object::latex_canonical_form "
902 "after L.incma_latex" << endl;
903 }
904
905 FREE_int(row_labels_int);
906 FREE_int(col_labels_int);
907
908
909 ost << "\\\\" << endl;
910
911 FREE_int(Inc2);
912 FREE_int(Vi);
913 FREE_int(Bj);
914
915 if (f_v) {
916 cout << "encoded_combinatorial_object::latex_canonical_form done" << endl;
917 }
918}
919
922{
923 int i, j, i0, j0;
924
925 Inc2 = NEW_int(nb_rows * nb_cols);
927
928 for (i = 0; i < nb_rows; i++) {
929 i0 = NO->canonical_labeling[i];
930 for (j = 0; j < nb_cols; j++) {
931 j0 = NO->canonical_labeling[nb_rows + j] - nb_rows;
932 if (Incma[i0 * nb_cols + j0]) {
933 Inc2[i * nb_cols + j] = 1;
934 }
935 }
936 }
937
938}
939
941 int *&Flags, int &nb_flags_counted,
943{
944 int i, j;
945
946 apply_canonical_labeling(Inc2, NO);
947
948 Flags = NEW_int(nb_rows * nb_cols);
949 nb_flags_counted = 0;
950 for (i = 0; i < nb_rows; i++) {
951 for (j = 0; j < nb_cols; j++) {
952 if (Inc2[i * nb_cols + j]) {
953 Flags[nb_flags_counted++] = i * nb_cols + j;
954 }
955 }
956 }
957 if (nb_flags_counted != nb_flags) {
958 cout << "encoded_combinatorial_object::apply_canonical_labeling_and_get_flags nb_flags_counted != nb_flags" << endl;
959 exit(1);
960 }
961}
962
965 std::string *row_labels,
966 std::string *col_labels,
967 int verbose_level)
968{
969 int f_v = (verbose_level >= 1);
970
971 if (f_v) {
972 cout << "encoded_combinatorial_object::latex_canonical_form" << endl;
973 }
974
976
977 int *Vi;
978 int *Bj;
979 int V, B;
980 int i, j;
981 //int fst, len;
982
983 V = 0;
984 B = 0;
985 Vi = NEW_int(nb_rows);
986 Bj = NEW_int(nb_cols);
987
988 Vi[V++] = nb_rows;
989 Bj[B++] = nb_cols;
990#if 0
991 for (i = 0; i < nb_orbits; i++) {
992 fst = orbit_first[i];
993 if (fst == nb_rows) {
994 break;
995 }
996 len = orbit_len[i];
997 Vi[V++] = len;
998 }
999 for (; i < nb_orbits; i++) {
1000 fst = orbit_first[i];
1001 len = orbit_len[i];
1002 Bj[B++] = len;
1003 }
1004#endif
1005
1006 if (f_v) {
1007 cout << "encoded_combinatorial_object::latex_canonical_form Vi=";
1008 Int_vec_print(cout, Vi, V);
1009 cout << endl;
1010 }
1011 if (f_v) {
1012 cout << "encoded_combinatorial_object::latex_canonical_form Bj=";
1013 Int_vec_print(cout, Bj, B);
1014 cout << endl;
1015 }
1016
1017 int *Inc2;
1018 int i0, j0;
1019
1020 Inc2 = NEW_int(nb_rows * nb_cols);
1021 Int_vec_zero(Inc2, nb_rows * nb_cols);
1022
1023 for (i = 0; i < nb_rows; i++) {
1024 i0 = NO->canonical_labeling[i];
1025 for (j = 0; j < nb_cols; j++) {
1026 j0 = NO->canonical_labeling[nb_rows + j] - nb_rows;
1027 if (Incma[i0 * nb_cols + j0]) {
1028 Inc2[i * nb_cols + j] = 1;
1029 }
1030 }
1031 }
1032
1033 ost << "Flags : ";
1034
1035 int *Flags;
1036 int nb_flags = 0;
1037
1038 Flags = NEW_int(nb_rows * nb_cols);
1039 for (i = 0; i < nb_rows; i++) {
1040 for (j = 0; j < nb_cols; j++) {
1041 if (Inc2[i * nb_cols + j]) {
1042 Flags[nb_flags++] = i * nb_cols + j;
1043 }
1044 }
1045 }
1046 if (nb_flags < 100) {
1047 Int_vec_print(ost, Flags, nb_flags);
1048 }
1049 else {
1050 ost << "too many to print." << endl;
1051 }
1052 FREE_int(Flags);
1053 ost << "\\\\" << endl;
1054
1055
1057
1059
1060 if (f_v) {
1061 cout << "encoded_combinatorial_object::latex_canonical_form "
1062 "before L.incma_latex_with_text_labels" << endl;
1063 }
1065 Descr,
1066 nb_rows /*v */,
1067 nb_cols /*b */,
1068 V, B, Vi, Bj,
1069 Inc2,
1070 TRUE, row_labels,
1071 TRUE, col_labels,
1072 verbose_level - 1);
1073
1074 if (f_v) {
1075 cout << "encoded_combinatorial_object::latex_canonical_form "
1076 "after L.incma_latex_with_text_labels" << endl;
1077 }
1078
1079
1080 ost << "\\\\" << endl;
1081
1082 FREE_int(Inc2);
1083 FREE_int(Vi);
1084 FREE_int(Bj);
1085
1086 if (f_v) {
1087 cout << "encoded_combinatorial_object::latex_canonical_form done" << endl;
1088 }
1089}
1090
1091
1092
1093
1094}}}
1095
encoding of combinatorial object for use with nauty
void latex_TDA(std::ostream &ost, int nb_orbits, int *orbit_first, int *orbit_len, int *orbit, int verbose_level)
void compute_canonical_form(data_structures::bitvector *&Canonical_form, int *canonical_labeling, int verbose_level)
void latex_canonical_form(std::ostream &ost, data_structures::nauty_output *NO, int verbose_level)
void apply_canonical_labeling_and_get_flags(int *&Inc2, int *&Flags, int &nb_flags_counted, data_structures::nauty_output *NO)
void init_canonical_form(encoded_combinatorial_object *Enc, data_structures::nauty_output *NO, int verbose_level)
void compute_canonical_incma(int *canonical_labeling, int *&Incma_out, int verbose_level)
void latex_canonical_form_with_labels(std::ostream &ost, data_structures::nauty_output *NO, std::string *row_labels, std::string *col_labels, int verbose_level)
void latex_TDA_with_labels(std::ostream &ost, int nb_orbits, int *orbit_first, int *orbit_len, int *orbit, 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)
void init_everything(int nb_rows, int nb_cols, int *Incma, int *partition, int verbose_level)
compact storage of 0/1-data as bitvectors
projective space PG(n,q) of dimension n over Fq
Definition: geometry.h:1916
void create_points_on_line(long int line_rk, long int *line, int verbose_level)
void planes_through_a_line(long int line_rk, std::vector< long int > &plane_ranks, int verbose_level)
void incma_latex_with_labels(std::ostream &fp, int v, int b, int V, int B, int *Vi, int *Bj, int *row_labels_int, int *col_labels_int, int *incma, int verbose_level)
void incma_latex(std::ostream &fp, int v, int b, int V, int B, int *Vi, int *Bj, int *incma, int verbose_level)
void incma_latex_with_text_labels(std::ostream &fp, graphics::draw_incidence_structure_description *Descr, int v, int b, int V, int B, int *Vi, int *Bj, int *incma, int f_labelling_points, std::string *point_labels, int f_labelling_blocks, std::string *block_labels, int verbose_level)
graphics::draw_incidence_structure_description * Draw_incidence_structure_description
#define FREE_int(p)
Definition: foundations.h:640
#define Int_vec_zero(A, B)
Definition: foundations.h:713
#define NEW_OBJECT(type)
Definition: foundations.h:638
#define FREE_OBJECT(p)
Definition: foundations.h:651
#define NEW_int(n)
Definition: foundations.h:625
#define TRUE
Definition: foundations.h:231
#define Int_vec_copy(A, B, C)
Definition: foundations.h:693
#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
orbiter_kernel_system::orbiter_session * Orbiter
global Orbiter session
the orbiter library for the classification of combinatorial objects