Orbiter 2022
Combinatorial Objects
decomposition_with_fuse.cpp
Go to the documentation of this file.
1/*
2 * decomposition_with_fuse.cpp
3 *
4 * Created on: Dec 26, 2021
5 * Author: betten
6 */
7
8
9
10
11#include "foundations.h"
12
13using namespace std;
14
15
16
17namespace orbiter {
18namespace layer1_foundations {
19namespace geometry_builder {
20
21
23{
24 gg = NULL;
25
26 nb_fuse = 0;
27 Fuse_first = NULL;
28 Fuse_len = NULL;
29 K0 = NULL;
30 KK = NULL;
31 K1 = NULL;
32 F_last_k_in_col = NULL;
33
34
35 Conf = NULL;
36
37 row_partition = NULL;
38 col_partition = NULL;
39 Partition = NULL;
41
42
43}
44
46{
47 if (Fuse_first) {
49 }
50 if (Fuse_len) {
52 }
53 if (K0) {
54 FREE_int(K0);
55 }
56 if (KK) {
57 FREE_int(KK);
58 }
59 if (K1) {
60 FREE_int(K1);
61 }
62 if (F_last_k_in_col) {
64 }
65
66 if (Conf) {
68 }
69
70 if (row_partition) {
72 }
73 if (col_partition) {
75 }
76 if (Partition) {
77 int i;
78
79 for (i = 0; i <= gg->GB->V; i++) {
81 }
83 }
85 int i;
86
87 for (i = 0; i <= gg->GB->V; i++) {
89 }
91 }
92
93}
94
96{
97 return Conf + I * gg->GB->b_len + J;
98}
99
100
101void decomposition_with_fuse::init(gen_geo *gg, int verbose_level)
102{
103 int f_v = (verbose_level >= 1);
104
105 if (f_v) {
106 cout << "decomposition_with_fuse::init" << endl;
107 }
108
110
111 if (f_v) {
112 cout << "decomposition_with_fuse::init before init_fuse" << endl;
113 }
114 init_fuse(verbose_level);
115 if (f_v) {
116 cout << "decomposition_with_fuse::init after init_fuse" << endl;
117 }
118
119 if (f_v) {
120 cout << "decomposition_with_fuse::init before TDO_init" << endl;
121 }
122 TDO_init(gg->GB->v, gg->GB->b, gg->GB->TDO, verbose_level);
123 if (f_v) {
124 cout << "decomposition_with_fuse::init after TDO_init" << endl;
125 }
126
127 if (f_v) {
128 cout << "decomposition_with_fuse::init before init_partition" << endl;
129 }
130 init_partition(verbose_level);
131 if (f_v) {
132 cout << "decomposition_with_fuse::init after init_partition" << endl;
133 }
134
135
136 if (f_v) {
137 cout << "decomposition_with_fuse::init done" << endl;
138 }
139}
140
141void decomposition_with_fuse::TDO_init(int *v, int *b, int *theTDO, int verbose_level)
142{
143 int f_v = (verbose_level >= 1);
144
145 if (f_v) {
146 cout << "decomposition_with_fuse::TDO_init" << endl;
147 }
148 int I, fuse_idx, f, l;
149
151
152
153 if (f_v) {
154 cout << "decomposition_with_fuse::TDO_init before loops" << endl;
155 }
156 for (fuse_idx = 0; fuse_idx < nb_fuse; fuse_idx++) {
157 f = Fuse_first[fuse_idx];
158 l = Fuse_len[fuse_idx];
159 if (f_v) {
160 cout << "decomposition_with_fuse::TDO_init fuse_idx=" << fuse_idx
161 << " f=" << f << " l=" << l << endl;
162 }
163 for (I = f; I < f + l; I++) {
164 if (f_v) {
165 cout << "decomposition_with_fuse::TDO_init fuse_idx=" << fuse_idx
166 << " f=" << f << " l=" << l
167 << " I=" << I << " v[I]=" << v[I] << endl;
168 }
169 init_tdo_line(fuse_idx,
170 I /* tdo_line */, v[I] /* v */, b,
171 theTDO + I * gg->GB->b_len /* r */,
172 verbose_level - 1);
173 }
174 }
175 if (f_v) {
176 cout << "decomposition_with_fuse::TDO_init after loops" << endl;
177 }
178
179
180 print_conf();
181
182 gg->inc->print_param();
183
184
185
186 if (f_v) {
187 cout << "decomposition_with_fuse::TDO_init before init_k" << endl;
188 }
189 init_k(verbose_level - 1);
190 if (f_v) {
191 cout << "decomposition_with_fuse::TDO_init after init_k" << endl;
192 }
193 if (f_v) {
194 cout << "decomposition_with_fuse::TDO_init before conf_init_last_non_zero_flag" << endl;
195 }
196 conf_init_last_non_zero_flag(verbose_level - 1);
197 if (f_v) {
198 cout << "decomposition_with_fuse::TDO_init after conf_init_last_non_zero_flag" << endl;
199 }
200 if (f_v) {
201 cout << "decomposition_with_fuse::TDO_init done" << endl;
202 }
203}
204
205
206void decomposition_with_fuse::init_tdo_line(int fuse_idx, int tdo_line,
207 int v, int *b, int *r, int verbose_level)
208{
209 int f_v = (verbose_level >= 1);
210 int i0, j, rr;
211
212 if (f_v) {
213 cout << "decomposition_with_fuse::init_tdo_line tdo_line=" << tdo_line << endl;
214 cout << "r=";
215 Int_vec_print(cout, r, gg->GB->b_len);
216 cout << endl;
217 }
218 if (tdo_line >= gg->GB->v_len) {
219 cout << "decomposition_with_fuse::init_tdo_line tdo_line >= GB->v_len" << endl;
220 exit(1);
221 }
222
223
224
225 for (j = 0; j < gg->GB->b_len; j++) {
226
227 if (f_v) {
228 cout << "decomposition_with_fuse::init_tdo_line "
229 "tdo_line=" << tdo_line << " j=" << j << endl;
230 }
231
232 gen_geo_conf *C = get_conf_IJ(tdo_line, j);
233
234 C->fuse_idx = fuse_idx;
235
236 C->v = v;
237 C->b = b[j];
238 C->r = r[j];
239
240 if (j == 0) {
241 C->j0 = 0;
242 C->r0 = 0;
243 }
244 else {
245 gen_geo_conf *C_left = get_conf_IJ(tdo_line, j - 1);
246
247 C->j0 = C_left->j0 + C_left->b;
248 C->r0 = C_left->r0 + C_left->r;
249 }
250
251 if (tdo_line == 0) {
252 C->i0 = 0;
253 }
254 else {
255 gen_geo_conf *C_top = get_conf_IJ(tdo_line - 1, j);
256
257 C->i0 = C_top->i0 + C_top->v;
258 }
259 i0 = C->i0;
260
261 if (j == gg->GB->b_len - 1) {
262 rr = C->r0 + C->r;
263 }
264 }
265
266
267 if (f_v) {
268 cout << "decomposition_with_fuse::init_tdo_line done" << endl;
269 }
270}
271
273{
274 int I, J;
275
276 for (I = 0; I < gg->GB->v_len; I++) {
277 for (J = 0; J < gg->GB->b_len; J++) {
278 cout << "I=" << I << " J=" << J << ":" << endl;
279 Conf[I * gg->GB->b_len + J].print(cout);
280 }
281 }
282}
283
285{
286 int f_v = (verbose_level >= 1);
287
288 if (f_v) {
289 cout << "decomposition_with_fuse::init_fuse" << endl;
290 }
293 int f, i;
294
295 nb_fuse = gg->GB->fuse_len;
296 f = 0;
297 for (i = 0; i < gg->GB->fuse_len; i++) {
298 Fuse_first[i] = f;
299 Fuse_len[i] = gg->GB->fuse[i];
300 f += gg->GB->fuse[i];
301 }
302
303 if (f_v) {
304 cout << "decomposition_with_fuse::init_fuse done" << endl;
305 }
306
307}
308
309void decomposition_with_fuse::init_k(int verbose_level)
310{
311 int f_v = (verbose_level >= 1);
312
313 if (f_v) {
314 cout << "decomposition_with_fuse::init_k" << endl;
315 }
316 int I, J, fuse_idx, f, l, k, s, b;
317
318
319 K0 = NEW_int(gg->GB->v_len * gg->GB->b_len);
320 KK = NEW_int(gg->GB->v_len * gg->GB->b_len);
321 K1 = NEW_int(gg->GB->v_len * gg->GB->b_len);
323
324 for (fuse_idx = 0; fuse_idx < nb_fuse; fuse_idx++) {
325 for (J = 0; J < gg->GB->b_len; J++) {
326 if (fuse_idx == 0) {
327 K0[fuse_idx * gg->GB->b_len + J] = 0;
328 }
329 F_last_k_in_col[fuse_idx * gg->GB->b_len + J] = FALSE;
330 }
331 }
332 for (fuse_idx = 0; fuse_idx < nb_fuse; fuse_idx++) {
333 f = Fuse_first[fuse_idx];
334 l = Fuse_len[fuse_idx];
335 s = 0;
336 for (J = 0; J < gg->GB->b_len; J++) {
337 if (fuse_idx) {
338 K0[fuse_idx * gg->GB->b_len + J] = K1[(fuse_idx - 1) * gg->GB->b_len + J];
339 }
340 s = 0;
341 for (I = f; I < f + l; I++) {
342 gen_geo_conf *C = get_conf_IJ(I, J);
343 s += C->v * C->r;
344 b = C->b;
345 }
346 k = s / b;
347 if (k * b != s) {
348 cout << "geo_init_k b does not divide s ! fuse_idx = " << fuse_idx
349 << " J = " << J << " s = " << s << " b = " << b << endl;
350 exit(1);
351 }
352 KK[fuse_idx * gg->GB->b_len + J] = k;
353 K1[fuse_idx * gg->GB->b_len + J] = K0[fuse_idx * gg->GB->b_len + J] + k;
354 }
355 }
356 for (J = 0; J < gg->GB->b_len; J++) {
357 for (fuse_idx = nb_fuse - 1; fuse_idx >= 0; fuse_idx--) {
358 k = KK[fuse_idx * gg->GB->b_len + J];
359 if (k) {
360 F_last_k_in_col[fuse_idx * gg->GB->b_len + J] = TRUE;
361 break;
362 }
363 }
364 }
365 if (f_v) {
366 cout << "KK:" << endl;
367 for (fuse_idx = 0; fuse_idx < nb_fuse; fuse_idx++) {
368 for (J = 0; J < gg->GB->b_len; J++) {
369 cout << setw(3) << KK[fuse_idx * gg->GB->b_len + J] << " ";
370 }
371 cout << endl;
372 }
373 cout << "K0:" << endl;
374 for (fuse_idx = 0; fuse_idx < nb_fuse; fuse_idx++) {
375 for (J = 0; J < gg->GB->b_len; J++) {
376 cout << setw(3) << K0[fuse_idx * gg->GB->b_len + J] << " ";
377 }
378 cout << endl;
379 }
380
381 cout << "K1:" << endl;
382 for (fuse_idx = 0; fuse_idx < nb_fuse; fuse_idx++) {
383 for (J = 0; J < gg->GB->b_len; J++) {
384 cout << setw(3) << K1[fuse_idx * gg->GB->b_len + J] << " ";
385 }
386 cout << endl;
387 }
388
389 cout << "F_last_k_in_col:" << endl;
390 for (fuse_idx = 0; fuse_idx < nb_fuse; fuse_idx++) {
391 for (J = 0; J < gg->GB->b_len; J++) {
392 cout << setw(3) << F_last_k_in_col[fuse_idx * gg->GB->b_len + J] << " ";
393 }
394 cout << endl;
395 }
396 }
397 if (f_v) {
398 cout << "decomposition_with_fuse::init_k done" << endl;
399 }
400}
401
403{
404 int f_v = (verbose_level >= 1);
405
406 if (f_v) {
407 cout << "decomposition_with_fuse::conf_init_last_non_zero_flag" << endl;
408 }
409 int fuse_idx, ff, fl, i, I, r;
410
411 for (fuse_idx = 0; fuse_idx < nb_fuse; fuse_idx++) {
412 ff = Fuse_first[fuse_idx];
413 fl = Fuse_len[fuse_idx];
414 for (i = fl - 1; i >= 0; i--) {
415 I = ff + i;
417 }
418 for (i = fl - 1; i >= 0; i--) {
419 I = ff + i;
420 r = Conf[I * gg->GB->b_len + 0].r;
421 if (r > 0) {
423 break;
424 }
425 }
426 }
427
428 if (f_v) {
429 cout << "f_last_non_zero_in_fuse:" << endl;
430 for (I = 0; I < gg->GB->v_len; I++) {
431 i = Conf[I * gg->GB->b_len + 0].f_last_non_zero_in_fuse;
432 cout << setw(3) << i << " ";
433 }
434 cout << endl;
435 }
436 if (f_v) {
437 cout << "decomposition_with_fuse::conf_init_last_non_zero_flag" << endl;
438 }
439}
440
442{
443 int f_v = (verbose_level >= 1);
444 int i, j, I, J;
445
446 if (f_v) {
447 cout << "decomposition_with_fuse::init_partition" << endl;
448 }
451
452 for (i = 0; i < gg->GB->V; i++) {
453 row_partition[i] = 1;
454 }
455 for (j = 0; j < gg->GB->B; j++) {
456 col_partition[j] = 1;
457 }
458
459
460 for (I = 0; I < gg->GB->v_len; I++) {
461
462
463 gen_geo_conf *C = get_conf_IJ(I, 0);
464 i = C->i0 + C->v - 1;
465
466 if (f_v) {
467 cout << "I=" << I << " i=" << i << endl;
468 }
469
470 row_partition[i] = 0;
471
472 }
473
474
475 for (J = 0; J < gg->GB->b_len; J++) {
476
477 gen_geo_conf *C = get_conf_IJ(0, J);
478 j = C->j0 + C->b - 1;
479
480 if (f_v) {
481 cout << "J=" << J << " j=" << j << endl;
482 }
483
484 col_partition[j] = 0;
485
486 }
487
488 if (f_v) {
489 cout << "row_partition: ";
491 cout << endl;
492
493 cout << "col_partition: ";
495 cout << endl;
496 }
497
498 Partition = NEW_pint(gg->GB->V + 1);
499
500 for (i = 0; i <= gg->GB->V; i++) {
501 Partition[i] = NEW_int(i + gg->GB->B);
503 if (i) {
504 Partition[i][i - 1] = 0;
505 }
507
508 if (f_v) {
509 cout << "Partition[" << i << "]: ";
510 Int_vec_print(cout, Partition[i], i + gg->GB->B);
511 cout << endl;
512 }
513 }
514
516
517 for (i = 0; i <= gg->GB->V; i++) {
518 Partition_fixing_last[i] = NEW_int(i + gg->GB->B);
520 if (i) {
521 Partition_fixing_last[i][i - 1] = 0;
522 }
523 if (i >= 2) {
524 Partition_fixing_last[i][i - 2] = 0;
525 }
527
528 if (f_v) {
529 cout << "Partition_fixing_last[" << i << "]: ";
530 Int_vec_print(cout, Partition_fixing_last[i], i + gg->GB->B);
531 cout << endl;
532 }
533 }
534
535
536 if (f_v) {
537 cout << "decomposition_with_fuse::init_partition done" << endl;
538 }
539
540}
541
542
543
544}}}
545
546
void init_tdo_line(int fuse_idx, int tdo_line, int v, int *b, int *r, int verbose_level)
description of a configuration which is part of class decomposition_with_fuse
classification of geometries with a given row-tactical decomposition
#define FREE_OBJECTS(p)
Definition: foundations.h:652
#define FREE_int(p)
Definition: foundations.h:640
#define NEW_pint(n)
Definition: foundations.h:627
#define NEW_int(n)
Definition: foundations.h:625
#define NEW_OBJECTS(type, n)
Definition: foundations.h:639
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define Int_vec_copy(A, B, C)
Definition: foundations.h:693
#define FREE_pint(p)
Definition: foundations.h:641
#define Int_vec_print(A, B, C)
Definition: foundations.h:685
the orbiter library for the classification of combinatorial objects