Orbiter 2022
Combinatorial Objects
incidence_structure.cpp
Go to the documentation of this file.
1// incidence_structure.cpp
2//
3// Anton Betten
4//
5// June 20, 2010
6
7
8
9#include "foundations.h"
10
11using namespace std;
12
13
14namespace orbiter {
15namespace layer1_foundations {
16namespace geometry {
17
18
19
20// #############################################################################
21// incidence_structure
22// #############################################################################
23
25{
26 //label[0] = 0;
27 M = NULL;
28 O = NULL;
29 H = NULL;
30 nb_lines_on_point = NULL;
31 nb_points_on_line = NULL;
32 lines_on_point = NULL;
33 points_on_line = NULL;
34 null();
35}
36
38{
39 freeself();
40}
41
43{
44}
45
47{
48 if (M) {
49 FREE_int(M);
50 }
51 if (O) {
52 // do not destroy
53 }
54 if (H) {
55 // do not destroy
56 }
59 }
62 }
63 if (lines_on_point) {
65 }
66 if (points_on_line) {
68 }
69 null();
70}
71
73{
74 int *Mtx;
75 int i, j, nb;
76 int *Lines;
77
78 Lines = NEW_int(nb_cols);
79 Mtx = NEW_int(nb_rows * nb_rows);
80 for (i = 0; i < nb_rows; i++) {
81 for (j = i; j < nb_rows; j++) {
82 nb = lines_through_two_points(Lines, i, j, 0);
83 Mtx[i * nb_rows + j] = nb;
84 Mtx[j * nb_rows + i] = nb;
85 }
86 }
87 cout << "nb of lines through two points:" << endl;
89
90 FREE_int(Lines);
91}
92
94 int p1, int p2, int verbose_level)
95{
96 int h1, h2, l1, l2, nb;
97
98 nb = 0;
99 for (h1 = 0; h1 < nb_lines_on_point[p1]; h1++) {
100 l1 = lines_on_point[p1 * max_r + h1];
101 for (h2 = 0; h2 < nb_lines_on_point[p2]; h2++) {
102 l2 = lines_on_point[p2 * max_r + h2];
103 if (l1 == l2) {
104 lines[nb++] = l1;
105 break;
106 }
107 }
108 }
109 return nb;
110}
111
113{
114 int f_v = (verbose_level >= 1);
115 int i;
116
117 if (f_v) {
118 cout << "incidence_structure::init_projective_space" << endl;
119 }
122 nb_rows = P->N_points;
123 nb_cols = P->N_lines;
124
127 r = P->r;
128 k = P->k;
131 for (i = 0; i < nb_rows; i++) {
132 nb_lines_on_point[i] = r;
133 }
134 for (i = 0; i < nb_cols; i++) {
135 nb_points_on_line[i] = k;
136 }
137 //int *nb_lines_on_point;
138 //int *nb_points_on_line;
139 max_r = min_r = r;
140 max_k = min_k = k;
141
142 if (f_v) {
143 cout << "incidence_structure::init_projective_space nb_rows=" << nb_rows << endl;
144 cout << "incidence_structure::init_projective_space nb_cols=" << nb_cols << endl;
145 }
146}
147
149{
150 int f_v = (verbose_level >= 1);
151 //int f_vv = (verbose_level >= 2);
152 //algebra_global Algebra;
153
154 if (f_v) {
155 cout << "incidence_structure::init_hjelmslev" << endl;
156 }
161 //max_r = min_r = r = O->alpha;
162 //max_k = min_k = k = O->q + 1;
165 if (f_v) {
166 cout << "incidence_structure::init_hjelmslev nb_rows=" << nb_rows << endl;
167 cout << "incidence_structure::init_hjelmslev nb_cols=" << nb_cols << endl;
168 }
169 int *Mtx;
170 int *Inc_Mtx;
171 int *v;
172 int *base_cols;
173 int mtx_rk;
174 int i, j, h, k, n;
175
176 k = H->k;
177 n = H->n;
178 Mtx = NEW_int((k + 1) * n);
179 Inc_Mtx = NEW_int(nb_rows * nb_cols);
180 v = NEW_int(k);
181 base_cols = NEW_int(n);
182 for (i = 0; i < nb_rows; i++) {
183 for (j = 0; j < nb_cols; j++) {
184 cout << "i=" << i << " j=" << j << endl;
185 H->R->PHG_element_unrank(Mtx, 1, n, i);
186 H->unrank_lint(Mtx + n, j, 0);
187 Int_vec_print_integer_matrix_width(cout, Mtx, k + 1, n, n, 1);
188 mtx_rk = H->R->Gauss_int(
189 Mtx, TRUE, FALSE, base_cols, FALSE, NULL,
190 k + 1, n, n, 2);
191 cout << "after Gauss:" << endl;
192 Int_vec_print_integer_matrix_width(cout, Mtx, k + 1, n, n, 1);
193 cout << "the rank is " << mtx_rk << endl;
194
195 for (h = 0; h < n; h++) {
196 if (Mtx[k * n + h]) {
197 break;
198 }
199 }
200 if (h < n) {
201 if (f_v) {
202 cout << "the last row is nonzero, the point is "
203 "not on the line" << endl;
204 }
205 Inc_Mtx[i * nb_cols + j] = 0;
206 }
207 else {
208 if (f_v) {
209 cout << "the last row is zero, the point is on "
210 "the line" << endl;
211 }
212 Inc_Mtx[i * nb_cols + j] = 1;
213 }
214
215#if 0
216 if (mtx_rk == H->k) {
217 Inc_Mtx[i * nb_cols + j] = 1;
218 }
219 else {
220 Inc_Mtx[i * nb_cols + j] = 0;
221 }
222#endif
223 }
224 }
225 if (f_v) {
226 cout << "incidence matrix" << endl;
228 Inc_Mtx, nb_rows, nb_cols, nb_cols, 1);
229 }
230
231 init_by_matrix(nb_rows, nb_cols, Inc_Mtx, verbose_level);
233
234 FREE_int(Mtx);
235 FREE_int(Inc_Mtx);
236 FREE_int(v);
237 FREE_int(base_cols);
238 if (f_v) {
239 cout << "incidence_structure::init_hjelmslev done" << endl;
240 }
241}
242
244 orthogonal_geometry::orthogonal *O, int verbose_level)
245{
246 int f_v = (verbose_level >= 1);
247 //int f_vv = (verbose_level >= 2);
248 int i;
249
250 if (f_v) {
251 cout << "incidence_structure::init_orthogonal" << endl;
252 }
257 max_r = min_r = r = O->alpha;
258 max_k = min_k = k = O->q + 1;
260 nb_cols = O->nb_lines;
263 for (i = 0; i < nb_rows; i++) {
265 }
266 for (i = 0; i < nb_cols; i++) {
268 }
269 if (f_v) {
270 cout << "incidence_structure::init_orthogonal done" << endl;
271 }
272}
273
275 int nb_inc, int *X, int verbose_level)
276{
277 int *M;
278 int h, i, a;
279
280 M = NEW_int(m * n);
281 for (i = 0; i < m * n; i++) {
282 M[i] = 0;
283 }
284 for (h = 0; h < nb_inc; h++) {
285 a = X[h];
286 M[a] = 1;
287 }
288 init_by_matrix(m, n, M, verbose_level);
289 FREE_int(M);
290}
291
293 int *R, int *X, int max_r, int verbose_level)
294{
295 int f_v = (verbose_level >= 1);
296 int *M;
297 int i, j, h;
298
299 if (f_v) {
300 cout << "incidence_structure::init_by_R_and_X "
301 "m=" << m << " n=" << n << endl;
302 }
303 M = NEW_int(m * n);
304 for (i = 0; i < m * n; i++) {
305 M[i] = 0;
306 }
307 for (i = 0; i < m; i++) {
308 for (h = 0; h < R[i]; h++) {
309 j = X[i * max_r + h];
310 M[i * n + j] = 1;
311 }
312 }
313 init_by_matrix(m, n, M, verbose_level - 1);
314}
315
317 data_structures::set_of_sets *SoS, int verbose_level)
318{
319 int f_v = (verbose_level >= 1);
320 int *M;
321 int i, j, h, m, n;
322
323 if (f_v) {
324 cout << "incidence_structure::init_by_set_of_sets" << endl;
325 }
326 m = SoS->nb_sets;
327 n = SoS->underlying_set_size;
328 M = NEW_int(m * n);
329 Int_vec_zero(M, m * n);
330 for (i = 0; i < m; i++) {
331 for (h = 0; h < SoS->Set_size[i]; h++) {
332 j = SoS->Sets[i][h];
333 M[i * n + j] = 1;
334 }
335 }
336 init_by_matrix(m, n, M, verbose_level - 1);
337 if (f_v) {
338 cout << "incidence_structure::init_by_set_of_sets done" << endl;
339 }
340}
341
343 int m, int n, int *M, int verbose_level)
344{
345 int i;
346 int f_v = (verbose_level >= 1);
347 //int f_vv = (verbose_level >= 2);
348
349 if (f_v) {
350 cout << "incidence_structure::init_by_matrix "
351 "m=" << m << " n=" << n << endl;
352 }
354 nb_rows = m;
355 nb_cols = n;
359 for (i = 0; i < m * n; i++) {
361 }
362 init_by_matrix2(verbose_level);
363 if (f_v) {
364 cout << "incidence_structure::init_by_matrix done" << endl;
365 }
366}
367
369 int m, int n, data_structures::bitmatrix *Bitmatrix,
370 int verbose_level)
371{
372 int i, j;
373 int f_v = (verbose_level >= 1);
374 //int f_vv = (verbose_level >= 2);
375
376 if (f_v) {
377 cout << "incidence_structure::init_by_matrix_as_bitvector "
378 "m=" << m << " n=" << n << endl;
379 }
381 nb_rows = m;
382 nb_cols = n;
383 M = NEW_int(m * n);
386 for (i = 0; i < m; i++) {
387 for (j = 0; j < n; j++) {
388 M[i] = Bitmatrix->s_ij(i, j);
389 }
390 }
391 init_by_matrix2(verbose_level);
392
393 if (f_v) {
394 cout << "incidence_structure::init_by_matrix_as_bitvector "
395 "done" << endl;
396 }
397}
398
400{
401 int i, j, h;
402 int f_v = (verbose_level >= 1);
403 int m = nb_rows;
404 int n = nb_cols;
405
406 if (f_v) {
407 cout << "incidence_structure::init_by_matrix2" << endl;
408 }
409 for (i = 0; i < m; i++) {
410 nb_lines_on_point[i] = 0;
411 for (j = 0; j < n; j++) {
412 if (M[i * n + j]) {
414 }
415 }
416 }
417 for (j = 0; j < n; j++) {
418 nb_points_on_line[j] = 0;
419 for (i = 0; i < m; i++) {
420 if (M[i * n + j]) {
422 }
423 }
424 }
427 for (i = 1; i < m; i++) {
428 if (nb_lines_on_point[i] > max_r) {
430 }
431 if (nb_lines_on_point[i] < min_r) {
433 }
434 }
435
436 if (f_v) {
437 cout << "incidence_structure::init_by_matrix2 "
438 "min_r=" << min_r << " max_r=" << max_r << endl;
439 }
440
443 for (j = 1; j < n; j++) {
444 if (nb_points_on_line[j] > max_k) {
446 }
447 if (nb_points_on_line[j] < min_k) {
449 }
450 }
451
452 if (f_v) {
453 cout << "incidence_structure::init_by_matrix2 "
454 "min_k=" << min_k << " max_k=" << max_k << endl;
455 }
456
457 if (max_r == min_r) {
459 r = max_r;
460 }
461 else {
463 }
464 if (max_k == min_k) {
466 k = max_k;
467 }
468 else {
470 }
473 for (i = 0; i < m * max_r; i++) {
474 lines_on_point[i] = 0;
475 }
476 for (i = 0; i < n * max_k; i++) {
477 points_on_line[i] = 0;
478 }
479 for (i = 0; i < m; i++) {
480 h = 0;
481 for (j = 0; j < n; j++) {
482 if (M[i * n + j]) {
483 lines_on_point[i * max_r + h++] = j;
484 }
485 }
486 }
487 for (j = 0; j < n; j++) {
488 h = 0;
489 for (i = 0; i < m; i++) {
490 if (M[i * n + j]) {
491 points_on_line[j * max_k + h++] = i;
492 }
493 }
494 }
495#if 0
496 if (f_vv) {
497 cout << "lines_on_point:" << endl;
498 print_integer_matrix_width(cout,
499 lines_on_point, m, max_r, max_r, 4);
500 cout << "points_on_line:" << endl;
501 print_integer_matrix_width(cout,
502 points_on_line, n, max_k, max_k, 4);
503 }
504#endif
505 if (f_v) {
506 cout << "incidence_structure::init_by_matrix2 done" << endl;
507 }
508}
509
510
512{
513 return nb_rows;
514}
515
517{
518 return nb_cols;
519}
520
522{
525 return M[i * nb_cols + j];
526 }
527 else if (realization_type ==
529 long int p1, p2, rk;
530 int *v;
531 int *base_cols;
532
533 //cout << "incidence_structure::get_ij i=" << i << " j=" << j << endl;
534 v = NEW_int(3 * O->n);
535 base_cols = NEW_int(O->n);
536 //cout << "before O->unrank_point(v, 1, i);" << endl;
537 O->unrank_point(v, 1, i, 0);
538 //cout << "before O->unrank_line(v, p1, p2, j);" << endl;
539 O->unrank_line(p1, p2, j, 0 /* verbose_level */);
540 //cout << "before O->unrank_point(v + 1 * O->n, 1, p1);" << endl;
541 O->unrank_point(v + 1 * O->n, 1, p1, 0);
542 //cout << "before O->unrank_point(v + 2 * O->n, 1, p2);" << endl;
543 O->unrank_point(v + 2 * O->n, 1, p2, 0);
544 rk = O->F->Linear_algebra->Gauss_simple(v, 3, O->n, base_cols, 0/* verbose_level*/);
545
546 FREE_int(v);
547 FREE_int(base_cols);
548
549 if (rk == 2) {
550 return TRUE;
551 }
552 if (rk == 3) {
553 return FALSE;
554 }
555 cout << "incidence_structure::get_ij fatal: rk=" << rk << endl;
556 exit(1);
557 }
558 cout << "incidence_structure::get_ij: unknown realization_type";
559 exit(1);
560}
561
562int incidence_structure::get_lines_on_point(int *data, int i, int verbose_level)
563{
564 int f_v = (verbose_level >= 1);
565 int r;
566
567 if (f_v) {
568 cout << "incidence_structure::get_lines_on_point" << endl;
569 }
570 if (i < 0 || i >= nb_rows) {
571 cout << "incidence_structure::get_lines_on_point "
572 "i=" << i << " is illegal" << endl;
573 exit(1);
574 }
577 int h;
578 for (h = 0; h < nb_lines_on_point[i]; h++) {
579 data[h] = lines_on_point[i * max_r + h];
580 }
581 r = nb_lines_on_point[i];
582 }
583 else if (realization_type ==
585 O->lines_on_point_by_line_rank_must_fit_into_int(i, data, 0/*verbose_level - 2*/);
586 r = O->alpha;
587 }
588 else if (realization_type ==
590 long int *Data;
591 int h;
592
593 Data = NEW_lint(P->r);
594 P->create_lines_on_point(i, Data, verbose_level);
595 for (h = 0; h < P->r; h++) {
596 data[h] = Data[h];
597 }
598 FREE_lint(Data);
599 r = P->r;
600 }
601 else {
602 cout << "incidence_structure::get_lines_on_point "
603 "fatal: unknown realization_type";
604 exit(1);
605 }
606 if (f_v) {
607 cout << "incidence_structure::get_lines_on_point pt = " << i << " : ";
608 Int_vec_print(cout, data, r);
609 cout << endl;
610 cout << "incidence_structure::get_lines_on_point done" << endl;
611 }
612 return r;
613}
614
615int incidence_structure::get_points_on_line(int *data, int j, int verbose_level)
616{
617 int f_v = (verbose_level >= 1);
618 int k;
619
620 if (f_v) {
621 cout << "incidence_structure::get_points_on_line" << endl;
622 }
625 int h;
626 for (h = 0; h < nb_points_on_line[j]; h++) {
627 data[h] = points_on_line[j * max_k + h];
628 }
629 k = nb_points_on_line[j];
630 }
631 else if (realization_type ==
633 long int *Data;
634 int h;
635
636 Data = NEW_lint(nb_points_on_line[j]);
637 O->points_on_line_by_line_rank(j, Data, 0/* verbose_level - 2*/);
638 for (h = 0; h < nb_points_on_line[j]; h++) {
639 data[h] = Data[h];
640 }
641 FREE_lint(Data);
642 k = O->q + 1;
643 }
644 else if (realization_type ==
646 long int *Data;
647 int h;
648
649 Data = NEW_lint(P->k);
650 P->create_points_on_line(j, Data, 0 /*verbose_level*/);
651 for (h = 0; h < P->k; h++) {
652 data[h] = Data[h];
653 }
654 FREE_lint(Data);
655 k = P->k;
656 }
657 else {
658 cout << "incidence_structure::get_points_on_line "
659 "fatal: unknown realization_type";
660 exit(1);
661 }
662 if (f_v) {
663 cout << "incidence_structure::get_points_on_line "
664 "line = " << j << " : ";
665 Int_vec_print(cout, data, k);
666 cout << endl;
667 cout << "incidence_structure::get_points_on_line done" << endl;
668 }
669 return k;
670}
671
673{
674 if (f_rowsums_constant) {
675 return nb_rows * r;
676 }
677 else {
678 int i, j, nb = 0;
679
680 for (i = 0; i < nb_rows; i++) {
681 for (j = 0; j < nb_cols; j++) {
682 if (get_ij(i, j)) {
683 nb++;
684 }
685 }
686 }
687 return nb;
688 }
689}
690
692{
693 int i, j, nb_inc;
694
695 nb_inc = get_nb_inc();
696
697 ofstream f(fname);
698 f << nb_rows << " " << nb_cols << " " << nb_inc << endl;
699 for (i = 0; i < nb_rows; i++) {
700 for (j = 0; j < nb_cols; j++) {
701 if (get_ij(i, j)) {
702 f << i * nb_cols + j << " ";
703 }
704 }
705 }
706 f << "0" << endl; // ago not known
707 f << "-1" << endl;
708}
709
711{
712 int i, j; //, nb_inc;
713 int w;
715
716 //nb_inc = get_nb_inc();
717
718 if (!f_rowsums_constant) {
719 cout << "incidence_structure::save_row_by_row_file "
720 "rowsums are not constant" << endl;
721 exit(1);
722 }
723 ofstream f(fname);
724 w = NT.int_log10(nb_cols) + 1;
725 f << nb_rows << " " << nb_cols << " " << r << endl;
726 for (i = 0; i < nb_rows; i++) {
727 for (j = 0; j < r; j++) {
728 f << setw(w) << lines_on_point[i * r + j] << " ";
729 }
730 f << endl;
731 }
732 f << "-1" << endl;
733}
734
735
737{
738 int i, j;
739
740 if (nb_cols == 0) {
741 cout << "incidence_structure::print nb_cols == 0" << endl;
742 return;
743 }
744 for (i = 0; i < nb_rows; i++) {
745 for (j = 0; j < nb_cols; j++) {
746 if (get_ij(i, j)) {
747 ost << "1";
748 }
749 else {
750 ost << ".";
751 }
752 }
753 ost << endl;
754 }
755}
756
759 int depth, int &step, int &f_refine, int &f_refine_prev,
760 int verbose_level)
761{
762 int f_v = (verbose_level >= 1);
763
764 if (f_v) {
765 cout << "incidence_structure::compute_TDO_safe_first" << endl;
766 }
767 step = 0;
768 f_refine_prev = TRUE;
769}
770
773 int depth, int &step, int &f_refine, int &f_refine_prev,
774 int verbose_level)
775// returns TRUE when we are done, FALSE otherwise
776{
777 int f_v = (verbose_level >= 1);
778 int f_vv = (verbose_level >= 2);
779 int f_vvv = (verbose_level >= 3);
780
781 if (f_v) {
782 cout << "incidence_structure::compute_TDO_safe_next" << endl;
783 }
784 if (EVEN(step)) {
786 PStack, verbose_level - 3);
787 }
788 else {
789 f_refine = refine_row_partition_safe(
790 PStack, verbose_level - 3);
791 }
792
793 if (f_vv) {
794 cout << "incidence_structure::compute_TDO_safe_next "
795 "step=" << step << " after refine" << endl;
796 }
797 if (f_vvv) {
798 if (EVEN(step)) {
799 int f_list_incidences = FALSE;
801 f_list_incidences, FALSE, verbose_level);
803 }
804 else {
805 int f_list_incidences = FALSE;
807 f_list_incidences, FALSE, verbose_level);
809 }
810 }
811 step++;
812 if (!f_refine_prev && !f_refine) {
813 return TRUE;
814 }
815 f_refine_prev = f_refine;
816 return FALSE;
817}
818
820 int depth, int verbose_level)
821{
822 int f_v = (verbose_level >= 1);
823 //int f_vv = (verbose_level >= 2);
824 //int f_vvv = (verbose_level >= 3);
825 int f_refine, f_refine_prev;
826 int i;
827
828 if (f_v) {
829 cout << "incidence_structure::compute_TDO_safe" << endl;
830 }
831
832 f_refine_prev = TRUE;
833 for (i = 0; i < depth; i++) {
834 if (f_v) {
835 cout << "incidence_structure::compute_TDO_safe i = " << i << endl;
836 }
837
838
839 if (EVEN(i)) {
840 if (f_v) {
841 cout << "incidence_structure::compute_TDO_safe before refine_column_partition_safe" << endl;
842 }
843 f_refine = refine_column_partition_safe(PStack, verbose_level - 2);
844 if (f_v) {
845 cout << "incidence_structure::compute_TDO_safe after refine_column_partition_safe" << endl;
846 }
847 }
848 else {
849 if (f_v) {
850 cout << "incidence_structure::compute_TDO_safe before refine_row_partition_safe" << endl;
851 }
852 f_refine = refine_row_partition_safe(PStack, verbose_level - 2);
853 if (f_v) {
854 cout << "incidence_structure::compute_TDO_safe after refine_row_partition_safe" << endl;
855 }
856 }
857
858 if (f_v) {
859 cout << "incidence_structure::compute_TDO_safe "
860 "i=" << i << " after refine" << endl;
861 if (EVEN(i)) {
862 int f_list_incidences = FALSE;
864 f_list_incidences, FALSE, verbose_level);
866 }
867 else {
868 int f_list_incidences = FALSE;
870 f_list_incidences, FALSE, verbose_level);
872 }
873 }
874
875 if (!f_refine_prev && !f_refine) {
876 if (f_v) {
877 cout << "incidence_structure::compute_TDO_safe "
878 "no refinement, we are done" << endl;
879 }
880 goto done;
881 }
882 f_refine_prev = f_refine;
883 }
884
885done:
886 if (f_v) {
887 cout << "incidence_structure::compute_TDO_safe done" << endl;
888 }
889
890}
891
893 data_structures::partitionstack &PStack, int ht0,
894 int depth, int verbose_level)
895{
896 int h1, h2, ht1, remaining_depth = depth;
897 int f_v = (verbose_level >= 1);
898 //int f_vv = (verbose_level >= 2);
899 //int f_vvv = (verbose_level >= 3);
901
902 ht1 = PStack.ht;
903 h2 = 0;
904
905 if (f_v) {
906 cout << "incidence_structure::compute_TDO "
907 "depth=" << depth << " ht=" << PStack.ht << endl;
908 if (ht0 >= PStack.ht) {
909 cout << "ht0 >= PStack.ht, fatal" << endl;
910 exit(1);
911 }
912 }
913 while (remaining_depth) {
914
915 if (f_v) {
916 cout << "incidence_structure::compute_TDO "
917 "remaining_depth=" << remaining_depth << endl;
918 }
919 if (remaining_depth) {
920 h1 = compute_TDO_step(PStack, ht0, verbose_level);
921 h2 = Algo.hashing(h1, h2);
922 ht0 = ht1;
923 ht1 = PStack.ht;
924 remaining_depth--;
925 }
926 else {
927 break;
928 }
929 if (f_v) {
930 cout << "incidence_structure::compute_TDO after "
931 "compute_TDO_step ht0=" << ht0 << " ht1=" << ht1 << endl;
932 }
933 if (ht0 == ht1) {
934 break;
935 }
936 }
937 return h2;
938}
939
941 data_structures::partitionstack &PStack, int ht0, int verbose_level)
942{
943 int ht1, h1, h2;
944 int f_v = (verbose_level >= 1);
945 int f_vv = (verbose_level >= 2);
946 int f_vvv = (verbose_level >= 3);
947 int f_is_row_class;
949
950 ht1 = PStack.ht;
951 h2 = 0;
952 if (f_v) {
953 cout << "incidence_structure::compute_TDO_step "
954 "ht=" << PStack.ht << " ht0=" << ht0 << endl;
955 cout << "before PStack.is_row_class" << endl;
956 }
957 f_is_row_class = PStack.is_row_class(ht0);
958 if (f_v) {
959 cout << "after PStack.is_row_class" << endl;
960 }
961 if (f_is_row_class) {
962 if (f_vv) {
963 cout << "incidence_structure::compute_TDO_step before "
964 "refine_column_partition ht0=" << ht0
965 << " ht1=" << ht1 << endl;
966 }
967 h1 = refine_column_partition(PStack, ht0, verbose_level - 3);
968 //cout << "h1=" << h1 << endl;
969 h2 = Algo.hashing(h1, h2);
970 if (f_v) {
971 cout << "incidence_structure::compute_TDO_step after "
972 "refine_column_partition ht=" << PStack.ht << endl;
973 }
974 if (f_vv) {
975 int f_list_incidences = FALSE;
977 f_list_incidences, FALSE, verbose_level);
978 }
979 if (f_vvv) {
981 }
982 }
983 else {
984 if (f_vv) {
985 cout << "incidence_structure::compute_TDO_step before "
986 "refine_column_partition ht0=" << ht0
987 << " ht1=" << ht1 << endl;
988 }
989 h1 = refine_row_partition(PStack, ht0, verbose_level - 3);
990 //cout << "h1=" << h1 << endl;
991 h2 = Algo.hashing(h1, h2);
992 //cout << "h2=" << h2 << endl;
993 if (f_v) {
994 cout << "incidence_structure::compute_TDO_step after "
995 "refine_row_partition ht=" << PStack.ht << endl;
996 }
997 if (f_vv) {
998 int f_list_incidences = FALSE;
1000 PStack, f_list_incidences, FALSE, verbose_level);
1001 }
1002 if (f_vvv) {
1003 PStack.print_classes_points_and_lines(cout);
1004 }
1005 }
1006 return h2;
1007}
1008
1009
1011 int *row_classes, int *row_class_idx, int &nb_row_classes,
1012 int *col_classes, int *col_class_idx, int &nb_col_classes)
1013{
1014 int i, c;
1015
1017 row_classes, nb_row_classes,
1018 col_classes, nb_col_classes, 0 /*verbose_level*/);
1019 for (i = 0; i < PStack.ht; i++) {
1020 row_class_idx[i] = col_class_idx[i] = -1;
1021 }
1022 for (i = 0; i < nb_row_classes; i++) {
1023 c = row_classes[i];
1024 row_class_idx[c] = i;
1025 }
1026 for (i = 0; i < nb_col_classes; i++) {
1027 c = col_classes[i];
1028 col_class_idx[c] = i;
1029 }
1030}
1031
1033 data_structures::partitionstack &PStack, int verbose_level)
1034{
1035
1036 int f_v = (verbose_level >= 1);
1037 int f_vv = (verbose_level >= 5);
1038 int i, j, c, h, I, ht, first, next, N;
1039 int *row_classes;
1040 int *row_class_idx;
1041 int nb_row_classes;
1042 int *col_classes;
1043 int *col_class_idx;
1044 int nb_col_classes;
1045
1046 int *data;
1047 int *neighbors;
1048
1049 if (f_v) {
1050 cout << "incidence_structure::refine_column_partition_safe" << endl;
1051 }
1052 if (f_v) {
1053 cout << "incidence_structure::refine_column_partition_safe PStack.ht" << PStack.ht << endl;
1054 }
1055 row_classes = NEW_int(PStack.ht);
1056 col_classes = NEW_int(PStack.ht);
1057 row_class_idx = NEW_int(PStack.ht);
1058 col_class_idx = NEW_int(PStack.ht);
1059
1060 if (f_v) {
1061 cout << "incidence_structure::refine_column_partition_safe "
1062 "before get_partition" << endl;
1063 }
1064 get_partition(PStack,
1065 row_classes, row_class_idx, nb_row_classes,
1066 col_classes, col_class_idx, nb_col_classes);
1067 if (f_v) {
1068 cout << "incidence_structure::refine_column_partition_safe "
1069 "after get_partition" << endl;
1070 }
1071
1072 N = nb_points() + nb_lines();
1073 if (f_v) {
1074 cout << "incidence_structure::refine_column_partition_safe nb_row_classes= " << nb_row_classes << endl;
1075 }
1076 data = NEW_int(N * nb_row_classes);
1077 Int_vec_zero(data, N * nb_row_classes);
1078
1079 neighbors = NEW_int(max_k);
1080
1081 for (j = 0; j < nb_lines(); j++) {
1082 get_points_on_line(neighbors, j, 0 /*verbose_level - 2*/);
1083 for (h = 0; h < nb_points_on_line[j]; h++) {
1084 i = neighbors[h];
1085 c = PStack.cellNumber[PStack.invPointList[i]];
1086 I = row_class_idx[c];
1087 if (I == -1) {
1088 cout << "incidence_structure::refine_column_partition_safe "
1089 "I == -1" << endl;
1090 exit(1);
1091 }
1092 data[(nb_points() + j) * nb_row_classes + I]++;
1093 }
1094 }
1095 if (f_vv) {
1096 cout << "incidence_structure::refine_column_partition_safe "
1097 "data:" << endl;
1099 data + nb_points() * nb_row_classes,
1100 nb_lines(), nb_row_classes, nb_row_classes, 3);
1101 }
1102
1103 ht = PStack.ht;
1104
1105 for (c = 0; c < ht; c++) {
1106 if (PStack.is_row_class(c)) {
1107 continue;
1108 }
1109
1110 if (PStack.cellSize[c] == 1) {
1111 continue;
1112 }
1113 first = PStack.startCell[c];
1114 next = first + PStack.cellSize[c];
1115
1116 PStack.radix_sort(first /* left */,
1117 next - 1 /* right */,
1118 data, nb_row_classes, 0 /*radix*/, FALSE);
1119 }
1120
1121 FREE_int(data);
1122 FREE_int(neighbors);
1123
1124 FREE_int(row_classes);
1125 FREE_int(col_classes);
1126 FREE_int(row_class_idx);
1127 FREE_int(col_class_idx);
1128 if (f_v) {
1129 cout << "incidence_structure::refine_column_partition_safe done" << endl;
1130 }
1131 if (PStack.ht == ht) {
1132 return FALSE;
1133 }
1134 else {
1135 return TRUE;
1136 }
1137}
1138
1140 data_structures::partitionstack &PStack, int verbose_level)
1141{
1142
1143 int f_v = (verbose_level >= 1);
1144 int f_vv = (verbose_level >= 5);
1145 int i, j, c, h, J, ht, first, next;
1146 int *row_classes;
1147 int *row_class_idx;
1148 int nb_row_classes;
1149 int *col_classes;
1150 int *col_class_idx;
1151 int nb_col_classes;
1152
1153 int *data;
1154 int *neighbors;
1155
1156 if (f_v) {
1157 cout << "incidence_structure::refine_row_partition_safe" << endl;
1158 }
1159 row_classes = NEW_int(PStack.ht);
1160 col_classes = NEW_int(PStack.ht);
1161 row_class_idx = NEW_int(PStack.ht);
1162 col_class_idx = NEW_int(PStack.ht);
1163
1164 if (f_v) {
1165 cout << "incidence_structure::refine_row_partition_safe before get_partition" << endl;
1166 }
1167 get_partition(PStack,
1168 row_classes, row_class_idx, nb_row_classes,
1169 col_classes, col_class_idx, nb_col_classes);
1170 if (f_v) {
1171 cout << "incidence_structure::refine_row_partition_safe after get_partition" << endl;
1172 }
1173 if (f_v) {
1174 cout << "incidence_structure::refine_row_partition_safe nb_col_classes=" << nb_col_classes << endl;
1175 }
1176
1177 data = NEW_int(nb_points() * nb_col_classes);
1178 Int_vec_zero(data, nb_points() * nb_col_classes);
1179
1180
1181 neighbors = NEW_int(max_r);
1182
1183 for (i = 0; i < nb_points(); i++) {
1184 get_lines_on_point(neighbors, i, 0 /*verbose_level - 2*/);
1185 for (h = 0; h < nb_lines_on_point[i]; h++) {
1186 j = neighbors[h] + nb_points();
1187 c = PStack.cellNumber[PStack.invPointList[j]];
1188 J = col_class_idx[c];
1189 if (J == -1) {
1190 cout << "incidence_structure::refine_row_partition_safe J == -1" << endl;
1191 exit(1);
1192 }
1193 data[i * nb_col_classes + J]++;
1194 }
1195 }
1196 if (f_vv) {
1197 cout << "incidence_structure::refine_row_partition_safe data:" << endl;
1199 nb_col_classes, nb_col_classes, 3);
1200 }
1201
1202 ht = PStack.ht;
1203
1204 for (c = 0; c < ht; c++) {
1205 if (PStack.is_col_class(c)) {
1206 continue;
1207 }
1208
1209 if (PStack.cellSize[c] == 1) {
1210 continue;
1211 }
1212 first = PStack.startCell[c];
1213 next = first + PStack.cellSize[c];
1214
1215 PStack.radix_sort(first /* left */,
1216 next - 1 /* right */,
1217 data, nb_col_classes, 0 /*radix*/, FALSE);
1218 }
1219
1220 FREE_int(data);
1221 FREE_int(neighbors);
1222
1223 FREE_int(row_classes);
1224 FREE_int(col_classes);
1225 FREE_int(row_class_idx);
1226 FREE_int(col_class_idx);
1227 if (f_v) {
1228 cout << "incidence_structure::refine_row_partition_safe done" << endl;
1229 }
1230 if (PStack.ht == ht) {
1231 return FALSE;
1232 }
1233 else {
1234 return TRUE;
1235 }
1236}
1237
1240 int ht0, int verbose_level)
1241{
1242 int f_v = (verbose_level >= 1);
1243 int f_vv = (verbose_level >= 2);
1244 int f_vvv = (verbose_level >= 3);
1245 int row_cell, f, l, i, j, x, y, u, c, cell;
1246 int N, first, next, ht1, depth, idx, nb;
1247 int *data;
1248 int *neighbors, h;
1249
1250 N = nb_points() + nb_lines();
1251 ht1 = PStack.ht;
1252 depth = ht1 - ht0 + 1;
1253 if (f_v) {
1254 cout << "incidence_structure::refine_column_partition "
1255 "ht0=" << ht0 << " ht=" << PStack.ht
1256 << " depth=" << depth << endl;
1257 cout << "N=" << N << endl;
1258 cout << "depth=" << depth << endl;
1259 cout << "max_r=" << max_r << endl;
1260 }
1261 data = NEW_int(N * depth);
1262 Int_vec_zero(data, N * depth);
1263
1264 neighbors = NEW_int(max_r);
1265 for (y = 0; y < nb_lines(); y++) {
1266 j = nb_points() + y;
1267 c = PStack.cellNumber[PStack.invPointList[j]];
1268 data[j * depth + 0] = c;
1269 }
1270
1271 for (row_cell = ht0; row_cell < ht1; row_cell++) {
1272 idx = row_cell - ht0;
1273 f = PStack.startCell[row_cell];
1274 l = PStack.cellSize[row_cell];
1275 if (f_vvv) {
1276 cout << "incidence_structure::refine_column_partition "
1277 "idx=" << idx
1278 << " row_cell=" << row_cell
1279 << " f=" << f << " l=" << l << endl;
1280 }
1281 if (!PStack.is_row_class(row_cell)) {
1282 cout << "row_cell is not a row cell" << endl;
1283 cout << "row_cell=" << row_cell << endl;
1284 cout << "ht0=" << ht0 << endl;
1285 cout << "ht1=" << ht1 << endl;
1286 PStack.print(cout);
1287 cout << endl;
1288 exit(1);
1289 }
1290
1291
1292 for (i = 0; i < l; i++) {
1293 x = PStack.pointList[f + i];
1294 //if (f_v) {cout << i << " : " << x << " : ";}
1295 if (f_vv) {
1296 cout << "before get_lines_on_point" << endl;
1297 }
1298 nb = get_lines_on_point(neighbors, x, verbose_level - 2);
1299 if (f_vv) {
1300 cout << "after get_lines_on_point nb=" << nb << endl;
1301 }
1302
1303 //O.lines_on_point_by_line_rank(x,
1304 //neighbors, 0/*verbose_level - 2*/);
1305 //if (f_v) {int_vec_print(cout, neighbors,
1306 //O.alpha);cout << endl;}
1307 for (u = 0; u < nb; u++) {
1308 y = neighbors[u];
1309 j = nb_points() + y;
1310 data[j * depth + 1 + idx]++;
1311 }
1312 }
1313 }
1314#if 0
1315 if (f_vvv) {
1316 cout << "data:" << endl;
1317 for (y = 0; y < O.nb_lines; y++) {
1318 j = O.nb_points + y;
1319 cout << y << " : " << j << " : ";
1320 int_vec_print(cout, data + j * depth, depth);
1321 cout << endl;
1322 }
1323 cout << endl;
1324 }
1325#endif
1326
1327 ht0 = PStack.ht;
1328 for (cell = 0; cell < ht0; cell++) {
1329 if (PStack.is_row_class(cell)) {
1330 continue;
1331 }
1332
1333 if (PStack.cellSize[cell] == 1) {
1334 continue;
1335 }
1336 first = PStack.startCell[cell];
1337 next = first + PStack.cellSize[cell];
1338
1339 PStack.radix_sort(first /* left */,
1340 next - 1 /* right */,
1341 data, depth, 0 /*radix*/, FALSE);
1342 }
1343 if (f_vv) {
1344 cout << "incidence_structure::refine_column_partition "
1345 "after sorting, with " << PStack.ht - ht0
1346 << " n e w classes" << endl;
1347 PStack.print(cout);
1348 cout << endl;
1349 }
1350
1351 if (f_vvv) {
1352 PStack.print_column_refinement_info(ht0, data, depth);
1353 }
1354
1355 h = PStack.hash_column_refinement_info(ht0, data, depth, 0);
1356
1357 FREE_int(data);
1358 FREE_int(neighbors);
1359 return h;
1360}
1361
1364 int ht0, int verbose_level)
1365{
1366 int f_v = (verbose_level >= 1);
1367 int f_vv = (verbose_level >= 2);
1368 int f_vvv = (verbose_level >= 3);
1369 int col_cell, f, l, i, j, x, y, u, c, cell;
1370 int N, first, next, ht1, depth, idx, nb;
1371 int *data;
1372 int *neighbors, nb_neighbors, h;
1373
1374 N = nb_points() + nb_lines();
1375 ht1 = PStack.ht;
1376 depth = ht1 - ht0 + 1;
1377 if (f_v) {
1378 cout << "incidence_structure::refine_row_partition "
1379 "ht0=" << ht0 << " ht=" << PStack.ht
1380 << " depth=" << depth << endl;
1381 }
1382 data = NEW_int(N * depth);
1383 Int_vec_zero(data, N * depth);
1384
1385 nb_neighbors = max_k;
1386 neighbors = NEW_int(nb_neighbors);
1387 for (x = 0; x < nb_points(); x++) {
1388 i = x;
1389 c = PStack.cellNumber[PStack.invPointList[i]];
1390 data[i * depth + 0] = c;
1391 }
1392
1393 for (col_cell = ht0; col_cell < ht1; col_cell++) {
1394 idx = col_cell - ht0;
1395 f = PStack.startCell[col_cell];
1396 l = PStack.cellSize[col_cell];
1397 if (f_vvv) {
1398 cout << "incidence_structure::refine_row_partition "
1399 "idx=" << idx
1400 << " col_cell=" << col_cell
1401 << " f=" << f
1402 << " l=" << l << endl;
1403 }
1404
1405 if (!PStack.is_col_class(col_cell)) {
1406 cout << "col_cell is not a col cell" << endl;
1407 cout << "ht0=" << ht0 << endl;
1408 cout << "ht1=" << ht1 << endl;
1409 PStack.print(cout);
1410 cout << endl;
1411 exit(1);
1412 }
1413
1414
1415
1416 for (j = 0; j < l; j++) {
1417 y = PStack.pointList[f + j];
1418 //if (f_v) {cout << j << " : " << y << " : ";}
1419
1420 //O.points_on_line_by_line_rank(y - O.nb_points,
1421 //neighbors, 0/* verbose_level - 2*/);
1422 nb = get_points_on_line(neighbors, y - nb_points(), verbose_level - 2);
1423
1424 //if (f_v) {int_vec_print(cout, neighbors,
1425 //O.alpha);cout << endl;}
1426 for (u = 0; u < nb; u++) {
1427 x = neighbors[u];
1428 i = x;
1429 data[i * depth + 1 + idx]++;
1430 }
1431 }
1432 }
1433#if 0
1434 if (f_vvv) {
1435 cout << "data:" << endl;
1436 for (i = 0; i < O.nb_lines; i++) {
1437 cout << i << " : ";
1438 int_vec_print(cout, data + i * depth, depth);
1439 cout << endl;
1440 }
1441 cout << endl;
1442 }
1443#endif
1444
1445 ht0 = PStack.ht;
1446 for (cell = 0; cell < ht0; cell++) {
1447 if (PStack.is_col_class(cell)) {
1448 continue;
1449 }
1450
1451 if (PStack.cellSize[cell] == 1) {
1452 continue;
1453 }
1454 first = PStack.startCell[cell];
1455 next = first + PStack.cellSize[cell];
1456
1457 PStack.radix_sort(first /* left */,
1458 next - 1 /* right */,
1459 data, depth, 0 /*radix*/, FALSE);
1460 }
1461 if (f_vv) {
1462 cout << "incidence_structure::refine_row_partition "
1463 "after sorting, with " << PStack.ht - ht0
1464 << " n e w classes" << endl;
1465 PStack.print(cout);
1466 cout << endl;
1467 }
1468
1469 if (f_vv) {
1470 PStack.print_row_refinement_info(ht0, data, depth);
1471 }
1472
1473 h = PStack.hash_row_refinement_info(ht0, data, depth, 0);
1474
1475
1476 FREE_int(data);
1477 FREE_int(neighbors);
1478 return h;
1479}
1480
1483 ostream &ost, int f_enter_math_mode,
1484 int *row_classes, int *row_class_inv, int nb_row_classes,
1485 int *col_classes, int *col_class_inv, int nb_col_classes,
1486 int f_local_coordinates, int verbose_level)
1487{
1488 int f_v = (verbose_level >= 1);
1489 int *incidences;
1490 int c1, c2, f1, f2, l1; //, l2;
1491 int i, j, rij;
1492 int u, v, x, a, b, c, J;
1493 int *row_scheme;
1494 int *S;
1496
1497 if (f_v) {
1498 cout << "incidence_structure::print_row_tactical_decomposition_scheme_incidences_tex" << endl;
1499 }
1500
1501 row_scheme = NEW_int(nb_row_classes * nb_col_classes);
1502
1504 row_classes, row_class_inv, nb_row_classes,
1505 col_classes, col_class_inv, nb_col_classes,
1506 row_scheme, verbose_level - 2);
1507
1508
1509 for (i = 0; i < nb_row_classes; i++) {
1510 c1 = row_classes[i];
1511 f1 = PStack.startCell[c1];
1512 l1 = PStack.cellSize[c1];
1513
1514 for (j = 0; j < nb_col_classes; j++) {
1515
1516 rij = row_scheme[i * nb_col_classes + j];
1517
1518 if (rij == 0) {
1519 continue;
1520 }
1521
1522 S = NEW_int(rij);
1524 row_classes, row_class_inv, nb_row_classes,
1525 col_classes, col_class_inv, nb_col_classes,
1526 i, j,
1527 rij, incidences, verbose_level - 2);
1528
1529 c2 = col_classes[j];
1530 f2 = PStack.startCell[c2];
1531 //l2 = PStack.cellSize[c2];
1532
1533 ost << "\\subsubsection*{Row class " << i
1534 << " (cell " << c1 << ") vs. col class "
1535 << j << " (cell " << c2 << ")";
1536 if (f_local_coordinates) {
1537 ost << " (in local coordinates)";
1538 }
1539 ost << ", $r_{" << i << ", " << j << "}=" << rij << "$}" << endl;
1540 //ost << "f1=" << f1 << " l1=" << l1 << endl;
1541 //ost << "f2=" << f2 << " l2=" << l2 << endl;
1542 for (u = 0; u < l1; u++) {
1543 x = PStack.pointList[f1 + u];
1544 ost << setw(4) << u << " : $P_{" << setw(4) << x
1545 << "}$ is incident with ";
1546 for (v = 0; v < rij; v++) {
1547 a = incidences[u * rij + v];
1548 if (f_local_coordinates) {
1549 b = nb_points() + a;
1550 c = PStack.cellNumber[PStack.invPointList[b]];
1551 J = col_class_inv[c];
1552 if (J != j) {
1553 cout << "incidence_structure::print_row_"
1554 "tactical_decomposition_scheme_"
1555 "incidences_tex J != j" << endl;
1556 cout << "j=" << j << endl;
1557 cout << "J=" << J << endl;
1558 }
1559 a = PStack.invPointList[b] - f2;
1560 }
1561 S[v] = a;
1562 //ost << a << " ";
1563 }
1564 Sorting.int_vec_heapsort(S, rij);
1565 ost << "$\\{";
1566 for (v = 0; v < rij; v++) {
1567 ost << "\\ell_{" << setw(4) << S[v] << "}";
1568 if (v < rij - 1) {
1569 ost << ", ";
1570 }
1571 }
1572 ost << "\\}$";
1573
1574 ost << "\\\\" << endl;
1575 }
1576
1577 FREE_int(incidences);
1578 FREE_int(S);
1579 } // next j
1580 } // next i
1581
1582 FREE_int(row_scheme);
1583}
1584
1587 ostream &ost, int f_enter_math_mode,
1588 int *row_classes, int *row_class_inv, int nb_row_classes,
1589 int *col_classes, int *col_class_inv, int nb_col_classes,
1590 int f_local_coordinates, int verbose_level)
1591{
1592 int f_v = (verbose_level >= 1);
1593 int *incidences;
1594 int c1, c2, f1, f2, /*l1,*/ l2;
1595 int i, j, kij;
1596 int u, v, y, a, b, c, I;
1597 int *col_scheme;
1598 int *S;
1600
1601 if (f_v) {
1602 cout << "incidence_structure::print_col_tactical_decomposition_scheme_incidences_tex" << endl;
1603 }
1604
1605 col_scheme = NEW_int(nb_row_classes * nb_col_classes);
1606
1608 row_classes, row_class_inv, nb_row_classes,
1609 col_classes, col_class_inv, nb_col_classes,
1610 col_scheme, verbose_level - 2);
1611
1612
1613 for (i = 0; i < nb_row_classes; i++) {
1614 c1 = row_classes[i];
1615 f1 = PStack.startCell[c1];
1616 //l1 = PStack.cellSize[c1];
1617
1618 for (j = 0; j < nb_col_classes; j++) {
1619
1620 kij = col_scheme[i * nb_col_classes + j];
1621
1622 if (kij == 0) {
1623 continue;
1624 }
1625
1626 S = NEW_int(kij);
1628 row_classes, row_class_inv, nb_row_classes,
1629 col_classes, col_class_inv, nb_col_classes,
1630 i, j,
1631 kij, incidences, verbose_level - 2);
1632
1633 c2 = col_classes[j];
1634 f2 = PStack.startCell[c2];
1635 l2 = PStack.cellSize[c2];
1636
1637 ost << "\\subsubsection*{Row class " << i
1638 << " (cell " << c1 << ") vs. col class "
1639 << j << " (cell " << c2 << ")";
1640 if (f_local_coordinates) {
1641 ost << " (in local coordinates)";
1642 }
1643 ost << ", $k_{" << i << ", " << j << "}="
1644 << kij << "$}" << endl;
1645 //ost << "f1=" << f1 << " l1=" << l1 << endl;
1646 //ost << "f2=" << f2 << " l2=" << l2 << endl;
1647 for (u = 0; u < l2; u++) {
1648 y = PStack.pointList[f2 + u] - nb_points();
1649 ost << setw(4) << u << " : $\\ell_{" << setw(4)
1650 << y << "}$ is incident with ";
1651 for (v = 0; v < kij; v++) {
1652 a = incidences[u * kij + v];
1653 if (f_local_coordinates) {
1654 b = a;
1655 c = PStack.cellNumber[PStack.invPointList[b]];
1656 I = row_class_inv[c];
1657 if (I != i) {
1658 cout << "incidence_structure::print_col_"
1659 "tactical_decomposition_scheme_"
1660 "incidences_tex I != i" << endl;
1661 cout << "i=" << i << endl;
1662 cout << "I=" << I << endl;
1663 }
1664 a = PStack.invPointList[b] - f1;
1665 }
1666 S[v] = a;
1667 //ost << a << " ";
1668 }
1669 Sorting.int_vec_heapsort(S, kij);
1670 ost << "$\\{";
1671 for (v = 0; v < kij; v++) {
1672 ost << "P_{" << setw(4) << S[v] << "}";
1673 if (v < kij - 1) {
1674 ost << ", ";
1675 }
1676 }
1677 ost << "\\}$";
1678
1679 ost << "\\\\" << endl;
1680 }
1681
1682 FREE_int(incidences);
1683 FREE_int(S);
1684 } // next j
1685 } // next i
1686
1687 FREE_int(col_scheme);
1688}
1689
1692 int *row_classes, int *row_class_inv, int nb_row_classes,
1693 int *col_classes, int *col_class_inv, int nb_col_classes,
1694 int row_class_idx, int col_class_idx,
1695 int rij, int *&incidences, int verbose_level)
1696{
1697 int f_v = (verbose_level >= 1);
1698 int c1, c2, f1, /*f2,*/ l1, /*l2,*/ x, nb, u, y, c, i, j;
1699 int *sz;
1700 int *neighbors;
1701
1702 if (f_v) {
1703 cout << "incidence_structure::get_incidences_by_row_scheme" << endl;
1704 }
1705 c1 = row_classes[row_class_idx];
1706 f1 = PStack.startCell[c1];
1707 l1 = PStack.cellSize[c1];
1708 c2 = col_classes[col_class_idx];
1709 //f2 = PStack.startCell[c2];
1710 //l2 = PStack.cellSize[c2];
1711 incidences = NEW_int(l1 * rij);
1712 neighbors = NEW_int(max_r);
1713 sz = NEW_int(l1);
1714 for (i = 0; i < l1; i++) {
1715 sz[i] = 0;
1716 }
1717 for (i = 0; i < l1; i++) {
1718 x = PStack.pointList[f1 + i];
1719 nb = get_lines_on_point(neighbors, x, verbose_level - 2);
1720 //O.lines_on_point_by_line_rank(x, neighbors, verbose_level - 2);
1721 for (u = 0; u < nb; u++) {
1722 y = neighbors[u];
1723 j = nb_points() + y;
1724 c = PStack.cellNumber[PStack.invPointList[j]];
1725 if (c == c2) {
1726 incidences[i * rij + sz[i]++] = y;
1727 }
1728 }
1729 } // next i
1730
1731 for (i = 0; i < l1; i++) {
1732 if (sz[i] != rij) {
1733 cout << "sz[i] != rij" << endl;
1734 exit(1);
1735 }
1736 }
1737
1738 FREE_int(sz);
1739 FREE_int(neighbors);
1740}
1741
1744 int *row_classes, int *row_class_inv, int nb_row_classes,
1745 int *col_classes, int *col_class_inv, int nb_col_classes,
1746 int row_class_idx, int col_class_idx,
1747 int kij, int *&incidences, int verbose_level)
1748{
1749 int f_v = (verbose_level >= 1);
1750 int c1, c2, /*f1,*/ f2, /*l1,*/ l2, x, nb, u, y, c, i, j;
1751 int *sz;
1752 int *neighbors;
1753
1754 if (f_v) {
1755 cout << "incidence_structure::get_incidences_by_col_scheme" << endl;
1756 }
1757 c1 = row_classes[row_class_idx];
1758 //f1 = PStack.startCell[c1];
1759 //l1 = PStack.cellSize[c1];
1760 c2 = col_classes[col_class_idx];
1761 f2 = PStack.startCell[c2];
1762 l2 = PStack.cellSize[c2];
1763 incidences = NEW_int(l2 * kij);
1764 neighbors = NEW_int(max_k);
1765 sz = NEW_int(l2);
1766 for (j = 0; j < l2; j++) {
1767 sz[j] = 0;
1768 }
1769 for (j = 0; j < l2; j++) {
1770 y = PStack.pointList[f2 + j] - nb_points();
1771 nb = get_points_on_line(neighbors, y, verbose_level - 2);
1772 for (u = 0; u < nb; u++) {
1773 x = neighbors[u];
1774 i = x;
1775 c = PStack.cellNumber[PStack.invPointList[i]];
1776 if (c == c1) {
1777 incidences[j * kij + sz[j]++] = x;
1778 }
1779 }
1780 } // next j
1781
1782 for (j = 0; j < l2; j++) {
1783 if (sz[j] != kij) {
1784 cout << "sz[j] != kij" << endl;
1785 exit(1);
1786 }
1787 }
1788
1789 FREE_int(sz);
1790 FREE_int(neighbors);
1791}
1792
1793
1796 int *row_classes, int *row_class_inv, int nb_row_classes,
1797 int *col_classes, int *col_class_inv, int nb_col_classes,
1798 int *row_scheme, int verbose_level)
1799{
1800 int f_v = (verbose_level >= 1);
1801 int I, J, i, j, c1, f1, l1, x, y, u, c, nb;
1802 int *neighbors;
1803 int *data0;
1804 int *data1;
1805
1806 if (f_v) {
1807 cout << "incidence_structure::get_row_decomposition_scheme" << endl;
1808 }
1809 neighbors = NEW_int(max_r);
1810 data0 = NEW_int(nb_col_classes);
1811 data1 = NEW_int(nb_col_classes);
1812 Int_vec_zero(row_scheme, nb_row_classes * nb_col_classes);
1813 for (I = 0; I < nb_row_classes; I++) {
1814 c1 = row_classes[I];
1815 f1 = PStack.startCell[c1];
1816 l1 = PStack.cellSize[c1];
1817 Int_vec_zero(data0, nb_col_classes);
1818 for (i = 0; i < l1; i++) {
1819 x = PStack.pointList[f1 + i];
1820 Int_vec_zero(data1, nb_col_classes);
1821 nb = get_lines_on_point(neighbors, x, verbose_level - 2);
1822 for (u = 0; u < nb; u++) {
1823 y = neighbors[u];
1824 j = nb_points() + y;
1825 c = PStack.cellNumber[PStack.invPointList[j]];
1826 J = col_class_inv[c];
1827 data1[J]++;
1828 }
1829 if (i == 0) {
1830 Int_vec_copy(data1, data0, nb_col_classes);
1831 }
1832 else {
1833 for (J = 0; J < nb_col_classes; J++) {
1834 if (data0[J] != data1[J]) {
1835 cout << "incidence_structure::get_row_"
1836 "decomposition_scheme not row-tactical "
1837 "I=" << I << " i=" << i
1838 << " J=" << J << endl;
1839 }
1840 }
1841 }
1842 } // next i
1843
1844 Int_vec_copy(data0,
1845 row_scheme + I * nb_col_classes,
1846 nb_col_classes);
1847 }
1848 FREE_int(neighbors);
1849 FREE_int(data0);
1850 FREE_int(data1);
1851 if (f_v) {
1852 cout << "incidence_structure::get_row_decomposition_scheme done" << endl;
1853 }
1854}
1855
1858 int *row_classes, int *row_class_inv, int nb_row_classes,
1859 int *col_classes, int *col_class_inv, int nb_col_classes,
1860 int *row_scheme, int verbose_level)
1861{
1862 int f_v = (verbose_level >= 1);
1863 int I, J, i, j, c1, f1, l1, x, y, u, c, nb;
1864 int *neighbors;
1865 int *data0;
1866 int *data1;
1867
1868 if (f_v) {
1869 cout << "incidence_structure::get_row_decomposition_scheme_if_possible" << endl;
1870 }
1871 neighbors = NEW_int(max_r);
1872 data0 = NEW_int(nb_col_classes);
1873 data1 = NEW_int(nb_col_classes);
1874 for (i = 0; i < nb_row_classes * nb_col_classes; i++) {
1875 row_scheme[i] = 0;
1876 }
1877 for (I = 0; I < nb_row_classes; I++) {
1878 c1 = row_classes[I];
1879 f1 = PStack.startCell[c1];
1880 l1 = PStack.cellSize[c1];
1881 for (j = 0; j < nb_col_classes; j++) {
1882 data0[j] = 0;
1883 }
1884 for (i = 0; i < l1; i++) {
1885 x = PStack.pointList[f1 + i];
1886 for (J = 0; J < nb_col_classes; J++) {
1887 data1[J] = 0;
1888 }
1889 nb = get_lines_on_point(neighbors, x, verbose_level - 2);
1890 //O.lines_on_point_by_line_rank(x, neighbors,
1891 //verbose_level - 2);
1892 for (u = 0; u < nb; u++) {
1893 y = neighbors[u];
1894 j = nb_points() + y;
1895 c = PStack.cellNumber[PStack.invPointList[j]];
1896 J = col_class_inv[c];
1897 data1[J]++;
1898 }
1899 if (i == 0) {
1900 for (J = 0; J < nb_col_classes; J++) {
1901 data0[J] = data1[J];
1902 }
1903 }
1904 else {
1905 for (J = 0; J < nb_col_classes; J++) {
1906 if (data0[J] != data1[J]) {
1907 data0[J] = -1;
1908 //cout << "not row-tactical I=" << I
1909 //<< " i=" << i << " J=" << J << endl;
1910 }
1911 }
1912 }
1913 } // next i
1914 for (J = 0; J < nb_col_classes; J++) {
1915 row_scheme[I * nb_col_classes + J] = data0[J];
1916 }
1917 }
1918 FREE_int(neighbors);
1919 FREE_int(data0);
1920 FREE_int(data1);
1921}
1922
1925 int *row_classes, int *row_class_inv, int nb_row_classes,
1926 int *col_classes, int *col_class_inv, int nb_col_classes,
1927 int *col_scheme, int verbose_level)
1928{
1929 int f_v = (verbose_level >= 1);
1930 int I, J, i, j, c1, f1, l1, x, y, u, c, nb;
1931 int *neighbors;
1932 int *data0;
1933 int *data1;
1934
1935 if (f_v) {
1936 cout << "incidence_structure::get_col_decomposition_scheme" << endl;
1937 }
1938 neighbors = NEW_int(max_k);
1939 data0 = NEW_int(nb_row_classes);
1940 data1 = NEW_int(nb_row_classes);
1941 for (i = 0; i < nb_row_classes * nb_col_classes; i++) {
1942 col_scheme[i] = 0;
1943 }
1944 for (J = 0; J < nb_col_classes; J++) {
1945 c1 = col_classes[J];
1946 f1 = PStack.startCell[c1];
1947 l1 = PStack.cellSize[c1];
1948 for (i = 0; i < nb_row_classes; i++) {
1949 data0[i] = 0;
1950 }
1951 for (j = 0; j < l1; j++) {
1952 y = PStack.pointList[f1 + j] - nb_points();
1953 for (I = 0; I < nb_row_classes; I++) {
1954 data1[I] = 0;
1955 }
1956
1957 //O.points_on_line_by_line_rank(y, neighbors,
1958 //verbose_level - 2);
1959 nb = get_points_on_line(neighbors, y, verbose_level - 2);
1960
1961 for (u = 0; u < nb; u++) {
1962 x = neighbors[u];
1963 c = PStack.cellNumber[PStack.invPointList[x]];
1964 I = row_class_inv[c];
1965 data1[I]++;
1966 }
1967 if (j == 0) {
1968 for (I = 0; I < nb_row_classes; I++) {
1969 data0[I] = data1[I];
1970 }
1971 }
1972 else {
1973 for (I = 0; I < nb_row_classes; I++) {
1974 if (data0[I] != data1[I]) {
1975 cout << "not col-tactical J=" << J
1976 << " j=" << j << " I=" << I << endl;
1977 }
1978 }
1979 }
1980 } // next j
1981 for (I = 0; I < nb_row_classes; I++) {
1982 col_scheme[I * nb_col_classes + J] = data0[I];
1983 }
1984 }
1985 FREE_int(neighbors);
1986 FREE_int(data0);
1987 FREE_int(data1);
1988}
1989
1992 int *row_classes, int *row_class_inv, int nb_row_classes,
1993 int *col_classes, int *col_class_inv, int nb_col_classes,
1994 int *row_scheme, int *col_scheme, int verbose_level)
1995{
1996 int I, J, c1, l1, c2, l2, a, b, c;
1997
1998 for (I = 0; I < nb_row_classes; I++) {
1999 c1 = row_classes[I];
2000 l1 = PStack.cellSize[c1];
2001 for (J = 0; J < nb_col_classes; J++) {
2002 c2 = col_classes[J];
2003 l2 = PStack.cellSize[c2];
2004 a = row_scheme[I * nb_col_classes + J];
2005 b = a * l1;
2006 if (b % l2) {
2007 cout << "incidence_structure::row_scheme_to_col_scheme: "
2008 "cannot be tactical" << endl;
2009 exit(1);
2010 }
2011 c = b / l2;
2012 col_scheme[I * nb_col_classes + J] = c;
2013 }
2014 }
2015}
2016
2019 int f_list_incidences, int f_local_coordinates, int verbose_level)
2020{
2021 int *row_classes, *row_class_inv, nb_row_classes;
2022 int *col_classes, *col_class_inv, nb_col_classes;
2023 int *row_scheme;
2024 int f_v = (verbose_level >= 1);
2025
2026 if (f_v) {
2027 cout << "incidence_structure::get_and_print_row_decomposition_scheme "
2028 "computing col scheme" << endl;
2029 }
2031 row_classes, row_class_inv, nb_row_classes,
2032 col_classes, col_class_inv, nb_col_classes,
2033 0);
2034
2035 row_scheme = NEW_int(nb_row_classes * nb_col_classes);
2036
2038 row_classes, row_class_inv, nb_row_classes,
2039 col_classes, col_class_inv, nb_col_classes,
2040 row_scheme, 0);
2041
2042 //cout << *this << endl;
2043
2044 if (f_v) {
2045 cout << "row_scheme:" << endl;
2046 PStack.print_decomposition_scheme(cout,
2047 row_classes, nb_row_classes,
2048 col_classes, nb_col_classes,
2049 row_scheme, -1, -1);
2050 }
2051
2052 if (f_list_incidences) {
2053 cout << "incidences by row-scheme:" << endl;
2055 PStack,
2056 cout, FALSE /* f_enter_math_mode */,
2057 row_classes, row_class_inv, nb_row_classes,
2058 col_classes, col_class_inv, nb_col_classes,
2059 f_local_coordinates, 0 /*verbose_level*/);
2060 }
2061
2062 FREE_int(row_classes);
2063 FREE_int(row_class_inv);
2064 FREE_int(col_classes);
2065 FREE_int(col_class_inv);
2066 FREE_int(row_scheme);
2067}
2068
2071 int f_list_incidences, int f_local_coordinates, int verbose_level)
2072{
2073 int *row_classes, *row_class_inv, nb_row_classes;
2074 int *col_classes, *col_class_inv, nb_col_classes;
2075 int *col_scheme;
2076 int f_v = (verbose_level >= 1);
2077
2078 if (f_v) {
2079 cout << "incidence_structure::get_and_print_col_decomposition_scheme "
2080 "computing col scheme" << endl;
2081 }
2083 row_classes, row_class_inv, nb_row_classes,
2084 col_classes, col_class_inv, nb_col_classes,
2085 verbose_level);
2086
2087 col_scheme = NEW_int(nb_row_classes * nb_col_classes);
2088
2090 row_classes, row_class_inv, nb_row_classes,
2091 col_classes, col_class_inv, nb_col_classes,
2092 col_scheme, 0 /*verbose_level*/);
2093
2094 //cout << *this << endl;
2095
2096 if (f_v) {
2097 cout << "col_scheme:" << endl;
2098 PStack.print_decomposition_scheme(cout,
2099 row_classes, nb_row_classes,
2100 col_classes, nb_col_classes,
2101 col_scheme, -1, -1);
2102 }
2103
2104 if (f_list_incidences) {
2105 cout << "incidences by col-scheme:" << endl;
2107 PStack,
2108 cout, FALSE /* f_enter_math_mode */,
2109 row_classes, row_class_inv, nb_row_classes,
2110 col_classes, col_class_inv, nb_col_classes,
2111 f_local_coordinates, 0 /*verbose_level*/);
2112 }
2113
2114 FREE_int(row_classes);
2115 FREE_int(row_class_inv);
2116 FREE_int(col_classes);
2117 FREE_int(col_class_inv);
2118 FREE_int(col_scheme);
2119}
2120
2123{
2124 int *row_classes, *row_class_inv, nb_row_classes;
2125 int *col_classes, *col_class_inv, nb_col_classes;
2126 int *row_scheme, *col_scheme;
2127 int verbose_level = 0;
2128 int f_v = (verbose_level >= 1);
2129
2130 if (f_v) {
2131 cout << "incidence_structure::get_and_print_decomposition_schemes "
2132 "computing both schemes" << endl;
2133 }
2135 row_classes, row_class_inv, nb_row_classes,
2136 col_classes, col_class_inv, nb_col_classes,
2137 verbose_level);
2138
2139 row_scheme = NEW_int(nb_row_classes * nb_col_classes);
2140 col_scheme = NEW_int(nb_row_classes * nb_col_classes);
2141
2143 row_classes, row_class_inv, nb_row_classes,
2144 col_classes, col_class_inv, nb_col_classes,
2145 row_scheme, verbose_level);
2146
2148 row_classes, row_class_inv, nb_row_classes,
2149 col_classes, col_class_inv, nb_col_classes,
2150 row_scheme, col_scheme, verbose_level);
2151
2152 //cout << *this << endl;
2153
2154 cout << "row_scheme:" << endl;
2155 PStack.print_decomposition_scheme(cout,
2156 row_classes, nb_row_classes,
2157 col_classes, nb_col_classes,
2158 row_scheme, -1, -1);
2159
2160 cout << "col_scheme:" << endl;
2161 PStack.print_decomposition_scheme(cout,
2162 row_classes, nb_row_classes,
2163 col_classes, nb_col_classes,
2164 col_scheme, -1, -1);
2165
2166 FREE_int(row_classes);
2167 FREE_int(row_class_inv);
2168 FREE_int(col_classes);
2169 FREE_int(col_class_inv);
2170 FREE_int(row_scheme);
2171 FREE_int(col_scheme);
2172}
2173
2176{
2177 int *row_classes, *row_class_inv, nb_row_classes;
2178 int *col_classes, *col_class_inv, nb_col_classes;
2179 int *row_scheme, *col_scheme;
2180 int verbose_level = 0;
2181 int f_v = (verbose_level >= 1);
2182
2183 if (f_v) {
2184 cout << "incidence_structure::get_and_print_decomposition_schemes_tex "
2185 "computing both schemes" << endl;
2186 }
2188 row_classes, row_class_inv, nb_row_classes,
2189 col_classes, col_class_inv, nb_col_classes,
2190 verbose_level);
2191
2192 row_scheme = NEW_int(nb_row_classes * nb_col_classes);
2193 col_scheme = NEW_int(nb_row_classes * nb_col_classes);
2194
2196 row_classes, row_class_inv, nb_row_classes,
2197 col_classes, col_class_inv, nb_col_classes,
2198 row_scheme, verbose_level);
2199
2201 row_classes, row_class_inv, nb_row_classes,
2202 col_classes, col_class_inv, nb_col_classes,
2203 row_scheme, col_scheme, verbose_level);
2204
2205 //cout << *this << endl;
2206
2207 cout << "row_scheme:" << endl;
2208 PStack.print_decomposition_scheme_tex(cout,
2209 row_classes, nb_row_classes,
2210 col_classes, nb_col_classes,
2211 row_scheme);
2212
2213 cout << "col_scheme:" << endl;
2214 PStack.print_decomposition_scheme_tex(cout,
2215 row_classes, nb_row_classes,
2216 col_classes, nb_col_classes,
2217 col_scheme);
2218 cout << "tactical scheme:" << endl;
2220 row_classes, nb_row_classes,
2221 col_classes, nb_col_classes,
2222 row_scheme, col_scheme, FALSE /* f_print_subscripts */);
2223
2224 FREE_int(row_classes);
2225 FREE_int(row_class_inv);
2226 FREE_int(col_classes);
2227 FREE_int(col_class_inv);
2228 FREE_int(row_scheme);
2229 FREE_int(col_scheme);
2230}
2231
2233 std::ostream &ost, int f_enter_math, data_structures::partitionstack &PStack)
2234{
2235 int *row_classes, *row_class_inv, nb_row_classes;
2236 int *col_classes, *col_class_inv, nb_col_classes;
2237 int *row_scheme, *col_scheme;
2238 int verbose_level = 0;
2239 int f_v = (verbose_level >= 1);
2240
2241 if (f_v) {
2242 cout << "incidence_structure::get_and_print_tactical_decomposition_scheme_tex "
2243 "computing both schemes" << endl;
2244 }
2246 row_classes, row_class_inv, nb_row_classes,
2247 col_classes, col_class_inv, nb_col_classes,
2248 verbose_level);
2249
2250 row_scheme = NEW_int(nb_row_classes * nb_col_classes);
2251 col_scheme = NEW_int(nb_row_classes * nb_col_classes);
2252
2254 row_classes, row_class_inv, nb_row_classes,
2255 col_classes, col_class_inv, nb_col_classes,
2256 row_scheme, verbose_level);
2257
2259 row_classes, row_class_inv, nb_row_classes,
2260 col_classes, col_class_inv, nb_col_classes,
2261 row_scheme, col_scheme, verbose_level);
2262
2264 ost, f_enter_math,
2265 row_classes, nb_row_classes,
2266 col_classes, nb_col_classes,
2267 row_scheme, col_scheme, FALSE /* f_print_subscripts */);
2268
2269 FREE_int(row_classes);
2270 FREE_int(row_class_inv);
2271 FREE_int(col_classes);
2272 FREE_int(col_class_inv);
2273 FREE_int(row_scheme);
2274 FREE_int(col_scheme);
2275}
2276
2278 int *&row_classes, int *&row_class_inv, int &nb_row_classes,
2279 int *&col_classes, int *&col_class_inv, int &nb_col_classes,
2280 int *&scheme, int f_row_scheme, data_structures::partitionstack &PStack)
2281{
2282 int verbose_level = 0;
2283
2285 row_classes, row_class_inv, nb_row_classes,
2286 col_classes, col_class_inv, nb_col_classes,
2287 verbose_level);
2288
2289 scheme = NEW_int(nb_row_classes * nb_col_classes);
2290 if (f_row_scheme) {
2292 row_classes, row_class_inv, nb_row_classes,
2293 col_classes, col_class_inv, nb_col_classes,
2294 scheme, verbose_level);
2295 }
2296 else {
2298 row_classes, row_class_inv, nb_row_classes,
2299 col_classes, col_class_inv, nb_col_classes,
2300 scheme, verbose_level);
2301 }
2302}
2303
2305 int *row_classes, int *row_class_inv,
2306 int *col_classes, int *col_class_inv,
2307 int *scheme)
2308{
2309 FREE_int(row_classes);
2310 FREE_int(row_class_inv);
2311 FREE_int(col_classes);
2312 FREE_int(col_class_inv);
2313 FREE_int(scheme);
2314}
2315
2317 std::ostream &ost, int f_enter_math, int f_print_subscripts,
2319{
2320 int *row_classes, *row_class_inv, nb_row_classes;
2321 int *col_classes, *col_class_inv, nb_col_classes;
2322 int *row_scheme; //, *col_scheme;
2323 int verbose_level = 0;
2324 int f_v = FALSE;
2325
2326 if (f_v) {
2327 cout << "incidence_structure::get_and_print_row_tactical_"
2328 "decomposition_scheme_tex computing row scheme" << endl;
2329 }
2331 row_classes, row_class_inv, nb_row_classes,
2332 col_classes, col_class_inv, nb_col_classes,
2333 verbose_level);
2334
2335 row_scheme = NEW_int(nb_row_classes * nb_col_classes);
2336 //col_scheme = NEW_int(nb_row_classes * nb_col_classes);
2337
2338 if (f_v) {
2339 cout << "incidence_structure::get_and_print_row_tactical_"
2340 "decomposition_scheme_tex before get_row_"
2341 "decomposition_scheme" << endl;
2342 }
2344 row_classes, row_class_inv, nb_row_classes,
2345 col_classes, col_class_inv, nb_col_classes,
2346 row_scheme, verbose_level);
2347
2348
2349 if (f_v) {
2350 cout << "incidence_structure::get_and_print_row_tactical_"
2351 "decomposition_scheme_tex before PStack.print_row_"
2352 "tactical_decomposition_scheme_tex" << endl;
2353 }
2354 PStack.print_row_tactical_decomposition_scheme_tex(ost, f_enter_math,
2355 row_classes, nb_row_classes,
2356 col_classes, nb_col_classes,
2357 row_scheme, f_print_subscripts);
2358
2359 FREE_int(row_classes);
2360 FREE_int(row_class_inv);
2361 FREE_int(col_classes);
2362 FREE_int(col_class_inv);
2363 FREE_int(row_scheme);
2364 //FREE_int(col_scheme);
2365}
2366
2368 std::ostream &ost, int f_enter_math, int f_print_subscripts,
2370{
2371 int *row_classes, *row_class_inv, nb_row_classes;
2372 int *col_classes, *col_class_inv, nb_col_classes;
2373 int *col_scheme;
2374 int verbose_level = 0;
2375 int f_v = FALSE;
2376
2377 if (f_v) {
2378 cout << "incidence_structure::get_and_print_column_"
2379 "tactical_decomposition_scheme_tex computing "
2380 "column scheme" << endl;
2381 }
2383 row_classes, row_class_inv, nb_row_classes,
2384 col_classes, col_class_inv, nb_col_classes,
2385 verbose_level);
2386
2387 //row_scheme = NEW_int(nb_row_classes * nb_col_classes);
2388 col_scheme = NEW_int(nb_row_classes * nb_col_classes);
2389
2391 row_classes, row_class_inv, nb_row_classes,
2392 col_classes, col_class_inv, nb_col_classes,
2393 col_scheme, verbose_level);
2394
2395
2397 ost, f_enter_math,
2398 row_classes, nb_row_classes,
2399 col_classes, nb_col_classes,
2400 col_scheme, f_print_subscripts);
2401
2402 FREE_int(row_classes);
2403 FREE_int(row_class_inv);
2404 FREE_int(col_classes);
2405 FREE_int(col_class_inv);
2406 //FREE_int(row_scheme);
2407 FREE_int(col_scheme);
2408}
2409
2411 std::ostream &ost, int f_enter_math, data_structures::partitionstack &PStack)
2412{
2413 int *row_classes, *row_class_inv, nb_row_classes;
2414 int *col_classes, *col_class_inv, nb_col_classes;
2415 int *row_scheme;
2416 int verbose_level = 0;
2417 int f_v = FALSE;
2418
2419 if (f_v) {
2420 cout << "incidence_structure::print_non_tactical_decomposition_scheme_tex" << endl;
2421 }
2423 row_classes, row_class_inv, nb_row_classes,
2424 col_classes, col_class_inv, nb_col_classes,
2425 verbose_level);
2426
2427 row_scheme = NEW_int(nb_row_classes * nb_col_classes);
2428
2430 row_classes, row_class_inv, nb_row_classes,
2431 col_classes, col_class_inv, nb_col_classes,
2432 row_scheme, verbose_level);
2433
2434
2435 PStack.print_row_tactical_decomposition_scheme_tex(ost, f_enter_math,
2436 row_classes, nb_row_classes,
2437 col_classes, nb_col_classes,
2438 row_scheme, FALSE /* f_print_subscripts */);
2439
2440 FREE_int(row_classes);
2441 FREE_int(row_class_inv);
2442 FREE_int(col_classes);
2443 FREE_int(col_class_inv);
2444 FREE_int(row_scheme);
2445}
2446
2448 std::ostream &ost, data_structures::partitionstack &P,
2449 int row_cell, int i, int *col_classes, int nb_col_classes,
2450 int width, int f_labeled)
2451{
2452 int f1, f2, e1, e2;
2453 int J, j, h, l, cell;
2454 int first_column_element = P.startCell[1];
2455
2456 f1 = P.startCell[row_cell];
2457 e1 = P.pointList[f1 + i];
2458 if (f_labeled) {
2459 ost << setw((int) width) << e1;
2460 }
2461 for (J = 0; J <= nb_col_classes; J++) {
2462 ost << "|";
2463 if (J == nb_col_classes)
2464 break;
2465 cell = col_classes[J];
2466 f2 = P.startCell[cell];
2467 l = P.cellSize[cell];
2468 for (j = 0; j < l; j++) {
2469 e2 = P.pointList[f2 + j] - first_column_element;
2470 if (get_ij(e1, e2)) {
2471 if (f_labeled) {
2472 ost << setw((int) width) << e1 * nb_lines() + e2;
2473 }
2474 else {
2475 ost << "X";
2476 //ost << "1";
2477 }
2478 }
2479 else {
2480 if (f_labeled) {
2481 for (h = 0; h < width - 1; h++) {
2482 ost << " ";
2483 }
2484 ost << ".";
2485 }
2486 else {
2487 ost << ".";
2488 //ost << "0";
2489 }
2490 }
2491 }
2492 }
2493 //ost << endl;
2494}
2495
2497 std::ostream &ost, data_structures::partitionstack &P,
2498 int *col_classes, int nb_col_classes, int width)
2499{
2500 int f2, e2;
2501 int J, j, h, l, cell;
2502 int first_column_element = P.startCell[1];
2503
2504 for (h = 0; h < width; h++) {
2505 ost << " ";
2506 }
2507 for (J = 0; J <= nb_col_classes; J++) {
2508 ost << "|";
2509 if (J == nb_col_classes) {
2510 break;
2511 }
2512 cell = col_classes[J];
2513 f2 = P.startCell[cell];
2514 l = P.cellSize[cell];
2515 for (j = 0; j < l; j++) {
2516 e2 = P.pointList[f2 + j] - first_column_element;
2517 ost << setw((int) width) << e2 + first_column_element;
2518 }
2519 }
2520 ost << endl;
2521}
2522
2524 std::ostream &ost, data_structures::partitionstack &P,
2525 int *col_classes, int nb_col_classes, int width, int f_labeled)
2526{
2527 int J, j, h, l, cell;
2528
2529 if (f_labeled) {
2530 for (h = 0; h < width; h++) {
2531 ost << "-";
2532 }
2533 }
2534 else {
2535 //ost << "-";
2536 }
2537 for (J = 0; J <= nb_col_classes; J++) {
2538 ost << "+";
2539 if (J == nb_col_classes) {
2540 break;
2541 }
2542 cell = col_classes[J];
2543 l = P.cellSize[cell];
2544 for (j = 0; j < l; j++) {
2545 if (f_labeled) {
2546 for (h = 0; h < width; h++) {
2547 ost << "-";
2548 }
2549 }
2550 else {
2551 ost << "-";
2552 }
2553 }
2554 }
2555 ost << endl;
2556}
2557
2559 std::ostream &ost, data_structures::partitionstack &P, int f_labeled)
2560{
2561 //int *A;
2562 int *row_classes;
2563 int nb_row_classes;
2564 int *col_classes;
2565 int nb_col_classes;
2566 int I, i, cell, l;
2567 int width;
2568 int mn;
2570
2571 mn = nb_points() * nb_lines();
2572
2573 width = NT.int_log10(mn) + 1;
2574
2575 //A = get_incidence_matrix();
2576
2577 row_classes = NEW_int(nb_points() + nb_lines());
2578 col_classes = NEW_int(nb_points() + nb_lines());
2579 P.get_row_and_col_classes(row_classes, nb_row_classes,
2580 col_classes, nb_col_classes, 0 /* verbose_level */);
2581 //ost << "nb_row_classes = " << nb_row_classes << endl;
2582 //ost << "nb_col_classes = " << nb_col_classes << endl;
2583
2584 if (f_labeled) {
2585 print_column_labels(ost, P,
2586 col_classes, nb_col_classes, width);
2587 }
2588 for (I = 0; I <= nb_row_classes; I++) {
2589 print_hline(ost, P, col_classes,
2590 nb_col_classes, width, f_labeled);
2591 cell = row_classes[I];
2592 if (I < nb_row_classes) {
2593 l = P.cellSize[cell];
2594 for (i = 0; i < l; i++) {
2595 print_line(ost, P, cell, i,
2596 col_classes, nb_col_classes, width, f_labeled);
2597 ost << endl;
2598 }
2599 }
2600 }
2601 FREE_int(row_classes);
2602 FREE_int(col_classes);
2603 //FREE_int(A);
2604}
2605
2607 int *Adj, int verbose_level)
2608// G[nb_points() * nb_points()]
2609{
2610 int f_v = (verbose_level >= 1);
2611 int i, j, h, l, u;
2612
2613 if (f_v) {
2614 cout << "incidence_structure::point_collinearity_graph" << endl;
2615 }
2616 for (i = 0; i < nb_points(); i++) {
2617 for (j = 0; j < nb_points(); j++) {
2618 Adj[i * nb_points() + j] = 0;
2619 }
2620 }
2621 for (i = 0; i < nb_points(); i++) {
2622 for (h = 0; h < nb_lines_on_point[i]; h++) {
2623 l = lines_on_point[i * max_r + h];
2624 for (u = 0; u < nb_points_on_line[l]; u++) {
2625 j = points_on_line[l * max_k + u];
2626 if (j == i) {
2627 continue;
2628 }
2629 Adj[i * nb_points() + j] = 1;
2630 Adj[j * nb_points() + i] = 1;
2631 }
2632 }
2633 }
2634 if (f_v) {
2635 cout << "incidence_structure::point_collinearity_graph "
2636 "the graph is:" << endl;
2638 nb_points(), nb_points(), nb_points(), 1);
2639 }
2640}
2641
2643 int *Adj, int verbose_level)
2644// G[nb_lines() * nb_lines()]
2645{
2646 int f_v = (verbose_level >= 1);
2647 int i, j, h, l, m, u;
2648
2649 if (f_v) {
2650 cout << "incidence_structure::line_intersection_graph" << endl;
2651 }
2652 for (i = 0; i < nb_lines(); i++) {
2653 for (j = 0; j < nb_lines(); j++) {
2654 Adj[i * nb_lines() + j] = 0;
2655 }
2656 }
2657 for (l = 0; l < nb_lines(); l++) {
2658 for (u = 0; u < nb_points_on_line[l]; u++) {
2659 i = points_on_line[l * max_k + u];
2660 for (h = 0; h < nb_lines_on_point[i]; h++) {
2661 m = lines_on_point[i * max_r + h];
2662 if (l == m) {
2663 continue;
2664 }
2665 Adj[l * nb_lines() + m] = 1;
2666 Adj[m * nb_lines() + l] = 1;
2667 }
2668 }
2669 }
2670 if (f_v) {
2671 cout << "incidence_structure::line_intersection_graph "
2672 "the graph is:" << endl;
2674 nb_lines(), nb_lines(), nb_lines(), 1);
2675 }
2676}
2677
2679{
2680
2681 cout << "incidence_structure::latex_it" << endl;
2682 cout << "currently disabled" << endl;
2683 exit(1);
2684
2685#if 0
2686 int nb_V, nb_B;
2687 int *Vi, *Bj;
2688 int *R;
2689 int *X;
2690 int f_v = TRUE;
2691 latex_interface L;
2692
2693 rearrange(Vi, nb_V, Bj, nb_B, R, X, P);
2694
2695 L.incma_latex(ost,
2696 nb_points(), nb_lines(),
2697 nb_V, nb_B, Vi, Bj,
2698 R, X, max_r);
2699
2700 FREE_int(Vi);
2701 FREE_int(Bj);
2702 FREE_int(R);
2703 FREE_int(X);
2704#endif
2705
2706
2707}
2708
2709void incidence_structure::rearrange(int *&Vi, int &nb_V,
2710 int *&Bj, int &nb_B, int *&R, int *&X, data_structures::partitionstack &P)
2711{
2712 int *row_classes;
2713 int nb_row_classes;
2714 int *col_classes;
2715 int nb_col_classes;
2716 //int *Vi, *Bj;
2717 int *row_perm;
2718 int *row_perm_inv;
2719 int *col_perm;
2720 int *col_perm_inv;
2721 int i, j, ii, jj, c, a, h;
2722 //int *R;
2723 //int *X;
2725
2726 row_classes = NEW_int(nb_points() + nb_lines());
2727 col_classes = NEW_int(nb_points() + nb_lines());
2728 P.get_row_and_col_classes(row_classes, nb_row_classes,
2729 col_classes, nb_col_classes, 0 /* verbose_level */);
2730 //ost << "nb_row_classes = " << nb_row_classes << endl;
2731 //ost << "nb_col_classes = " << nb_col_classes << endl;
2732
2733 nb_V = nb_row_classes;
2734 nb_B = nb_col_classes;
2735 Vi = NEW_int(nb_row_classes);
2736 Bj = NEW_int(nb_col_classes);
2737 for (i = 0; i < nb_row_classes; i++) {
2738 c = row_classes[i];
2739 a = P.cellSize[c];
2740 Vi[i] = a;
2741 }
2742 for (i = 0; i < nb_col_classes; i++) {
2743 c = col_classes[i];
2744 a = P.cellSize[c];
2745 Bj[i] = a;
2746 }
2747
2748 row_perm = NEW_int(nb_points());
2749 row_perm_inv = NEW_int(nb_points());
2750 col_perm = NEW_int(nb_lines());
2751 col_perm_inv = NEW_int(nb_lines());
2752
2753 P.get_row_and_col_permutation(
2754 row_classes, nb_row_classes,
2755 col_classes, nb_col_classes,
2756 row_perm, row_perm_inv,
2757 col_perm, col_perm_inv);
2758
2759#if 0
2760 cout << "row_perm:" << endl;
2761 int_vec_print(cout, row_perm, nb_points());
2762 cout << endl;
2763 cout << "col_perm:" << endl;
2764 int_vec_print(cout, col_perm, nb_lines());
2765 cout << endl;
2766#endif
2767
2768 R = NEW_int(nb_points());
2769 X = NEW_int(nb_points() * max_r);
2770
2771 for (i = 0; i < nb_points(); i++) {
2772 ii = row_perm_inv[i];
2773 R[i] = nb_lines_on_point[ii];
2774 for (h = 0; h < nb_lines_on_point[ii]; h++) {
2775 jj = lines_on_point[ii * max_r + h];
2776 j = col_perm[jj];
2777 X[i * max_r + h] = j;
2778 }
2779 Sorting.int_vec_heapsort(X + i * max_r, nb_lines_on_point[ii]);
2780 }
2781
2782
2783
2784 FREE_int(row_classes);
2785 FREE_int(col_classes);
2786 //FREE_int(Vi);
2787 //FREE_int(Bj);
2788 FREE_int(row_perm);
2789 FREE_int(row_perm_inv);
2790 FREE_int(col_perm);
2791 FREE_int(col_perm_inv);
2792 //FREE_int(R);
2793 //FREE_int(X);
2794}
2795
2796
2797
2800 int f_row_tactical, int f_col_tactical,
2801 int f_detailed, int f_local_coordinates, int verbose_level)
2802{
2803 int *row_classes, *row_class_inv, nb_row_classes;
2804 int *col_classes, *col_class_inv, nb_col_classes;
2805 int f_v = (verbose_level >= 1);
2806
2807 if (f_v) {
2808 cout << "incidence_structure::decomposition_print_tex get decomposition" << endl;
2809 }
2811 row_classes, row_class_inv, nb_row_classes,
2812 col_classes, col_class_inv, nb_col_classes,
2813 verbose_level);
2814
2815 ost << "\\subsection*{Decomposition}" << endl;
2816 PStack.print_decomposition_tex(ost, row_classes, nb_row_classes,
2817 col_classes, nb_col_classes);
2818
2819 if (f_row_tactical) {
2820 int *row_scheme;
2821 row_scheme = NEW_int(nb_row_classes * nb_col_classes);
2823 row_classes, row_class_inv, nb_row_classes,
2824 col_classes, col_class_inv, nb_col_classes,
2825 row_scheme, 0);
2826 if (f_v) {
2827 cout << "incidence_structure::decomposition_"
2828 "print_tex row_scheme:" << endl;
2829 cout << "row_scheme:" << endl;
2830 PStack.print_decomposition_scheme(cout,
2831 row_classes, nb_row_classes,
2832 col_classes, nb_col_classes,
2833 row_scheme, -1, -1);
2834 }
2835
2836 if (f_detailed) {
2837 ost << "\\subsection*{Incidences by row-scheme}" << endl;
2839 PStack,
2840 ost, FALSE /* f_enter_math_mode */,
2841 row_classes, row_class_inv, nb_row_classes,
2842 col_classes, col_class_inv, nb_col_classes,
2843 f_local_coordinates, 0 /*verbose_level*/);
2844 }
2845 FREE_int(row_scheme);
2846 }
2847 if (f_col_tactical) {
2848 int *col_scheme;
2849 col_scheme = NEW_int(nb_row_classes * nb_col_classes);
2851 row_classes, row_class_inv, nb_row_classes,
2852 col_classes, col_class_inv, nb_col_classes,
2853 col_scheme, 0);
2854 if (f_v) {
2855 cout << "incidence_structure::decomposition_"
2856 "print_tex col_scheme:" << endl;
2857 cout << "col_scheme:" << endl;
2858 PStack.print_decomposition_scheme(cout,
2859 row_classes, nb_row_classes,
2860 col_classes, nb_col_classes,
2861 col_scheme, -1, -1);
2862 }
2863
2864 if (f_detailed) {
2865 ost << "\\subsection*{Incidences by col-scheme}" << endl;
2867 PStack,
2868 ost, FALSE /* f_enter_math_mode */,
2869 row_classes, row_class_inv, nb_row_classes,
2870 col_classes, col_class_inv, nb_col_classes,
2871 f_local_coordinates, 0 /*verbose_level*/);
2872 }
2873 FREE_int(col_scheme);
2874 }
2875
2876
2877
2878
2879
2880 FREE_int(row_classes);
2881 FREE_int(row_class_inv);
2882 FREE_int(col_classes);
2883 FREE_int(col_class_inv);
2884}
2885
2886
2887
2890 int f_tdo_steps, int f_tdo_depth, int tdo_depth,
2891 int f_write_tdo_files, int f_pic,
2892 int f_include_tdo_scheme, int f_include_tdo_extra,
2893 int f_write_tdo_class_files,
2894 int verbose_level)
2895{
2896 int f_v = (verbose_level >= 1);
2897 int TDO_depth;
2898
2899 if (f_v) {
2900 cout << "incidence_structure::do_tdo_high_level" << endl;
2901 }
2902
2903 if (f_tdo_depth) {
2904 TDO_depth = tdo_depth;
2905 }
2906 else {
2907 TDO_depth = nb_points() + nb_lines();
2908 }
2909
2910 if (f_tdo_steps) {
2912 TDO_depth,
2913 f_write_tdo_files,
2914 f_pic,
2915 f_include_tdo_scheme,
2916 f_include_tdo_extra,
2917 verbose_level);
2918 }
2919 else {
2920 compute_tdo(S,
2921 f_write_tdo_files,
2922 f_pic,
2923 f_include_tdo_scheme,
2924 verbose_level);
2925 }
2926 if (f_write_tdo_class_files) {
2927 int *row_classes, *row_class_inv, nb_row_classes;
2928 int *col_classes, *col_class_inv, nb_col_classes;
2929 int i;
2930
2932 row_classes, row_class_inv, nb_row_classes,
2933 col_classes, col_class_inv, nb_col_classes,
2934 verbose_level - 1);
2935
2936 for (i = 0; i < nb_row_classes; i++) {
2937 string fname;
2938 fname.assign(label);
2939 char str[1000];
2940 sprintf(str, "_TDO_point_class_%d.txt", i);
2941 fname.append(str);
2943 row_classes[i], fname, verbose_level - 1);
2944 }
2945 for (i = 0; i < nb_col_classes; i++) {
2946 string fname;
2947 fname.assign(label);
2948 char str[1000];
2949 sprintf(str, "_TDO_line_class_%d.txt", i);
2950 fname.append(str);
2952 col_classes[i], fname, verbose_level - 1);
2953 }
2954 FREE_int(row_classes);
2955 FREE_int(row_class_inv);
2956 FREE_int(col_classes);
2957 FREE_int(col_class_inv);
2958 }
2959}
2960
2961
2962
2963
2964
2967 int f_write_tdo_files,
2968 int f_pic,
2969 int f_include_tdo_scheme,
2970 int verbose_level)
2971{
2972 int f_v = (verbose_level >= 1);
2973 int f_vv = (verbose_level >= 2);
2974 string fname;
2975 int f_list_incidences = FALSE;
2977
2978 if (f_v) {
2979 cout << "incidence_structure_compute_tdo" << endl;
2980 }
2981
2982 int N;
2983
2984
2985 if (f_v) {
2986 cout << "incidence_structure_compute_tdo "
2987 "initial partition:" << endl;
2988 S.print(cout);
2989 cout << endl;
2990 }
2991 N = nb_points() + nb_lines();
2992
2993 int TDO_depth = N;
2994 int f_labeled = TRUE;
2995
2996 compute_TDO_safe(S, TDO_depth, verbose_level - 1);
2997
2998 if (f_vv) {
2999 print_partitioned(cout, S, f_labeled);
3000 }
3001
3002 if (f_v) {
3003 cout << "TDO:" << endl;
3004 if (TDO_depth < N) {
3005 if (EVEN(TDO_depth)) {
3007 S, f_list_incidences, FALSE, verbose_level);
3008 }
3009 else {
3011 S, f_list_incidences, FALSE, verbose_level);
3012 }
3013 }
3014 else {
3017 }
3018 }
3019
3020 if (f_write_tdo_files) {
3021 fname.assign(label);
3022 fname.append("_tdo_scheme.tex");
3023 {
3024 ofstream fp(fname);
3025
3026 //fp << "$$" << endl;
3028 fp, TRUE /* f_enter_math */, S);
3029 //fp << "$$" << endl;
3030 }
3031 if (f_v) {
3032 cout << "written file " << fname << " of size "
3033 << Fio.file_size(fname) << endl;
3034 }
3035
3036 fname.assign(label);
3037 fname.append("_tdo.tex");
3038 {
3039 ofstream fp(fname);
3040
3041 if (f_include_tdo_scheme) {
3042 fp << "$\\begin{array}{c}" << endl;
3043 if (f_pic) {
3044 latex_it(fp, S);
3045 fp << "\\\\" << endl;
3046 }
3048 fp, FALSE /* f_enter_math */, S);
3049 fp << "\\end{array}$" << endl;
3050 }
3051 else {
3052 latex_it(fp, S);
3053 }
3054 }
3055 if (f_v) {
3056 cout << "written file " << fname << " of size "
3057 << Fio.file_size(fname) << endl;
3058 }
3059 }
3060
3061}
3062
3065 int TDO_depth,
3066 int f_write_tdo_files,
3067 int f_pic,
3068 int f_include_tdo_scheme,
3069 int f_include_extra,
3070 int verbose_level)
3071{
3072 int f_v = (verbose_level >= 1);
3073 int f_vv = (verbose_level >= 2);
3074 string fname;
3075 string fname_pic;
3076 string fname_scheme;
3077 string fname_extra;
3078 int step, f_refine, f_refine_prev, f_done;
3079 int f_local_coordinates = FALSE;
3080 int f_list_incidences = FALSE;
3082
3083 if (f_v) {
3084 cout << "incidence_structure::compute_tdo_stepwise" << endl;
3085 }
3086
3087
3089 TDO_depth, step, f_refine, f_refine_prev, verbose_level);
3090
3091 S.sort_cells();
3092
3093 f_done = FALSE;
3094 while (TRUE) {
3095 if (f_v) {
3096 cout << "incidence_structure::compute_tdo_stepwise "
3097 "TDO step=" << step << " ht=" << S.ht << endl;
3098 if (step == 0) {
3100 cout, FALSE /* f_enter_math */, S);
3101 }
3102 else if (EVEN(step - 1)) {
3103
3105 S, f_list_incidences, FALSE, verbose_level);
3107 cout, TRUE /* f_enter_math */,
3108 FALSE /* f_print_subscripts */, S);
3109 }
3110 else {
3111
3113 S, f_list_incidences, FALSE, verbose_level);
3115 cout, TRUE /* f_enter_math */,
3116 FALSE /* f_print_subscripts */, S);
3117 }
3119 }
3120 if (f_write_tdo_files) {
3121
3122 char str[1000];
3123
3124 sprintf(str, "_tdo_step_%d.tex", step);
3125 fname.assign(label);
3126 fname.append(str);
3127
3128 sprintf(str, "_tdo_step_%d_pic.tex", step);
3129 fname_pic.assign(label);
3130 fname_pic.append(str);
3131
3132 sprintf(str, "_tdo_step_%d_scheme.tex", step);
3133 fname_scheme.assign(label);
3134 fname_scheme.append(str);
3135
3136 sprintf(str, "_tdo_step_%d_extra.tex", step);
3137 fname_extra.assign(label);
3138 fname_extra.append(str);
3139
3140 {
3141 ofstream fp(fname);
3142 ofstream fp_pic(fname_pic);
3143 ofstream fp_scheme(fname_scheme);
3144 ofstream fp_extra(fname_extra);
3145
3146 if (f_include_tdo_scheme) {
3147 fp << "\\subsection*{Step $" << step
3148 << "$, Height $" << S.ht << "$}" << endl;
3149 //fp << "$ht=" << S.ht << "$\\\\" << endl;
3150 //fp << "\\bigskip" << endl;
3151 fp << "$\\begin{array}{c}" << endl;
3152
3153 if (f_pic) {
3154 fp << "\\input " << fname_pic << endl;
3155 latex_it(fp_pic, S);
3156 fp << "\\\\" << endl;
3157 }
3158
3159 fp << "\\input " << fname_scheme << endl;
3160 if (step == 0) {
3162 fp_scheme, FALSE /* f_enter_math */, S);
3163 }
3164 else if (EVEN(step - 1)) {
3166 fp_scheme, FALSE /* f_enter_math */,
3167 FALSE /* f_print_subscripts */, S);
3168 }
3169 else {
3171 fp_scheme, FALSE /* f_enter_math */,
3172 FALSE /* f_print_subscripts */, S);
3173 }
3174 fp << "\\end{array}$" << endl;
3175
3176 if (f_include_extra) {
3177 if (step == 0) {
3178 decomposition_print_tex(fp_extra, S,
3179 FALSE, FALSE, FALSE,
3180 f_local_coordinates, verbose_level);
3181 fp << "\\input " << fname_extra << endl;
3182 }
3183 else if (EVEN(step - 1)) {
3184 decomposition_print_tex(fp_extra, S,
3185 FALSE, TRUE, TRUE,
3186 f_local_coordinates, verbose_level);
3187 fp << "\\input " << fname_extra << endl;
3188 //PStack.print_classes_points_and_lines(cout);
3189 }
3190 else {
3191 decomposition_print_tex(fp_extra, S,
3192 TRUE, FALSE, TRUE,
3193 f_local_coordinates, verbose_level);
3194 fp << "\\input " << fname_extra << endl;
3195 }
3196 }
3197 }
3198 else {
3199 latex_it(fp_pic, S);
3200 }
3201 }
3202 if (f_v) {
3203 cout << "written file " << fname << " of size "
3204 << Fio.file_size(fname) << endl;
3205 cout << "written file " << fname_pic << " of size "
3206 << Fio.file_size(fname_pic) << endl;
3207 cout << "written file " << fname_scheme << " of size "
3208 << Fio.file_size(fname_scheme) << endl;
3209 cout << "written file " << fname_extra << " of size "
3210 << Fio.file_size(fname_extra) << endl;
3211 }
3212 }
3213 if (f_done) {
3214 break;
3215 }
3216
3217 f_done = compute_TDO_safe_next(S,
3218 TDO_depth, step, f_refine, f_refine_prev, verbose_level);
3219 S.sort_cells();
3220 }
3221
3222
3223
3224 if (f_vv) {
3225 int f_labeled = FALSE;
3226
3227 print_partitioned(cout, S, f_labeled);
3228 }
3229
3230 if (f_v) {
3231 cout << "TDO:" << endl;
3232 if (TDO_depth < nb_points() + nb_lines()) {
3233 if (EVEN(TDO_depth)) {
3235 f_list_incidences, FALSE, verbose_level);
3236 }
3237 else {
3239 f_list_incidences, FALSE, verbose_level);
3240 }
3241 }
3242 else {
3245 }
3246 }
3247
3248 if (f_write_tdo_files) {
3249 fname.assign(label);
3250 fname.append("_tdo.tex");
3251
3252 fname_pic.assign(label);
3253 fname_pic.append("_tdo_pic.tex");
3254
3255 fname_scheme.assign(label);
3256 fname_scheme.append("_tdo_scheme.tex");
3257
3258 {
3259 ofstream fp(fname);
3260 ofstream fp_pic(fname_pic);
3261 ofstream fp_scheme(fname_scheme);
3262
3263 if (f_include_tdo_scheme) {
3264 fp << "\\subsection*{The TDO at Height $"
3265 << S.ht << "$}" << endl;
3266 fp << "$\\begin{array}{c}" << endl;
3267 if (f_pic) {
3268 fp << "\\input " << fname_pic << endl;
3269 latex_it(fp_pic, S);
3270 fp << "\\\\" << endl;
3271 }
3272 fp << "\\input " << fname_scheme << endl;
3274 fp_scheme, FALSE /* f_enter_math */, S);
3275 fp << "\\end{array}$" << endl;
3276 }
3277 else {
3278 latex_it(fp_pic, S);
3279 }
3280 }
3281 if (f_v) {
3282 cout << "written file " << fname << " of size "
3283 << Fio.file_size(fname) << endl;
3284 cout << "written file " << fname_pic << " of size "
3285 << Fio.file_size(fname_pic) << endl;
3286 cout << "written file " << fname_scheme << " of size "
3287 << Fio.file_size(fname_scheme) << endl;
3288 }
3289 }
3290
3291}
3292
3295 int verbose_level)
3296{
3297 int f_v = (verbose_level >= 1);
3298 int N;
3299
3300
3301 if (f_v) {
3302 cout << "incidence_structure::init_partitionstack_trivial" << endl;
3303 }
3304 N = nb_points() + nb_lines();
3305
3306 S->allocate(N, 0);
3307
3308 // split off the column class:
3310 S->split_cell(0);
3311
3312}
3313
3316 int f_row_part, int nb_row_parts, int *row_parts,
3317 int f_col_part, int nb_col_parts, int *col_parts,
3318 int nb_distinguished_point_sets,
3319 int **distinguished_point_sets, int *distinguished_point_set_size,
3320 int nb_distinguished_line_sets,
3321 int **distinguished_line_sets, int *distinguished_line_set_size,
3322 int verbose_level)
3323{
3324 int f_v = (verbose_level >= 1);
3325 int f_vv = (verbose_level >= 2);
3326 int f_v3 = (verbose_level >= 3);
3327 int N;
3328 int i, j, a, h;
3329
3330
3331 if (f_v) {
3332 cout << "incidence_structure::init_partitionstack" << endl;
3333 }
3334 N = nb_points() + nb_lines();
3335
3336 S->allocate(N, 0);
3337
3338 // split off the column class:
3340 S->split_cell(0);
3341
3342
3343
3344 if (f_row_part) {
3345 a = row_parts[0];
3346 for (i = 1; i < nb_row_parts; i++) {
3347 S->subset_continguous(a, nb_points() - a);
3348 S->split_cell(0);
3349 a += row_parts[i];
3350 }
3351 }
3352 if (f_col_part) {
3353 a = nb_points() + col_parts[0];
3354 for (i = 1; i < nb_col_parts; i++) {
3355 S->subset_continguous(a, nb_points() + nb_lines() - a);
3356 S->split_cell(0);
3357 a += col_parts[i];
3358 }
3359 }
3360
3361
3362
3363 for (j = 0; j < nb_distinguished_point_sets; j++) {
3364 if (f_v) {
3365 cout << "splitting off " << j << "-th distinguished point "
3366 "set of size "
3367 << distinguished_point_set_size[j] << endl;
3368 }
3369 if (f_v3) {
3370 cout << "which is the following set of size "
3371 << distinguished_point_set_size[j] << ":" << endl;
3372 Int_vec_print(cout, distinguished_point_sets[j],
3373 distinguished_point_set_size[j]);
3374 cout << endl;
3375 }
3376 S->split_multiple_cells(distinguished_point_sets[j],
3377 distinguished_point_set_size[j], TRUE, verbose_level);
3378 if (f_vv) {
3379 cout << "incidence_structure::init_partitionstack "
3380 "partition:" << endl;
3382 }
3383 }
3384
3385
3386
3387 for (j = 0; j < nb_distinguished_line_sets; j++) {
3388 if (f_v) {
3389 cout << "splitting off " << j << "-th distinguished "
3390 "line set of size "
3391 << distinguished_line_set_size[j] << endl;
3392 }
3393 if (f_v3) {
3394 cout << "which is the following set of size "
3395 << distinguished_line_set_size[j] << ":" << endl;
3396 Int_vec_print(cout, distinguished_line_sets[j],
3397 distinguished_line_set_size[j]);
3398 cout << endl;
3399 }
3400
3401 int *set;
3402 int set_sz;
3403
3404 set_sz = distinguished_line_set_size[j];
3405 set = NEW_int(set_sz);
3406 for (h = 0; h < set_sz; h++) {
3407 set[h] = distinguished_line_sets[j][h] + nb_points();
3408 }
3409
3410
3411 if (f_vv) {
3412 cout << "incidence_structure::init_partitionstack "
3413 "After adding Inc->nb_points():" << endl;
3414 Int_vec_print(cout, set, set_sz);
3415 cout << endl;
3416 }
3417
3418
3419 S->split_multiple_cells(set, set_sz, TRUE, verbose_level);
3420 FREE_int(set);
3421 if (f_vv) {
3422 cout << "incidence_structure::init_partitionstack "
3423 "partition:" << endl;
3425 }
3426 }
3427
3428 if (f_vv) {
3429 cout << "incidence_structure::init_partitionstack "
3430 "we have arrived at the following partition:" << endl;
3432 }
3433 if (f_v) {
3434 cout << "incidence_structure::init_partitionstack done" << endl;
3435 }
3436}
3437
3439 int nb_distinguished_point_sets,
3440 int nb_distinguished_line_sets,
3441 int Aut_counter, int *Aut, int *Base, int Base_length,
3442 int verbose_level)
3443{
3444 int f_v = (verbose_level >= 1);
3445 int i, j, h;
3446 int m, n;
3447 int nb_rows, nb_cols, total;
3448
3449 if (f_v) {
3450 cout << "incidence_structure::shrink_aut_generators" << endl;
3451 }
3452 m = nb_points();
3453 n = nb_lines();
3454
3455 nb_rows = m;
3456 nb_cols = n;
3457
3458 nb_rows += nb_distinguished_line_sets;
3459 nb_cols += nb_distinguished_point_sets;
3460
3461 total = nb_rows + nb_cols;
3462
3463 for (h = 0; h < Aut_counter; h++) {
3464 for (i = 0; i < m; i++) {
3465 Aut[h * (m + n) + i] = Aut[h * total + i];
3466 }
3467 for (j = 0; j < n; j++) {
3468 Aut[h * (m + n) + m + j] =
3469 Aut[h * total + nb_rows + j] -
3470 nb_distinguished_line_sets;
3471 }
3472 for (i = Base_length - 1; i >= 0; i--) {
3473 if (Base[i] > m) {
3474 if (Base[i] < nb_rows) {
3475 cout << "Base[i] > m && Base[i] < nb_rows" << endl;
3476 exit(1);
3477 }
3478 Base[i] -= nb_distinguished_line_sets;
3479 }
3480 }
3481 }
3482
3483 if (f_v) {
3484 cout << "incidence_structure::shrink_aut_generators "
3485 "done" << endl;
3486 }
3487}
3488
3490 int Aut_counter, int *Aut,
3491 int Base_length, int *Base, int *Transversal_length)
3492{
3493 int m, n, i, j, h;
3494 int *AUT;
3496
3497 m = nb_points();
3498 n = nb_lines();
3499 AUT = NEW_int(m + n);
3500
3501 cout << "incidence_structure::print_aut_generators "
3502 "base_length = " << Base_length << endl;
3503 cout << "The base is : " << endl;
3504 for (i = Base_length - 1; i >= 0; i--) {
3505 cout << Base[i] << " ";
3506 }
3507 cout << endl;
3508 cout << "The transversal lengths are: " << endl;
3509 for (i = 0; i < Base_length; i++) {
3510 cout << Transversal_length[i] << " ";
3511 }
3512 cout << endl;
3513 cout << "We have found " << Aut_counter << " gens:" << endl;
3514 for (h = 0; h < Aut_counter; h++) {
3515 for (i = 0; i < m; i++) {
3516 AUT[i] = Aut[h * (m + n) + i];
3517 }
3518 for (j = 0; j < n; j++) {
3519 AUT[m + j] = Aut[h * (m + n) + m + j] - m;
3520 }
3521 cout << h << " : " ;
3522 cout << "generator " << h << ":" << endl;
3523 for (i = 0; i < m + n; i++)
3524 cout << AUT[i] << " ";
3525 cout << endl;
3526 Combi.perm_print_product_action(cout, AUT, m + n, m,
3527 0 /* offset */, FALSE /* f_cycle_length */);
3528 cout << endl;
3529 //for ( j = 0; j < m + n; j++ ){
3530 //cout << Aut[h * (m + n) + j] << " ";
3531 //}
3532 //cout << endl;
3533 }
3534 cout << endl;
3535
3536 FREE_int(AUT);
3537}
3538
3540 int *&Adj, int &v, int *&partition,
3541 int f_row_part, int nb_row_parts, int *row_parts,
3542 int f_col_part, int nb_col_parts, int *col_parts,
3543 int nb_distinguished_point_sets,
3544 int **distinguished_point_sets, int *distinguished_point_set_size,
3545 int nb_distinguished_line_sets,
3546 int **distinguished_line_sets, int *distinguished_line_set_size,
3547 int verbose_level)
3548// side effect: the distinguished sets will be sorted afterwards
3549{
3550 int f_v = (verbose_level >= 1);
3551 int f_vv = (verbose_level >= 2);
3552 //int f_v4 = (verbose_level >= 4);
3553 int m = nb_points();
3554 int n = nb_lines();
3555 int i, j, J, j0, l, u, k, h, h1, h2, i1, i2, idx, y, z;
3556 int v1, v2, v3;
3557 int my_nb_col_parts;
3558 int *my_col_parts;
3560
3561 if (f_v) {
3562 cout << "incidence_structure::compute_extended_collinearity_graph" << endl;
3563 }
3564 v = v1 = m;
3565 if (f_col_part) {
3566 v += nb_col_parts - 1;
3567 }
3568 v2 = v;
3569 v += nb_distinguished_point_sets;
3570 v3 = v;
3571 for (i = 0; i < nb_distinguished_line_sets; i++) {
3572 v += distinguished_line_set_size[i];
3573 }
3574 if (f_v) {
3575 cout << "incidence_structure::compute_extended_"
3576 "collinearity_graph v=" << v << endl;
3577 }
3578
3579 for (i = 0; i < nb_distinguished_point_sets; i++) {
3580 Sorting.int_vec_heapsort(distinguished_point_sets[i],
3581 distinguished_point_set_size[i]);
3582 }
3583 for (i = 0; i < nb_distinguished_line_sets; i++) {
3584 Sorting.int_vec_heapsort(distinguished_line_sets[i],
3585 distinguished_line_set_size[i]);
3586 }
3587 partition = NEW_int(v);
3588 for (i = 0; i < v; i++) {
3589 partition[i] = 1;
3590 }
3591 Adj = NEW_int(v * v);
3592 for (i = 0; i < v * v; i++) {
3593 Adj[i] = 0;
3594 }
3595
3596
3597 if (f_col_part) {
3598 my_nb_col_parts = nb_col_parts;
3599 my_col_parts = NEW_int(my_nb_col_parts);
3600 for (i = 0; i < nb_col_parts; i++) {
3601 my_col_parts[i] = col_parts[i];
3602 }
3603 }
3604 else {
3605 my_nb_col_parts = 1;
3606 my_col_parts = NEW_int(my_nb_col_parts);
3607 my_col_parts[0] = n;
3608 }
3609 j0 = 0;
3610 for (J = 0; J < my_nb_col_parts; J++) {
3611 l = my_col_parts[J];
3612 for (u = 0; u < l; u++) {
3613 j = j0 + u;
3614 k = nb_points_on_line[j];
3615 // keep track of which column class block j belongs to
3616 // we do this for the all column classes but the first
3617 if (J) {
3618 for (h = 0; h < k; h++) {
3619 i = points_on_line[j * max_k + h];
3620 Adj[i * v + v1 + J - 1] = 1;
3621 Adj[(v1 + J - 1) * v + i] = 1;
3622 }
3623 }
3624 // record the collinearity information resulting from block j:
3625 for (h1 = 0; h1 < k; h1++) {
3626 i1 = points_on_line[j * max_k + h1];
3627 for (h2 = h1 + 1; h2 < k; h2++) {
3628 i2 = points_on_line[j * max_k + h2];
3629 Adj[i1 * v + i2] = 1;
3630 Adj[i2 * v + i1] = 1;
3631 }
3632 }
3633
3634#if 0
3635 // keep track of whether block j is in a distinguished line set:
3636 for (h = 0; h < nb_distinguished_line_sets; h++) {
3637 if (int_vec_search(distinguished_line_sets[h],
3638 distinguished_line_set_size[h], j, idx)) {
3639 Adj[j * v + v3 + h] = 1;
3640 Adj[(v3 + h) * v + j] = 1;
3641 }
3642 }
3643#endif
3644
3645 }
3646 }
3647
3648 // record the distinguished line sets:
3649 z = v2;
3650 for (h = 0; h < nb_distinguished_line_sets; h++) {
3651 for (u = 0; u < distinguished_line_set_size[h]; u++) {
3652 j = distinguished_line_sets[h][u];
3653 k = nb_points_on_line[j];
3654 for (y = 0; y < k; y++) {
3655 i = points_on_line[j * max_k + y];
3656 Adj[i * v + z + u] = 1;
3657 Adj[(z + u) * v + i] = 1;
3658 }
3659 }
3660 z += distinguished_line_set_size[h];
3661 }
3662
3663
3664 // finally, we record the distinguished point sets:
3665 for (i = 0; i < m; i++) {
3666 for (h = 0; h < nb_distinguished_point_sets; h++) {
3667 if (Sorting.int_vec_search(distinguished_point_sets[h],
3668 distinguished_point_set_size[h], i, idx)) {
3669 Adj[i * v + v2 + h] = 1;
3670 Adj[(v2 + h) * v + i] = 1;
3671 }
3672 }
3673 }
3674
3675 // initialize the partition:
3676 z = 0;
3677 if (f_row_part) {
3678 for (h = 0; h < nb_row_parts; h++) {
3679 partition[z + row_parts[h] - 1] = 0;
3680 z += row_parts[h];
3681 }
3682 }
3683 else {
3684 partition[m - 1] = 0;
3685 }
3686 z = v1;
3687 for (h = 0; h < my_nb_col_parts; h++) {
3688 partition[z + h] = 0;
3689 }
3690 z = v2;
3691 for (h = 0; h < nb_distinguished_point_sets; h++) {
3692 partition[z + h] = 0;
3693 }
3694 z = v3;
3695 for (h = 0; h < nb_distinguished_line_sets; h++) {
3696 l = distinguished_line_set_size[h];
3697 partition[z + l - 1] = 0;
3698 z += l;
3699 }
3700 if (f_vv) {
3701 cout << "incidence_structure::compute_extended_collinearity_graph "
3702 "Adj=" << endl;
3703 Int_vec_print_integer_matrix_width(cout, Adj, v, v, v, 1);
3704 }
3705
3706
3707 if (f_v) {
3708 cout << "incidence_structure::compute_extended_collinearity_graph done" << endl;
3709 }
3710
3711 FREE_int(my_col_parts);
3712}
3713
3715 int *&M, int &nb_rows, int &nb_cols, int &total, int *&partition,
3716 int f_row_part, int nb_row_parts, int *row_parts,
3717 int f_col_part, int nb_col_parts, int *col_parts,
3718 int nb_distinguished_point_sets,
3719 int **distinguished_point_sets, int *distinguished_point_set_size,
3720 int nb_distinguished_line_sets,
3721 int **distinguished_line_sets, int *distinguished_line_set_size,
3722 int verbose_level)
3723{
3724 int f_v = (verbose_level >= 1);
3725 int f_vv = (verbose_level >= 2);
3726 int f_v4 = (verbose_level >= 4);
3727 int m = nb_points();
3728 int n = nb_lines();
3729 int i, j, h, a;
3730
3731 if (f_v) {
3732 cout << "incidence_structure::compute_extended_matrix" << endl;
3733 }
3734
3735 nb_rows = m;
3736 nb_cols = n;
3737
3738 nb_rows += nb_distinguished_line_sets;
3739 nb_cols += nb_distinguished_point_sets;
3740
3741 total = nb_rows + nb_cols;
3742
3743 if (f_vv) {
3744 cout << "nb_distinguished_line_sets="
3745 << nb_distinguished_line_sets << endl;
3746 cout << "nb_distinguished_point_sets="
3747 << nb_distinguished_point_sets << endl;
3748 cout << "m=" << m << endl;
3749 cout << "n=" << n << endl;
3750 cout << "nb_rows=" << nb_rows << endl;
3751 cout << "nb_cols=" << nb_cols << endl;
3752 cout << "total=" << total << endl;
3753 }
3754
3755 partition = NEW_int(total);
3756 M = NEW_int(nb_rows * nb_cols);
3757 for (i = 0; i < nb_rows * nb_cols; i++) {
3758 M[i] = 0;
3759 }
3760 for (i = 0; i < m; i++) {
3761 for (h = 0; h < nb_lines_on_point[i]; h++) {
3762 a = lines_on_point[i * max_r + h];
3763 M[i * nb_cols + a] = 1;
3764 }
3765 }
3766
3767
3768 for (j = 0; j < nb_distinguished_point_sets; j++) {
3769 if (f_v) {
3770 cout << "The " << j << "-th distinguished point set is:" << endl;
3771 Int_vec_print(cout, distinguished_point_sets[j],
3772 distinguished_point_set_size[j]);
3773 cout << endl;
3774 }
3775 for (i = 0; i < distinguished_point_set_size[j]; i++) {
3776 a = distinguished_point_sets[j][i];
3777 M[a * nb_cols + n + j] = 1;
3778 }
3779 }
3780
3781
3782 for (j = 0; j < nb_distinguished_line_sets; j++) {
3783 if (f_v) {
3784 cout << "The " << j << "-th distinguished line set is:" << endl;
3785 Int_vec_print(cout, distinguished_line_sets[j],
3786 distinguished_line_set_size[j]);
3787 cout << endl;
3788 }
3789 for (i = 0; i < distinguished_line_set_size[j]; i++) {
3790 a = distinguished_line_sets[j][i];
3791 M[(m + j) * nb_cols + a] = 1;
3792 }
3793 }
3794
3795
3796 if (f_v4) {
3797 cout << "incidence_structure::compute_extended_matrix "
3798 "The extended incidence matrix is:" << endl;
3800 }
3801
3802
3803 for (i = 0; i < total; i++) {
3804 partition[i] = 1;
3805 }
3806
3807 if (f_row_part) {
3808 int a;
3809 a = 0;
3810 for (i = 0; i < nb_row_parts; i++) {
3811 a += row_parts[i];
3812 partition[a - 1] = 0;
3813 }
3814 }
3815 else {
3816 partition[m - 1] = 0;
3817 }
3818 if (f_col_part) {
3819 int a;
3820 a = nb_rows;
3821 for (i = 0; i < nb_col_parts; i++) {
3822 a += col_parts[i];
3823 partition[a - 1] = 0;
3824 }
3825 }
3826 else {
3827 partition[nb_rows + n - 1] = 0;
3828 }
3829#if 0
3830 for (i = 0; i < PB.P.ht; i++) {
3831 j = PB.P.startCell[i] + PB.P.cellSize[i] - 1;
3832 if (PB.P.startCell[i] >= m) {
3833 j += nb_distinguished_line_sets;
3834 }
3835 partition[j] = 0;
3836 }
3837#endif
3838
3839 for (i = 0; i < nb_distinguished_line_sets; i++) {
3840 partition[m + i] = 0;
3841 }
3842
3843 for (j = 0; j < nb_distinguished_point_sets; j++) {
3844 partition[nb_rows + n + j] = 0;
3845 }
3846 if (f_v4) {
3847 cout << "incidence_structure::compute_extended_matrix "
3848 "The partition is:" << endl;
3849 Int_vec_print(cout, partition, total);
3850 cout << endl;
3851 }
3852
3853
3854 if (f_v) {
3855 cout << "incidence_structure::compute_extended_matrix done" << endl;
3856 }
3857}
3858
3859
3861{
3862 int i, j, a;
3864
3866 B->allocate(nb_rows * nb_cols);
3867
3868 for (i = 0; i < nb_rows; i++) {
3869 for (j = 0; j < nb_cols; j++) {
3870 if (M[i * nb_cols + j]) {
3871 a = i * nb_cols + j;
3872 //bitvector_set_bit(bitvec, a);
3873 B->m_i(a, 1);
3874 }
3875 }
3876 }
3877 return B;
3878}
3879
3880
3882 long int *canonical_labeling, int verbose_level)
3883{
3884 int f_v = (verbose_level >= 1);
3885 int f_vv = (verbose_level >= 2);
3886 int *Incma_out;
3887 int i, j, ii, jj;
3888
3889 if (f_v) {
3890 cout << "incidence_structure::apply_canonical_labeling" << endl;
3891 }
3892
3893 if (f_vv) {
3894 cout << "incidence_structure::apply_canonical_labeling labeling:" << endl;
3895 Lint_vec_print(cout, canonical_labeling, nb_rows + nb_cols);
3896 cout << endl;
3897 }
3898
3899 Incma_out = NEW_int(nb_rows * nb_cols);
3900 //Orbiter->Int_vec.zero(Incma_out, nb_rows * nb_cols);
3901 for (i = 0; i < nb_rows; i++) {
3902 ii = canonical_labeling[i];
3903 for (j = 0; j < nb_cols; j++) {
3904 jj = canonical_labeling[nb_rows + j] - nb_rows;
3905 //cout << "i=" << i << " j=" << j << " ii=" << ii
3906 //<< " jj=" << jj << endl;
3907 Incma_out[i * nb_cols + j] = M[ii * nb_cols + jj];
3908 }
3909 }
3910
3911
3912 incidence_structure *Inc_out;
3913
3915
3916 Inc_out->init_by_matrix(nb_rows, nb_cols, Incma_out, verbose_level);
3917
3918 FREE_int(Incma_out);
3919 if (f_v) {
3920 cout << "incidence_structure::apply_canonical_labeling done" << endl;
3921 }
3922 return Inc_out;
3923}
3924
3925void incidence_structure::save_as_csv(std::string &fname_csv, int verbose_level)
3926{
3928
3929 Fio.int_matrix_write_csv(fname_csv, M, nb_rows, nb_cols);
3930}
3931
3932#if 0
3933void incidence_structure::save_as_Levi_graph(std::string &fname_bin,
3934 int f_point_labels, long int *point_labels,
3935 int verbose_level)
3936{
3937 file_io Fio;
3938 colored_graph *CG;
3939
3940 CG = NEW_OBJECT(colored_graph);
3941
3942 CG->create_Levi_graph_from_incidence_matrix(
3943 M, nb_rows, nb_cols,
3944 f_point_labels, point_labels,
3945 verbose_level);
3946 CG->save(fname_bin, verbose_level);
3947
3948 FREE_OBJECT(CG);
3949}
3950#endif
3951
3953 long int *blocks,
3954 int N_points, int design_b, int design_k, int partition_class_size,
3955 int *&partition, int verbose_level)
3956{
3957 int f_v = (verbose_level >= 1);
3958
3959
3960 if (f_v) {
3961 cout << "incidence_structure::init_large_set" << endl;
3962 }
3963
3964 int *block;
3965 int *Incma;
3966 int nb_classes;
3967 int nb_rows;
3968 int nb_cols;
3969 int N;
3970 int u, i, j, t, a;
3972
3973
3974 nb_classes = design_b / partition_class_size;
3975 nb_rows = N_points + nb_classes;
3976 nb_cols = design_b + 1;
3977 N = nb_rows + nb_cols;
3978 if (f_v) {
3979 cout << "incidence_structure::init_large_set nb_rows=" << nb_rows << " nb_cols=" << nb_cols << " N=" << N << endl;
3980 }
3981
3982 Incma = NEW_int(nb_rows * nb_cols);
3983 Int_vec_zero(Incma, nb_rows * nb_cols);
3984 block = NEW_int(design_k);
3985
3986 for (u = 0; u < nb_classes; u++) {
3987 for (j = 0; j < partition_class_size; j++) {
3988 a = blocks[u * partition_class_size + j];
3989 Combi.unrank_k_subset(a, block, N_points, design_k);
3990 for (t = 0; t < design_k; t++) {
3991 i = block[t];
3992 Incma[i * nb_cols + u * partition_class_size + j] = 1;
3993 }
3994 Incma[(N_points + u) * nb_cols + u * partition_class_size + j] = 1;
3995 }
3996 Incma[(N_points + u) * nb_cols + nb_cols - 1] = 1;
3997 }
3998
3999 init_by_matrix(nb_rows, nb_cols, Incma, verbose_level);
4000 if (f_v) {
4002 }
4003
4004
4005 partition = NEW_int(N);
4006 for (i = 0; i < N; i++) {
4007 partition[i] = 1;
4008 }
4009 partition[N_points - 1] = 0;
4010 partition[nb_rows - 1] = 0;
4011 partition[nb_rows + design_b - 1] = 0;
4012 partition[nb_rows + nb_cols - 1] = 0;
4013
4014
4015 if (f_v) {
4017
4018 T.init(partition, N, FALSE, 0);
4019 T.print_array_tex(cout, TRUE);
4020 }
4021
4022
4023 FREE_int(Incma);
4024 FREE_int(block);
4025
4026 if (f_v) {
4027 cout << "incidence_structure::init_large_set done" << endl;
4028 }
4029}
4030
4031
4032
4033}}}
4034
4035
4036
void perm_print_product_action(std::ostream &ost, int *a, int m_plus_n, int m, int offset, int f_cycle_length)
matrices over GF(2) stored as bitvectors
compact storage of 0/1-data as bitvectors
data structure for set partitions following Jeffrey Leon
void get_row_and_col_classes(int *row_classes, int &nb_row_classes, int *col_classes, int &nb_col_classes, int verbose_level)
void print_column_refinement_info(int ht0, int *data, int depth)
void print_decomposition_tex(std::ostream &ost, int *row_classes, int nb_row_classes, int *col_classes, int nb_col_classes)
void allocate_and_get_decomposition(int *&row_classes, int *&row_class_inv, int &nb_row_classes, int *&col_classes, int *&col_class_inv, int &nb_col_classes, int verbose_level)
void split_multiple_cells(int *set, int set_size, int f_front, int verbose_level)
void print_tactical_decomposition_scheme_tex_internal(std::ostream &ost, int f_enter_math_mode, int *row_classes, int nb_row_classes, int *col_classes, int nb_col_classes, int *row_scheme, int *col_scheme, int f_print_subscripts)
void print_row_tactical_decomposition_scheme_tex(std::ostream &ost, int f_enter_math_mode, int *row_classes, int nb_row_classes, int *col_classes, int nb_col_classes, int *row_scheme, int f_print_subscripts)
void print_tactical_decomposition_scheme_tex(std::ostream &ost, int *row_classes, int nb_row_classes, int *col_classes, int nb_col_classes, int *row_scheme, int *col_scheme, int f_print_subscripts)
void radix_sort(int left, int right, int *C, int length, int radix, int verbose_level)
void print_column_tactical_decomposition_scheme_tex(std::ostream &ost, int f_enter_math_mode, int *row_classes, int nb_row_classes, int *col_classes, int nb_col_classes, int *col_scheme, int f_print_subscripts)
int hash_column_refinement_info(int ht0, int *data, int depth, int hash0)
int hash_row_refinement_info(int ht0, int *data, int depth, int hash0)
void write_cell_to_file_points_or_lines(int i, std::string &fname, int verbose_level)
void print_decomposition_scheme_tex(std::ostream &ost, int *row_classes, int nb_row_classes, int *col_classes, int nb_col_classes, int *scheme)
void print_decomposition_scheme(std::ostream &ost, int *row_classes, int nb_row_classes, int *col_classes, int nb_col_classes, int *scheme, int marker1, int marker2)
a collection of functions related to sorted vectors
int int_vec_search(int *v, int len, int a, int &idx)
Definition: sorting.cpp:1094
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 print_array_tex(std::ostream &ost, int f_backwards)
Definition: tally.cpp:471
void unrank_lint(int *M, long int rk, int verbose_level)
Definition: hjelmslev.cpp:90
interface for various incidence geometries
Definition: geometry.h:1099
void get_col_decomposition_scheme(data_structures::partitionstack &PStack, int *row_classes, int *row_class_inv, int nb_row_classes, int *col_classes, int *col_class_inv, int nb_col_classes, int *col_scheme, int verbose_level)
void free_scheme(int *row_classes, int *row_class_inv, int *col_classes, int *col_class_inv, int *scheme)
void get_and_print_row_tactical_decomposition_scheme_tex(std::ostream &ost, int f_enter_math, int f_print_subscripts, data_structures::partitionstack &PStack)
void print_line(std::ostream &ost, data_structures::partitionstack &P, int row_cell, int i, int *col_classes, int nb_col_classes, int width, int f_labeled)
void init_by_incidences(int m, int n, int nb_inc, int *X, int verbose_level)
void compute_extended_collinearity_graph(int *&Adj, int &v, int *&partition, int f_row_part, int nb_row_parts, int *row_parts, int f_col_part, int nb_col_parts, int *col_parts, int nb_distinguished_point_sets, int **distinguished_point_sets, int *distinguished_point_set_size, int nb_distinguished_line_sets, int **distinguished_line_sets, int *distinguished_line_set_size, int verbose_level)
void compute_TDO_safe_first(data_structures::partitionstack &PStack, int depth, int &step, int &f_refine, int &f_refine_prev, int verbose_level)
int refine_row_partition_safe(data_structures::partitionstack &PStack, int verbose_level)
void get_scheme(int *&row_classes, int *&row_class_inv, int &nb_row_classes, int *&col_classes, int *&col_class_inv, int &nb_col_classes, int *&scheme, int f_row_scheme, data_structures::partitionstack &PStack)
void get_row_decomposition_scheme(data_structures::partitionstack &PStack, int *row_classes, int *row_class_inv, int nb_row_classes, int *col_classes, int *col_class_inv, int nb_col_classes, int *row_scheme, int verbose_level)
incidence_structure * apply_canonical_labeling(long int *canonical_labeling, int verbose_level)
void get_and_print_decomposition_schemes_tex(data_structures::partitionstack &PStack)
void init_partitionstack(data_structures::partitionstack *S, int f_row_part, int nb_row_parts, int *row_parts, int f_col_part, int nb_col_parts, int *col_parts, int nb_distinguished_point_sets, int **distinguished_point_sets, int *distinguished_point_set_size, int nb_distinguished_line_sets, int **distinguished_line_sets, int *distinguished_line_set_size, int verbose_level)
void get_partition(data_structures::partitionstack &PStack, int *row_classes, int *row_class_idx, int &nb_row_classes, int *col_classes, int *col_class_idx, int &nb_col_classes)
int lines_through_two_points(int *lines, int p1, int p2, int verbose_level)
void get_and_print_decomposition_schemes(data_structures::partitionstack &PStack)
void rearrange(int *&Vi, int &nb_V, int *&Bj, int &nb_B, int *&R, int *&X, data_structures::partitionstack &P)
int compute_TDO_safe_next(data_structures::partitionstack &PStack, int depth, int &step, int &f_refine, int &f_refine_prev, int verbose_level)
void compute_tdo(data_structures::partitionstack &S, int f_write_tdo_files, int f_pic, int f_include_tdo_scheme, int verbose_level)
void compute_extended_matrix(int *&M, int &nb_rows, int &nb_cols, int &total, int *&partition, int f_row_part, int nb_row_parts, int *row_parts, int f_col_part, int nb_col_parts, int *col_parts, int nb_distinguished_point_sets, int **distinguished_point_sets, int *distinguished_point_set_size, int nb_distinguished_line_sets, int **distinguished_line_sets, int *distinguished_line_set_size, int verbose_level)
void init_by_R_and_X(int m, int n, int *R, int *X, int max_r, int verbose_level)
void print_column_labels(std::ostream &ost, data_structures::partitionstack &P, int *col_classes, int nb_col_classes, int width)
void init_by_set_of_sets(data_structures::set_of_sets *SoS, int verbose_level)
void print_aut_generators(int Aut_counter, int *Aut, int Base_length, int *Base, int *Transversal_length)
int compute_TDO(data_structures::partitionstack &PStack, int ht0, int depth, int verbose_level)
void init_large_set(long int *blocks, int N_points, int design_b, int design_k, int partition_class_size, int *&partition, int verbose_level)
void get_and_print_col_decomposition_scheme(data_structures::partitionstack &PStack, int f_list_incidences, int f_local_coordinates, int verbose_level)
void init_by_matrix_as_bitmatrix(int m, int n, data_structures::bitmatrix *Bitmatrix, int verbose_level)
void decomposition_print_tex(std::ostream &ost, data_structures::partitionstack &PStack, int f_row_tactical, int f_col_tactical, int f_detailed, int f_local_coordinates, int verbose_level)
void init_orthogonal(orthogonal_geometry::orthogonal *O, int verbose_level)
void get_and_print_tactical_decomposition_scheme_tex(std::ostream &ost, int f_enter_math, data_structures::partitionstack &PStack)
int refine_column_partition_safe(data_structures::partitionstack &PStack, int verbose_level)
int get_lines_on_point(int *data, int i, int verbose_level)
void shrink_aut_generators(int nb_distinguished_point_sets, int nb_distinguished_line_sets, int Aut_counter, int *Aut, int *Base, int Base_length, int verbose_level)
void compute_tdo_stepwise(data_structures::partitionstack &S, int TDO_depth, int f_write_tdo_files, int f_pic, int f_include_tdo_scheme, int f_include_extra, int verbose_level)
void init_projective_space(projective_space *P, int verbose_level)
void save_as_csv(std::string &fname_csv, int verbose_level)
int refine_column_partition(data_structures::partitionstack &PStack, int ht0, int verbose_level)
void get_incidences_by_row_scheme(data_structures::partitionstack &PStack, int *row_classes, int *row_class_inv, int nb_row_classes, int *col_classes, int *col_class_inv, int nb_col_classes, int row_class_idx, int col_class_idx, int rij, int *&incidences, int verbose_level)
int compute_TDO_step(data_structures::partitionstack &PStack, int ht0, int verbose_level)
void get_and_print_column_tactical_decomposition_scheme_tex(std::ostream &ost, int f_enter_math, int f_print_subscripts, data_structures::partitionstack &PStack)
void print_non_tactical_decomposition_scheme_tex(std::ostream &ost, int f_enter_math, data_structures::partitionstack &PStack)
void row_scheme_to_col_scheme(data_structures::partitionstack &PStack, int *row_classes, int *row_class_inv, int nb_row_classes, int *col_classes, int *col_class_inv, int nb_col_classes, int *row_scheme, int *col_scheme, int verbose_level)
void print_partitioned(std::ostream &ost, data_structures::partitionstack &P, int f_labeled)
void do_tdo_high_level(data_structures::partitionstack &S, int f_tdo_steps, int f_tdo_depth, int tdo_depth, int f_write_tdo_files, int f_pic, int f_include_tdo_scheme, int f_include_tdo_extra, int f_write_tdo_class_files, int verbose_level)
int get_points_on_line(int *data, int j, int verbose_level)
void print_row_tactical_decomposition_scheme_incidences_tex(data_structures::partitionstack &PStack, std::ostream &ost, int f_enter_math_mode, int *row_classes, int *row_class_inv, int nb_row_classes, int *col_classes, int *col_class_inv, int nb_col_classes, int f_local_coordinates, int verbose_level)
void init_by_matrix(int m, int n, int *M, int verbose_level)
void print_hline(std::ostream &ost, data_structures::partitionstack &P, int *col_classes, int nb_col_classes, int width, int f_labeled)
void get_and_print_row_decomposition_scheme(data_structures::partitionstack &PStack, int f_list_incidences, int f_local_coordinates, int verbose_level)
void init_partitionstack_trivial(data_structures::partitionstack *S, int verbose_level)
void get_incidences_by_col_scheme(data_structures::partitionstack &PStack, int *row_classes, int *row_class_inv, int nb_row_classes, int *col_classes, int *col_class_inv, int nb_col_classes, int row_class_idx, int col_class_idx, int kij, int *&incidences, int verbose_level)
void get_row_decomposition_scheme_if_possible(data_structures::partitionstack &PStack, int *row_classes, int *row_class_inv, int nb_row_classes, int *col_classes, int *col_class_inv, int nb_col_classes, int *row_scheme, int verbose_level)
void compute_TDO_safe(data_structures::partitionstack &PStack, int depth, int verbose_level)
void latex_it(std::ostream &ost, data_structures::partitionstack &P)
void print_col_tactical_decomposition_scheme_incidences_tex(data_structures::partitionstack &PStack, std::ostream &ost, int f_enter_math_mode, int *row_classes, int *row_class_inv, int nb_row_classes, int *col_classes, int *col_class_inv, int nb_col_classes, int f_local_coordinates, int verbose_level)
int refine_row_partition(data_structures::partitionstack &PStack, int ht0, int verbose_level)
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 create_lines_on_point(long int point_rk, long int *line_pencil, int verbose_level)
int Gauss_simple(int *A, int m, int n, int *base_cols, int verbose_level)
void int_matrix_write_csv(std::string &fname, int *M, int m, int n)
Definition: file_io.cpp:1300
void points_on_line_by_line_rank(long int line_rk, long int *line, int verbose_level)
void unrank_point(int *v, int stride, long int rk, int verbose_level)
void lines_on_point_by_line_rank_must_fit_into_int(long int pt, int *line_pencil_line_ranks, int verbose_level)
void unrank_line(long int &p1, long int &p2, long int index, int verbose_level)
int Gauss_int(int *A, int f_special, int f_complete, int *base_cols, int f_P, int *P, int m, int n, int Pn, int verbose_level)
void PHG_element_unrank(int *v, int stride, int len, int rk)
#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 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 Int_vec_print_integer_matrix_width(A, B, C, D, E, F)
Definition: foundations.h:691
#define Int_matrix_print(A, B, C)
Definition: foundations.h:707
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define EVEN(x)
Definition: foundations.h:221
#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
#define INCIDENCE_STRUCTURE_REALIZATION_BY_PROJECTIVE_SPACE
Definition: geometry.h:1094
#define INCIDENCE_STRUCTURE_REALIZATION_BY_MATRIX
Definition: geometry.h:1091
#define INCIDENCE_STRUCTURE_REALIZATION_BY_HJELMSLEV
Definition: geometry.h:1093
#define INCIDENCE_STRUCTURE_REALIZATION_BY_ORTHOGONAL
Definition: geometry.h:1092
the orbiter library for the classification of combinatorial objects