Orbiter 2022
Combinatorial Objects
spread_table_activity.cpp
Go to the documentation of this file.
1/*
2 * spread_table_activity.cpp
3 *
4 * Created on: Apr 3, 2021
5 * Author: betten
6 */
7
8
9#include "orbiter.h"
10
11using namespace std;
12
13namespace orbiter {
14namespace layer5_applications {
15namespace spreads {
16
17
19{
20 Descr = NULL;
21 P = NULL;
22
23}
24
26{
27
28}
29
30
31
34 int verbose_level)
35{
36 int f_v = (verbose_level >= 1);
37
38 if (f_v) {
39 cout << "spread_table_activity::init" << endl;
40 }
41
44
45 if (f_v) {
46 cout << "spread_table_activity::init done" << endl;
47 }
48}
49
51{
52 int f_v = (verbose_level >= 1);
53
54 if (Descr->f_find_spread) {
55 cout << "f_find_spread" << endl;
56 long int *spread_elts;
57 int sz;
58 int idx;
60
61
62
63 Lint_vec_scan(Descr->find_spread_text, spread_elts, sz);
64
65 if (sz != P->spread_size) {
66 cout << "the set does not have the right size" << endl;
67 cout << "sz=" << sz << endl;
68 cout << "P->spread_size=" << P->spread_size << endl;
69 exit(1);
70 }
71
72 Sorting.lint_vec_heapsort(spread_elts, sz);
73
74 idx = P->find_spread(spread_elts, verbose_level);
75
76 cout << "The given spread has index " << idx << " in the spread table" << endl;
77
78
79 }
81 cout << "f_find_spread_and_dualize" << endl;
82 long int *spread_elts;
83 int sz;
84 int a, b;
86
87
88
90
91 if (sz != P->spread_size) {
92 cout << "the set does not have the right size" << endl;
93 cout << "sz=" << sz << endl;
94 cout << "P->spread_size=" << P->spread_size << endl;
95 exit(1);
96 }
97
98 Sorting.lint_vec_heapsort(spread_elts, sz);
99
100
101 a = P->find_spread(spread_elts, verbose_level);
102
103 cout << "The given spread has index " << a << " in the spread table" << endl;
104
106
107 cout << "The dual spread has index " << b << " in the spread table" << endl;
108
109 }
110 else if (Descr->f_dualize_packing) {
111 cout << "f_dualize_packing" << endl;
112 long int *packing;
113 int sz;
114 long int *dual_packing;
115 int a, b;
117
118
119
121
122 cout << "The packing is : ";
123 Lint_vec_print(cout, packing, sz);
124 cout << endl;
125
126 dual_packing = NEW_lint(sz);
127 for (int i = 0; i < sz; i++) {
128 a = packing[i];
130 dual_packing[i] = b;
131 }
132
133 cout << "The dual packing is : ";
134 Lint_vec_print(cout, dual_packing, sz);
135 cout << endl;
136
137 }
138 else if (Descr->f_print_spreads) {
139 cout << "f_print_spread" << endl;
140
141 int *idx;
142 int nb;
143
145
146 cout << "before report_spreads" << endl;
147 report_spreads(idx, nb, verbose_level);
148
149 }
150
151 else if (Descr->f_export_spreads_to_csv) {
152 cout << "f_export_spreads_to_csv" << endl;
153
154 int *idx;
155 int nb;
156
158
159 cout << "before export_spreads_to_csv" << endl;
161
162 }
163
165 cout << "f_find_spreads_containing_two_lines" << endl;
166
167 std::vector<int> v;
170 int i;
171
173 line1,
174 line2,
175 verbose_level);
176
177 cout << "We found " << v.size() << " spreads containing " << line1 << " and " << line2 << endl;
178 cout << "They are:" << endl;
179 for (i = 0; i < v.size(); i++) {
180 cout << v[i];
181 if (i < v.size() - 1) {
182 cout << ", ";
183 }
184 }
185 cout << endl;
186
187 }
188
190 cout << "f_find_spreads_containing_one_line" << endl;
191
193 int line2;
194 int *N;
195
196 N = NEW_int(P->P3->N_lines);
197 Int_vec_zero(N, P->P3->N_lines);
198
199 for (line2 = 0; line2 < P->P3->N_lines; line2++) {
200 if (line2 == line1) {
201 continue;
202 }
203 {
204 std::vector<int> v;
206 line1,
207 line2,
208 verbose_level);
209 N[line2] = v.size();
210 }
211 }
213
214 N_t.init(N, P->P3->N_lines, FALSE, 0);
215 cout << "type of covering based on all lines together with line " << line1 << ":" << endl;
216 N_t.print(TRUE);
217 cout << endl;
218
219 }
220 if (f_v) {
221 cout << "spread_table_activity::perform_activity" << endl;
222
223 }
224
225}
226
227
228void spread_table_activity::export_spreads_to_csv(std::string &fname, int *spread_idx, int nb, int verbose_level)
229{
230 int f_v = (verbose_level >= 1);
231
232
233 if (f_v) {
234 cout << "spread_table_activity::export_spreads_to_csv" << endl;
235 }
236
237 long int *T;
238 int i, j, idx;
240
241 T = NEW_lint(nb * P->spread_size);
242 for (i = 0; i < nb; i++) {
243 long int *spread_elts;
244
245 idx = spread_idx[i];
246 spread_elts = P->Spread_table_with_selection->get_spread(idx);
247 for (j = 0; j < P->spread_size; j++) {
248 T[i * P->spread_size + j] = spread_elts[j];
249 }
250 }
251 Fio.lint_matrix_write_csv(fname, T, nb, P->spread_size);
252 cout << "Written file " << fname << " of size " << Fio.file_size(fname) << endl;
253
254 if (f_v) {
255 cout << "spread_table_activity::export_spreads_to_csv done" << endl;
256 }
257}
258
259void spread_table_activity::report_spreads(int *spread_idx, int nb, int verbose_level)
260{
261 int f_v = (verbose_level >= 1);
262
263
264 if (f_v) {
265 cout << "spread_table_activity::report_spreads" << endl;
266 }
267
268 {
269 char str[1000];
270 string fname;
271 char title[1000];
272 char author[1000];
273
274 snprintf(title, 1000, "Spreads");
275 //strcpy(author, "");
276 author[0] = 0;
277
278 sprintf(str, "Spreads");
279 fname.assign(str);
280
281
282
283 int i, idx;
284
285
286 for (i = 0; i < nb; i++) {
287 idx = spread_idx[i];
288 sprintf(str, "_%d", idx);
289 fname.append(str);
290 }
291 fname.append(".tex");
292
293 {
294 ofstream ost(fname);
296
297 L.head(ost,
298 FALSE /* f_book*/,
299 TRUE /* f_title */,
300 title, author,
301 FALSE /* f_toc */,
302 FALSE /* f_landscape */,
303 TRUE /* f_12pt */,
304 TRUE /* f_enlarged_page */,
305 TRUE /* f_pagenumbers */,
306 NULL /* extra_praeamble */);
307
308
309 if (f_v) {
310 cout << "spread_table_activity::report_spread before report_spread2" << endl;
311 }
312
313
314
315 for (i = 0; i < nb; i++) {
316 idx = spread_idx[i];
317 report_spread2(ost, idx, verbose_level);
318 }
319 if (f_v) {
320 cout << "spread_table_activity::report_spread after report_spread2" << endl;
321 }
322
323 if (f_v) {
324 cout << "spread_table_activity::report_spread after report_spread2" << endl;
325 }
326
327
328 L.foot(ost);
329
330 }
332
333 cout << "written file " << fname << " of size "
334 << Fio.file_size(fname) << endl;
335 }
336
337 if (f_v) {
338 cout << "spread_table_activity::report_spread done" << endl;
339 }
340}
341
342void spread_table_activity::report_spread2(std::ostream &ost, int spread_idx, int verbose_level)
343{
344 int f_v = (verbose_level >= 1);
345
346 if (f_v) {
347 cout << "spread_table_activity::report_spread2" << endl;
348 }
349
350 long int *spread_elts;
351
352
353 spread_elts = P->Spread_table_with_selection->get_spread(spread_idx);
354
355 ost << "The spread " << spread_idx << " is:\\\\" << endl;
356 Lint_vec_print(ost, spread_elts, P->spread_size);
357 ost << "\\\\" << endl;
358
359 P->P3->Grass_lines->print_set_tex(ost, spread_elts, P->spread_size);
360
361 if (f_v) {
362 cout << "spread_table_activity::report_spread2 done" << endl;
363 }
364}
365
366
367
368
369}}}
370
371
a collection of functions related to sorted vectors
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_set_tex(std::ostream &ost, long int *v, int len)
Definition: grassmann.cpp:157
void lint_matrix_write_csv(std::string &fname, long int *M, int m, int n)
Definition: file_io.cpp:1323
void head(std::ostream &ost, int f_book, int f_title, const char *title, const char *author, int f_toc, int f_landscape, int f_12pt, int f_enlarged_page, int f_pagenumbers, const char *extras_for_preamble)
classification of packings in PG(3,q)
Definition: packings.h:66
spreads::spread_table_with_selection * Spread_table_with_selection
Definition: packings.h:85
description of an activity for a spread table
Definition: spreads.h:405
void init(spreads::spread_table_activity_description *Descr, packings::packing_classify *P, int verbose_level)
void report_spreads(int *spread_idx, int nb, int verbose_level)
void export_spreads_to_csv(std::string &fname, int *spread_idx, int nb, int verbose_level)
void report_spread2(std::ostream &ost, int spread_idx, int verbose_level)
void find_spreads_containing_two_lines(std::vector< int > &v, int line1, int line2, int verbose_level)
#define Int_vec_scan(A, B, C)
Definition: foundations.h:716
#define Int_vec_zero(A, B)
Definition: foundations.h:713
#define Lint_vec_scan(A, B, C)
Definition: foundations.h:717
#define Lint_vec_print(A, B, C)
Definition: foundations.h:686
#define NEW_int(n)
Definition: foundations.h:625
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define NEW_lint(n)
Definition: foundations.h:628
the orbiter library for the classification of combinatorial objects