Orbiter 2022
Combinatorial Objects
inc_encoding.cpp
Go to the documentation of this file.
1/*
2 * inc_encoding.cpp
3 *
4 * Created on: Aug 17, 2021
5 * Author: betten
6 */
7
8
9
10#include "foundations.h"
11
12using namespace std;
13
14
15
16namespace orbiter {
17namespace layer1_foundations {
18namespace geometry_builder {
19
20
22{
23 theX = NULL;
24 dim_n = 0;
25 v = 0;
26 b = 0;
27 R = NULL;
28
29}
30
32{
33 if (theX) {
34 delete [] theX;
35 }
36}
37
38int &inc_encoding::theX_ir(int i, int r)
39{
40 return theX[i * dim_n + r];
41}
42
43void inc_encoding::init(int v, int b, int *R, int verbose_level)
44{
45 int f_v = (verbose_level >= 1);
46 int i;
47
48 if (f_v) {
49 cout << "inc_encoding::init v=" << v << " b=" << b << endl;
50 cout << "inc_encoding::init R=" << endl;
51 for (i = 0; i < v; i++) {
52 cout << i << " : " << R[i] << endl;
53 }
54 }
58
59 dim_n = 0;
60 for (i = 0; i < v; i++) {
61 dim_n = MAXIMUM(dim_n, R[i]);
62 }
63 if (f_v) {
64 cout << "inc_encoding::init dim_n=" << dim_n << endl;
65 }
66 theX = new int[v * dim_n];
67 if (f_v) {
68 cout << "inc_encoding::init done" << endl;
69 }
70}
71
72long int inc_encoding::rank_row(int row)
73{
74 int *S;
75 int k, i;
76 long int rk;
78
79 S = NEW_int(dim_n);
80
81 k = R[row];
82 for (i = 0; i < k; i++) {
83 S[i] = theX[row * dim_n + i];
84 }
85
86 rk = Combi.rank_k_subset(S, b, k);
87
88 FREE_int(S);
89
90 return rk;
91}
92
93void inc_encoding::get_flags(int row, std::vector<int> &flags)
94{
95 int i, h, r, a;
96
97
98 for (i = 0; i < row; i++) {
99 r = R[i];
100 for (h = 0; h < r; h++) {
101 a = i * b + theX[i * dim_n + h];
102 flags.push_back(a);
103 }
104 }
105}
106
107
109{
110 int i, j, l, u, v;
111 int f_found_u;
112
113 if (m == 0) {
114 return FALSE;
115 }
116 if (n == 0) {
117 return FALSE;
118 }
119
120 v = theX[m * dim_n + n];
121 for (l = 0; l < n; l++) {
122 u = theX[m * dim_n + l];
123 for (i = 0; i < m; i++) {
124 // loop over all previous rows
125
126 // search for u:
127
128 f_found_u = FALSE;
129 for (j = 0; j < R[i] - 1; j++) {
130
131 // < R[i] - 1,
132 // since one incidence is reserved for v
133
134 if (theX[i * dim_n + j] == u) {
135 f_found_u = TRUE;
136 break;
137 }
138 }
139 if (!f_found_u) {
140 continue; /* next i */
141 }
142
143 // look for v
144 for (j++; j < R[i]; j++) {
145 if (theX[i * dim_n + j] == v) {
146 return TRUE;
147 }
148 }
149 // v is not found, square test is negative
150
151 } // next i
152 } // next l
153 return FALSE;
154}
155
157 std::ostream &ost, gen_geo *gg, int f_print_isot, iso_type *it)
158{
159 int J, j;
160
161 //cout << "inc_encoding::print_horizontal_bar" << endl;
162 J = 0;
163 for (j = 0; j <= b; j++) {
164 if ((j == b) ||
165 (J < gg->Test_semicanonical->nb_i_vbar &&
166 j == gg->Test_semicanonical->i_vbar[J])) {
167 ost << "+";
168 J++;
169 }
170 if (j == b) {
171 break;
172 }
173 ost << "-";
174 }
175 if (f_print_isot && it) {
176 it->print_status(ost, TRUE /* f_with_flags */);
177 }
178 ost << endl;
179
180}
181
183 std::ostream &ost, int v_cur, int v_cut,
184 gen_geo *gg, int f_print_isot)
185{
186 int *the_X;
187
188 the_X = theX;
189 print_partitioned_override_theX(ost, v_cur, v_cut, gg, the_X, f_print_isot);
190}
191
192
194 std::ostream &ost, int v_cur, int v_cut,
195 gen_geo *gg, int *the_X, int f_print_isot)
196{
197 int i, j, r, I, J, f_kreuz;
198 iso_type *it;
199
200
201 ost << endl;
202 I = 0;
203 for (i = 0; i <= v; i++) {
204
205 //cout << "inc_encoding::print_partitioned_override_theX i=" << i << endl;
206
207 if ((i == v) ||
208 (I < gg->Test_semicanonical->nb_i_hbar &&
209 i == gg->Test_semicanonical->i_hbar[I])) {
210 print_horizontal_bar(ost, gg, FALSE /* f_print_isot */, NULL);
211 I++;
212 }
213
214 if (i == v) {
215 break;
216 }
217
218 if (i == v_cur) {
219 break;
220 }
221
222 // output a line of the geometry:
223 J = 0;
224 r = 0;
225 for (j = 0; j <= b; j++) {
226 if ((j == b) ||
227 (J < gg->Test_semicanonical->nb_i_vbar &&
228 j == gg->Test_semicanonical->i_vbar[J])) {
229 ost << "|";
230 J++;
231 }
232 if (j == b) {
233 break;
234 }
235
236 if (i >= v_cut || r >= R[i]) {
237 f_kreuz = FALSE;
238 }
239 else if (the_X[r] == j) {
240 f_kreuz = TRUE;
241 }
242 else {
243 f_kreuz = FALSE;
244 }
245
246 if (f_kreuz) {
247 ost << "X";
248 r++;
249 }
250 else {
251 ost << ".";
252 }
253
254 }
255
256 {
258 int *S;
259 int row, k, ii;
260 long int rk;
261
262 S = NEW_int(dim_n);
263
264 row = i;
265 k = R[row];
266 for (ii = 0; ii < k; ii++) {
267 S[ii] = theX[row * dim_n + ii];
268 }
269
270 rk = Combi.rank_k_subset(S, b, k);
271 ost << setw(3) << i << " : ";
272 ost << setw(4) << rk << " : ";
273
274 FREE_int(S);
275 }
276
277 if (gg->GB->Descr->f_orderly) {
278 iso_type *It;
279
281
282 if (It) {
284 << " / " << It->Canonical_forms->B.size();
285 }
286 }
287 else {
288 if (gg->inc->iso_type_at_line[i] && f_print_isot) {
289
290 it = gg->inc->iso_type_at_line[i];
291
292 it->print_status(ost, TRUE /* f_with_flags */);
293 }
294 }
295 ost << endl;
296
297 the_X += dim_n;
298
299 } // next i
300
301 if (i == v && gg->inc->iso_type_no_vhbars && f_print_isot) {
302 print_horizontal_bar(ost, gg, TRUE /* f_print_isot */, gg->inc->iso_type_no_vhbars);
303
304 ost << endl;
305 }
306
307 ost << endl;
308}
309
311{
312 int i, j, i1, j1, o;
313
314 cout << " ";
315 for (j = 0; j < b; j++) {
316 cout << setw(2) << qv->data[j] << " ";
317 }
318 cout << endl;
319 for (i = 0; i < v; i++) {
320 i1 = pv->data[i];
321 cout << setw(2) << i1 << " ";
322 for (j = 0; j < b; j++) {
323 j1 = qv->data[j];
324 for (o = 0; o < R[i1]; o++) {
325 /* before: r */
326 if (theX[i1 * dim_n + o] == j1) {
327 break;
328 }
329 }
330 if (o < R[i1]) {
331 cout << " X ";
332 }
333 else {
334 cout << " . ";
335 }
336 }
337 cout << endl;
338 }
339 cout << endl;
340}
341
342#if 0
343tactical_decomposition *inc_encoding::calc_tdo_without_vhbar(
344 int f_second_tactical_decomposition, int verbose_level)
345{
346 int f_v = (verbose_level >= 1);
347
348 if (f_v) {
349 cout << "inc_encoding::calc_tdo_without_vhbar" << endl;
350 }
351 tactical_decomposition *tdo = NULL;
352
353 tdo = new tactical_decomposition;
354
355 tdo->init(this, verbose_level);
356
357 tdo->make_point_and_block_partition(tdo->G_current, tdo->G_last);
358
359 tdo->calc2(v, verbose_level);
360
361 tdo->tdos = tdo->get_tdos(tdo->G_current, tdo->G_next, FALSE, verbose_level);
362
363 if (f_second_tactical_decomposition) {
364
365 tdo->second_order_tdo(v, verbose_level);
366
367 delete tdo->tdos;
368 tdo->tdos = tdo->tdos2;
369 tdo->tdos2 = NULL;
370 }
371
372
373 if (f_v) {
374 cout << "inc_encoding::calc_tdo_without_vhbar done" << endl;
375 }
376 return tdo;
377}
378#endif
379
381 int *theY, cperm *p, cperm *q, int verbose_level)
382/* p vertauscht nur innerhalb
383 * der Bereiche gleicher R[] Laenge.
384 * int theY[v * MAX_R]. */
385{
386 int f_v = (verbose_level >= 1);
387
388 if (f_v) {
389 cout << "inc_encoding::apply_permutation v=" << v << " b=" << b << endl;
390 cout << "inc_encoding::apply_permutation p=";
391 p->print();
392 cout << endl;
393 cout << "inc_encoding::apply_permutation q=";
394 q->print();
395 cout << endl;
396 }
397 int i, j, r, i1, j1;
398 int *theZ;
399
400 theZ = NEW_int(v * b);
401 for (i = 0; i < v; i++) {
402 for (j = 0; j < b; j++) {
403 theZ[i * b + j] = 0;
404 }
405 }
406 for (i = 0; i < v; i++) {
407 for (r = 0; r < inc->Encoding->R[i]; r++) {
408 j = theX[i * dim_n + r];
409 i1 = p->data[i];
410 j1 = q->data[j];
411 if (i1 >= v) {
412 cout << "inc_encoding::apply_permutation i1 >= v" << endl;
413 exit(1);
414 }
415 if (j1 >= b) {
416 cout << "inc_encoding::apply_permutation j1 >= b" << endl;
417 exit(1);
418 }
419 // (i, j) is mapped to (i1, j1)
420 theZ[i1 * b + j1] = 1;
421 }
422 }
423 if (f_v) {
424 cout << "theZ:" << endl;
425 for (i = 0; i < v; i++) {
426 for (j = 0; j < b; j++) {
427 cout << theZ[i * b + j];
428 }
429 cout << endl;
430 }
431
432 }
433 for (i = 0; i < v; i++) {
434 if (f_v) {
435 cout << "inc_encoding::apply_permutation i=" << i << endl;
436 }
437 r = 0;
438 for (j = 0; j < b; j++) {
439 if (theZ[i * b + j]) {
440 if (r == inc->Encoding->R[i]) {
441 cout << "inc_theX_apply_pq r == inc->Encoding->R[i]" << endl;
442 inc->print_R(v, p, q);
443 exit(1);
444 }
445 theY[i * dim_n + r] = j;
446 r++;
447 }
448 }
449 if (r != inc->Encoding->R[i]) {
450 cout << "inc_theX_apply_pq r != inc->R[i]" << endl;
451 inc->print_R(v, p, q);
452 exit(1);
453 }
454 }
455 FREE_int(theZ);
456}
457
458
459
460}}}
461
462
a permutation for use in class gen_geo
classification of geometries with a given row-tactical decomposition
void get_flags(int row, std::vector< int > &flags)
void print_partitioned(std::ostream &ost, int v_cur, int v_cut, gen_geo *gg, int f_print_isot)
void print_horizontal_bar(std::ostream &ost, gen_geo *gg, int f_print_isot, iso_type *it)
void init(int v, int b, int *R, int verbose_level)
void apply_permutation(incidence *inc, int v, int *theY, cperm *p, cperm *q, int verbose_level)
void print_partitioned_override_theX(std::ostream &ost, int v_cur, int v_cut, gen_geo *gg, int *the_X, int f_print_isot)
encoding of an incidence geometry during classification
classification of geometries based on canonical forms
data_structures::classify_using_canonical_forms * Canonical_forms
void print_status(std::ostream &ost, int f_with_flags)
Definition: iso_type.cpp:523
#define FREE_int(p)
Definition: foundations.h:640
#define NEW_int(n)
Definition: foundations.h:625
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define MAXIMUM(x, y)
Definition: foundations.h:217
the orbiter library for the classification of combinatorial objects