Orbiter 2022
Combinatorial Objects
polarity.cpp
Go to the documentation of this file.
1/*
2 * polarity.cpp
3 *
4 * Created on: Oct 18, 2021
5 * Author: betten
6 */
7
8
9
10
11#include "foundations.h"
12
13
14using namespace std;
15
16
17namespace orbiter {
18namespace layer1_foundations {
19namespace geometry {
20
21
23{
24 P = NULL;
27}
28
30{
33 }
36 }
37}
38
40{
41 int f_v = (verbose_level >= 1);
42 int f_vv = FALSE; //(verbose_level >= 1);
43 int i, j;
44 int *A;
45 int a;
46 int n, d;
47 long int N_points;
48
49 if (f_v) {
50 cout << "polarity::init_standard_polarity" << endl;
51 }
52 polarity::P = P;
53 n = P->n;
54 d = n + 1;
55 N_points = P->N_points;
56
57 Point_to_hyperplane = NEW_int(N_points);
58 Hyperplane_to_point = NEW_int(N_points);
59
60 A = NEW_int(d * d);
61
62 for (i = 0; i < P->N_points; i++) {
63 P->Grass_hyperplanes->unrank_lint(i, 0 /*verbose_level - 4*/);
64 for (j = 0; j < n * d; j++) {
65 A[j] = P->Grass_hyperplanes->M[j];
66 }
67 if (f_vv) {
68 cout << "hyperplane " << i << ":" << endl;
70 A, n, d, d,
71 P->F->log10_of_q + 1);
72 }
73 P->F->Linear_algebra->perp_standard(d, n, A, 0);
74 if (FALSE) {
76 A, d, d, d,
77 P->F->log10_of_q + 1);
78 }
79 P->F->PG_element_rank_modified(A + n * d, 1, d, a);
80 if (f_vv) {
81 cout << "hyperplane " << i << " is perp of point ";
82 Int_vec_print(cout, A + n * d, d);
83 cout << " = " << a << endl;
84 }
87 }
88 if (FALSE /* f_vv */) {
89 cout << "i : pt_to_hyperplane[i] : hyperplane_to_pt[i]" << endl;
90 for (i = 0; i < N_points; i++) {
91 cout << setw(4) << i << " "
92 << setw(4) << Point_to_hyperplane[i] << " "
93 << setw(4) << Hyperplane_to_point[i] << endl;
94 }
95 }
96 FREE_int(A);
97 if (f_v) {
98 cout << "polarity::init_standard_polarity done" << endl;
99 }
100}
101
102void polarity::init_general_polarity(projective_space *P, int *Mtx, int verbose_level)
103{
104 int f_v = (verbose_level >= 1);
105 int f_vv = FALSE; //(verbose_level >= 1);
106 int i;
107 int *v;
108 int *A;
109 int a;
110 int n, d;
111 long int N_points;
112
113 if (f_v) {
114 cout << "polarity::init_general_polarity" << endl;
115 }
116 polarity::P = P;
117 n = P->n;
118 d = n + 1;
119 N_points = P->N_points;
120
121 Point_to_hyperplane = NEW_int(N_points);
122 Hyperplane_to_point = NEW_int(N_points);
123
124 v = NEW_int(d);
125 A = NEW_int(d * d);
126
127 for (i = 0; i < P->N_points; i++) {
128
129 P->F->PG_element_unrank_modified(v, 1, d, i);
130
131
133 A, 1, d, d, 0 /* verbose_level*/);
134
135
136 if (f_vv) {
137 cout << "point " << i << " * Mtx = " << endl;
139 A, 1, d, d,
140 P->F->log10_of_q + 1);
141 }
142 P->F->Linear_algebra->perp_standard(d, 1, A, 0);
143 if (FALSE) {
145 A, d, d, d,
146 P->F->log10_of_q + 1);
147 }
148 a = P->Grass_hyperplanes->rank_lint_here(A + d, 0 /*verbose_level - 4*/);
149 if (f_vv) {
150 cout << "hyperplane " << i << " is perp of point ";
151 Int_vec_print(cout, A + 2 * d, d);
152 cout << " = " << a << endl;
153 }
154 Point_to_hyperplane[i] = a;
155 Hyperplane_to_point[a] = i;
156 }
157 if (FALSE /* f_vv */) {
158 cout << "i : pt_to_hyperplane[i] : hyperplane_to_pt[i]" << endl;
159 for (i = 0; i < N_points; i++) {
160 cout << setw(4) << i << " "
161 << setw(4) << Point_to_hyperplane[i] << " "
162 << setw(4) << Hyperplane_to_point[i] << endl;
163 }
164 }
165 FREE_int(v);
166 FREE_int(A);
167 if (f_v) {
168 cout << "polarity::init_general_polarity done" << endl;
169 }
170}
171
173{
174 int f_v = (verbose_level >= 1);
175 int *Mtx;
176 int n, d, i;
177
178 if (f_v) {
179 cout << "polarity::init_reversal_polarity" << endl;
180 }
181 polarity::P = P;
182 n = P->n;
183 d = n + 1;
184
185 Mtx = NEW_int(d * d);
186 Int_vec_zero(Mtx, d * d);
187
188 for (i = 0; i < d; i++) {
189 Mtx[i * d + d - 1 - i] = 1;
190 }
191
192 if (f_v) {
193 cout << "polarity::init_reversal_polarity before init_general_polarity" << endl;
194 }
195
196 init_general_polarity(P, Mtx, verbose_level);
197
198 if (f_v) {
199 cout << "polarity::init_reversal_polarity after init_general_polarity" << endl;
200 }
201
202 FREE_int(Mtx);
203
204 if (f_v) {
205 cout << "polarity::init_reversal_polarity done" << endl;
206 }
207}
208
209void polarity::report(std::ostream &f)
210{
211 int i;
212
213 //f << "Polarity point $\\leftrightarrow$ hyperplane:\\\\" << endl;
214 f << "\\begin{multicols}{4}" << endl;
215 for (i = 0; i < P->N_points; i++) {
216 f << "$" << i << " \\leftrightarrow " << Point_to_hyperplane[i] << "$\\\\" << endl;
217 }
218 f << "\\end{multicols}" << endl;
219 f << "\\clearpage" << endl << endl;
220}
221
222}}}
223
224
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)
void unrank_lint(long int rk, int verbose_level)
Definition: grassmann.cpp:343
long int rank_lint_here(int *Mtx, int verbose_level)
Definition: grassmann.cpp:275
void init_general_polarity(projective_space *P, int *Mtx, int verbose_level)
Definition: polarity.cpp:102
void init_standard_polarity(projective_space *P, int verbose_level)
Definition: polarity.cpp:39
void init_reversal_polarity(projective_space *P, int verbose_level)
Definition: polarity.cpp:172
projective space PG(n,q) of dimension n over Fq
Definition: geometry.h:1916
void mult_matrix_matrix(int *A, int *B, int *C, int m, int n, int o, int verbose_level)
int perp_standard(int n, int k, int *A, int verbose_level)
#define FREE_int(p)
Definition: foundations.h:640
#define Int_vec_zero(A, B)
Definition: foundations.h:713
#define NEW_int(n)
Definition: foundations.h:625
#define Int_vec_print_integer_matrix_width(A, B, C, D, E, F)
Definition: foundations.h:691
#define FALSE
Definition: foundations.h:234
#define Int_vec_print(A, B, C)
Definition: foundations.h:685
the orbiter library for the classification of combinatorial objects