Orbiter 2022
Combinatorial Objects
null_polarity_generator.cpp
Go to the documentation of this file.
1// null_polarity_generator.cpp
2//
3// Anton Betten
4// December 11, 2015
5
6#include "foundations.h"
7
8using namespace std;
9
10
11
12namespace orbiter {
13namespace layer1_foundations {
14namespace algebra {
15
16
18{
19 null();
20}
21
23{
24 freeself();
25}
26
28{
29 nb_candidates = NULL;
30 cur_candidate = NULL;
31 candidates = NULL;
32 Mtx = NULL;
33 v = NULL;
34 w = NULL;
35 Points = NULL;
36 nb_gens = 0;
37 Data = NULL;
38 transversal_length = NULL;
39}
40
42{
43 int i;
44
45 if (nb_candidates) {
47 }
48 if (cur_candidate) {
50 }
51 if (candidates) {
52 for (i = 0; i < n + 1; i++) {
54 }
56 }
57 if (Mtx) {
59 }
60 if (v) {
61 FREE_int(v);
62 }
63 if (w) {
64 FREE_int(w);
65 }
66 if (Points) {
68 }
69 if (Data) {
71 }
74 }
75 null();
76}
77
79{
80 int f_v = (verbose_level >= 1);
81 int i;
84
85 if (f_v) {
86 cout << "null_polarity_generator::init" << endl;
87 }
90 q = F->q;
91 qn = NT.i_power_j(q, n);
92 nb_candidates = NEW_int(n + 1);
94 candidates = NEW_pint(n + 1);
95 for (i = 0; i < n + 1; i++) {
96 candidates[i] = NEW_int(qn);
97 }
98
99 Mtx = NEW_int(n * n);
100 v = NEW_int(n);
101 w = NEW_int(n);
102 Points = NEW_int(qn * n);
103 for (i = 0; i < qn; i++) {
104 Gg.AG_element_unrank(q, Points + i * n, 1, n, i);
105 }
106
107 create_first_candidate_set(verbose_level);
108
109 if (f_v) {
110 cout << "first candidate set has size " << nb_candidates[0] << endl;
111 }
112
113 //backtrack_search(0 /* depth */, verbose_level);
114
115
116
117 int first_moved = n;
118 int nb;
119
120 nb_gens = 0;
121 first_moved = n;
123 for (i = 0; i < n; i++) {
124 transversal_length[i] = 1;
125 }
127 first_moved, 0, verbose_level);
128
129 if (f_v) {
130 cout << "We found " << nb_gens << " strong generators" << endl;
131 cout << "transversal_length = ";
133 cout << endl;
134 cout << "group order: ";
135
137
139 cout << endl;
140 }
141
142 Data = NEW_int(nb_gens * n * n);
143
144 nb = 0;
145 first_moved = n;
146 get_strong_generators(Data, nb, first_moved, 0, verbose_level);
147
148 if (nb != nb_gens) {
149 cout << "nb != nb_gens" << endl;
150 exit(1);
151 }
152
153 if (f_v) {
154 cout << "The strong generators are:" << endl;
155 for (i = 0; i < nb_gens; i++) {
156 cout << "generator " << i << " / " << nb_gens << ":" << endl;
158 }
159 }
160
161
162 if (f_v) {
163 cout << "null_polarity_generator::init done" << endl;
164 }
165}
166
168 int &nb, int *transversal_length, int &first_moved,
169 int depth, int verbose_level)
170{
171 //int f_v = (verbose_level >= 1);
172 int a;
173
174 if (depth == n) {
175 //cout << "solution " << nb << endl;
176 //int_matrix_print(Mtx, n, n);
177 if (first_moved < n) {
178 transversal_length[first_moved]++;
179 }
180 nb++;
181 return FALSE;
182 }
183 for (cur_candidate[depth] = 0;
184 cur_candidate[depth] < nb_candidates[depth];
185 cur_candidate[depth]++) {
186 if (cur_candidate[depth] && depth < first_moved) {
187 first_moved = depth;
188 }
189 a = candidates[depth][cur_candidate[depth]];
190 if (FALSE) {
191 cout << "depth " << depth << " " << cur_candidate[depth]
192 << " / " << nb_candidates[depth]
193 << " which is " << a << endl;
194 }
195 Int_vec_copy(Points + a * n, Mtx + depth * n, n);
196 create_next_candidate_set(depth, 0 /* verbose_level */);
197
199 first_moved, depth + 1, verbose_level) &&
200 depth > first_moved) {
201 return FALSE;
202 }
203 }
204 return TRUE;
205}
206
208 int *Data, int &nb, int &first_moved, int depth,
209 int verbose_level)
210{
211 //int f_v = (verbose_level >= 1);
212 int a;
213
214 if (depth == n) {
215 //cout << "solution " << nb << endl;
216 //int_matrix_print(Mtx, n, n);
217 Int_vec_copy(Mtx, Data + nb * n * n, n * n);
218 nb++;
219 return FALSE;
220 }
221 for (cur_candidate[depth] = 0;
222 cur_candidate[depth] < nb_candidates[depth];
223 cur_candidate[depth]++) {
224 if (cur_candidate[depth] && depth < first_moved) {
225 first_moved = depth;
226 }
227 a = candidates[depth][cur_candidate[depth]];
228 if (FALSE) {
229 cout << "depth " << depth << " " << cur_candidate[depth]
230 << " / " << nb_candidates[depth] << " which is "
231 << a << endl;
232 }
233 Int_vec_copy(Points + a * n, Mtx + depth * n, n);
234 create_next_candidate_set(depth, 0 /* verbose_level */);
235
236 if (!get_strong_generators(Data, nb, first_moved,
237 depth + 1, verbose_level) && depth > first_moved) {
238 return FALSE;
239 }
240 }
241 return TRUE;
242}
243
245 int &nb_sol, int depth, int verbose_level)
246{
247 int f_v = (verbose_level >= 1);
248 int a;
249
250 if (depth == n) {
251 if (f_v) {
252 cout << "solution " << nb_sol << endl;
254 }
255 nb_sol++;
256 return;
257 }
258 for (cur_candidate[depth] = 0;
259 cur_candidate[depth] < nb_candidates[depth];
260 cur_candidate[depth]++) {
261 a = candidates[depth][cur_candidate[depth]];
262 if (FALSE) {
263 cout << "depth " << depth << " "
264 << cur_candidate[depth] << " / "
265 << nb_candidates[depth]
266 << " which is " << a << endl;
267 }
268 Int_vec_copy(Points + a * n, Mtx + depth * n, n);
269 create_next_candidate_set(depth, 0 /* verbose_level */);
270
271 backtrack_search(nb_sol, depth + 1, verbose_level);
272 }
273}
274
276 int verbose_level)
277{
278 int f_v = (verbose_level >= 1);
279 int i, nb;
280
281 if (f_v) {
282 cout << "null_polarity_generator::create_"
283 "first_candidate_set" << endl;
284 }
285 nb = 0;
286 for (i = 0; i < qn; i++) {
287 Int_vec_copy(Points + i * n, v, n);
288 if (dot_product(v, v) == 1) {
289 candidates[0][nb++] = i;
290 }
291 }
292 nb_candidates[0] = nb;
293
294 if (f_v) {
295 cout << "null_polarity_generator::create_"
296 "first_candidate_set done" << endl;
297 }
298}
299
301 int level, int verbose_level)
302{
303 int f_v = (verbose_level >= 1);
304 int i, ai, nb;
305
306 if (f_v) {
307 cout << "null_polarity_generator::create_next_candidate_set "
308 "level=" << level << endl;
309 }
310 nb = 0;
311 Int_vec_copy(Mtx + level * n, v, n);
312 for (i = 0; i < nb_candidates[level]; i++) {
313 ai = candidates[level][i];
314 Int_vec_copy(Points + ai * n, w, n);
315 if (dot_product(v, w) == 0) {
316 candidates[level + 1][nb++] = ai;
317 }
318 }
319 nb_candidates[level + 1] = nb;
320
321 if (f_v) {
322 cout << "null_polarity_generator::create_next_candidate_set "
323 "done, found " << nb_candidates[level + 1]
324 << " candidates at level " << level + 1 << endl;
325 }
326}
327
328
330{
331 return F->Linear_algebra->dot_product(n, u1, u2);
332}
333
334}}}
void backtrack_search(int &nb_sol, int depth, int verbose_level)
int count_strong_generators(int &nb, int *transversal_length, int &first_moved, int depth, int verbose_level)
void init(field_theory::finite_field *F, int n, int verbose_level)
int get_strong_generators(int *Data, int &nb, int &first_moved, int depth, int verbose_level)
various functions related to geometries
Definition: geometry.h:721
void AG_element_unrank(int q, int *v, int stride, int len, long int a)
void print_longinteger_after_multiplying(std::ostream &ost, int *factors, int len)
#define FREE_int(p)
Definition: foundations.h:640
#define NEW_pint(n)
Definition: foundations.h:627
#define NEW_int(n)
Definition: foundations.h:625
#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_pint(p)
Definition: foundations.h:641
#define Int_vec_print(A, B, C)
Definition: foundations.h:685
orbiter_kernel_system::orbiter_session * Orbiter
global Orbiter session
the orbiter library for the classification of combinatorial objects