Orbiter 2022
Combinatorial Objects
desarguesian_spread.cpp
Go to the documentation of this file.
1// desarguesian_spread.cpp
2//
3// Anton Betten
4// July 5, 2014
5
6#include "foundations.h"
7
8using namespace std;
9
10
11
12namespace orbiter {
13namespace layer1_foundations {
14namespace geometry {
15
16
17
19{
20 n = m = s = q = Q = 0;
21 Fq = NULL;
22 FQ = NULL;
23 SubS = NULL;
24 Gr = NULL;
25 N = 0;
26 nb_points = 0;
29 Spread_elements = NULL;
30 Rk = NULL;
31 List_of_points = NULL;
32 //null();
33};
34
35
36
38{
39 freeself();
40}
41
43{
44}
45
47{
48#if 0
49 if (SubS) {
51 }
52#endif
53 if (Gr) {
55 }
56 if (Spread_elements) {
58 }
59 if (Rk) {
61 }
62 if (List_of_points) {
64 }
65 null();
66}
67
68void desarguesian_spread::init(int n, int m, int s,
70 int verbose_level)
71{
72 int f_v = (verbose_level >= 1);
75
76 if (f_v) {
77 cout << "desarguesian_spread::init m=" << m
78 << " n=" << n << " s=" << s << endl;
79 }
84
85 FQ = SubS->FQ;
86 Fq = SubS->Fq;
87 q = Fq->q;
88 Q = FQ->q;
89 if (f_v) {
90 cout << "desarguesian_spread::init q=" << q << endl;
91 cout << "desarguesian_spread::init Q=" << Q << endl;
92 }
93 if (NT.i_power_j(q, s) != Q) {
94 cout << "desarguesian_spread::init "
95 "i_power_j(q, s) != Q" << endl;
96 exit(1);
97 }
98 if (s != SubS->s) {
99 cout << "desarguesian_spread::init s != SubS->s" << endl;
100 exit(1);
101 }
102
104 Gr->init(n, s /*k*/, Fq, verbose_level);
105
106
107
108 nb_points = Gg.nb_PG_elements(n - 1, q);
109 if (f_v) {
110 cout << "desarguesian_spread::init "
111 "nb_points = " << nb_points << endl;
112 }
113
114 N = Gg.nb_PG_elements(m - 1, Q);
115 if (f_v) {
116 cout << "desarguesian_spread::init N = " << N << endl;
117 }
118
120 if (f_v) {
121 cout << "desarguesian_spread::init "
122 "nb_points_per_spread_element = "
124 }
125
126 if (f_v) {
127 cout << "desarguesian_spread::init "
128 "before calculate_spread_elements" << endl;
129 }
130 calculate_spread_elements(verbose_level - 2);
131 if (f_v) {
132 cout << "desarguesian_spread::init "
133 "after calculate_spread_elements" << endl;
134 }
135
136 if (f_v) {
137 cout << "desarguesian_spread::init done" << endl;
138 }
139}
140
142 int verbose_level)
143{
144 int f_v = (verbose_level >= 1);
145 int f_vv = (verbose_level >= 2);
146 int *v;
147 int *w;
148 int *z;
149 int h, i, j, a, b, c, J, t;
150
151 if (f_v) {
152 cout << "desarguesian_spread::calculate_spread_elements" << endl;
153 }
156 Rk = NEW_lint(N);
157
158 v = NEW_int(m);
159 w = NEW_int(m);
160 z = NEW_int(s * n);
161 for (h = 0; h < N; h++) {
162 if (f_vv) {
163 cout << "h=" << h << " / " << N << endl;
164 }
166 if (f_vv) {
167 Int_vec_print(cout, v, m);
168 cout << endl;
169 }
170 for (i = 0; i < s; i++) {
171
172 if (FALSE) {
173 cout << "i=" << i << " / " << s << endl;
174 }
175 // multiply by the i-th basis element,
176 // put into the vector w[m]
177 a = SubS->Basis[i];
178 for (j = 0; j < m; j++) {
179 b = v[j];
180 if (FALSE) {
181 cout << "j=" << j << " / " << m
182 << " a=" << a << " b=" << b << endl;
183 }
184 c = FQ->mult(b, a);
185 w[j] = c;
186 }
187
188 for (j = 0; j < m; j++) {
189 J = j * s;
190 b = w[j];
191 for (t = 0; t < s; t++) {
192 c = SubS->components[b * s + t];
193 z[i * n + J + t] = c;
194 }
195 }
196 }
197 if (f_vv) {
198 cout << "basis element " << h << " / " << N << ":" << endl;
199 Int_vec_print(cout, v, m);
200 cout << endl;
201 Int_matrix_print(z, s, n);
202 }
203 Int_vec_copy(z,
206
207 Rk[h] = Gr->rank_lint_here(Spread_elements + h * spread_element_size, 0 /* verbose_level */);
208 }
209 FREE_int(v);
210 FREE_int(w);
211 FREE_int(z);
212
213
214 int *Spread_elt_basis;
215 int rk;
216
217 if (f_v) {
218 cout << "desarguesian_spread::calculate_spread_elements "
219 "computing List_of_points" << endl;
220 }
221 v = NEW_int(s);
222 w = NEW_int(n);
224 for (h = 0; h < N; h++) {
225 if (f_vv) {
226 cout << "h=" << h << " / " << N << endl;
227 }
228 Spread_elt_basis = Spread_elements + h * spread_element_size;
229 for (i = 0; i < nb_points_per_spread_element; i++) {
231 Fq->Linear_algebra->mult_vector_from_the_left(v, Spread_elt_basis, w, s, n);
232 Fq->PG_element_rank_modified(w, 1, n, rk);
234 }
235 if (f_vv) {
236 cout << "basis element " << h << " / " << N << ":" << endl;
237 Int_matrix_print(Spread_elt_basis, s, n);
238 cout << "Consists of the following points:" << endl;
239 Int_vec_print(cout,
242 cout << endl;
243 }
244 }
245 FREE_int(v);
246 FREE_int(w);
247
248 if (f_v) {
249 cout << "desarguesian_spread::calculate_spread_elements done" << endl;
250 }
251}
252
253
255 int k, int *subspace,
256 int *intersection_dimensions, int verbose_level)
257// intersection_dimensions[N]
258{
259 int f_v = (verbose_level >= 1);
260 int f_vv = (verbose_level >= 2);
261 int h, k3;
262 int *intersection;
263
264 if (f_v) {
265 cout << "desarguesian_spread::compute_intersection_type" << endl;
266 }
267
268 intersection = NEW_int(n * n);
269 for (h = 0; h < N; h++) {
270 if (f_vv) {
271 cout << "desarguesian_spread::compute_intersection_type "
272 << h << " / " << N << endl;
273 }
276 k, subspace,
277 k3, intersection,
278 0 /*verbose_level - 2*/);
279
280 intersection_dimensions[h] = k3;
281 }
282 FREE_int(intersection);
283 if (f_v) {
284 cout << "desarguesian_spread::compute_intersection_type "
285 "done" << endl;
286 }
287}
288
290 int *Basis, int basis_sz,
291 int *is_in_shadow, int verbose_level)
292{
293 int f_v = (verbose_level >= 1);
294 int f_vv = (verbose_level >= 2);
295 int *Intersection_dimensions;
296 int i, j, rk;
297
298
299 if (f_v) {
300 cout << "desarguesian_spread::compute_shadow" << endl;
301 }
302
303 Intersection_dimensions = NEW_int(N);
304 compute_intersection_type(basis_sz, Basis,
305 Intersection_dimensions, 0 /*verbose_level - 1*/);
306
307 if (f_vv) {
308 cout << "Intersection_dimensions:";
309 Int_vec_print(cout, Intersection_dimensions, N);
310 cout << endl;
311 }
312
313 for (i = 0; i < nb_points; i++) {
314 is_in_shadow[i] = FALSE;
315 }
316 for (i = 0; i < N; i++) {
317 if (Intersection_dimensions[i]) {
318 for (j = 0; j < nb_points_per_spread_element; j++) {
320 if (is_in_shadow[rk]) {
321 cout << "is_in_shadow[rk] is TRUE, something is "
322 "wrong with the spread" << endl;
323 exit(1);
324 }
325 is_in_shadow[rk] = TRUE;
326 }
327 }
328 }
329
330 FREE_int(Intersection_dimensions);
331 if (f_v) {
332 cout << "desarguesian_spread::compute_shadow done" << endl;
333 }
334}
335
336void desarguesian_spread::compute_linear_set(int *Basis, int basis_sz,
337 long int *&the_linear_set, int &the_linear_set_sz,
338 int verbose_level)
339{
340 int f_v = (verbose_level >= 1);
341 int *Intersection_dimensions;
342 int i, j;
343
344 if (f_v) {
345 cout << "desarguesian_spread::compute_linear_set" << endl;
346 }
347 Intersection_dimensions = NEW_int(N);
348
349 compute_intersection_type(basis_sz, Basis,
350 Intersection_dimensions, 0 /*verbose_level - 1*/);
351
352 the_linear_set_sz = 0;
353 for (i = 0; i < N; i++) {
354 if (Intersection_dimensions[i]) {
355 the_linear_set_sz++;
356 }
357 }
358 the_linear_set = NEW_lint(the_linear_set_sz);
359 j = 0;
360 for (i = 0; i < N; i++) {
361 if (Intersection_dimensions[i]) {
362 the_linear_set[j++] = i;
363 }
364 }
365 if (f_v) {
366 cout << "desarguesian_spread::compute_linear_set "
367 "The linear set is: ";
368 Lint_vec_print(cout, the_linear_set, the_linear_set_sz);
369 cout << endl;
370 }
371
372 FREE_int(Intersection_dimensions);
373
374 if (f_v) {
375 cout << "desarguesian_spread::compute_linear_set done" << endl;
376 }
377}
378
380{
381 int a, b, i, j;
382 int *v;
383
384 v = NEW_int(m);
385 for (a = 0; a < N; a++) {
387 ost << "$";
388 Int_vec_print(ost, v, m);
389 ost << "$";
390 ost << " & ";
391 ost << "$";
392 ost << "\\left[" << endl;
393 ost << "\\begin{array}{*{" << n << "}{c}}" << endl;
394 for (i = 0; i < s; i++) {
395 for (j = 0; j < n; j++) {
396 b = Spread_elements[a * spread_element_size + i * n + j];
397 ost << b << " ";
398 if (j < n - 1) {
399 ost << "& ";
400 }
401 }
402 ost << "\\\\" << endl;
403 }
404 ost << "\\end{array}" << endl;
405 ost << "\\right]" << endl;
406 ost << "$";
407 ost << "\\\\" << endl;
408 ost << "\\hline" << endl;
409 }
410 FREE_int(v);
411}
412
414{
415 int a, b, i, j;
416 int *v;
417
418 v = NEW_int(m);
419 ost << "\\clearpage" << endl;
420 ost << "The spread elements are:\\\\ " << endl;
421 ost << "\\begin{multicols}{2}" << endl;
422 ost << "\\noindent" << endl;
423 for (a = 0; a < N; a++) {
424 ost << a << " / " << N << ":";
426 ost << "$";
427 Int_vec_print(ost, v, m);
428 ost << "=";
429 ost << "\\left[" << endl;
430 ost << "\\begin{array}{*{" << n << "}{c}}" << endl;
431 for (i = 0; i < s; i++) {
432 for (j = 0; j < n; j++) {
433 b = Spread_elements[a * spread_element_size + i * n + j];
434 ost << b << " ";
435 if (j < n - 1) {
436 ost << "& ";
437 }
438 }
439 ost << "\\\\" << endl;
440 }
441 ost << "\\end{array}" << endl;
442 ost << "\\right]_{" << Rk[a] << "}" << endl;
443 ost << "$";
444 ost << "\\\\" << endl;
445 }
446 ost << "\\end{multicols}" << endl;
447 ost << "Spread elements by rank: ";
448 Lint_vec_print(ost, Rk, N);
449 ost << "\\\\" << endl;
450 FREE_int(v);
451}
452
453
455{
456 int i;
457
458 for (i = 0; i < sz; i++) {
460 if (i < sz - 1) {
461 cout << ", ";
462 }
463 }
464}
465
467{
468 int *v;
469
470 v = NEW_int(m);
472 cout << "D_{";
473 Int_vec_print(cout, v, m);
474 cout << "}";
475
476 FREE_int(v);
477}
478
479
481{
482 int f_v = (verbose_level >= 1);
483
484
485 if (f_v) {
486 cout << "desarguesian_spread::create_latex_report" << endl;
487 }
488
489 {
490 char str[1000];
491 string fname;
492 char title[1000];
493 char author[1000];
494
495 snprintf(str, 1000, "Desarguesian_Spread_%d_%d.tex", n - 1, q);
496 fname.assign(str);
497 snprintf(title, 1000, "Desarguesian Spread in ${\\rm PG}(%d,%d)$", n - 1, q);
498 //strcpy(author, "");
499 author[0] = 0;
500
501
502 {
503 ofstream ost(fname);
505
506 L.head(ost,
507 FALSE /* f_book*/,
508 TRUE /* f_title */,
509 title, author,
510 FALSE /* f_toc */,
511 FALSE /* f_landscape */,
512 TRUE /* f_12pt */,
513 TRUE /* f_enlarged_page */,
514 TRUE /* f_pagenumbers */,
515 NULL /* extra_praeamble */);
516
517
518 if (f_v) {
519 cout << "desarguesian_spread::create_latex_report before report" << endl;
520 }
521 report(ost, verbose_level);
522 if (f_v) {
523 cout << "desarguesian_spread::create_latex_report after report" << endl;
524 }
525
526
527 L.foot(ost);
528
529 }
531
532 cout << "written file " << fname << " of size "
533 << Fio.file_size(fname) << endl;
534 }
535
536 if (f_v) {
537 cout << "desarguesian_spread::create_latex_report done" << endl;
538 }
539}
540
541void desarguesian_spread::report(std::ostream &ost, int verbose_level)
542{
543 int f_v = (verbose_level >= 1);
544
545 if (f_v) {
546 cout << "desarguesian_spread::report" << endl;
547 }
548
549
551
552 if (f_v) {
553 cout << "desarguesian_spread::report done" << endl;
554 }
555}
556
557
558
559}}}
560
561
void PG_element_rank_modified(int *v, int stride, int len, int &a)
void PG_element_unrank_modified(int *v, int stride, int len, int a)
a finite field as a vector space over a subfield
void compute_shadow(int *Basis, int basis_sz, int *is_in_shadow, int verbose_level)
void init(int n, int m, int s, field_theory::subfield_structure *SubS, int verbose_level)
void compute_linear_set(int *Basis, int basis_sz, long int *&the_linear_set, int &the_linear_set_sz, int verbose_level)
void compute_intersection_type(int k, int *subspace, int *intersection_dimensions, int verbose_level)
various functions related to geometries
Definition: geometry.h:721
to rank and unrank subspaces of a fixed dimension in F_q^n
Definition: geometry.h:892
long int rank_lint_here(int *Mtx, int verbose_level)
Definition: grassmann.cpp:275
void init(int n, int k, field_theory::finite_field *F, int verbose_level)
Definition: grassmann.cpp:70
void mult_vector_from_the_left(int *v, int *A, int *vA, int m, int n)
int intersect_subspaces(int n, int k1, int *A, int k2, int *B, int &k3, int *intersection, int verbose_level)
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)
#define FREE_int(p)
Definition: foundations.h:640
#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_matrix_print(A, B, C)
Definition: foundations.h:707
#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_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
the orbiter library for the classification of combinatorial objects