Orbiter 2022
Combinatorial Objects
orthogonal_blt.cpp
Go to the documentation of this file.
1/*
2 * orthogonal_blt.cpp
3 *
4 * Created on: Oct 31, 2019
5 * Author: betten
6 */
7
8
9
10
11#include "foundations.h"
12
13using namespace std;
14
15
16namespace orbiter {
17namespace layer1_foundations {
18namespace orthogonal_geometry {
19
20
21
22#if 0
23void orthogonal::create_Linear_BLT_set(long int *set, int *ABC, int verbose_level)
24// a(t)= 1, b(t) = t, c(t) = t^2, all t \in GF(q)
25// together with the point (0, 0, 0, 1, 0)
26{
27 int f_v = (verbose_level >= 1);
28 int f_vv = (verbose_level >= 2);
29 int v[5];
30 int i, a, b, c;
31
32 int q = F->q;
33
34 if (f_v) {
35 cout << "orthogonal::create_Linear_BLT_set" << endl;
36 }
37 int_vec_zero(ABC, 3 * (q + 1));
38 for (i = 0; i < q; i++) {
39 a = i;
40 b = F->power(i, 2);
41 c = F->power(i, 3);
42 if (f_vv) {
43 cout << "i=" << i << " a=" << a
44 << " b=" << b << " c=" << c << endl;
45 }
46 ABC[i * 3 + 0] = a;
47 ABC[i * 3 + 1] = b;
48 ABC[i * 3 + 2] = c;
49 F->create_BLT_point(v, a, b, c, verbose_level - 2);
50 if (f_vv) {
51 cout << "point " << i << " : ";
52 int_vec_print(cout, v, 5);
53 cout << endl;
54 }
55 set[i] = rank_point(v, 1, 0);
56 if (f_vv) {
57 cout << "rank " << set[i] << endl;
58 }
59 }
60 int_vec_init5(v, 0, 0, 0, 1, 0);
61 if (f_vv) {
62 cout << "point : ";
63 int_vec_print(cout, v, 5);
64 cout << endl;
65 }
66 set[q] = rank_point(v, 1, 0);
67 if (f_vv) {
68 cout << "rank " << set[q] << endl;
69 }
70 if (f_v) {
71 cout << "orthogonal::create_Linear_BLT_set done" << endl;
72 }
73}
74
75#endif
76
77
78void orthogonal::create_FTWKB_BLT_set(long int *set, int *ABC, int verbose_level)
79// for q congruent 2 mod 3
80// a(t)= t, b(t) = 3*t^2, c(t) = 3*t^3, all t \in GF(q)
81// together with the point (0, 0, 0, 1, 0)
82{
83 int f_v = (verbose_level >= 1);
84 int f_vv = (verbose_level >= 2);
85 int v[5];
86 int r, i, a, b, c;
88
89 int q = F->q;
90
91 if (q <= 5) {
92 cout << "orthogonal::create_FTWKB_BLT_set q <= 5" << endl;
93 exit(1);
94 }
95 r = q % 3;
96 if (r != 2) {
97 cout << "orthogonal::create_FTWKB_BLT_set q mod 3 must be 2" << endl;
98 exit(1);
99 }
100 Int_vec_zero(ABC, 3 * (q + 1));
101 for (i = 0; i < q; i++) {
102 a = i;
103 b = F->mult(3, F->power(i, 2));
104 c = F->mult(3, F->power(i, 3));
105 if (f_vv) {
106 cout << "i=" << i << " a=" << a
107 << " b=" << b << " c=" << c << endl;
108 }
109 ABC[i * 3 + 0] = a;
110 ABC[i * 3 + 1] = b;
111 ABC[i * 3 + 2] = c;
112 Gg.create_BLT_point(F, v, a, b, c, verbose_level - 2);
113 if (f_vv) {
114 cout << "point " << i << " : ";
115 Int_vec_print(cout, v, 5);
116 cout << endl;
117 }
118 set[i] = rank_point(v, 1, 0);
119 if (f_vv) {
120 cout << "rank " << set[i] << endl;
121 }
122 }
123 orbiter_kernel_system::Orbiter->Int_vec->init5(v, 0, 0, 0, 1, 0);
124 if (f_vv) {
125 cout << "point : ";
126 Int_vec_print(cout, v, 5);
127 cout << endl;
128 }
129 set[q] = rank_point(v, 1, 0);
130 if (f_vv) {
131 cout << "rank " << set[q] << endl;
132 }
133 if (f_v) {
134 cout << "orthogonal::create_FTWKB_BLT_set the BLT set FTWKB is ";
135 Lint_vec_print(cout, set, q + 1);
136 cout << endl;
137 }
138}
139
140void orthogonal::create_K1_BLT_set(long int *set, int *ABC, int verbose_level)
141// for a nonsquare m, and q=p^e
142// a(t)= t, b(t) = 0, c(t) = -m*t^p, all t \in GF(q)
143// together with the point (0, 0, 0, 1, 0)
144{
145 int f_v = (verbose_level >= 1);
146 int f_vv = (verbose_level >= 2);
147 int v[5];
148 int i, m, minus_one, exponent, a, b, c;
149 int q;
151
152 q = F->q;
153 m = F->p; // the primitive element is a nonsquare
154 exponent = F->p;
155 minus_one = F->negate(1);
156 if (f_v) {
157 cout << "m=" << m << endl;
158 cout << "exponent=" << exponent << endl;
159 cout << "minus_one=" << minus_one << endl;
160 }
161 Int_vec_zero(ABC, 3 * (q + 1));
162 for (i = 0; i < q; i++) {
163 a = i;
164 b = 0;
165 c = F->mult(minus_one, F->mult(m, F->power(i, exponent)));
166 if (f_vv) {
167 cout << "i=" << i << " a=" << a
168 << " b=" << b << " c=" << c << endl;
169 }
170 Gg.create_BLT_point(F, v, a, b, c, verbose_level - 2);
171 ABC[i * 3 + 0] = a;
172 ABC[i * 3 + 1] = b;
173 ABC[i * 3 + 2] = c;
174 if (f_vv) {
175 cout << "point " << i << " : ";
176 Int_vec_print(cout, v, 5);
177 cout << endl;
178 }
179 set[i] = rank_point(v, 1, 0);
180 if (f_vv) {
181 cout << "rank " << set[i] << endl;
182 }
183 }
184 orbiter_kernel_system::Orbiter->Int_vec->init5(v, 0, 0, 0, 1, 0);
185 if (f_vv) {
186 cout << "point : ";
187 Int_vec_print(cout, v, 5);
188 cout << endl;
189 }
190 set[q] = rank_point(v, 1, 0);
191 if (f_vv) {
192 cout << "rank " << set[q] << endl;
193 }
194 if (f_v) {
195 cout << "orthogonal::create_K1_BLT_set the BLT set K1 is ";
196 Lint_vec_print(cout, set, q + 1);
197 cout << endl;
198 }
199}
200
201void orthogonal::create_K2_BLT_set(long int *set, int *ABC, int verbose_level)
202// for q congruent 2 or 3 mod 5
203// a(t)= t, b(t) = 5*t^3, c(t) = 5*t^5, all t \in GF(q)
204// together with the point (0, 0, 0, 1, 0)
205{
206 int f_v = (verbose_level >= 1);
207 int f_vv = (verbose_level >= 2);
208 int v[5];
209 int five, r, i, a, b, c;
210 int q;
212
213 q = F->q;
214 if (q <= 5) {
215 cout << "orthogonal::create_K2_BLT_set q <= 5" << endl;
216 return;
217 }
218 r = q % 5;
219 if (r != 2 && r != 3) {
220 cout << "orthogonal::create_K2_BLT_set "
221 "q mod 5 must be 2 or 3" << endl;
222 return;
223 }
224 five = 5 % F->p;
225 Int_vec_zero(ABC, 3 * (q + 1));
226 for (i = 0; i < q; i++) {
227 a = i;
228 b = F->mult(five, F->power(i, 3));
229 c = F->mult(five, F->power(i, 5));
230 if (f_vv) {
231 cout << "i=" << i << " a=" << a
232 << " b=" << b << " c=" << c << endl;
233 }
234 Gg.create_BLT_point(F, v, a, b, c, verbose_level - 2);
235 ABC[i * 3 + 0] = a;
236 ABC[i * 3 + 1] = b;
237 ABC[i * 3 + 2] = c;
238 if (f_vv) {
239 cout << "point " << i << " : ";
240 Int_vec_print(cout, v, 5);
241 cout << endl;
242 }
243 set[i] = rank_point(v, 1, 0);
244 if (f_vv) {
245 cout << "rank " << set[i] << endl;
246 }
247 }
248 orbiter_kernel_system::Orbiter->Int_vec->init5(v, 0, 0, 0, 1, 0);
249 if (f_vv) {
250 cout << "point : ";
251 Int_vec_print(cout, v, 5);
252 cout << endl;
253 }
254 set[q] = rank_point(v, 1, 0);
255 if (f_vv) {
256 cout << "rank " << set[q] << endl;
257 }
258 if (f_v) {
259 cout << "orthogonal::create_K2_BLT_set "
260 "the BLT set K2 is ";
261 Lint_vec_print(cout, set, q + 1);
262 cout << endl;
263 }
264}
265
267 long int *set, int verbose_level)
268{
269 int f_v = (verbose_level >= 1);
270 int f_vv = (verbose_level >= 2);
271 int v[5], v0, v1, v2, v3, v4;
272 int i;
273 int coordinates[] = {
274 0,0,0,0,1,
275 1,0,0,0,0,
276 1,20,1,33,5,
277 1,6,23,19,23,
278 1,32,11,35,17,
279 1,33,12,14,23,
280 1,25,8,12,6,
281 1,16,6,1,22,
282 1,23,8,5,6,
283 1,8,6,13,8,
284 1,22,19,20,13,
285 1,21,23,16,23,
286 1,28,6,9,8,
287 1,2,26,7,13,
288 1,5,9,36,35,
289 1,12,23,10,17,
290 1,14,16,25,23,
291 1,9,8,26,35,
292 1,1,11,8,19,
293 1,19,12,11,17,
294 1,18,27,22,22,
295 1,24,36,17,35,
296 1,26,27,23,5,
297 1,27,25,24,22,
298 1,36,21,32,35,
299 1,7,16,31,8,
300 1,35,5,15,5,
301 1,10,36,6,13,
302 1,30,4,3,5,
303 1,4,3,30,19,
304 1,17,13,2,19,
305 1,11,28,18,17,
306 1,13,16,27,22,
307 1,29,12,28,6,
308 1,15,10,34,19,
309 1,3,30,4,13,
310 1,31,9,21,8,
311 1,34,9,29,6
312 };
313 int q;
314
315 q = F->q;
316 if (q != 37) {
317 cout << "orthogonal::create_LP_37_72_BLT_set q = 37" << endl;
318 return;
319 }
320 for (i = 0; i <= q; i++) {
321 v0 = coordinates[i * 5 + 2];
322 v1 = coordinates[i * 5 + 0];
323 v2 = coordinates[i * 5 + 4];
324 v3 = coordinates[i * 5 + 1];
325 v4 = coordinates[i * 5 + 3];
327 if (f_vv) {
328 cout << "point " << i << " : ";
329 Int_vec_print(cout, v, 5);
330 cout << endl;
331 }
332 set[i] = rank_point(v, 1, 0);
333 if (f_vv) {
334 cout << "rank " << set[i] << endl;
335 }
336 }
337 if (f_v) {
338 cout << "orthogonal::create_LP_37_72_BLT_set "
339 "the BLT set LP_37_72 is ";
340 Lint_vec_print(cout, set, q + 1);
341 cout << endl;
342 }
343}
344
345void orthogonal::create_LP_37_4a_BLT_set(long int *set, int verbose_level)
346{
347 int f_v = (verbose_level >= 1);
348 int f_vv = (verbose_level >= 2);
349 int v[5], v0, v1, v2, v3, v4;
350 int i;
351 int coordinates[] = {
352 0,0,0,0,1,
353 1,0,0,0,0,
354 1,9,16,8,5,
355 1,13,20,26,2,
356 1,4,12,14,22,
357 1,19,23,5,5,
358 1,24,17,19,32,
359 1,18,18,10,14,
360 1,2,4,36,23,
361 1,7,5,24,29,
362 1,36,20,22,29,
363 1,14,10,13,14,
364 1,28,22,7,23,
365 1,32,28,20,19,
366 1,30,27,23,24,
367 1,3,30,28,15,
368 1,1,20,31,13,
369 1,11,36,33,6,
370 1,29,22,30,15,
371 1,20,10,4,5,
372 1,8,14,32,29,
373 1,25,15,9,31,
374 1,26,13,18,29,
375 1,23,19,6,19,
376 1,35,11,15,20,
377 1,22,11,25,32,
378 1,10,16,2,20,
379 1,17,18,27,31,
380 1,15,29,16,29,
381 1,31,18,1,15,
382 1,12,34,35,15,
383 1,33,23,17,20,
384 1,27,23,21,14,
385 1,34,22,3,6,
386 1,21,11,11,18,
387 1,5,33,12,35,
388 1,6,22,34,15,
389 1,16,31,29,18
390 };
391 int q;
392
393 q = F->q;
394 if (q != 37) {
395 cout << "orthogonal::create_LP_37_4a_BLT_set q = 37" << endl;
396 return;
397 }
398 for (i = 0; i <= q; i++) {
399 v0 = coordinates[i * 5 + 2];
400 v1 = coordinates[i * 5 + 0];
401 v2 = coordinates[i * 5 + 4];
402 v3 = coordinates[i * 5 + 1];
403 v4 = coordinates[i * 5 + 3];
405 if (f_vv) {
406 cout << "point " << i << " : ";
407 Int_vec_print(cout, v, 5);
408 cout << endl;
409 }
410 set[i] = rank_point(v, 1, 0);
411 if (f_vv) {
412 cout << "rank " << set[i] << endl;
413 }
414 }
415 if (f_v) {
416 cout << "orthogonal::create_LP_37_4a_BLT_set "
417 "the BLT set LP_37_4a is ";
418 Lint_vec_print(cout, set, q + 1);
419 cout << endl;
420 }
421}
422
423void orthogonal::create_LP_37_4b_BLT_set(long int *set, int verbose_level)
424{
425 int f_v = (verbose_level >= 1);
426 int f_vv = (verbose_level >= 2);
427 int v[5], v0, v1, v2, v3, v4;
428 int i;
429 int coordinates[] = {
430 0,0,0,0,1,
431 1,0,0,0,0,
432 1,3,7,25,24,
433 1,35,30,32,15,
434 1,4,10,30,2,
435 1,14,8,17,31,
436 1,30,18,2,23,
437 1,19,0,10,32,
438 1,8,18,12,24,
439 1,34,2,20,19,
440 1,28,34,15,15,
441 1,2,21,23,31,
442 1,13,29,36,23,
443 1,23,13,8,17,
444 1,25,12,35,17,
445 1,1,14,4,22,
446 1,17,2,19,6,
447 1,12,17,1,32,
448 1,27,23,3,19,
449 1,20,2,21,20,
450 1,33,30,22,2,
451 1,11,16,31,32,
452 1,29,6,13,31,
453 1,16,17,7,6,
454 1,6,25,14,31,
455 1,32,27,29,8,
456 1,15,8,9,23,
457 1,5,17,24,35,
458 1,18,13,33,14,
459 1,7,36,26,2,
460 1,21,34,28,32,
461 1,10,22,16,22,
462 1,26,34,27,29,
463 1,31,13,34,35,
464 1,9,13,18,2,
465 1,22,28,5,31,
466 1,24,3,11,23,
467 1,36,27,6,17
468 };
469 int q;
470
471 q = F->q;
472 if (q != 37) {
473 cout << "orthogonal::create_LP_37_4b_BLT_set q = 37" << endl;
474 return;
475 }
476 for (i = 0; i <= q; i++) {
477 v0 = coordinates[i * 5 + 2];
478 v1 = coordinates[i * 5 + 0];
479 v2 = coordinates[i * 5 + 4];
480 v3 = coordinates[i * 5 + 1];
481 v4 = coordinates[i * 5 + 3];
483 if (f_vv) {
484 cout << "point " << i << " : ";
485 Int_vec_print(cout, v, 5);
486 cout << endl;
487 }
488 set[i] = rank_point(v, 1, 0);
489 if (f_vv) {
490 cout << "rank " << set[i] << endl;
491 }
492 }
493 if (f_v) {
494 cout << "orthogonal::create_LP_37_4b_BLT_set "
495 "the BLT set LP_37_4b is ";
496 Lint_vec_print(cout, set, q + 1);
497 cout << endl;
498 }
499}
500
502 long int *set, int verbose_level)
503// This example can be found in Maska Law's thesis on page 115.
504// Maska Law: Flocks, generalised quadrangles
505// and translatrion planes from BLT-sets,
506// The University of Western Australia, 2003.
507// Note the coordinates here are different (for an unknown reason).
508// Law suggests to construct an infinite family
509// starting from the subgroup A_4 of
510// the stabilizer of the Fisher/Thas/Walker/Kantor examples.
511{
512 int f_v = (verbose_level >= 1);
513 int f_vv = (verbose_level >= 2);
514 int v[5], v0, v1, v2, v3, v4;
515 int i;
516 int coordinates[] = {
517#if 1
518 0,0,0,0,1,
519 1,0,0,0,0,
520 1,20,1,33,5,
521 1,6,23,19,23,
522 1,32,11,35,17,
523 1,33,12,14,23,
524 1,25,8,12,6,
525 1,16,6,1,22,
526 1,23,8,5,6,
527 1,8,6,13,8,
528 1,22,19,20,13,
529 1,21,23,16,23,
530 1,28,6,9,8,
531 1,2,26,7,13,
532 1,5,9,36,35,
533 1,12,23,10,17,
534 1,14,16,25,23,
535 1,9,8,26,35,
536 1,1,11,8,19,
537 1,19,12,11,17,
538 1,18,27,22,22,
539 1,24,36,17,35,
540 1,26,27,23,5,
541 1,27,25,24,22,
542 1,36,21,32,35,
543 1,7,16,31,8,
544 1,35,5,15,5,
545 1,10,36,6,13,
546 1,30,4,3,5,
547 1,4,3,30,19,
548 1,17,13,2,19,
549 1,11,28,18,17,
550 1,13,16,27,22,
551 1,29,12,28,6,
552 1,15,10,34,19,
553 1,3,30,4,13,
554 1,31,9,21,8,
555 1,34,9,29,6
556#endif
557 };
558 int q;
559
560 q = F->q;
561 if (q != 71) {
562 cout << "orthogonal::create_Law_71_BLT_set q = 71" << endl;
563 return;
564 }
565 for (i = 0; i <= q; i++) {
566 v0 = coordinates[i * 5 + 2];
567 v1 = coordinates[i * 5 + 0];
568 v2 = coordinates[i * 5 + 4];
569 v3 = coordinates[i * 5 + 1];
570 v4 = coordinates[i * 5 + 3];
572 if (f_vv) {
573 cout << "point " << i << " : ";
574 Int_vec_print(cout, v, 5);
575 cout << endl;
576 }
577 set[i] = rank_point(v, 1, 0);
578 if (f_vv) {
579 cout << "rank " << set[i] << endl;
580 }
581 }
582 if (f_v) {
583 cout << "orthogonal::create_Law_71_BLT_set "
584 "the BLT set LP_71 is ";
585 Lint_vec_print(cout, set, q + 1);
586 cout << endl;
587 }
588}
589
590
591int orthogonal::BLT_test_full(int size, long int *set, int verbose_level)
592{
593 if (!collinearity_test(size, set, 0/*verbose_level - 2*/)) {
594 return FALSE;
595 }
596 if (!BLT_test(size, set, verbose_level)) {
597 return FALSE;
598 }
599 return TRUE;
600}
601
602int orthogonal::BLT_test(int size, long int *set, int verbose_level)
603{
604 int f_v = (verbose_level >= 1);
605 int f_vv = (verbose_level >= 2);
606 int i, x, y, z, a;
607 int f_OK = TRUE;
608 int fxy, fxz, fyz, l1, l2, l3;
609 int two;
610 int m1[5], m3[5];
611
612 if (size <= 2)
613 return TRUE;
614 if (f_v) {
615 cout << "BLT_test for" << endl;
616 Lint_vec_print(cout, set, size);
617 if (f_vv) {
618 for (i = 0; i < size; i++) {
619 unrank_point(v1, 1, set[i], verbose_level - 1);
620 cout << i << " : " << set[i] << " : ";
621 Int_vec_print(cout, v1, n);
622 cout << endl;
623 }
624 }
625 }
626 x = set[0];
627 z = set[size - 1];
628 two = F->add(1, 1);
629 unrank_point(v1, 1, x, verbose_level - 1);
630 unrank_point(v3, 1, z, verbose_level - 1);
631
632 m1[0] = F->mult(two, v1[0]);
633 m1[1] = v1[2];
634 m1[2] = v1[1];
635 m1[3] = v1[4];
636 m1[4] = v1[3];
637
638 //fxz = evaluate_bilinear_form(v1, v3, 1);
639 // too slow !!!
640 fxz = F->add5(
641 F->mult(m1[0], v3[0]),
642 F->mult(m1[1], v3[1]),
643 F->mult(m1[2], v3[2]),
644 F->mult(m1[3], v3[3]),
645 F->mult(m1[4], v3[4])
646 );
647
648 m3[0] = F->mult(two, v3[0]);
649 m3[1] = v3[2];
650 m3[2] = v3[1];
651 m3[3] = v3[4];
652 m3[4] = v3[3];
653
654
655 if (f_vv) {
656 l1 = F->log_alpha(fxz);
657 cout << "fxz=" << fxz << " (log " << l1 << ") ";
658 if (EVEN(l1))
659 cout << "+";
660 else
661 cout << "-";
662 cout << endl;
663 }
664
665 for (i = 1; i < size - 1; i++) {
666
667 y = set[i];
668
669 unrank_point(v2, 1, y, verbose_level - 1);
670
671 //fxy = evaluate_bilinear_form(v1, v2, 1);
672 fxy = F->add5(
673 F->mult(m1[0], v2[0]),
674 F->mult(m1[1], v2[1]),
675 F->mult(m1[2], v2[2]),
676 F->mult(m1[3], v2[3]),
677 F->mult(m1[4], v2[4])
678 );
679
680 //fyz = evaluate_bilinear_form(v2, v3, 1);
681 fyz = F->add5(
682 F->mult(m3[0], v2[0]),
683 F->mult(m3[1], v2[1]),
684 F->mult(m3[2], v2[2]),
685 F->mult(m3[3], v2[3]),
686 F->mult(m3[4], v2[4])
687 );
688
689 a = F->product3(fxy, fxz, fyz);
690 if (f_vv) {
691 l2 = F->log_alpha(fxy);
692 l3 = F->log_alpha(fyz);
693 cout << "i=" << i << " fxy=" << fxy << " (log=" << l2
694 << ") fyz=" << fyz << " (log=" << l3
695 << ") a=" << a << endl;
696 }
697
698
699 if (f_is_minus_square[a]) {
700 f_OK = FALSE;
701 if (f_v) {
702 l1 = F->log_alpha(fxz);
703 l2 = F->log_alpha(fxy);
704 l3 = F->log_alpha(fyz);
705 cout << "not OK; i=" << i << endl;
706 cout << "{x,y,z}={" << x << "," << y
707 << "," << z << "}" << endl;
708 Int_vec_print(cout, v1, n);
709 cout << endl;
710 Int_vec_print(cout, v2, n);
711 cout << endl;
712 Int_vec_print(cout, v3, n);
713 cout << endl;
714 cout << "fxz=" << fxz << " ";
715 if (EVEN(l1))
716 cout << "+";
717 else
718 cout << "-";
719 cout << " (log=" << l1 << ")" << endl;
720 cout << "fxy=" << fxy << " ";
721 if (EVEN(l2))
722 cout << "+";
723 else
724 cout << "-";
725 cout << " (log=" << l2 << ")" << endl;
726 cout << "fyz=" << fyz << " ";
727 if (EVEN(l3))
728 cout << "+";
729 else
730 cout << "-";
731 cout << " (log=" << l3 << ")" << endl;
732 cout << "a=" << a << "(log=" << F->log_alpha(a)
733 << ") is the negative of a square" << endl;
735 }
736 break;
737 }
738 }
739
740 if (f_v) {
741 if (!f_OK) {
742 cout << "BLT_test fails" << endl;
743 }
744 else {
745 cout << endl;
746 }
747 }
748 return f_OK;
749}
750
751int orthogonal::collinearity_test(int size, long int *set, int verbose_level)
752{
753 int f_v = (verbose_level >= 1);
754 int i, x, y;
755 int f_OK = TRUE;
756 int fxy;
757
758 if (f_v) {
759 cout << "collinearity test for" << endl;
760 for (i = 0; i < size; i++) {
761 unrank_point(v1, 1, set[i], verbose_level - 1);
762 //Q_epsilon_unrank(*M->GFq, u, 1, epsilon, k,
763 //form_c1, form_c2, form_c3, line[i]);
764 Int_vec_print(cout, v1, 5);
765 cout << endl;
766 }
767 }
768 y = set[size - 1];
769 //Q_epsilon_unrank(*M->GFq, v, 1, epsilon, k,
770 //form_c1, form_c2, form_c3, y);
771 unrank_point(v1, 1, y, verbose_level - 1);
772
773 for (i = 0; i < size - 1; i++) {
774 x = set[i];
775 unrank_point(v2, 1, x, verbose_level - 1);
776 //Q_epsilon_unrank(*M->GFq, u, 1, epsilon, k,
777 //form_c1, form_c2, form_c3, x);
778
779 //fxy = evaluate_bilinear_form(*M->GFq, u, v, d, Gram);
780 fxy = evaluate_bilinear_form(v1, v2, 1);
781
782 if (fxy == 0) {
783 f_OK = FALSE;
784 if (f_v) {
785 cout << "not OK; ";
786 cout << "{x,y}={" << x << "," << y
787 << "} are collinear" << endl;
788 Int_vec_print(cout, v1, 5);
789 cout << endl;
790 Int_vec_print(cout, v2, 5);
791 cout << endl;
792 cout << "fxy=" << fxy << endl;
793 }
794 break;
795 }
796 }
797
798 if (f_v) {
799 if (!f_OK) {
800 cout << "collinearity test fails" << endl;
801 }
802 }
803 return f_OK;
804}
805
806int orthogonal::triple_is_collinear(long int pt1, long int pt2, long int pt3)
807{
808 int verbose_level = 0;
809 int rk;
810 int *base_cols;
811
812 base_cols = NEW_int(n);
813 unrank_point(T1, 1, pt1, verbose_level - 1);
814 unrank_point(T1 + n, 1, pt2, verbose_level - 1);
815 unrank_point(T1 + 2 * n, 1, pt3, verbose_level - 1);
817 FALSE /* f_special */,
818 FALSE /* f_complete */,
819 base_cols,
820 FALSE /* f_P */, NULL, 3, n, 0,
821 0 /* verbose_level */);
822 FREE_int(base_cols);
823 if (rk < 2) {
824 cout << "orthogonal::triple_is_collinear rk < 2" << endl;
825 exit(1);
826 }
827 if (rk == 2) {
828 return TRUE;
829 }
830 else {
831 return FALSE;
832 }
833}
834
836{
837 if (DOUBLYEVEN(q - 1)) {
838 if (EVEN(i)) {
839 return TRUE;
840 }
841 else {
842 return FALSE;
843 }
844 }
845 else {
846 if (EVEN(i)) {
847 return FALSE;
848 }
849 else {
850 return TRUE;
851 }
852 }
853}
854
856{
857 int i;
858
859 cout << "field element indices and f_minus_square:" << endl;
860 for (i = 0; i < q; i++) {
861 cout << i << " : "
862 << setw(3) << index_minus_square[i] << ","
863 << setw(3) << index_minus_square_without[i] << ","
864 << setw(3) << index_minus_nonsquare[i] << " : "
865 << setw(3) << f_is_minus_square[i] << endl;
866 }
867}
868
869// formerly DISCRETA/extras.cpp
870//
871// Anton Betten
872// Sept 17, 2010
873
874// plane_invariant started 2/23/09
875
876
878 int size, int *set,
879 int &nb_planes, int *&intersection_matrix,
880 int &Block_size, int *&Blocks,
881 int verbose_level)
882// using hash values
883{
884 int f_v = (verbose_level >= 1);
885 int f_vv = (verbose_level >= 2);
886 int f_vvv = (verbose_level >= 3);
887 int *Mtx;
888 int *Hash;
889 int rk, H, log2_of_q, n_choose_k;
890 int f_special = FALSE;
891 int f_complete = TRUE;
892 int base_col[1000];
893 int subset[1000];
894 int level = 3;
895 int n = 5;
896 int cnt;
897 int i;
898 int q;
903
904
905
906 q = F->q;
907 n_choose_k = Combi.int_n_choose_k(size, level);
908 log2_of_q = NT.int_log2(q);
909
910 Mtx = NEW_int(level * n);
911 Hash = NEW_int(n_choose_k);
912
913 Combi.first_k_subset(subset, size, level);
914 cnt = -1;
915
916 if (f_v) {
917 cout << "computing planes spanned by 3-subsets" << endl;
918 cout << "n_choose_k=" << n_choose_k << endl;
919 cout << "log2_of_q=" << log2_of_q << endl;
920 }
921 while (TRUE) {
922 cnt++;
923
924 for (i = 0; i < level; i++) {
925 F->Orthogonal_indexing->Q_unrank(Mtx + i * n, 1, n - 1, set[subset[i]], 0 /* verbose_level */);
926 }
927 if (f_vvv) {
928 cout << "subset " << setw(5) << cnt << " : ";
929 Int_vec_print(cout, subset, level);
930 cout << " : "; // << endl;
931 }
932 //print_integer_matrix_width(cout, Mtx, level, n, n, 3);
933 rk = F->Linear_algebra->Gauss_int(Mtx, f_special, f_complete,
934 base_col, FALSE, NULL, level, n, n, 0);
935 if (f_vvv) {
936 cout << "after Gauss, rank = " << rk << endl;
937 Int_vec_print_integer_matrix_width(cout, Mtx, level, n, n, 3);
938 }
939 H = 0;
940 for (i = 0; i < level * n; i++) {
941 H = Algo.hashing_fixed_width(H, Mtx[i], log2_of_q);
942 }
943 if (f_vvv) {
944 cout << "hash =" << setw(10) << H << endl;
945 }
946 Hash[cnt] = H;
947 if (!Combi.next_k_subset(subset, size, level)) {
948 break;
949 }
950 }
951 int *Hash_sorted, *sorting_perm, *sorting_perm_inv,
952 nb_types, *type_first, *type_len;
953
954 Sorting.int_vec_classify(n_choose_k, Hash, Hash_sorted,
955 sorting_perm, sorting_perm_inv,
956 nb_types, type_first, type_len);
957
958
959 if (f_v) {
960 cout << nb_types << " types of planes" << endl;
961 }
962 if (f_vvv) {
963 for (i = 0; i < nb_types; i++) {
964 cout << setw(3) << i << " : "
965 << setw(4) << type_first[i] << " : "
966 << setw(4) << type_len[i] << " : "
967 << setw(10) << Hash_sorted[type_first[i]] << endl;
968 }
969 }
970 int *type_len_sorted, *sorting_perm2, *sorting_perm_inv2,
971 nb_types2, *type_first2, *type_len2;
972
973 Sorting.int_vec_classify(nb_types, type_len, type_len_sorted,
974 sorting_perm2, sorting_perm_inv2,
975 nb_types2, type_first2, type_len2);
976
977 if (f_v) {
978 cout << "multiplicities:" << endl;
979 for (i = 0; i < nb_types2; i++) {
980 //cout << setw(3) << i << " : "
981 //<< setw(4) << type_first2[i] << " : "
982 cout << setw(4) << type_len2[i] << " x "
983 << setw(10) << type_len_sorted[type_first2[i]] << endl;
984 }
985 }
986 int f, ff, ll, j, u, ii, jj, idx;
987
988 f = type_first2[nb_types2 - 1];
989 nb_planes = type_len2[nb_types2 - 1];
990 if (f_v) {
991 if (nb_planes == 1) {
992 cout << "there is a unique plane that appears "
993 << type_len_sorted[f]
994 << " times among the 3-sets of points" << endl;
995 }
996 else {
997 cout << "there are " << nb_planes
998 << " planes that each appear "
999 << type_len_sorted[f]
1000 << " times among the 3-sets of points" << endl;
1001 for (i = 0; i < nb_planes; i++) {
1002 j = sorting_perm_inv2[f + i];
1003 cout << "The " << i << "-th plane, which is " << j
1004 << ", appears " << type_len_sorted[f + i]
1005 << " times" << endl;
1006 }
1007 }
1008 }
1009 if (f_vvv) {
1010 cout << "these planes are:" << endl;
1011 for (i = 0; i < nb_planes; i++) {
1012 cout << "plane " << i << endl;
1013 j = sorting_perm_inv2[f + i];
1014 ff = type_first[j];
1015 ll = type_len[j];
1016 for (u = 0; u < ll; u++) {
1017 cnt = sorting_perm_inv[ff + u];
1018 Combi.unrank_k_subset(cnt, subset, size, level);
1019 cout << "subset " << setw(5) << cnt << " : ";
1020 Int_vec_print(cout, subset, level);
1021 cout << " : " << endl;
1022 }
1023 }
1024 }
1025
1026 //return;
1027
1028 //int *Blocks;
1029 int *Block;
1030 //int Block_size;
1031
1032
1033 Block = NEW_int(size);
1034 Blocks = NEW_int(nb_planes * size);
1035
1036 for (i = 0; i < nb_planes; i++) {
1037 j = sorting_perm_inv2[f + i];
1038 ff = type_first[j];
1039 ll = type_len[j];
1040 if (f_vv) {
1041 cout << setw(3) << i << " : " << setw(3) << " : "
1042 << setw(4) << ff << " : "
1043 << setw(4) << ll << " : "
1044 << setw(10) << Hash_sorted[type_first[j]] << endl;
1045 }
1046 Block_size = 0;
1047 for (u = 0; u < ll; u++) {
1048 cnt = sorting_perm_inv[ff + u];
1049 Combi.unrank_k_subset(cnt, subset, size, level);
1050 if (f_vvv) {
1051 cout << "subset " << setw(5) << cnt << " : ";
1052 Int_vec_print(cout, subset, level);
1053 cout << " : " << endl;
1054 }
1055 for (ii = 0; ii < level; ii++) {
1056 F->Orthogonal_indexing->Q_unrank(Mtx + ii * n, 1, n - 1, set[subset[ii]], 0 /* verbose_level */);
1057 }
1058 for (ii = 0; ii < level; ii++) {
1059 if (!Sorting.int_vec_search(Block, Block_size, subset[ii], idx)) {
1060 for (jj = Block_size; jj > idx; jj--) {
1061 Block[jj] = Block[jj - 1];
1062 }
1063 Block[idx] = subset[ii];
1064 Block_size++;
1065 }
1066 }
1067 rk = F->Linear_algebra->Gauss_int(Mtx, f_special,
1068 f_complete, base_col, FALSE, NULL, level, n, n, 0);
1069 if (f_vvv) {
1070 cout << "after Gauss, rank = " << rk << endl;
1071 Int_vec_print_integer_matrix_width(cout, Mtx, level, n, n, 3);
1072 }
1073
1074 H = 0;
1075 for (ii = 0; ii < level * n; ii++) {
1076 H = Algo.hashing_fixed_width(H, Mtx[ii], log2_of_q);
1077 }
1078 if (f_vvv) {
1079 cout << "hash =" << setw(10) << H << endl;
1080 }
1081 }
1082 if (f_vv) {
1083 cout << "found Block ";
1084 Int_vec_print(cout, Block, Block_size);
1085 cout << endl;
1086 }
1087 for (u = 0; u < Block_size; u++) {
1088 Blocks[i * Block_size + u] = Block[u];
1089 }
1090 }
1091 if (f_vv) {
1092 cout << "Incidence structure between points "
1093 "and high frequency planes:" << endl;
1094 if (nb_planes < 30) {
1096 nb_planes, Block_size, Block_size, 3);
1097 }
1098 }
1099
1100 int *Incma, *Incma_t, *IIt, *ItI;
1101 int a;
1102
1103 Incma = NEW_int(size * nb_planes);
1104 Incma_t = NEW_int(nb_planes * size);
1105 IIt = NEW_int(size * size);
1106 ItI = NEW_int(nb_planes * nb_planes);
1107
1108
1109 for (i = 0; i < size * nb_planes; i++) {
1110 Incma[i] = 0;
1111 }
1112 for (i = 0; i < nb_planes; i++) {
1113 for (j = 0; j < Block_size; j++) {
1114 a = Blocks[i * Block_size + j];
1115 Incma[a * nb_planes + i] = 1;
1116 }
1117 }
1118 if (f_vv) {
1119 cout << "Incidence matrix:" << endl;
1121 size, nb_planes, nb_planes, 1);
1122 }
1123 for (i = 0; i < size; i++) {
1124 for (j = 0; j < nb_planes; j++) {
1125 Incma_t[j * size + i] = Incma[i * nb_planes + j];
1126 }
1127 }
1128 for (i = 0; i < size; i++) {
1129 for (j = 0; j < size; j++) {
1130 a = 0;
1131 for (u = 0; u < nb_planes; u++) {
1132 a += Incma[i * nb_planes + u] * Incma_t[u * size + j];
1133 }
1134 IIt[i * size + j] = a;
1135 }
1136 }
1137 if (f_vv) {
1138 cout << "I * I^\\top = " << endl;
1139 Int_vec_print_integer_matrix_width(cout, IIt, size, size, size, 2);
1140 }
1141 for (i = 0; i < nb_planes; i++) {
1142 for (j = 0; j < nb_planes; j++) {
1143 a = 0;
1144 for (u = 0; u < size; u++) {
1145 a += Incma[u * nb_planes + i] * Incma[u * nb_planes + j];
1146 }
1147 ItI[i * nb_planes + j] = a;
1148 }
1149 }
1150 if (f_v) {
1151 cout << "I^\\top * I = " << endl;
1153 nb_planes, nb_planes, nb_planes, 3);
1154 }
1155
1156 intersection_matrix = NEW_int(nb_planes * nb_planes);
1157 for (i = 0; i < nb_planes; i++) {
1158 for (j = 0; j < nb_planes; j++) {
1159 intersection_matrix[i * nb_planes + j] = ItI[i * nb_planes + j];
1160 }
1161 }
1162
1163#if 0
1164 {
1165 char fname[1000];
1166
1167 snprintf(fname, 1000, "plane_invariant_%d_%d.txt", q, k);
1168
1169 ofstream fp(fname);
1170 fp << nb_planes << endl;
1171 for (i = 0; i < nb_planes; i++) {
1172 for (j = 0; j < nb_planes; j++) {
1173 fp << ItI[i * nb_planes + j] << " ";
1174 }
1175 fp << endl;
1176 }
1177 fp << -1 << endl;
1178 fp << "# Incidence structure between points "
1179 "and high frequency planes:" << endl;
1180 fp << l << " " << Block_size << endl;
1181 print_integer_matrix_width(fp,
1182 Blocks, nb_planes, Block_size, Block_size, 3);
1183 fp << -1 << endl;
1184
1185 }
1186#endif
1187
1188 FREE_int(Mtx);
1189 FREE_int(Hash);
1190 FREE_int(Block);
1191 //FREE_int(Blocks);
1192 FREE_int(Incma);
1193 FREE_int(Incma_t);
1194 FREE_int(IIt);
1195 FREE_int(ItI);
1196
1197
1198 FREE_int(Hash_sorted);
1199 FREE_int(sorting_perm);
1200 FREE_int(sorting_perm_inv);
1201 FREE_int(type_first);
1202 FREE_int(type_len);
1203
1204
1205
1206 FREE_int(type_len_sorted);
1207 FREE_int(sorting_perm2);
1208 FREE_int(sorting_perm_inv2);
1209 FREE_int(type_first2);
1210 FREE_int(type_len2);
1211
1212
1213
1214}
1215
1216
1217
1218
1219}}}
1220
int hashing_fixed_width(int hash0, int a, int bit_length)
Definition: algorithms.cpp:58
void init5(int *v, int a0, int a1, int a2, int a3, int a4)
Definition: int_vec.cpp:264
a collection of functions related to sorted vectors
int int_vec_search(int *v, int len, int a, int &idx)
Definition: sorting.cpp:1094
void int_vec_classify(int length, int *the_vec, int *&the_vec_sorted, int *&sorting_perm, int *&sorting_perm_inv, int &nb_types, int *&type_first, int *&type_len)
Definition: sorting.cpp:1503
int add5(int i1, int i2, int i3, int i4, int i5)
orthogonal_geometry::orthogonal_indexing * Orthogonal_indexing
various functions related to geometries
Definition: geometry.h:721
void create_BLT_point(field_theory::finite_field *F, int *v5, int a, int b, int c, int verbose_level)
int Gauss_int(int *A, int f_special, int f_complete, int *base_cols, int f_P, int *P, int m, int n, int Pn, int verbose_level)
void Q_unrank(int *v, int stride, int k, long int a, int verbose_level)
long int rank_point(int *v, int stride, int verbose_level)
void unrank_point(int *v, int stride, long int rk, int verbose_level)
void create_Law_71_BLT_set(long int *set, int verbose_level)
void create_FTWKB_BLT_set(long int *set, int *ABC, int verbose_level)
int collinearity_test(int size, long int *set, int verbose_level)
void create_LP_37_4a_BLT_set(long int *set, int verbose_level)
void create_LP_37_72_BLT_set(long int *set, int verbose_level)
void create_K2_BLT_set(long int *set, int *ABC, int verbose_level)
int BLT_test_full(int size, long int *set, int verbose_level)
int BLT_test(int size, long int *set, int verbose_level)
void create_K1_BLT_set(long int *set, int *ABC, int verbose_level)
void plane_invariant(unusual_model *U, int size, int *set, int &nb_planes, int *&intersection_matrix, int &Block_size, int *&Blocks, int verbose_level)
int triple_is_collinear(long int pt1, long int pt2, long int pt3)
void create_LP_37_4b_BLT_set(long int *set, int verbose_level)
Penttila's unusual model to create BLT-sets.
Definition: orthogonal.h:676
#define FREE_int(p)
Definition: foundations.h:640
#define Int_vec_zero(A, B)
Definition: foundations.h:713
#define Lint_vec_print(A, B, C)
Definition: foundations.h:686
#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 TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define EVEN(x)
Definition: foundations.h:221
#define DOUBLYEVEN(x)
Definition: foundations.h:223
#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