Orbiter 2022
Combinatorial Objects
invariants_packing.cpp
Go to the documentation of this file.
1// invariants_packing.cpp
2//
3// Anton Betten
4// Feb 21, 2013
5//
6//
7//
8//
9//
10
11#include "orbiter.h"
12
13using namespace std;
14
15namespace orbiter {
16namespace layer5_applications {
17namespace packings {
18
19
20//static int packing_types_compare_function(void *a, void *b, void *data);
21
22
23
25{
26 T = NULL;
27 P = NULL;
28 Iso = NULL;
29 Inv = NULL;
30 Ago = NULL;
31 Ago_induced = NULL;
32 Ago_int = NULL;
33 //Type_of_packing = NULL;
35 Classify = NULL;
36#if 0
37 List_of_types = NULL;
38 Frequency = NULL;
39 nb_types = 0;
40 packing_type_idx = NULL;
41#endif
42 Dual_idx = NULL;
43 f_self_dual = NULL;
44
45 null();
46}
47
49{
50 freeself();
51}
52
54{
55}
56
58{
59 if (Inv) {
60 delete [] Inv;
61 }
62 if (Ago) {
63 delete [] Ago;
64 }
65 if (Ago_induced) {
66 delete [] Ago_induced;
67 }
68 if (Ago_int) {
70 }
73 }
74 if (Classify) {
76 }
77#if 0
78 if (List_of_types) {
79 int i;
80 for (i = 0; i < nb_types; i++) {
81 FREE_int(List_of_types[i]);
82 }
83 FREE_pint(List_of_types);
84 }
85 if (Frequency) {
86 FREE_int(Frequency);
87 }
88 if (packing_type_idx) {
89 FREE_int(packing_type_idx);
90 }
91#endif
92 if (Dual_idx) {
94 }
95 if (f_self_dual) {
97 }
98 null();
99}
100
102 packing_classify *P, int verbose_level)
103{
104 int f_v = (verbose_level >= 1);
105 //int f_vv = (verbose_level >= 2);
106 int orbit, i;
108
109 if (f_v) {
110 cout << "invariants_packing::init" << endl;
111 }
113 T = P->T;
115
116
118
119
120 for (orbit = 0; orbit < Iso->Reps->count; orbit++) {
121
122 if (f_v) {
123 cout << "invariants_packing::init orbit " << orbit
124 << " / " << Iso->Reps->count << endl;
125 }
126
127 int rep, first, /*c,*/ id;
128
129 rep = Iso->Reps->rep[orbit];
130 first = Iso->orbit_fst[rep];
131 //c = Iso->starter_number[first];
132 id = Iso->orbit_perm[first];
134
135 Inv[orbit].init(P, Iso->prefix_invariants,
136 Iso->prefix_tex, orbit, P->the_packing,
137 verbose_level - 1);
138
139 }
140 if (f_v) {
141 cout << "invariants_packing::init loading invariants done" << endl;
142 }
143
144
145
146
147 Iso->compute_Ago_Ago_induced(Ago, Ago_induced, verbose_level - 1);
148
150 for (orbit = 0; orbit < Iso->Reps->count; orbit++) {
151 Ago_int[orbit] = Ago[orbit].as_int();
152 }
153
154
157
158 // compute Spread_type_of_packing:
159
160 for (orbit = 0; orbit < Iso->Reps->count; orbit++) {
161 int rep, first, /*c,*/ id, a;
162
163 rep = Iso->Reps->rep[orbit];
164 first = Iso->orbit_fst[rep];
165 //c = Iso->starter_number[first];
166 id = Iso->orbit_perm[first];
168
169
170 for (i = 0; i < Iso->size; i++) {
173 }
174 }
175
177
178 Classify->init(Spread_type_of_packing, Iso->size /* data_length */,
180 verbose_level);
181
182#if 0
183 List_of_types = NEW_pint(Iso->Reps->count);
184 Frequency = NEW_int(Iso->Reps->count);
185 nb_types = 0;
186 int idx;
187
188 for (orbit = 0; orbit < Iso->Reps->count; orbit++) {
189 if (f_vv) {
190 cout << "invariants_packing::init orbit=" << orbit << endl;
191 }
192 if (Sorting.vec_search((void **)List_of_types,
193 packing_types_compare_function, this,
194 nb_types,
195 Spread_type_of_packing + orbit * P->nb_iso_types_of_spreads,
196 idx,
197 0 /* verbose_level */)) {
198 Frequency[idx]++;
199 }
200 else {
201 if (f_vv) {
202 cout << "invariants_packing::init New type ";
203 int_vec_print(cout,
204 Spread_type_of_packing + orbit * P->nb_iso_types_of_spreads,
205 P->nb_iso_types_of_spreads);
206 cout << " at position " << idx << endl;
207 }
208 for (i = nb_types; i > idx; i--) {
209 List_of_types[i] = List_of_types[i - 1];
210 Frequency[i] = Frequency[i - 1];
211 }
212 List_of_types[idx] = NEW_int(P->nb_iso_types_of_spreads);
213 Frequency[idx] = 1;
214 int_vec_copy(Spread_type_of_packing + orbit * P->nb_iso_types_of_spreads, List_of_types[idx],
215 P->nb_iso_types_of_spreads);
216 nb_types++;
217 if (f_vv) {
218 cout << "invariants_packing::init "
219 "nb_types=" << nb_types << endl;
220 }
221 }
222 }
223#endif
224
225 if (f_v) {
226 cout << "invariants_packing::init "
227 "We found " << Classify->nb_types
228 << " types of packings" << endl;
229 for (i = 0; i < Classify->nb_types; i++) {
230 Int_vec_print(cout,
233 cout << " : " << Classify->Frequency_in_lex_order[i] << endl;
234 }
235 }
236
237#if 0
238 packing_type_idx = NEW_int(Iso->Reps->count);
239 for (orbit = 0; orbit < Iso->Reps->count; orbit++) {
240 if (Sorting.vec_search((void **)List_of_types,
241 packing_types_compare_function, this,
242 nb_types,
243 Spread_type_of_packing + orbit * P->nb_iso_types_of_spreads,
244 idx,
245 0 /* verbose_level */)) {
246 packing_type_idx[orbit] = idx;
247 }
248 else {
249 cout << "invariants_packing::init "
250 "error: did not find type of packing" << endl;
251 exit(1);
252 }
253 }
254#endif
255
256 if (f_v) {
257 cout << "invariants_packing::init "
258 "before compute_dual_packings" << endl;
259 }
260 compute_dual_packings(Iso, verbose_level);
261 if (f_v) {
262 cout << "invariants_packing::init "
263 "after compute_dual_packings" << endl;
264 }
265
266 if (f_v) {
267 cout << "invariants_packing::init done" << endl;
268 }
269}
270
272 isomorph *Iso, int verbose_level)
273{
274 int f_v = (verbose_level >= 1);
275 //int f_vv = (verbose_level >= 2);
276 int orbit, i;
278
279 if (f_v) {
280 cout << "invariants_packing::compute_dual_packings" << endl;
281 }
284
285 for (orbit = 0; orbit < Iso->Reps->count; orbit++) {
286
287 int rep, first, /*c,*/ id;
288 int f_implicit_fusion = TRUE;
289
290 rep = Iso->Reps->rep[orbit];
291 first = Iso->orbit_fst[rep];
292 //c = Iso->starter_number[first];
293 id = Iso->orbit_perm[first];
295
296
297 for (i = 0; i < Iso->size; i++) {
299 }
302 for (i = 0; i < Iso->size; i++) {
303 if (P->the_packing[i] != P->dual_packing[i]) {
304 break;
305 }
306 }
307 if (i == Iso->size) {
308 f_self_dual[orbit] = TRUE;
309 }
310 else {
311 f_self_dual[orbit] = FALSE;
312 }
313
314
317 f_implicit_fusion, verbose_level - 3);
318 }
319
321 string fname;
322
323 fname.assign("Dual_idx.csv");
325 Iso->Reps->count, fname, "dual_idx", "f_self_dual");
326
327 fname.assign("Dual_spread_idx.csv");
329 P->Spread_table_with_selection->Spread_tables->nb_spreads, fname, "dual_spread_idx");
330
331 if (f_v) {
332 cout << "invariants_packing::compute_dual_packings done" << endl;
333 }
334}
335
337 isomorph *Iso, ostream &ost,
338 int f_only_self_dual, int f_only_not_self_dual,
339 int verbose_level)
340{
341 int f_v = (verbose_level >= 1);
342 //int f_vv = (verbose_level >= 2);
343 int i;
344 string fname;
346
347 if (f_v) {
348 cout << "invariants_packing::make_table" << endl;
349 }
350
351 if (f_only_self_dual) {
352 ost << "\\chapter{Self Polar Packings}" << endl << endl;
353 }
354 else if (f_only_not_self_dual) {
355 ost << "\\chapter{Not Self Polar Packings}" << endl << endl;
356 }
357 else {
358 ost << "\\chapter{All Packings}" << endl << endl;
359 }
360
361 ost << "For each packing, let $a_i$ be the number of spreads "
362 "of isomorphism type $i$\\\\" << endl;
363 ost << "The type of the packing is the vector $(a_0,\\ldots, "
364 "a_{N-1})$ where $N$ is the number of isomorphism types "
365 "of spreads of $\\PG(3," << P->q << ")$\\\\" << endl;
366 ost << endl;
367 ost << "\\begin{center}" << endl;
368 ost << "\\begin{tabular}{|c|c|l|p{6cm}}" << endl;
369 ost << "\\hline" << endl;
370 ost << "Type & Number of Packings & Distr. of Aut Group "
371 "Orders\\\\" << endl;
372 ost << "\\hline" << endl;
373 ost << "\\hline" << endl;
374 for (i = 0; i < Classify->nb_types; i++) {
375 char str[1000];
376
377 if (f_only_self_dual) {
378 sprintf(str, "ids_of_self_dual_type_%d.csv", i);
379 }
380 else if (f_only_not_self_dual) {
381 sprintf(str, "ids_of_not_self_dual_type_%d.csv", i);
382 }
383 else {
384 sprintf(str, "ids_of_all_type_%d.csv", i);
385 }
386 fname.assign(str);
389 ost << " & ";
390 // ost << Frequency[i] << " & ";
391
392 int *set;
393 int *ago;
394 int nb, j, dual, a;
395
396 nb = 0;
397 set = NEW_int(Classify->Frequency[i]);
398 ago = NEW_int(Classify->Frequency[i]);
399 for (j = 0; j < Iso->Reps->count; j++) {
400 if (Classify->rep_idx[j] == i) {
401 if (f_only_self_dual) {
402 dual = Dual_idx[j];
403 if (dual == j) {
404 set[nb++] = j;
405 }
406 }
407 else if (f_only_not_self_dual) {
408 dual = Dual_idx[j];
409 if (dual != j && dual > j) {
410 set[nb++] = j;
411 }
412 }
413 else {
414 set[nb++] = j;
415 }
416 }
417 }
418 for (j = 0; j < nb; j++) {
419 a = set[j];
420 ago[j] = Ago_int[a];
421 }
422
423 Fio.int_vecs_write_csv(set, ago, nb, fname, "ID", "ago");
424
426
427 C.init(ago, nb, FALSE, 0);
428
429 ost << nb << " & ";
430 C.print_naked_tex(ost, TRUE /*f_backwards*/);
431
432 ost << "\\\\" << endl;
433 FREE_int(set);
434 FREE_int(ago);
435 }
436 ost << "\\hline" << endl;
437 ost << "\\end{tabular}" << endl;
438 ost << "\\end{center}" << endl << endl;
439
440 if (f_v) {
441 cout << "invariants_packing::make_table done" << endl;
442 }
443}
444
445#if 0
446static int packing_types_compare_function(void *a, void *b, void *data)
447{
449 int *A = (int *) a;
450 int *B = (int *) b;
451 int i;
452
453 for (i = 0; i < inv->P->Spread_table_with_selection->nb_iso_types_of_spreads; i++) {
454 if (A[i] > B[i]) {
455 return 1;
456 }
457 if (A[i] < B[i]) {
458 return -1;
459 }
460 }
461 return 0;
462}
463#endif
464
465
466}}}
467
a collection of functions related to sorted vectors
int vec_search(void **v, int(*compare_func)(void *a, void *b, void *data), void *data_for_compare, int len, void *a, int &idx, int verbose_level)
Definition: sorting.cpp:945
a statistical analysis of data consisting of vectors of ints
void init(int *data, int data_length, int data_set_sz, int verbose_level)
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_naked_tex(std::ostream &ost, int f_backwards)
Definition: tally.cpp:413
void int_vecs_write_csv(int *v1, int *v2, int len, std::string &fname, const char *label1, const char *label2)
Definition: file_io.cpp:1207
void lint_vec_write_csv(long int *v, int len, std::string &fname, const char *label)
Definition: file_io.cpp:1191
classification of combinatorial objects using subobjects
Definition: isomorph.h:30
void compute_Ago_Ago_induced(ring_theory::longinteger_object *&Ago, ring_theory::longinteger_object *&Ago_induced, int verbose_level)
Definition: isomorph.cpp:1642
void load_solution(int id, long int *data)
int identify_database_is_open(long int *set, int f_implicit_fusion, int verbose_level)
collection of invariants of a set of packings in PG(3,q)
Definition: packings.h:23
ring_theory::longinteger_object * Ago_induced
Definition: packings.h:31
void make_table(isomorph *Iso, std::ostream &ost, int f_only_self_dual, int f_only_not_self_dual, int verbose_level)
data_structures::tally_vector_data * Classify
Definition: packings.h:38
void init(isomorph *Iso, packing_classify *P, int verbose_level)
void compute_dual_packings(isomorph *Iso, int verbose_level)
classification of packings in PG(3,q)
Definition: packings.h:66
spreads::spread_table_with_selection * Spread_table_with_selection
Definition: packings.h:85
geometric invariants of a packing in PG(3,q)
Definition: packings.h:189
void init(packing_classify *P, std::string &prefix, std::string &prefix_tex, int iso_cnt, long int *the_packing, int verbose_level)
#define FREE_int(p)
Definition: foundations.h:640
#define Int_vec_zero(A, B)
Definition: foundations.h:713
#define NEW_pint(n)
Definition: foundations.h:627
#define NEW_OBJECT(type)
Definition: foundations.h:638
#define FREE_OBJECT(p)
Definition: foundations.h:651
#define NEW_int(n)
Definition: foundations.h:625
#define NEW_OBJECTS(type, n)
Definition: foundations.h:639
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#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