Orbiter 2022
Combinatorial Objects
projective_space2.cpp
Go to the documentation of this file.
1/*
2 * projective_space2.cpp
3 *
4 * Created on: Nov 3, 2019
5 * Author: anton
6 */
7
8
9#include "foundations.h"
10
11
12using namespace std;
13
14
15
16namespace orbiter {
17namespace layer1_foundations {
18namespace geometry {
19
20
21
22
23
24
25void projective_space::print_set_numerical(std::ostream &ost, long int *set, int set_size)
26{
27 long int i, a;
28 int *v;
29
30 v = NEW_int(n + 1);
31 for (i = 0; i < set_size; i++) {
32 a = set[i];
33 unrank_point(v, a);
34 ost << setw(3) << i << " : " << setw(5) << a << " : ";
35 Int_vec_print(ost, v, n + 1);
36 ost << "=";
38 Int_vec_print(ost, v, n + 1);
39 ost << "\\\\" << endl;
40 }
41 FREE_int(v);
42}
43
44void projective_space::print_set(long int *set, int set_size)
45{
46 long int i, a;
47 int *v;
48
49 v = NEW_int(n + 1);
50 for (i = 0; i < set_size; i++) {
51 a = set[i];
52 unrank_point(v, a);
53 cout << setw(3) << i << " : " << setw(5) << a << " : ";
54 F->int_vec_print_field_elements(cout, v, n + 1);
55 cout << "=";
57 F->int_vec_print_field_elements(cout, v, n + 1);
58 cout << endl;
59 }
60 FREE_int(v);
61}
62
64 long int *set, int set_size)
65{
66 long int i, a;
67 int *v;
68
69 v = NEW_int(2 * (n + 1));
70 for (i = 0; i < set_size; i++) {
71 a = set[i];
72 unrank_line(v, a);
73 cout << setw(3) << i << " : " << setw(5) << a << " : ";
74 Int_vec_print(cout, v, 2 * (n + 1));
75 cout << endl;
76 }
77 FREE_int(v);
78}
79
80
82 long int *pts, int nb_pts, int verbose_level)
83{
84 int f_v = (verbose_level >= 1);
85 int f_vv = (verbose_level >= 2);
86 long int *subline;
87 int sz;
88 int i, idx, a;
89 int ret = TRUE;
91
92 if (f_v) {
93 cout << "projective_space::is_contained_in_Baer_subline "
94 "pts=" << endl;
95 Lint_vec_print(cout, pts, nb_pts);
96 cout << endl;
97 cout << "computing Baer subline determined by the "
98 "first three points:" << endl;
99 }
100 Baer_subline(pts, subline, sz, verbose_level - 2);
101 if (f_vv) {
102 cout << "projective_space::is_contained_in_Baer_subline "
103 "The Baer subline is:" << endl;
104 Lint_vec_print(cout, subline, sz);
105 cout << endl;
106 }
107 Sorting.lint_vec_heapsort(subline, sz);
108 for (i = 0; i < nb_pts; i++) {
109 a = pts[i];
110 if (!Sorting.lint_vec_search(subline, sz, a, idx, 0)) {
111 ret = FALSE;
112 if (f_vv) {
113 cout << "did not find " << i << "-th point " << a
114 << " in the list of points, hence not "
115 "contained in Baer subline" << endl;
116 }
117 goto done;
118 }
119
120 }
121done:
122 FREE_lint(subline);
123
124 return ret;
125}
126
128 int *pts, int nb_pts, int *six_coeffs, int verbose_level)
129// there is a memory problem in this function
130// detected 7/14/11
131// solved June 17, 2012:
132// coords and system were not freed
133// system was allocated too short
134{
135 int f_v = (verbose_level >= 1);
136 int f_vv = (verbose_level >= 2);
137 int *coords; //[nb_pts * 3];
138 int *system; //[nb_pts * 9];
139 int kernel[9 * 9];
140 int base_cols[9];
141 int i, x, y, z, xq, yq, zq, rk;
142 int Q, q, little_e;
143 int kernel_m, kernel_n;
145
146 if (f_v) {
147 cout << "projective_space::determine_hermitian_form_in_plane" << endl;
148 }
149 coords = NEW_int(nb_pts * 3);
150 system = NEW_int(nb_pts * 9);
151 Q = F->q;
152 if (ODD(F->e)) {
153 cout << "projective_space::determine_hermitian_"
154 "form_in_plane field degree must be even" << endl;
155 exit(1);
156 }
157 little_e = F->e >> 1;
158 q = NT.i_power_j(F->p, little_e);
159 if (f_v) {
160 cout << "projective_space::determine_hermitian_"
161 "form_in_plane Q=" << Q << " q=" << q << endl;
162 }
163 if (n != 2) {
164 cout << "projective_space::determine_hermitian_"
165 "form_in_plane n != 2" << endl;
166 exit(1);
167 }
168 for (i = 0; i < nb_pts; i++) {
169 unrank_point(coords + i * 3, pts[i]);
170 }
171 if (f_vv) {
172 cout << "projective_space::determine_hermitian_"
173 "form_in_plane points:" << endl;
175 coords, nb_pts, 3, 3, F->log10_of_q);
176 }
177 for (i = 0; i < nb_pts; i++) {
178 x = coords[i * 3 + 0];
179 y = coords[i * 3 + 1];
180 z = coords[i * 3 + 2];
181 xq = F->frobenius_power(x, little_e);
182 yq = F->frobenius_power(y, little_e);
183 zq = F->frobenius_power(z, little_e);
184 system[i * 9 + 0] = F->mult(x, xq);
185 system[i * 9 + 1] = F->mult(y, yq);
186 system[i * 9 + 2] = F->mult(z, zq);
187 system[i * 9 + 3] = F->mult(x, yq);
188 system[i * 9 + 4] = F->mult(y, xq);
189 system[i * 9 + 5] = F->mult(x, zq);
190 system[i * 9 + 6] = F->mult(z, xq);
191 system[i * 9 + 7] = F->mult(y, zq);
192 system[i * 9 + 8] = F->mult(z, yq);
193 }
194 if (f_v) {
195 cout << "projective_space::determine_hermitian_"
196 "form_in_plane system:" << endl;
198 system, nb_pts, 9, 9, F->log10_of_q);
199 }
200
201
202
203 rk = F->Linear_algebra->Gauss_simple(system,
204 nb_pts, 9, base_cols, verbose_level - 2);
205 if (f_v) {
206 cout << "projective_space::determine_hermitian_form_in_plane "
207 "rk=" << rk << endl;
209 system, rk, 9, 9, F->log10_of_q);
210 }
211#if 0
212 if (rk != 8) {
213 if (f_v) {
214 cout << "projective_space::determine_hermitian_form_"
215 "in_plane system underdetermined" << endl;
216 }
217 return FALSE;
218 }
219#endif
221 MINIMUM(nb_pts, 9), 9, base_cols, rk,
222 kernel_m, kernel_n, kernel, 0 /* verbose_level */);
223 if (f_v) {
224 cout << "projective_space::determine_hermitian_form_"
225 "in_plane kernel:" << endl;
227 kernel_m, kernel_n, kernel_n, F->log10_of_q);
228 }
229 six_coeffs[0] = kernel[0 * kernel_n + 0];
230 six_coeffs[1] = kernel[1 * kernel_n + 0];
231 six_coeffs[2] = kernel[2 * kernel_n + 0];
232 six_coeffs[3] = kernel[3 * kernel_n + 0];
233 six_coeffs[4] = kernel[5 * kernel_n + 0];
234 six_coeffs[5] = kernel[7 * kernel_n + 0];
235 if (f_v) {
236 cout << "projective_space::determine_hermitian_form_in_plane "
237 "six_coeffs:" << endl;
238 Int_vec_print(cout, six_coeffs, 6);
239 cout << endl;
240 }
241 FREE_int(coords);
242 FREE_int(system);
243 return TRUE;
244}
245
247 int *pts, int nb_pts, int *circle_type,
248 int verbose_level)
249// circle_type[nb_pts]
250{
251 int f_v = (verbose_level >= 1);
252 int f_vv = (verbose_level >= 2);
253 long int *subline;
254 long int subset[3];
255 int idx_set[3];
256 int sz;
257 int i, idx, a, b;
260
261 if (f_v) {
262 cout << "projective_space::circle_type_of_line_subset "
263 "pts=" << endl;
264 Int_vec_print(cout, pts, nb_pts);
265 cout << endl;
266 //cout << "computing Baer subline determined by
267 //the first three points:" << endl;
268 }
269 for (i = 0; i < nb_pts; i++) {
270 circle_type[i] = 0;
271 }
272
273 Combi.first_k_subset(idx_set, nb_pts, 3);
274 do {
275 for (i = 0; i < 3; i++) {
276 subset[i] = pts[idx_set[i]];
277 }
278 Baer_subline(subset, subline, sz, verbose_level - 2);
279 b = 0;
280 Sorting.lint_vec_heapsort(subline, sz);
281 for (i = 0; i < nb_pts; i++) {
282 a = pts[i];
283 if (Sorting.lint_vec_search(subline, sz, a, idx, 0)) {
284 b++;
285 }
286 }
287
288
289 if (f_v) {
290 cout << "projective_space::circle_type_of_line_subset "
291 "The Baer subline determined by " << endl;
292 Lint_vec_print(cout, subset, 3);
293 cout << " is ";
294 Lint_vec_print(cout, subline, sz);
295 cout << " which intersects in " << b << " points" << endl;
296 }
297
298
299
300 FREE_lint(subline);
301 circle_type[b]++;
302 } while (Combi.next_k_subset(idx_set, nb_pts, 3));
303
304 if (f_vv) {
305 cout << "projective_space::circle_type_of_line_subset "
306 "circle_type before fixing =" << endl;
307 Int_vec_print(cout, circle_type, nb_pts);
308 cout << endl;
309 }
310 for (i = 4; i < nb_pts; i++) {
311 a = Combi.int_n_choose_k(i, 3);
312 if (circle_type[i] % a) {
313 cout << "projective_space::circle_type_of_line_subset "
314 "circle_type[i] % a" << endl;
315 exit(1);
316 }
317 circle_type[i] /= a;
318 }
319 if (f_vv) {
320 cout << "projective_space::circle_type_of_line_subset "
321 "circle_type after fixing =" << endl;
322 Int_vec_print(cout, circle_type, nb_pts);
323 cout << endl;
324 }
325}
326
328 long int *U, int &sz, int verbose_level)
329{
330 int f_v = (verbose_level >= 1);
331 int f_vv = (verbose_level >= 2);
332 int f_vvv = (verbose_level >= 3);
333 int *v;
334 long int e, i, a;
335 long int X, Y, Z, Xq, Yq, Zq;
336
337 if (f_v) {
338 cout << "projective_space::create_unital_XXq_YZq_ZYq" << endl;
339 }
340 if (n != 2) {
341 cout << "projective_space::create_unital_XXq_YZq_ZYq "
342 "n != 2" << endl;
343 exit(1);
344 }
345 if (ODD(F->e)) {
346 cout << "projective_space::create_unital_XXq_YZq_ZYq "
347 "ODD(F->e)" << endl;
348 exit(1);
349 }
350
351 v = NEW_int(3);
352 e = F->e >> 1;
353 if (f_vv) {
354 cout << "e=" << e << endl;
355 }
356 sz = 0;
357 for (i = 0; i < N_points; i++) {
358 unrank_point(v, i);
359 if (f_vvv) {
360 cout << "i=" << i << " : ";
361 Int_vec_print(cout, v, 3);
362 //cout << endl;
363 }
364 X = v[0];
365 Y = v[1];
366 Z = v[2];
367 Xq = F->frobenius_power(X, e);
368 Yq = F->frobenius_power(Y, e);
369 Zq = F->frobenius_power(Z, e);
370 a = F->add3(F->mult(X, Xq), F->mult(Y, Zq), F->mult(Z, Yq));
371 if (f_vvv) {
372 cout << " a=" << a << endl;
373 }
374 if (a == 0) {
375 //cout << "a=0, adding i=" << i << endl;
376 U[sz++] = i;
377 //int_vec_print(cout, U, sz);
378 //cout << endl;
379 }
380 }
381 if (f_vv) {
382 cout << "we found " << sz << " points:" << endl;
383 Lint_vec_print(cout, U, sz);
384 cout << endl;
385 print_set(U, sz);
386 }
387 FREE_int(v);
388
389 if (f_v) {
390 cout << "projective_space::create_unital_XXq_YZq_ZYq "
391 "done" << endl;
392 }
393}
394
395
397 grassmann *G, int rk, long int *set, int set_size,
398 long int *&intersection_set, int &intersection_set_size,
399 int verbose_level)
400{
401 int f_v = (verbose_level >= 1);
402
403 if (f_v) {
404 cout << "projective_space::intersection_of_subspace_with_point_set" << endl;
405 }
406
407 int h;
408 int d = n + 1;
409 int k = G->k;
410 int *M;
411
412 intersection_set = NEW_lint(set_size);
413 M = NEW_int((k + 1) * d);
414 intersection_set_size = 0;
415
416 G->unrank_lint(rk, 0 /* verbose_level */);
417
418 for (h = 0; h < set_size; h++) {
419 Int_vec_copy(G->M, M, k * d);
420 unrank_point(M + k * d, set[h]);
422 k + 1, d, 0 /*verbose_level*/) == k) {
423 intersection_set[intersection_set_size++] = set[h];
424 }
425 } // next h
426
427 FREE_int(M);
428 if (f_v) {
429 cout << "projective_space::intersection_of_subspace_with_point_set done" << endl;
430 }
431}
432
435 long int *set, int set_size,
436 long int *&intersection_set, int &intersection_set_size,
437 int verbose_level)
438{
439 int f_v = (verbose_level >= 1);
440
441 if (f_v) {
442 cout << "projective_space::intersection_of_subspace_with_point_set_rank_is_longinteger" << endl;
443 }
444 int h;
445 int d = n + 1;
446 int k = G->k;
447 int *M;
448
449 intersection_set = NEW_lint(set_size);
450 M = NEW_int((k + 1) * d);
451 intersection_set_size = 0;
452
453 G->unrank_longinteger(rk, 0 /* verbose_level */);
454
455 for (h = 0; h < set_size; h++) {
456 Int_vec_copy(G->M, M, k * d);
457 unrank_point(M + k * d, set[h]);
459 k + 1, d, 0 /*verbose_level*/) == k) {
460 intersection_set[intersection_set_size++] = set[h];
461 }
462 } // next h
463
464 FREE_int(M);
465 if (f_v) {
466 cout << "projective_space::intersection_of_subspace_with_point_set_rank_is_longinteger done" << endl;
467 }
468}
469
471 grassmann *G,
472 long int *set, int set_size,
473 int *&intersection_type, int &highest_intersection_number,
474 int *&intersection_matrix, int &nb_planes,
475 int verbose_level)
476{
477 int f_v = (verbose_level >= 1);
478 int f_vv = (verbose_level >= 2);
480 long int **Pts_on_plane;
481 int *nb_pts_on_plane;
482 int nb_planes_total;
483 int i, j, a, u, f, l, ii;
484
485 if (f_v) {
486 cout << "projective_space::plane_intersection_invariant" << endl;
487 }
488 if (f_v) {
489 cout << "projective_space::plane_intersection_invariant before plane_intersection_type_fast" << endl;
490 }
492 set, set_size,
493 R, Pts_on_plane, nb_pts_on_plane, nb_planes_total,
494 verbose_level - 1);
495 if (f_v) {
496 cout << "projective_space::plane_intersection_invariant after plane_intersection_type_fast" << endl;
497 }
498
500 int f_second = FALSE;
501
502 C.init(nb_pts_on_plane, nb_planes_total, f_second, 0);
503 if (f_v) {
504 cout << "projective_space::plane_intersection_invariant "
505 "plane-intersection type: ";
506 C.print(FALSE /* f_backwards*/);
507 }
508
509 if (f_v) {
510 cout << "The plane intersection type is (";
511 C.print_naked(FALSE /*f_backwards*/);
512 cout << ")" << endl << endl;
513 }
514 f = C.type_first[C.nb_types - 1];
515 highest_intersection_number = C.data_sorted[f];
516 intersection_type = NEW_int(highest_intersection_number + 1);
517
518 Int_vec_zero(intersection_type, highest_intersection_number + 1);
519
520 for (i = 0; i < C.nb_types; i++) {
521 f = C.type_first[i];
522 l = C.type_len[i];
523 a = C.data_sorted[f];
524 intersection_type[a] = l;
525 }
526 f = C.type_first[C.nb_types - 1];
527 nb_planes = C.type_len[C.nb_types - 1];
528
529 int *Incma, *Incma_t, *IIt, *ItI;
530
531 Incma = NEW_int(set_size * nb_planes);
532 Incma_t = NEW_int(nb_planes * set_size);
533 IIt = NEW_int(set_size * set_size);
534 ItI = NEW_int(nb_planes * nb_planes);
535
536
537 for (i = 0; i < set_size * nb_planes; i++) {
538 Incma[i] = 0;
539 }
540 for (i = 0; i < nb_planes; i++) {
541 ii = C.sorting_perm_inv[f + i];
542 for (j = 0; j < nb_pts_on_plane[ii]; j++) {
543 a = Pts_on_plane[ii][j];
544 Incma[a * nb_planes + i] = 1;
545 }
546 }
547 if (f_vv) {
548 cout << "Incidence matrix:" << endl;
550 Incma, set_size, nb_planes, nb_planes, 1);
551 }
552 for (i = 0; i < set_size; i++) {
553 for (j = 0; j < set_size; j++) {
554 a = 0;
555 for (u = 0; u < nb_planes; u++) {
556 a += Incma[i * nb_planes + u] *
557 Incma_t[u * set_size + j];
558 }
559 IIt[i * set_size + j] = a;
560 }
561 }
562 if (f_vv) {
563 cout << "I * I^\\top = " << endl;
565 IIt, set_size, set_size, set_size, 2);
566 }
567 for (i = 0; i < nb_planes; i++) {
568 for (j = 0; j < nb_planes; j++) {
569 a = 0;
570 for (u = 0; u < set_size; u++) {
571 a += Incma[u * nb_planes + i] *
572 Incma[u * nb_planes + j];
573 }
574 ItI[i * nb_planes + j] = a;
575 }
576 }
577 if (f_v) {
578 cout << "I^\\top * I = " << endl;
580 ItI, nb_planes, nb_planes, nb_planes, 3);
581 }
582
583 intersection_matrix = NEW_int(nb_planes * nb_planes);
584 Int_vec_copy(ItI,
585 intersection_matrix, nb_planes * nb_planes);
586
587 FREE_int(Incma);
588 FREE_int(Incma_t);
589 FREE_int(IIt);
590 FREE_int(ItI);
591
592
593 for (i = 0; i < nb_planes_total; i++) {
594 FREE_lint(Pts_on_plane[i]);
595 }
596 FREE_plint(Pts_on_plane);
597 FREE_int(nb_pts_on_plane);
598 FREE_OBJECTS(R);
599 if (f_v) {
600 cout << "projective_space::plane_intersection_invariant done" << endl;
601 }
602}
603
605 grassmann *G,
606 long int *set, int set_size,
607 int *&intersection_type, int &highest_intersection_number,
608 int verbose_level)
609{
610 int f_v = (verbose_level >= 1);
612 long int **Pts_on_plane;
613 int *nb_pts_on_plane;
614 int nb_planes;
615 int i, f, l, a;
616
617 if (f_v) {
618 cout << "projective_space::plane_intersection_type" << endl;
619 }
620 if (f_v) {
621 cout << "projective_space::plane_intersection_type before plane_intersection_type_fast" << endl;
622 }
624 set, set_size,
625 R, Pts_on_plane, nb_pts_on_plane, nb_planes,
626 verbose_level - 1);
627 if (f_v) {
628 cout << "projective_space::plane_intersection_type after plane_intersection_type_fast" << endl;
629 }
630
632 int f_second = FALSE;
633
634 C.init(nb_pts_on_plane, nb_planes, f_second, 0);
635 if (f_v) {
636 cout << "projective_space::plane_intersection_type "
637 "plane-intersection type: ";
638 C.print(FALSE /*f_backwards*/);
639 }
640
641 if (f_v) {
642 cout << "The plane intersection type is (";
643 C.print_naked(FALSE /*f_backwards*/);
644 cout << ")" << endl << endl;
645 }
646
647 f = C.type_first[C.nb_types - 1];
648 highest_intersection_number = C.data_sorted[f];
649 intersection_type = NEW_int(highest_intersection_number + 1);
650 Int_vec_zero(intersection_type, highest_intersection_number + 1);
651 for (i = 0; i < C.nb_types; i++) {
652 f = C.type_first[i];
653 l = C.type_len[i];
654 a = C.data_sorted[f];
655 intersection_type[a] = l;
656 }
657
658 for (i = 0; i < nb_planes; i++) {
659 FREE_lint(Pts_on_plane[i]);
660 }
661 FREE_plint(Pts_on_plane);
662 FREE_int(nb_pts_on_plane);
663 FREE_OBJECTS(R);
664 if (f_v) {
665 cout << "projective_space::plane_intersection_type done" << endl;
666 }
667
668}
669
671 grassmann *G,
672 long int *set, int set_size,
675 int verbose_level)
676{
677 int f_v = (verbose_level >= 1);
678 long int **Pts_on_plane;
679 int *nb_pts_on_plane;
680 int nb_planes;
681 int i;
682
683 if (f_v) {
684 cout << "projective_space::plane_intersections" << endl;
685 }
686 if (f_v) {
687 cout << "projective_space::plane_intersections before plane_intersection_type_fast" << endl;
688 }
690 set, set_size,
691 R, Pts_on_plane, nb_pts_on_plane, nb_planes,
692 verbose_level - 1);
693 if (f_v) {
694 cout << "projective_space::plane_intersections after plane_intersection_type_fast" << endl;
695 }
696 if (f_v) {
697 cout << "projective_space::plane_intersections "
698 "before Sos.init" << endl;
699 }
700 SoS.init_with_Sz_in_int(set_size, nb_planes,
701 Pts_on_plane, nb_pts_on_plane, verbose_level - 1);
702 if (f_v) {
703 cout << "projective_space::plane_intersections "
704 "after Sos.init" << endl;
705 }
706 for (i = 0; i < nb_planes; i++) {
707 FREE_lint(Pts_on_plane[i]);
708 }
709 FREE_plint(Pts_on_plane);
710 FREE_int(nb_pts_on_plane);
711 if (f_v) {
712 cout << "projective_space::plane_intersections done" << endl;
713 }
714}
715
717 grassmann *G,
718 long int *set, int set_size,
720 long int **&Pts_on_plane, int *&nb_pts_on_plane, int &len,
721 int verbose_level)
722{
723 int f_v = (verbose_level >= 1);
724 int f_vv = (verbose_level >= 2);
725 //int f_v3 = (verbose_level >= 3);
726 long int r, rk, i, u, d, N_planes, l;
727
728 int *Basis;
729 int *Basis_save;
730 int *Coords;
732
733 if (f_v) {
734 cout << "projective_space::plane_intersection_type_slow" << endl;
735 }
736 if (f_vv) {
737 print_set_numerical(cout, set, set_size);
738 }
739 if (!Sorting.test_if_set_with_return_value_lint(set, set_size)) {
740 cout << "projective_space::plane_intersection_type_slow "
741 "the input set if not a set" << endl;
742 exit(1);
743 }
744 d = n + 1;
745 N_planes = nb_rk_k_subspaces_as_lint(3);
746
747 if (f_v) {
748 cout << "N_planes=" << N_planes << endl;
749 }
750 // allocate data that is returned:
752 Pts_on_plane = NEW_plint(N_planes);
753 nb_pts_on_plane = NEW_int(N_planes);
754
755 // allocate temporary data:
756 Basis = NEW_int(4 * d);
757 Basis_save = NEW_int(4 * d);
758 Coords = NEW_int(set_size * d);
759
760 for (i = 0; i < set_size; i++) {
761 unrank_point(Coords + i * d, set[i]);
762 }
763 if (f_vv) {
764 cout << "projective_space::plane_intersection_type_slow "
765 "Coords:" << endl;
766 Int_matrix_print(Coords, set_size, d);
767 }
768
769 l = 0;
770 for (rk = 0; rk < N_planes; rk++) {
771
772 if (N_planes > 1000000) {
773 if ((rk % 250000) == 0) {
774 cout << "projective_space::plane_intersection_type_slow "
775 << rk << " / " << N_planes << endl;
776 }
777 }
778 G->unrank_lint_here(Basis_save, rk, 0 /* verbose_level */);
779 //int_vec_copy(G->M, Basis_save, 3 * d);
780 long int *pts_on_plane;
781 int nb = 0;
782
783 pts_on_plane = NEW_lint(set_size);
784
785 for (u = 0; u < set_size; u++) {
786 Int_vec_copy(Basis_save, Basis, 3 * d);
787 Int_vec_copy(Coords + u * d, Basis + 3 * d, d);
789 4, d, 0 /* verbose_level */);
790 if (r < 4) {
791 pts_on_plane[nb++] = u;
792 }
793 }
794
795
796 Pts_on_plane[l] = pts_on_plane;
797 nb_pts_on_plane[l] = nb;
798 R[l].create(rk, __FILE__, __LINE__);
799 l++;
800 } // rk
801 len = l;
802
803 FREE_int(Basis);
804 FREE_int(Basis_save);
805 FREE_int(Coords);
806 if (f_v) {
807 cout << "projective_space::plane_intersection_type_slow "
808 "done" << endl;
809 }
810}
811
813 grassmann *G,
814 long int *set, int set_size,
816 long int **&Pts_on_plane, int *&nb_pts_on_plane, int &len,
817 int verbose_level)
818{
819 int f_v = (verbose_level >= 1);
820 int f_vv = (verbose_level >= 2);
821 int f_v3 = (verbose_level >= 3);
822 int r, rk, rr, h, i, j, a, d, N_planes, N, N2, idx, l;
823
824 int *Basis;
825 int *Basis_save;
826 int *f_subset_done;
827 int *rank_idx;
828 int *Coords;
829
830 int subset[3];
831 int subset2[3];
832 int subset3[3];
834 long int *pts_on_plane;
837
838 if (f_v) {
839 cout << "projective_space::plane_intersection_type_fast" << endl;
840 }
841 if (f_vv) {
842 print_set_numerical(cout, set, set_size);
843 }
844
845 if (!Sorting.test_if_set_with_return_value_lint(set, set_size)) {
846 cout << "projective_space::plane_intersection_type_fast "
847 "the input set if not a set" << endl;
848 exit(1);
849 }
850 d = n + 1;
851 N_planes = nb_rk_k_subspaces_as_lint(3);
852 N = Combi.int_n_choose_k(set_size, 3);
853
854 if (f_v) {
855 cout << "N_planes=" << N_planes << endl;
856 cout << "N=number of 3-subsets of the set=" << N << endl;
857 }
858
859 // allocate data that is returned:
861 Pts_on_plane = NEW_plint(N);
862 nb_pts_on_plane = NEW_int(N);
863
864 // allocate temporary data:
865 Basis = NEW_int(4 * d);
866 Basis_save = NEW_int(4 * d);
867 rank_idx = NEW_int(N);
868 f_subset_done = NEW_int(N);
869 Coords = NEW_int(set_size * d);
870
871 for (i = 0; i < N; i++) {
872 f_subset_done[i] = FALSE;
873 }
874 for (i = 0; i < set_size; i++) {
875 unrank_point(Coords + i * d, set[i]);
876 }
877 if (f_vv) {
878 cout << "projective_space::plane_intersection_type_fast "
879 "Coords:" << endl;
880 Int_matrix_print(Coords, set_size, d);
881 }
882
883
884 len = 0;
885 for (rk = 0; rk < N; rk++) {
886 Combi.unrank_k_subset(rk, subset, set_size, 3);
887 if (f_v) {
888 cout << rk << "-th subset ";
889 Int_vec_print(cout, subset, 3);
890 cout << endl;
891 }
892 if (f_subset_done[rk]) {
893 if (f_v) {
894 cout << "skipping" << endl;
895 }
896 continue;
897 }
898 for (j = 0; j < 3; j++) {
899 a = subset[j];
900 //a = set[subset[j]];
901 Int_vec_copy(Coords + a * d, Basis + j * d, d);
902 //unrank_point(Basis + j * d, a);
903 }
904 if (f_v3) {
905 cout << "subset: ";
906 Int_vec_print(cout, subset, 3);
907 cout << " corresponds to Basis:" << endl;
908 Int_matrix_print(Basis, 3, d);
909 }
911 Basis, 3, d, 0 /* verbose_level */);
912 if (r < 3) {
913 if (TRUE || f_v) {
914 cout << "projective_space::plane_intersection_type_fast "
915 "not independent, skip" << endl;
916 cout << "subset: ";
917 Int_vec_print(cout, subset, 3);
918 cout << endl;
919 }
920 rank_idx[rk] = -1;
921 continue;
922 }
923 G->rank_longinteger_here(Basis, plane_rk, 0 /* verbose_level */);
924 if (f_v) {
925 cout << rk << "-th subset ";
926 Int_vec_print(cout, subset, 3);
927 cout << " plane_rk=" << plane_rk << endl;
928 }
929
930 if (Sorting.longinteger_vec_search(R, len, plane_rk, idx)) {
931 //rank_idx[rk] = idx;
932 // this case should never happen:
933 cout << "projective_space::plane_intersection_type_fast "
934 "longinteger_vec_search(R, len, plane_rk, idx) "
935 "is TRUE" << endl;
936 exit(1);
937 }
938 else {
939 if (f_v3) {
940 cout << "plane_rk=" << plane_rk
941 << " was not found" << endl;
942 }
943 pts_on_plane = NEW_lint(set_size);
944 //if (f_v3) {
945 //cout << "after allocating pts_on_plane,
946 //plane_rk=" << plane_rk << endl;
947 //}
948
949 plane_rk.assign_to(aa);
950 G->unrank_longinteger_here(Basis_save, aa,
951 0 /* verbose_level */);
952 if (f_v3) {
953 cout << "after unrank " << plane_rk
954 << ", Basis:" << endl;
955 Int_matrix_print(Basis_save, 3, d);
956 }
957
958 l = 0;
959 for (h = 0; h < set_size; h++) {
960 if (FALSE && f_v3) {
961 cout << "testing point " << h << ":" << endl;
962 cout << "plane_rk=" << plane_rk << endl;
963 }
964#if 0
965 plane_rk.assign_to(aa);
966 G->unrank_longinteger(aa, 0 /* verbose_level */);
967 if (f_v3) {
968 cout << "after unrank " << plane_rk << ":" << endl;
969 int_matrix_print(G->M, 3, d);
970 }
971 for (j = 0; j < 3 * d; j++) {
972 Basis[j] = G->M[j];
973 }
974#endif
975
976 Int_vec_copy(Basis_save, Basis, 3 * d);
977 //a = set[h];
978
979 Int_vec_copy(Coords + h * d, Basis + 3 * d, d);
980
981 //unrank_point(Basis + 3 * d, set[h]);
982 if (FALSE && f_v3) {
983 cout << "Basis and point:" << endl;
984 Int_matrix_print(Basis, 4, d);
985 }
987 4, d, 0 /* verbose_level */);
988 if (r == 3) {
989 pts_on_plane[l++] = h;
990 if (f_v3) {
991 cout << "point " << h
992 << " is on the plane" << endl;
993 }
994 }
995 else {
996 if (FALSE && f_v3) {
997 cout << "point " << h
998 << " is not on the plane" << endl;
999 }
1000 }
1001 }
1002 if (f_v) {
1003 cout << "We found an " << l << "-plane, "
1004 "its rank is " << plane_rk << endl;
1005 cout << "The ranks of points on that plane are : ";
1006 Lint_vec_print(cout, pts_on_plane, l);
1007 cout << endl;
1008 }
1009
1010
1011 if (l >= 3) {
1012 for (j = len; j > idx; j--) {
1013 R[j].swap_with(R[j - 1]);
1014 Pts_on_plane[j] = Pts_on_plane[j - 1];
1015 nb_pts_on_plane[j] = nb_pts_on_plane[j - 1];
1016 }
1017 for (j = 0; j < N; j++) {
1018 if (f_subset_done[j] && rank_idx[j] >= idx) {
1019 rank_idx[j]++;
1020 }
1021 }
1022 plane_rk.assign_to(R[idx]);
1023 if (f_v3) {
1024 cout << "after assign_to, "
1025 "plane_rk=" << plane_rk << endl;
1026 }
1027 rank_idx[rk] = idx;
1028 len++;
1029
1030
1031
1032
1033 N2 = Combi.int_n_choose_k(l, 3);
1034 for (i = 0; i < N2; i++) {
1035 Combi.unrank_k_subset(i, subset2, l, 3);
1036 for (h = 0; h < 3; h++) {
1037 subset3[h] = pts_on_plane[subset2[h]];
1038 }
1039 rr = Combi.rank_k_subset(subset3, set_size, 3);
1040 if (f_v) {
1041 cout << i << "-th subset3 ";
1042 Int_vec_print(cout, subset3, 3);
1043 cout << " rr=" << rr << endl;
1044 }
1045 if (!f_subset_done[rr]) {
1046 f_subset_done[rr] = TRUE;
1047 rank_idx[rr] = idx;
1048 }
1049 else if (rank_idx[rr] == -1) {
1050 rank_idx[rr] = idx;
1051 }
1052 else if (rank_idx[rr] != idx) {
1053 cout << "projective_space::plane_intersection_type_fast "
1054 "f_subset_done[rr] && "
1055 "rank_idx[rr] >= 0 && "
1056 "rank_idx[rr] != idx" << endl;
1057 exit(1);
1058 }
1059 }
1060 Pts_on_plane[idx] = pts_on_plane;
1061 nb_pts_on_plane[idx] = l;
1062 }
1063 else {
1064 // now l <= 2, we skip those planes:
1065
1066 FREE_lint(pts_on_plane);
1067 f_subset_done[rk] = TRUE;
1068 rank_idx[rk] = -2;
1069 }
1070 } // else
1071 } // next rk
1072
1073 FREE_int(Basis);
1074 FREE_int(Basis_save);
1075 FREE_int(f_subset_done);
1076 FREE_int(rank_idx);
1077 FREE_int(Coords);
1078 if (f_v) {
1079 cout << "projective_space::plane_intersection_type_fast done" << endl;
1080 }
1081}
1082
1084 long int *set, int set_size,
1085 int s,
1086 vector<int> &plane_ranks,
1087 int verbose_level)
1088{
1089 int f_v = (verbose_level >= 1);
1090 int f_vv = (verbose_level >= 2);
1091 //int f_v3 = (verbose_level >= 3);
1092 long int r, rk, i, u, d, N_planes;
1093
1094 int *Basis;
1095 int *Basis_save;
1096 int *Coords;
1098
1099 if (f_v) {
1100 cout << "projective_space::find_planes_which_intersect_in_at_least_s_points" << endl;
1101 }
1102 if (f_vv) {
1103 print_set_numerical(cout, set, set_size);
1104 }
1105 if (!Sorting.test_if_set_with_return_value_lint(set, set_size)) {
1106 cout << "projective_space::find_planes_which_intersect_in_at_least_s_points "
1107 "the input set if not a set" << endl;
1108 exit(1);
1109 }
1110 d = n + 1;
1111 N_planes = nb_rk_k_subspaces_as_lint(3);
1112
1113 if (f_v) {
1114 cout << "N_planes=" << N_planes << endl;
1115 }
1116
1117 // allocate temporary data:
1118 Basis = NEW_int(4 * d);
1119 Basis_save = NEW_int(4 * d);
1120 Coords = NEW_int(set_size * d);
1121
1122 for (i = 0; i < set_size; i++) {
1123 unrank_point(Coords + i * d, set[i]);
1124 }
1125 if (f_vv) {
1126 cout << "projective_space::find_planes_which_intersect_in_at_least_s_points "
1127 "Coords:" << endl;
1128 Int_matrix_print(Coords, set_size, d);
1129 }
1130
1131 int one_percent = 0;
1132
1133 if (N_planes > 1000000) {
1134 one_percent = N_planes / 100;
1135 }
1136 for (rk = 0; rk < N_planes; rk++) {
1137
1138 if (one_percent > 0) {
1139 if ((rk % one_percent) == 0) {
1140 cout << "projective_space::find_planes_which_intersect_in_at_least_s_points "
1141 << rk << " / " << N_planes << " which is "
1142 << rk / one_percent << " percent done" << endl;
1143 }
1144 }
1145 Grass_planes->unrank_lint_here(Basis_save, rk, 0 /* verbose_level */);
1146 //int_vec_copy(G->M, Basis_save, 3 * d);
1147
1148 int nb_pts_on_plane = 0;
1149
1150 for (u = 0; u < set_size; u++) {
1151 Int_vec_copy(Basis_save, Basis, 3 * d);
1152 Int_vec_copy(Coords + u * d, Basis + 3 * d, d);
1154 4, d, 0 /* verbose_level */);
1155 if (r < 4) {
1156 nb_pts_on_plane++;
1157 }
1158 }
1159
1160 if (nb_pts_on_plane >= s) {
1161 plane_ranks.push_back(rk);
1162 }
1163 } // rk
1164 if (f_v) {
1165 cout << "projective_space::find_planes_which_intersect_in_at_least_s_points we found "
1166 << plane_ranks.size() << " planes which intersect "
1167 "in at least " << s << " points" << endl;
1168 }
1169
1170 FREE_int(Basis);
1171 FREE_int(Basis_save);
1172 FREE_int(Coords);
1173 if (f_v) {
1174 cout << "projective_space::find_planes_which_intersect_in_at_least_s_points "
1175 "done" << endl;
1176 }
1177}
1178
1180 long int *set, int set_size,
1181 vector<int> &point_indices,
1182 vector<int> &point_local_coordinates,
1183 int verbose_level)
1184{
1185 int f_v = (verbose_level >= 1);
1186 int f_vv = (verbose_level >= 2);
1187 int r, i, u, d;
1188
1189 int *Basis;
1190 int *Basis_save;
1191 int *Coords;
1192 int base_cols[3];
1193 int coefficients[3];
1195
1196 if (f_v) {
1197 cout << "projective_space::plane_intersection" << endl;
1198 }
1199 d = n + 1;
1200 // allocate temporary data:
1201 Basis = NEW_int(4 * d);
1202 Basis_save = NEW_int(4 * d);
1203 Coords = NEW_int(set_size * d);
1204
1205 for (i = 0; i < set_size; i++) {
1206 unrank_point(Coords + i * d, set[i]);
1207 }
1208 if (f_vv) {
1209 cout << "projective_space::plane_intersection "
1210 "Coords:" << endl;
1211 Int_matrix_print(Coords, set_size, d);
1212 }
1213
1214 Grass_planes->unrank_lint_here(Basis_save, plane_rank, 0 /* verbose_level */);
1215
1216 int nb_pts_on_plane = 0;
1217 int local_rank;
1218
1219 for (u = 0; u < set_size; u++) {
1220 Int_vec_copy(Basis_save, Basis, 3 * d);
1221 Int_vec_copy(Coords + u * d, Basis + 3 * d, d);
1223 4, d, 0 /* verbose_level */);
1224 if (r < 4) {
1225 nb_pts_on_plane++;
1226 point_indices.push_back(u);
1227
1228 Int_vec_copy(Basis_save, Basis, 3 * d);
1229 Int_vec_copy(Coords + u * d, Basis + 3 * d, d);
1230
1231 F->Linear_algebra->Gauss_simple(Basis, 3, d,
1232 base_cols, 0 /*verbose_level */);
1234 3, d, Basis, base_cols,
1235 Basis + 3 * d, coefficients, verbose_level);
1237 coefficients, 1, 3, local_rank);
1238 point_local_coordinates.push_back(local_rank);
1239 }
1240 }
1241
1242 FREE_int(Basis);
1243 FREE_int(Basis_save);
1244 FREE_int(Coords);
1245 if (f_v) {
1246 cout << "projective_space::plane_intersection "
1247 "done" << endl;
1248 }
1249}
1250
1252 long int *set, int set_size,
1253 vector<int> &point_indices,
1254 int verbose_level)
1255{
1256 int f_v = (verbose_level >= 1);
1257 int f_vv = (verbose_level >= 2);
1258 int r, i, u, d;
1259
1260 int *Basis;
1261 int *Basis_save;
1262 int *Coords;
1264
1265 if (f_v) {
1266 cout << "projective_space::line_intersection" << endl;
1267 }
1268 d = n + 1;
1269 // allocate temporary data:
1270 Basis = NEW_int(3 * d);
1271 Basis_save = NEW_int(3 * d);
1272 Coords = NEW_int(set_size * d);
1273
1274 for (i = 0; i < set_size; i++) {
1275 unrank_point(Coords + i * d, set[i]);
1276 }
1277 if (f_vv) {
1278 cout << "projective_space::line_intersection "
1279 "Coords:" << endl;
1280 Int_matrix_print(Coords, set_size, d);
1281 }
1282
1283 Grass_lines->unrank_lint_here(Basis_save, line_rank, 0 /* verbose_level */);
1284
1285 for (u = 0; u < set_size; u++) {
1286 Int_vec_copy(Basis_save, Basis, 2 * d);
1287 Int_vec_copy(Coords + u * d, Basis + 2 * d, d);
1289 3, d, 0 /* verbose_level */);
1290 if (r < 3) {
1291 point_indices.push_back(u);
1292 }
1293 }
1294
1295 FREE_int(Basis);
1296 FREE_int(Basis_save);
1297 FREE_int(Coords);
1298 if (f_v) {
1299 cout << "projective_space::line_intersection "
1300 "done" << endl;
1301 }
1302}
1303
1305 projective_space *P5,
1306 long int *set_in, int set_size, long int *set_out,
1307 int verbose_level)
1308// Computes the Pluecker coordinates
1309// for a line in PG(3,q) in the following order:
1310// (x_1,x_2,x_3,x_4,x_5,x_6) =
1311// (Pluecker_12, Pluecker_34, Pluecker_13,
1312// Pluecker_42, Pluecker_14, Pluecker_23)
1313// satisfying the quadratic form x_1x_2 + x_3x_4 + x_5x_6 = 0
1314{
1315 int f_v = (verbose_level >= 1);
1316 int f_vv = (verbose_level >= 2);
1317 int d = n + 1;
1318 int h;
1319 int basis8[8];
1320 int v6[6];
1321 int *x4, *y4;
1322 long int a, b, c;
1323 int f_elements_exponential = TRUE;
1324 string symbol_for_print;
1325
1326
1327
1328
1329 if (f_v) {
1330 cout << "projective_space::klein_correspondence" << endl;
1331 }
1332
1333
1334 symbol_for_print.assign("\\alpha");
1335
1336 for (h = 0; h < set_size; h++) {
1337 a = set_in[h];
1338 Grass_lines->unrank_lint(a, 0 /* verbose_level */);
1339 if (f_vv) {
1340 cout << setw(5) << h << " : " << setw(5) << a << " :" << endl;
1341 F->latex_matrix(cout, f_elements_exponential,
1342 symbol_for_print, Grass_lines->M, 2, 4);
1343 cout << endl;
1344 }
1345 Int_vec_copy(Grass_lines->M, basis8, 8);
1346 if (f_vv) {
1347 Int_matrix_print(basis8, 2, 4);
1348 }
1349 x4 = basis8;
1350 y4 = basis8 + 4;
1351 v6[0] = F->Linear_algebra->Pluecker_12(x4, y4);
1352 v6[1] = F->Linear_algebra->Pluecker_34(x4, y4);
1353 v6[2] = F->Linear_algebra->Pluecker_13(x4, y4);
1354 v6[3] = F->Linear_algebra->Pluecker_42(x4, y4);
1355 v6[4] = F->Linear_algebra->Pluecker_14(x4, y4);
1356 v6[5] = F->Linear_algebra->Pluecker_23(x4, y4);
1357 if (f_vv) {
1358 cout << "v6 : ";
1359 Int_vec_print(cout, v6, 6);
1360 cout << endl;
1361 }
1362 a = F->mult(v6[0], v6[1]);
1363 b = F->mult(v6[2], v6[3]);
1364 c = F->mult(v6[4], v6[5]);
1365 d = F->add3(a, b, c);
1366 //cout << "a=" << a << " b=" << b << " c=" << c << endl;
1367 //cout << "d=" << d << endl;
1368 if (d) {
1369 cout << "d != 0" << endl;
1370 exit(1);
1371 }
1372 set_out[h] = P5->rank_point(v6);
1373 }
1374 if (f_v) {
1375 cout << "projective_space::klein_correspondence done" << endl;
1376 }
1377}
1378
1380 int line_rk, int *v6, int verbose_level)
1381{
1382 int f_v = (verbose_level >= 1);
1383 int f_vv = (verbose_level >= 2);
1384 int basis8[8];
1385 int *x4, *y4;
1386 int f_elements_exponential = FALSE;
1387 string symbol_for_print;
1388
1389 if (f_v) {
1390 cout << "projective_space::Pluecker_coordinates" << endl;
1391 }
1392 symbol_for_print.assign("\\alpha");
1393 Grass_lines->unrank_lint(line_rk, 0 /* verbose_level */);
1394 if (f_vv) {
1395 cout << setw(5) << line_rk << " :" << endl;
1396 F->latex_matrix(cout, f_elements_exponential,
1397 symbol_for_print, Grass_lines->M, 2, 4);
1398 cout << endl;
1399 }
1400 Int_vec_copy(Grass_lines->M, basis8, 8);
1401 if (f_vv) {
1402 Int_matrix_print(basis8, 2, 4);
1403 }
1404 x4 = basis8;
1405 y4 = basis8 + 4;
1406 v6[0] = F->Linear_algebra->Pluecker_12(x4, y4);
1407 v6[1] = F->Linear_algebra->Pluecker_34(x4, y4);
1408 v6[2] = F->Linear_algebra->Pluecker_13(x4, y4);
1409 v6[3] = F->Linear_algebra->Pluecker_42(x4, y4);
1410 v6[4] = F->Linear_algebra->Pluecker_14(x4, y4);
1411 v6[5] = F->Linear_algebra->Pluecker_23(x4, y4);
1412 if (f_vv) {
1413 cout << "v6 : ";
1414 Int_vec_print(cout, v6, 6);
1415 cout << endl;
1416 }
1417 if (f_v) {
1418 cout << "projective_space::Pluecker_coordinates done" << endl;
1419 }
1420}
1421
1423 projective_space *P5,
1424 int *table, int verbose_level)
1425{
1426 int f_v = (verbose_level >= 1);
1427 int f_vv = (verbose_level >= 2);
1428 int d = n + 1;
1429 int h;
1430 int basis8[8];
1431 int x6[6];
1432 int y6[6];
1433 int *x4, *y4;
1434 int a, b, c;
1435 int half;
1436 int f_elements_exponential = TRUE;
1437 string symbol_for_print;
1438 //int *table;
1439
1440 if (f_v) {
1441 cout << "projective_space::klein_correspondence" << endl;
1442 }
1443 symbol_for_print.assign("\\alpha");
1444 half = F->inverse(F->add(1, 1));
1445 if (f_v) {
1446 cout << "half=" << half << endl;
1447 cout << "N_lines=" << N_lines << endl;
1448 }
1449 //table = NEW_int(N_lines);
1450 for (h = 0; h < N_lines; h++) {
1451 Grass_lines->unrank_lint(h, 0 /* verbose_level */);
1452 if (f_vv) {
1453 cout << setw(5) << h << " :" << endl;
1454 F->latex_matrix(cout, f_elements_exponential,
1455 symbol_for_print, Grass_lines->M, 2, 4);
1456 cout << endl;
1457 }
1458 Int_vec_copy(Grass_lines->M, basis8, 8);
1459 if (f_vv) {
1460 Int_matrix_print(basis8, 2, 4);
1461 }
1462 x4 = basis8;
1463 y4 = basis8 + 4;
1464 x6[0] = F->Linear_algebra->Pluecker_12(x4, y4);
1465 x6[1] = F->Linear_algebra->Pluecker_34(x4, y4);
1466 x6[2] = F->Linear_algebra->Pluecker_13(x4, y4);
1467 x6[3] = F->Linear_algebra->Pluecker_42(x4, y4);
1468 x6[4] = F->Linear_algebra->Pluecker_14(x4, y4);
1469 x6[5] = F->Linear_algebra->Pluecker_23(x4, y4);
1470 if (f_vv) {
1471 cout << "x6 : ";
1472 Int_vec_print(cout, x6, 6);
1473 cout << endl;
1474 }
1475 a = F->mult(x6[0], x6[1]);
1476 b = F->mult(x6[2], x6[3]);
1477 c = F->mult(x6[4], x6[5]);
1478 d = F->add3(a, b, c);
1479 //cout << "a=" << a << " b=" << b << " c=" << c << endl;
1480 //cout << "d=" << d << endl;
1481 if (d) {
1482 cout << "d != 0" << endl;
1483 exit(1);
1484 }
1485 y6[0] = F->negate(x6[0]);
1486 y6[1] = x6[1];
1487 y6[2] = F->mult(half, F->add(x6[2], x6[3]));
1488 y6[3] = F->mult(half, F->add(x6[2], F->negate(x6[3])));
1489 y6[4] = x6[4];
1490 y6[5] = x6[5];
1491 if (f_vv) {
1492 cout << "y6 : ";
1493 Int_vec_print(cout, y6, 6);
1494 cout << endl;
1495 }
1496 table[h] = P5->rank_point(y6);
1497 }
1498
1499 cout << "lines in PG(3,q) to points in PG(5,q) "
1500 "in special model:" << endl;
1501 for (h = 0; h < N_lines; h++) {
1502 cout << setw(4) << h << " : " << setw(5) << table[h] << endl;
1503 }
1504
1505 //FREE_int(table);
1506 if (f_v) {
1507 cout << "projective_space::klein_correspondence_special_model done" << endl;
1508 }
1509}
1510
1512 std::ostream &f, int verbose_level)
1513{
1514 int f_v = (verbose_level >= 1);
1515
1516 if (f_v) {
1517 cout << "projective_space::cheat_sheet_points" << endl;
1518 }
1519 int i, d;
1520 int *v;
1521 string symbol_for_print;
1522
1523 d = n + 1;
1524
1525 symbol_for_print.assign("\\alpha");
1526 v = NEW_int(d);
1527
1528 f << "PG$(" << n << ", " << q << ")$ has "
1529 << N_points << " points:\\\\" << endl;
1530 if (F->e == 1) {
1531 f << "\\begin{multicols}{4}" << endl;
1532 for (i = 0; i < N_points; i++) {
1533 F->PG_element_unrank_modified(v, 1, d, i);
1534 f << "$P_{" << i << "}=\\bP";
1535 Int_vec_print(f, v, d);
1536 f << "$\\\\" << endl;
1537 }
1538 f << "\\end{multicols}" << endl;
1539 }
1540 else {
1541 f << "\\begin{multicols}{2}" << endl;
1542 for (i = 0; i < N_points; i++) {
1543 F->PG_element_unrank_modified(v, 1, d, i);
1544 f << "$P_{" << i << "}=\\bP";
1545 Int_vec_print(f, v, d);
1546 f << "=";
1547 F->int_vec_print_elements_exponential(f, v, d, symbol_for_print);
1548 f << "$\\\\" << endl;
1549 }
1550 f << "\\end{multicols}" << endl;
1551
1552 f << "\\begin{multicols}{2}" << endl;
1553 for (i = 0; i < N_points; i++) {
1554 F->PG_element_unrank_modified(v, 1, d, i);
1555 f << "$P_{" << i << "}=\\bP";
1556 Int_vec_print(f, v, d);
1557 //f << "=";
1558 //F->int_vec_print_elements_exponential(f, v, d, symbol_for_print);
1559 f << "$\\\\" << endl;
1560 }
1561 f << "\\end{multicols}" << endl;
1562
1563 }
1564
1565 if (F->has_quadratic_subfield()) {
1566 f << "Baer subgeometry:\\\\" << endl;
1567 f << "\\begin{multicols}{4}" << endl;
1568 int j, cnt = 0;
1569 for (i = 0; i < N_points; i++) {
1570 F->PG_element_unrank_modified(v, 1, d, i);
1572 for (j = 0; j < d; j++) {
1573 if (!F->belongs_to_quadratic_subfield(v[j])) {
1574 break;
1575 }
1576 }
1577 if (j == d) {
1578 cnt++;
1579 f << "$P_{" << i << "}=\\bP";
1580 Int_vec_print(f, v, d);
1581 f << "$\\\\" << endl;
1582 }
1583 }
1584 f << "\\end{multicols}" << endl;
1585 f << "There are " << cnt << " elements in the Baer subgeometry.\\\\" << endl;
1586
1587 }
1588 //f << "\\clearpage" << endl << endl;
1589
1590 f << "Normalized from the left:\\\\" << endl;
1591 f << "\\begin{multicols}{4}" << endl;
1592 for (i = 0; i < N_points; i++) {
1593 F->PG_element_unrank_modified(v, 1, d, i);
1595 f << "$P_{" << i << "}=\\bP";
1596 Int_vec_print(f, v, d);
1597 f << "$\\\\" << endl;
1598 }
1599 f << "\\end{multicols}" << endl;
1600 f << "\\clearpage" << endl << endl;
1601
1602
1603 cheat_polarity(f, verbose_level);
1604
1605
1606 FREE_int(v);
1607 if (f_v) {
1608 cout << "projective_space::cheat_sheet_points done" << endl;
1609 }
1610}
1611
1612void projective_space::cheat_polarity(std::ostream &f, int verbose_level)
1613{
1614 int f_v = (verbose_level >= 1);
1615
1616 if (f_v) {
1617 cout << "projective_space::cheat_polarity" << endl;
1618 }
1619
1620 f << "Standard polarity point $\\leftrightarrow$ hyperplane:\\\\" << endl;
1621
1623
1624 f << "Reversal polarity point $\\leftrightarrow$ hyperplane:\\\\" << endl;
1625
1627
1628 if (f_v) {
1629 cout << "projective_space::cheat_polarity done" << endl;
1630 }
1631}
1632
1634 std::ostream &f, int verbose_level)
1635{
1636 int f_v = (verbose_level >= 1);
1637
1638 if (f_v) {
1639 cout << "projective_space::cheat_sheet_point_table" << endl;
1640 }
1641 int I, i, j, a, d, nb_rows, nb_cols = 5;
1642 int nb_rows_per_page = 40, nb_tables;
1643 int nb_r;
1644 int *v;
1645
1646 d = n + 1;
1647
1648 v = NEW_int(d);
1649
1650 f << "PG$(" << n << ", " << q << ")$ has " << N_points
1651 << " points:\\\\" << endl;
1652
1653 nb_rows = (N_points + nb_cols - 1) / nb_cols;
1654 nb_tables = (nb_rows + nb_rows_per_page - 1) / nb_rows_per_page;
1655
1656 for (I = 0; I < nb_tables; I++) {
1657 f << "$$" << endl;
1658 f << "\\begin{array}{r|*{" << nb_cols << "}{r}}" << endl;
1659 f << "P_{" << nb_cols << "\\cdot i+j}";
1660 for (j = 0; j < nb_cols; j++) {
1661 f << " & " << j;
1662 }
1663 f << "\\\\" << endl;
1664 f << "\\hline" << endl;
1665
1666 if (I == nb_tables - 1) {
1667 nb_r = nb_rows - I * nb_rows_per_page;
1668 }
1669 else {
1670 nb_r = nb_rows_per_page;
1671 }
1672
1673 for (i = 0; i < nb_r; i++) {
1674 f << (I * nb_rows_per_page + i) * nb_cols;
1675 for (j = 0; j < nb_cols; j++) {
1676 a = (I * nb_rows_per_page + i) * nb_cols + j;
1677 f << " & ";
1678 if (a < N_points) {
1679 F->PG_element_unrank_modified(v, 1, d, a);
1680 Int_vec_print(f, v, d);
1681 }
1682 }
1683 f << "\\\\" << endl;
1684 }
1685 f << "\\end{array}" << endl;
1686 f << "$$" << endl;
1687 }
1688
1689 FREE_int(v);
1690 if (f_v) {
1691 cout << "projective_space::cheat_sheet_point_table done" << endl;
1692 }
1693}
1694
1695
1697 std::ostream &f, int verbose_level)
1698{
1699 int f_v = (verbose_level >= 1);
1700
1701 if (f_v) {
1702 cout << "projective_space::cheat_sheet_points_on_lines" << endl;
1703 }
1705
1706
1707 f << "PG$(" << n << ", " << q << ")$ has " << N_lines
1708 << " lines, each with " << k << " points:\\\\" << endl;
1709 if (Implementation->Lines == NULL) {
1710 f << "Don't have Lines table\\\\" << endl;
1711 }
1712 else {
1713 int *row_labels;
1714 int *col_labels;
1715 int i, nb;
1716
1717 row_labels = NEW_int(N_lines);
1718 col_labels = NEW_int(k);
1719 for (i = 0; i < N_lines; i++) {
1720 row_labels[i] = i;
1721 }
1722 for (i = 0; i < k; i++) {
1723 col_labels[i] = i;
1724 }
1725 //int_matrix_print_tex(f, Lines, N_lines, k);
1726 for (i = 0; i < N_lines; i += 40) {
1727 nb = MINIMUM(N_lines - i, 40);
1728 //f << "i=" << i << " nb=" << nb << "\\\\" << endl;
1729 f << "$$" << endl;
1731 Implementation->Lines + i * k, nb, k, row_labels + i,
1732 col_labels, TRUE /* f_tex */);
1733 f << "$$" << endl;
1734 }
1735 FREE_int(row_labels);
1736 FREE_int(col_labels);
1737 }
1738 if (f_v) {
1739 cout << "projective_space::cheat_sheet_points_on_lines done" << endl;
1740 }
1741}
1742
1744 std::ostream &f, int verbose_level)
1745{
1746 int f_v = (verbose_level >= 1);
1747
1748 if (f_v) {
1749 cout << "projective_space::cheat_sheet_lines_on_points" << endl;
1750 }
1752
1753 f << "PG$(" << n << ", " << q << ")$ has " << N_points
1754 << " points, each with " << r << " lines:\\\\" << endl;
1755 if (Implementation->Lines_on_point == NULL) {
1756 f << "Don't have Lines\\_on\\_point table\\\\" << endl;
1757 }
1758 else {
1759 int *row_labels;
1760 int *col_labels;
1761 int i, nb;
1762
1763 row_labels = NEW_int(N_points);
1764 col_labels = NEW_int(r);
1765 for (i = 0; i < N_points; i++) {
1766 row_labels[i] = i;
1767 }
1768 for (i = 0; i < r; i++) {
1769 col_labels[i] = i;
1770 }
1771 for (i = 0; i < N_points; i += 40) {
1772 nb = MINIMUM(N_points - i, 40);
1773 //f << "i=" << i << " nb=" << nb << "\\\\" << endl;
1774 f << "$$" << endl;
1776 Implementation->Lines_on_point + i * r, nb, r,
1777 row_labels + i, col_labels, TRUE /* f_tex */);
1778 f << "$$" << endl;
1779 }
1780 FREE_int(row_labels);
1781 FREE_int(col_labels);
1782
1783#if 0
1784 f << "$$" << endl;
1785 int_matrix_print_tex(f, Lines_on_point, N_points, r);
1786 f << "$$" << endl;
1787#endif
1788 }
1789 if (f_v) {
1790 cout << "projective_space::cheat_sheet_lines_on_points done" << endl;
1791 }
1792}
1793
1794
1796 std::ostream &f, int k, int verbose_level)
1797{
1798 int f_v = (verbose_level >= 1);
1799 grassmann *Gr;
1800 int *v;
1801 int n1, k1;
1802 int nb_k_subspaces;
1803 int i, j, u;
1804 int f_need_comma = FALSE;
1806
1807
1808 if (f_v) {
1809 cout << "projective_space::cheat_sheet_subspaces "
1810 "k=" << k << endl;
1811 }
1812 n1 = n + 1;
1813 k1 = k + 1;
1814 v = NEW_int(n1);
1815
1816 if (F->q >= 10) {
1817 f_need_comma = TRUE;
1818 }
1819
1820 Gr = NEW_OBJECT(grassmann);
1821 Gr->init(n1, k1, F, 0 /*verbose_level*/);
1822
1823
1824 //nb_points = N_points;
1825 nb_k_subspaces = Combi.generalized_binomial(n1, k1, q);
1826
1827
1828 f << "PG$(" << n << ", " << q << ")$ has "
1829 << nb_k_subspaces << " $" << k
1830 << "$-subspaces:\\\\" << endl;
1831
1832 if (nb_k_subspaces > 10000) {
1833 f << "Too many to print \\\\" << endl;
1834 }
1835 else {
1836 f << "%\\begin{multicols}{2}" << endl;
1837 for (u = 0; u < nb_k_subspaces; u++) {
1838 Gr->unrank_lint(u, 0 /* verbose_level*/);
1839 f << "$L_{" << u << "}=\\bL";
1840 f << "\\left[" << endl;
1841 f << "\\begin{array}{c}" << endl;
1842 for (i = 0; i < k1; i++) {
1843 for (j = 0; j < n1; j++) {
1844 f << Gr->M[i * n1 + j];
1845 if (f_need_comma && j < n1 - 1) {
1846 f << ", ";
1847 }
1848 }
1849 f << "\\\\" << endl;
1850 }
1851 f << "\\end{array}" << endl;
1852 f << "\\right]" << endl;
1853
1854 if (n == 3 && k == 1) {
1855 int v6[6];
1856
1857 Pluecker_coordinates(u, v6, 0 /* verbose_level */);
1858 f << "={\\rm\\bf Pl}(" << v6[0] << "," << v6[1] << ","
1859 << v6[2] << "," << v6[3] << "," << v6[4]
1860 << "," << v6[5] << " ";
1861 f << ")" << endl;
1862
1863 }
1864 f << "$\\\\" << endl;
1865
1866 if (((u + 1) % 1000) == 0) {
1867 f << "\\clearpage" << endl << endl;
1868 }
1869 }
1870 f << "%\\end{multicols}" << endl;
1871
1872
1873 if (n == 3 && k == 1) {
1874 do_pluecker_reverse(f, Gr, k, nb_k_subspaces, verbose_level);
1875 }
1876
1877 }
1878 if (n == 3 && k == 1) {
1879 f << "PG$(" << n << ", " << q << ")$ has "
1880 << "the following low weight Pluecker lines:\\\\" << endl;
1881 for (u = 0; u < nb_k_subspaces; u++) {
1882 int v6[6];
1883 int w;
1884
1885 Gr->unrank_lint(u, 0 /* verbose_level*/);
1886 Pluecker_coordinates(u, v6, 0 /* verbose_level */);
1887 w = 0;
1888 for (j = 0; j < 6; j++) {
1889 if (v6[j]) {
1890 w++;
1891 }
1892 }
1893 if (w == 1) {
1894 f << "$L_{" << u << "}=";
1895 f << "\\left[" << endl;
1896 f << "\\begin{array}{c}" << endl;
1897 for (i = 0; i < k1; i++) {
1898 for (j = 0; j < n1; j++) {
1899 f << Gr->M[i * n1 + j];
1900 if (f_need_comma && j < n1 - 1) {
1901 f << ", ";
1902 }
1903 }
1904 f << "\\\\" << endl;
1905 }
1906 f << "\\end{array}" << endl;
1907 f << "\\right]" << endl;
1908 f << "={\\rm\\bf Pl}(" << v6[0] << "," << v6[1] << ","
1909 << v6[2] << "," << v6[3] << "," << v6[4]
1910 << "," << v6[5] << " ";
1911 f << ")" << endl;
1912 f << "$\\\\" << endl;
1913
1914 }
1915 }
1916
1917
1918 }
1919
1920 f << "\\clearpage" << endl << endl;
1921
1922 FREE_OBJECT(Gr);
1923 FREE_int(v);
1924
1925 if (f_v) {
1926 cout << "projective_space::cheat_sheet_subspaces "
1927 "done" << endl;
1928 }
1929}
1930
1932 grassmann *Gr, int k, int nb_k_subspaces, int verbose_level)
1933{
1934 int f_v = (verbose_level >= 1);
1935 int i, j;
1936 int v6[6];
1937 int *T;
1938 int *Pos;
1940
1941 if (f_v) {
1942 cout << "projective_space::do_pluecker_reverse" << endl;
1943 }
1944 T = NEW_int(nb_k_subspaces);
1945 Pos = NEW_int(nb_k_subspaces);
1946 for (i = 0; i < nb_k_subspaces; i++) {
1947 Gr->unrank_lint(i, 0 /* verbose_level*/);
1948 Pluecker_coordinates(i, v6, 0 /* verbose_level */);
1949 F->PG_element_rank_modified(v6, 1, 6, j);
1950 T[i] = j;
1951 Pos[i] = i;
1952 }
1953 Sorting.int_vec_heapsort_with_log(T, Pos, nb_k_subspaces);
1954 if (f_v) {
1955 cout << "projective_space::do_pluecker_reverse after sort:" << endl;
1956 for (i = 0; i < nb_k_subspaces; i++) {
1957 cout << i << " : " << T[i] << " : " << Pos[i] << endl;
1958 }
1959 }
1960
1961
1962 int u, u0;
1963 int n1, k1;
1964 int f_need_comma = FALSE;
1965
1966 n1 = n + 1;
1967 k1 = k + 1;
1968 v = NEW_int(n1);
1969
1970 ost << "Lines sorted by Pluecker coordinates\\\\" << endl;
1971 ost << "%\\begin{multicols}{2}" << endl;
1972 for (u0 = 0; u0 < nb_k_subspaces; u0++) {
1973 u = Pos[u0];
1974 Gr->unrank_lint(u, 0 /* verbose_level*/);
1975
1976 int v6[6];
1977
1978 Pluecker_coordinates(u, v6, 0 /* verbose_level */);
1979 F->PG_element_normalize(v6, 1, 6);
1980 ost << "$" << u0 << /*"=" << u <<*/
1981 "={\\rm\\bf Pl}(" << v6[0] << "," << v6[1] << ","
1982 << v6[2] << "," << v6[3] << "," << v6[4]
1983 << "," << v6[5] << " ";
1984 ost << ")=" << endl;
1985
1986 ost << "L_{" << u << "}=";
1987 ost << "\\left[" << endl;
1988 ost << "\\begin{array}{c}" << endl;
1989 for (i = 0; i < k1; i++) {
1990 for (j = 0; j < n1; j++) {
1991 ost << Gr->M[i * n1 + j];
1992 if (f_need_comma && j < n1 - 1) {
1993 ost << ", ";
1994 }
1995 }
1996 ost << "\\\\" << endl;
1997 }
1998 ost << "\\end{array}" << endl;
1999 ost << "\\right]" << endl;
2000
2001
2002 ost << "$\\\\" << endl;
2003
2004 if (((u + 1) % 1000) == 0) {
2005 ost << "\\clearpage" << endl << endl;
2006 }
2007 }
2008 ost << "%\\end{multicols}" << endl;
2009
2010
2011 FREE_int(T);
2012 FREE_int(Pos);
2013 if (f_v) {
2014 cout << "projective_space::do_pluecker_reverse done" << endl;
2015 }
2016}
2017
2019 std::ostream &f, int verbose_level)
2020{
2021 int f_v = (verbose_level >= 1);
2022
2023 if (f_v) {
2024 cout << "projective_space::cheat_sheet_line_intersection" << endl;
2025 }
2026 int i, j, a;
2027
2028
2029 f << "intersection of 2 lines:" << endl;
2030 f << "$$" << endl;
2031 f << "\\begin{array}{|r|*{" << N_points << "}{r}|}" << endl;
2032 f << "\\hline" << endl;
2033 for (j = 0; j < N_points; j++) {
2034 f << "& " << j << endl;
2035 }
2036 f << "\\\\" << endl;
2037 f << "\\hline" << endl;
2038 for (i = 0; i < N_points; i++) {
2039 f << i;
2040 for (j = 0; j < N_points; j++) {
2042 f << " & ";
2043 if (i != j) {
2044 f << a;
2045 }
2046 }
2047 f << "\\\\[-3pt]" << endl;
2048 }
2049 f << "\\hline" << endl;
2050 f << "\\end{array}" << endl;
2051 f << "$$" << endl;
2052 f << "\\clearpage" << endl;
2053
2054 if (f_v) {
2055 cout << "projective_space::cheat_sheet_line_intersection done" << endl;
2056 }
2057
2058}
2059
2061 std::ostream &f, int verbose_level)
2062{
2063 int f_v = (verbose_level >= 1);
2064
2065 if (f_v) {
2066 cout << "projective_space::cheat_sheet_line_through_pairs_of_points" << endl;
2067 }
2068 int i, j, a;
2069
2070
2071
2072 f << "line through 2 points:" << endl;
2073 f << "$$" << endl;
2074 f << "\\begin{array}{|r|*{" << N_points << "}{r}|}" << endl;
2075 f << "\\hline" << endl;
2076 for (j = 0; j < N_points; j++) {
2077 f << "& " << j << endl;
2078 }
2079 f << "\\\\" << endl;
2080 f << "\\hline" << endl;
2081 for (i = 0; i < N_points; i++) {
2082 f << i;
2083 for (j = 0; j < N_points; j++) {
2084
2086 f << " & ";
2087 if (i != j) {
2088 f << a;
2089 }
2090 }
2091 f << "\\\\[-3pt]" << endl;
2092 }
2093 f << "\\hline" << endl;
2094 f << "\\end{array}" << endl;
2095 f << "$$" << endl;
2096 f << "\\clearpage" << endl;
2097
2098 if (f_v) {
2099 cout << "projective_space::cheat_sheet_line_through_pairs_of_points done" << endl;
2100 }
2101
2102}
2103
2105 long int *set, int set_size,
2106 long int **&Pts_on_conic, int *&nb_pts_on_conic, int &len,
2107 int verbose_level)
2108{
2109 int f_v = (verbose_level >= 1);
2110
2111 if (f_v) {
2112 cout << "projective_space::conic_type_randomized" << endl;
2113 }
2114 int f_vv = (verbose_level >= 2);
2115 int f_v3 = (verbose_level >= 3);
2116 int rk, h, i, j, a, /*d,*/ N, l, cnt;
2117
2118 long int input_pts[5];
2119 int six_coeffs[6];
2120 int vec[3];
2121
2122 int subset[5];
2124 long int *pts_on_conic;
2125 int allocation_length;
2126 geometry_global Gg;
2130
2131 if (f_v) {
2132 cout << "projective_space::conic_type_randomized" << endl;
2133 }
2134 if (n != 2) {
2135 cout << "projective_space::conic_type_randomized "
2136 "n != 2" << endl;
2137 exit(1);
2138 }
2139 if (f_vv) {
2140 print_set_numerical(cout, set, set_size);
2141 }
2142
2143 if (!Sorting.test_if_set_with_return_value_lint(set, set_size)) {
2144 cout << "projective_space::conic_type_randomized "
2145 "the input set if not a set" << endl;
2146 exit(1);
2147 }
2148 //d = n + 1;
2149 N = Combi.int_n_choose_k(set_size, 5);
2150
2151 if (f_v) {
2152 cout << "set_size=" << set_size << endl;
2153 cout << "N=number of 5-subsets of the set=" << N << endl;
2154 }
2155
2156 // allocate data that is returned:
2157 allocation_length = 1024;
2158 Pts_on_conic = NEW_plint(allocation_length);
2159 nb_pts_on_conic = NEW_int(allocation_length);
2160
2161
2162 len = 0;
2163 for (cnt = 0; cnt < nb_times; cnt++) {
2164
2165 rk = Os.random_integer(N);
2166 Combi.unrank_k_subset(rk, subset, set_size, 5);
2167 if (cnt && ((cnt % 1000) == 0)) {
2168 cout << cnt << " / " << nb_times << " : ";
2169 Int_vec_print(cout, subset, 5);
2170 cout << endl;
2171 }
2172
2173 for (i = 0; i < len; i++) {
2174 if (Sorting.lint_vec_is_subset_of(subset, 5,
2175 Pts_on_conic[i], nb_pts_on_conic[i], 0 /* verbose_level */)) {
2176
2177#if 0
2178 cout << "The set ";
2179 int_vec_print(cout, subset, 5);
2180 cout << " is a subset of the " << i << "th conic ";
2181 int_vec_print(cout, Pts_on_conic[i], nb_pts_on_conic[i]);
2182 cout << endl;
2183#endif
2184
2185 break;
2186 }
2187 }
2188 if (i < len) {
2189 continue;
2190 }
2191 for (j = 0; j < 5; j++) {
2192 a = subset[j];
2193 input_pts[j] = set[a];
2194 }
2195 if (FALSE /* f_v3 */) {
2196 cout << "subset: ";
2197 Int_vec_print(cout, subset, 5);
2198 cout << "input_pts: ";
2199 Lint_vec_print(cout, input_pts, 5);
2200 }
2201
2202 if (!determine_conic_in_plane(input_pts,
2203 5, six_coeffs, 0 /* verbose_level */)) {
2204 continue;
2205 }
2206
2207
2208 F->PG_element_normalize(six_coeffs, 1, 6);
2209 Gg.AG_element_rank_longinteger(F->q, six_coeffs, 1, 6, conic_rk);
2210 if (FALSE /* f_vv */) {
2211 cout << rk << "-th subset ";
2212 Int_vec_print(cout, subset, 5);
2213 cout << " conic_rk=" << conic_rk << endl;
2214 }
2215
2216 if (FALSE /* longinteger_vec_search(R, len, conic_rk, idx) */) {
2217
2218#if 0
2219 cout << "projective_space::conic_type_randomized "
2220 "longinteger_vec_search(R, len, conic_rk, idx) "
2221 "is TRUE" << endl;
2222 cout << "The current set is ";
2223 int_vec_print(cout, subset, 5);
2224 cout << endl;
2225 cout << "conic_rk=" << conic_rk << endl;
2226 cout << "The set where it should be is ";
2227 int_vec_print(cout, Pts_on_conic[idx], nb_pts_on_conic[idx]);
2228 cout << endl;
2229 cout << "R[idx]=" << R[idx] << endl;
2230 cout << "This is the " << idx << "th conic" << endl;
2231 exit(1);
2232#endif
2233
2234 }
2235 else {
2236 if (f_v3) {
2237 cout << "conic_rk=" << conic_rk << " was not found" << endl;
2238 }
2239 pts_on_conic = NEW_lint(set_size);
2240 l = 0;
2241 for (h = 0; h < set_size; h++) {
2242 if (FALSE && f_v3) {
2243 cout << "testing point " << h << ":" << endl;
2244 cout << "conic_rk=" << conic_rk << endl;
2245 }
2246
2247 unrank_point(vec, set[h]);
2248 a = F->Linear_algebra->evaluate_conic_form(six_coeffs, vec);
2249
2250
2251 if (a == 0) {
2252 pts_on_conic[l++] = h;
2253 if (f_v3) {
2254 cout << "point " << h << " is on the conic" << endl;
2255 }
2256 }
2257 else {
2258 if (FALSE && f_v3) {
2259 cout << "point " << h
2260 << " is not on the conic" << endl;
2261 }
2262 }
2263 }
2264 if (FALSE /*f_v*/) {
2265 cout << "We found an " << l
2266 << "-conic, its rank is " << conic_rk << endl;
2267
2268
2269 }
2270
2271
2272 if (l >= 8) {
2273
2274 if (f_v) {
2275 cout << "We found an " << l << "-conic, "
2276 "its rank is " << conic_rk << endl;
2277 cout << "The " << l << " points on the "
2278 << len << "th conic are: ";
2279 Lint_vec_print(cout, pts_on_conic, l);
2280 cout << endl;
2281
2282
2283
2284 }
2285
2286
2287#if 0
2288 for (j = len; j > idx; j--) {
2289 R[j].swap_with(R[j - 1]);
2290 Pts_on_conic[j] = Pts_on_conic[j - 1];
2291 nb_pts_on_conic[j] = nb_pts_on_conic[j - 1];
2292 }
2293 conic_rk.assign_to(R[idx]);
2294 Pts_on_conic[idx] = pts_on_conic;
2295 nb_pts_on_conic[idx] = l;
2296#else
2297
2298 //conic_rk.assign_to(R[len]);
2299 Pts_on_conic[len] = pts_on_conic;
2300 nb_pts_on_conic[len] = l;
2301
2302#endif
2303
2304
2305 len++;
2306 if (f_v) {
2307 cout << "We now have found " << len
2308 << " conics" << endl;
2309
2310
2312 int f_second = FALSE;
2313
2314 C.init(nb_pts_on_conic, len, f_second, 0);
2315
2316 if (f_v) {
2317 cout << "The conic intersection type is (";
2318 C.print_naked(FALSE /*f_backwards*/);
2319 cout << ")" << endl << endl;
2320 }
2321
2322
2323
2324 }
2325
2326 if (len == allocation_length) {
2327 int new_allocation_length = allocation_length + 1024;
2328
2329
2330 long int **Pts_on_conic1;
2331 int *nb_pts_on_conic1;
2332
2333 Pts_on_conic1 = NEW_plint(new_allocation_length);
2334 nb_pts_on_conic1 = NEW_int(new_allocation_length);
2335 for (i = 0; i < len; i++) {
2336 //R1[i] = R[i];
2337 Pts_on_conic1[i] = Pts_on_conic[i];
2338 nb_pts_on_conic1[i] = nb_pts_on_conic[i];
2339 }
2340 FREE_plint(Pts_on_conic);
2341 FREE_int(nb_pts_on_conic);
2342 Pts_on_conic = Pts_on_conic1;
2343 nb_pts_on_conic = nb_pts_on_conic1;
2344 allocation_length = new_allocation_length;
2345 }
2346
2347
2348
2349
2350 }
2351 else {
2352 // we skip this conic:
2353
2354 FREE_lint(pts_on_conic);
2355 }
2356 } // else
2357 } // next rk
2358 if (f_v) {
2359 cout << "projective_space::conic_type_randomized done" << endl;
2360 }
2361}
2362
2364 int f_randomized, int nb_times,
2365 long int *set, int set_size,
2366 int threshold,
2367 int *&intersection_type, int &highest_intersection_number,
2368 int f_save_largest_sets, data_structures::set_of_sets *&largest_sets,
2369 int verbose_level)
2370{
2371 int f_v = (verbose_level >= 1);
2372 //longinteger_object *R;
2373 long int **Pts_on_conic;
2374 int **Conic_eqn;
2375 int *nb_pts_on_conic;
2376 int nb_conics;
2377 int i, j, idx, f, l, a, t;
2378
2379 if (f_v) {
2380 cout << "projective_space::conic_intersection_type threshold = " << threshold << endl;
2381 }
2382
2383 if (f_randomized) {
2384 if (f_v) {
2385 cout << "projective_space::conic_intersection_type "
2386 "randomized" << endl;
2387 }
2388 conic_type_randomized(nb_times,
2389 set, set_size,
2390 Pts_on_conic, nb_pts_on_conic, nb_conics,
2391 verbose_level - 1);
2392 }
2393 else {
2394 if (f_v) {
2395 cout << "projective_space::conic_intersection_type "
2396 "not randomized" << endl;
2397 }
2398 conic_type(
2399 set, set_size, threshold,
2400 Pts_on_conic, Conic_eqn, nb_pts_on_conic, nb_conics,
2401 verbose_level - 1);
2402 }
2403
2405 int f_second = FALSE;
2406
2407 C.init(nb_pts_on_conic, nb_conics, f_second, 0);
2408 if (f_v) {
2409 cout << "projective_space::conic_intersection_type "
2410 "conic-intersection type: ";
2411 C.print(FALSE /*f_backwards*/);
2412 }
2413
2414 if (f_v) {
2415 cout << "The conic intersection type is (";
2416 C.print_naked(FALSE /*f_backwards*/);
2417 cout << ")" << endl << endl;
2418 }
2419
2420 f = C.type_first[C.nb_types - 1];
2421 highest_intersection_number = C.data_sorted[f];
2422 intersection_type = NEW_int(highest_intersection_number + 1);
2423 Int_vec_zero(intersection_type, highest_intersection_number + 1);
2424 for (i = 0; i < C.nb_types; i++) {
2425 f = C.type_first[i];
2426 l = C.type_len[i];
2427 a = C.data_sorted[f];
2428 intersection_type[a] = l;
2429 }
2430
2431 if (f_save_largest_sets) {
2433 t = C.nb_types - 1;
2434 f = C.type_first[t];
2435 l = C.type_len[t];
2436 largest_sets->init_basic_constant_size(set_size, l,
2437 highest_intersection_number, verbose_level);
2438 for (j = 0; j < l; j++) {
2439 idx = C.sorting_perm_inv[f + j];
2440 Lint_vec_copy(Pts_on_conic[idx],
2441 largest_sets->Sets[j],
2442 highest_intersection_number);
2443 }
2444 }
2445
2446 for (i = 0; i < nb_conics; i++) {
2447 FREE_lint(Pts_on_conic[i]);
2448 FREE_int(Conic_eqn[i]);
2449 }
2450 FREE_plint(Pts_on_conic);
2451 FREE_pint(Conic_eqn);
2452 FREE_int(nb_pts_on_conic);
2453 if (f_v) {
2454 cout << "projective_space::conic_intersection_type done" << endl;
2455 }
2456
2457}
2458
2460 long int *set, int set_size,
2461 std::vector<int> &Rk,
2462 int verbose_level)
2463{
2464 int f_v = (verbose_level >= 1);
2465 int rk, i;
2466 int threshold = 6;
2467 int N;
2468
2469 long int **Pts_on_conic;
2470 int **Conic_eqn;
2471 int *nb_pts_on_conic;
2472 int len;
2473
2474 //geometry_global Gg;
2477
2478 if (f_v) {
2479 cout << "projective_space::determine_nonconical_six_subsets" << endl;
2480 }
2481 if (n != 2) {
2482 cout << "projective_space::determine_nonconical_six_subsets n != 2" << endl;
2483 exit(1);
2484 }
2485
2486 if (f_v) {
2487 cout << "projective_space::determine_nonconical_six_subsets before conic_type" << endl;
2488 }
2489 conic_type(
2490 set, set_size,
2491 threshold,
2492 Pts_on_conic, Conic_eqn, nb_pts_on_conic, len,
2493 0 /*verbose_level*/);
2494 if (f_v) {
2495 cout << "projective_space::determine_nonconical_six_subsets after conic_type" << endl;
2496 }
2497 if (f_v) {
2498 cout << "There are " << len << " conics. They contain the following points:" << endl;
2499 for (i = 0; i < len; i++) {
2500 cout << i << " : " << nb_pts_on_conic[i] << " : ";
2501 Lint_vec_print(cout, Pts_on_conic[i], nb_pts_on_conic[i]);
2502 cout << endl;
2503 }
2504 }
2505
2506 int subset[6];
2507
2508 N = Combi.int_n_choose_k(set_size, 6);
2509
2510 if (f_v) {
2511 cout << "set_size=" << set_size << endl;
2512 cout << "N=number of 6-subsets of the set=" << N << endl;
2513 }
2514
2515
2516 for (rk = 0; rk < N; rk++) {
2517
2518 Combi.unrank_k_subset(rk, subset, set_size, 6);
2519 if (f_v) {
2520 cout << "projective_space::conic_type rk=" << rk << " / " << N << " : ";
2521 Int_vec_print(cout, subset, 6);
2522 cout << endl;
2523 }
2524
2525 for (i = 0; i < len; i++) {
2526 if (Sorting.lint_vec_is_subset_of(subset, 6,
2527 Pts_on_conic[i], nb_pts_on_conic[i], 0 /* verbose_level */)) {
2528
2529#if 1
2530 if (f_v) {
2531 cout << "The set ";
2532 Int_vec_print(cout, subset, 6);
2533 cout << " is a subset of the " << i << "th conic ";
2534 Lint_vec_print(cout,
2535 Pts_on_conic[i], nb_pts_on_conic[i]);
2536 cout << endl;
2537 }
2538#endif
2539
2540 break;
2541 }
2542 else {
2543 if (FALSE) {
2544 cout << " not on conic " << i << endl;
2545 }
2546 }
2547 }
2548 if (i == len) {
2549 Rk.push_back(rk);
2550 }
2551 }
2552
2553 for (i = 0; i < len; i++) {
2554 FREE_lint(Pts_on_conic[i]);
2555 FREE_int(Conic_eqn[i]);
2556 }
2557 FREE_plint(Pts_on_conic);
2558 FREE_pint(Conic_eqn);
2559 FREE_int(nb_pts_on_conic);
2560
2561 int nb, j, nb_E;
2562 int *Nb_E;
2563 long int Arc6[6];
2564
2565 nb = Rk.size();
2566 Nb_E = NEW_int(nb);
2567 if (f_v) {
2568 cout << "computing Eckardt point number distribution" << endl;
2569 }
2570 for (i = 0; i < nb; i++) {
2571 if ((i % 500) == 0) {
2572 cout << i << " / " << nb << endl;
2573 }
2574 rk = Rk[i];
2575 Combi.unrank_k_subset(rk, subset, set_size, 6);
2576 for (j = 0; j < 6; j++) {
2577 Arc6[j] = set[subset[j]];
2578 }
2580 Arc6, 0 /* verbose_level */);
2581 Nb_E[i] = nb_E;
2582 }
2583
2585
2586 T.init(Nb_E, nb, FALSE, 0);
2587 if (f_v) {
2588 cout << "Eckardt point number distribution : ";
2589 T.print_file_tex(cout, TRUE /* f_backwards*/);
2590 cout << endl;
2591 }
2592
2593 if (nb) {
2594 int m, idx;
2595 int *Idx;
2596 int nb_idx;
2597 int *System;
2598
2600 T.get_class_by_value(Idx, nb_idx, m /* value */, verbose_level);
2601 if (f_v) {
2602 cout << "The class of " << m << " is ";
2603 Int_vec_print(cout, Idx, nb_idx);
2604 cout << endl;
2605 }
2606
2607 System = NEW_int(nb_idx * 6);
2608
2609 for (i = 0; i < nb_idx; i++) {
2610 idx = Idx[i];
2611
2612 rk = Rk[idx];
2613 if (f_v) {
2614 cout << i << " / " << nb_idx << " idx=" << idx << ", rk=" << rk << " :" << endl;
2615 }
2616 Combi.unrank_k_subset(rk, subset, set_size, 6);
2617
2618 Int_vec_copy(subset, System + i * 6, 6);
2619
2620 for (j = 0; j < 6; j++) {
2621 Arc6[j] = set[subset[j]];
2622 }
2624 Arc6, 0 /* verbose_level */);
2625 if (nb_E != m) {
2626 cout << "nb_E != m" << endl;
2627 exit(1);
2628 }
2629 if (f_v) {
2630 cout << "The subset is ";
2631 Int_vec_print(cout, subset, 6);
2632 cout << " : ";
2633 cout << " the arc is ";
2634 Lint_vec_print(cout, Arc6, 6);
2635 cout << " nb_E = " << nb_E << endl;
2636 }
2637 }
2638
2640 std::string fname;
2641
2642 fname.assign("set_system.csv");
2643 Fio.int_matrix_write_csv(fname, System, nb_idx, 6);
2644 cout << "Written file " << fname << " of size " << Fio.file_size(fname) << endl;
2645
2646
2648
2649 T2.init(System, nb_idx * 6, FALSE, 0);
2650 if (f_v) {
2651 cout << "distribution of points: ";
2652 T2.print_file_tex(cout, TRUE /* f_backwards*/);
2653 cout << endl;
2654 }
2655
2656
2657 }
2658
2659
2660 if (f_v) {
2661 cout << "projective_space::determine_nonconical_six_subsets done" << endl;
2662 }
2663}
2664
2666 long int *set, int set_size,
2667 int threshold,
2668 long int **&Pts_on_conic, int **&Conic_eqn, int *&nb_pts_on_conic, int &nb_conics,
2669 int verbose_level)
2670{
2671 int f_v = (verbose_level >= 1);
2672 int f_vv = (verbose_level >= 2);
2673 int f_v3 = (verbose_level >= 3);
2674 int rk, h, i, j, a, /*d,*/ N, l;
2675
2676 long int input_pts[5];
2677 int six_coeffs[6];
2678 int vec[3];
2679
2680 int subset[5];
2682 int *coords;
2683 long int *pts_on_conic;
2684 int allocation_length;
2685 geometry_global Gg;
2688
2689 if (f_v) {
2690 cout << "projective_space::conic_type, threshold = " << threshold << endl;
2691 }
2692 if (n != 2) {
2693 cout << "projective_space::conic_type n != 2" << endl;
2694 exit(1);
2695 }
2696 if (f_vv) {
2697 print_set_numerical(cout, set, set_size);
2698 }
2699
2700 if (!Sorting.test_if_set_with_return_value_lint(set, set_size)) {
2701 cout << "projective_space::conic_type the input "
2702 "set if not a set" << endl;
2703 exit(1);
2704 }
2705 //d = n + 1;
2706 N = Combi.int_n_choose_k(set_size, 5);
2707
2708 if (f_v) {
2709 cout << "set_size=" << set_size << endl;
2710 cout << "N=number of 5-subsets of the set=" << N << endl;
2711 }
2712
2713
2714 coords = NEW_int(set_size * 3);
2715 for (i = 0; i < set_size; i++) {
2716 unrank_point(coords + i * 3, set[i]);
2717 }
2718 if (f_v) {
2719 cout << "projective_space::conic_type coords:" << endl;
2720 Int_vec_print_integer_matrix(cout, coords, set_size, 3);
2721 }
2722
2723
2724 // allocate data that is returned:
2725 allocation_length = 1024;
2726 Pts_on_conic = NEW_plint(allocation_length);
2727 Conic_eqn = NEW_pint(allocation_length);
2728 nb_pts_on_conic = NEW_int(allocation_length);
2729
2730
2731 nb_conics = 0;
2732 for (rk = 0; rk < N; rk++) {
2733
2734 Combi.unrank_k_subset(rk, subset, set_size, 5);
2735 if (FALSE) {
2736 cout << "projective_space::conic_type rk=" << rk << " / " << N << " : ";
2737 Int_vec_print(cout, subset, 5);
2738 cout << endl;
2739 }
2740
2741 for (i = 0; i < nb_conics; i++) {
2742 if (Sorting.lint_vec_is_subset_of(subset, 5,
2743 Pts_on_conic[i], nb_pts_on_conic[i], 0)) {
2744
2745#if 0
2746 cout << "The set ";
2747 int_vec_print(cout, subset, 5);
2748 cout << " is a subset of the " << i << "th conic ";
2749 int_vec_print(cout,
2750 Pts_on_conic[i], nb_pts_on_conic[i]);
2751 cout << endl;
2752#endif
2753
2754 break;
2755 }
2756 }
2757 if (i < nb_conics) {
2758 continue;
2759 }
2760 for (j = 0; j < 5; j++) {
2761 a = subset[j];
2762 input_pts[j] = set[a];
2763 }
2764 if (FALSE) {
2765 cout << "subset: ";
2766 Int_vec_print(cout, subset, 5);
2767 cout << endl;
2768 cout << "input_pts: ";
2769 Lint_vec_print(cout, input_pts, 5);
2770 cout << endl;
2771 }
2772
2773 if (!determine_conic_in_plane(input_pts, 5,
2774 six_coeffs, verbose_level - 2)) {
2775 if (FALSE) {
2776 cout << "determine_conic_in_plane returns FALSE" << endl;
2777 }
2778 continue;
2779 }
2780 if (f_v) {
2781 cout << "projective_space::conic_type rk=" << rk << " / " << N << " : ";
2782 Int_vec_print(cout, subset, 5);
2783 cout << " has not yet been considered and a conic exists" << endl;
2784 }
2785 if (f_v) {
2786 cout << "determine_conic_in_plane the conic exists" << endl;
2787 cout << "conic: ";
2788 Int_vec_print(cout, six_coeffs, 6);
2789 cout << endl;
2790 }
2791
2792
2793 F->PG_element_normalize(six_coeffs, 1, 6);
2794 Gg.AG_element_rank_longinteger(F->q, six_coeffs, 1, 6, conic_rk);
2795 if (FALSE /* f_vv */) {
2796 cout << rk << "-th subset ";
2797 Int_vec_print(cout, subset, 5);
2798 cout << " conic_rk=" << conic_rk << endl;
2799 }
2800
2801 if (FALSE /* longinteger_vec_search(R, len, conic_rk, idx) */) {
2802
2803#if 0
2804 cout << "projective_space::conic_type_randomized "
2805 "longinteger_vec_search(R, len, conic_rk, idx) "
2806 "is TRUE" << endl;
2807 cout << "The current set is ";
2808 int_vec_print(cout, subset, 5);
2809 cout << endl;
2810 cout << "conic_rk=" << conic_rk << endl;
2811 cout << "The set where it should be is ";
2812 int_vec_print(cout, Pts_on_conic[idx], nb_pts_on_conic[idx]);
2813 cout << endl;
2814 cout << "R[idx]=" << R[idx] << endl;
2815 cout << "This is the " << idx << "th conic" << endl;
2816 exit(1);
2817#endif
2818
2819 }
2820 else {
2821 if (f_v) {
2822 cout << "considering conic of rank conic_rk=" << conic_rk << ":" << endl;
2823 }
2824 pts_on_conic = NEW_lint(set_size);
2825 l = 0;
2826 for (h = 0; h < set_size; h++) {
2827
2828 //unrank_point(vec, set[h]);
2829 Int_vec_copy(coords + h * 3, vec, 3);
2830 if (f_v) {
2831 cout << "testing point " << h << ":" << endl;
2832 Int_vec_print(cout, vec, 3);
2833 cout << endl;
2834 }
2835 a = F->Linear_algebra->evaluate_conic_form(six_coeffs, vec);
2836
2837
2838 if (a == 0) {
2839 pts_on_conic[l++] = h;
2840 if (FALSE) {
2841 cout << "point " << h
2842 << " is on the conic" << endl;
2843 }
2844 }
2845 else {
2846 if (FALSE && f_v3) {
2847 cout << "point " << h
2848 << " is not on the conic" << endl;
2849 }
2850 }
2851 }
2852 if (f_v) {
2853 cout << "We found an " << l << "-conic, "
2854 "its rank is " << conic_rk << endl;
2855
2856
2857 }
2858
2859
2860 if (l >= threshold) {
2861
2862 if (f_v) {
2863 cout << "We found an " << l << "-conic, "
2864 "its rank is " << conic_rk << endl;
2865 cout << "The " << l << " points on the "
2866 << nb_conics << "th conic are: ";
2867 Lint_vec_print(cout, pts_on_conic, l);
2868 cout << endl;
2869 }
2870
2871
2872#if 0
2873 for (j = len; j > idx; j--) {
2874 R[j].swap_with(R[j - 1]);
2875 Pts_on_conic[j] = Pts_on_conic[j - 1];
2876 nb_pts_on_conic[j] = nb_pts_on_conic[j - 1];
2877 }
2878 conic_rk.assign_to(R[idx]);
2879 Pts_on_conic[idx] = pts_on_conic;
2880 nb_pts_on_conic[idx] = l;
2881#else
2882
2883 //conic_rk.assign_to(R[len]);
2884 Pts_on_conic[nb_conics] = pts_on_conic;
2885 Conic_eqn[nb_conics] = NEW_int(6);
2886 Int_vec_copy(six_coeffs, Conic_eqn[nb_conics], 6);
2887 nb_pts_on_conic[nb_conics] = l;
2888
2889#endif
2890
2891
2892 nb_conics++;
2893 if (f_v) {
2894 cout << "We now have found " << nb_conics
2895 << " conics" << endl;
2896
2897
2899 int f_second = FALSE;
2900
2901 C.init(nb_pts_on_conic, nb_conics, f_second, 0);
2902
2903 if (f_v) {
2904 cout << "The conic intersection type is (";
2905 C.print_naked(FALSE /*f_backwards*/);
2906 cout << ")" << endl << endl;
2907 }
2908
2909
2910
2911 }
2912
2913 if (nb_conics == allocation_length) {
2914 int new_allocation_length = allocation_length + 1024;
2915
2916
2917 long int **Pts_on_conic1;
2918 int **Conic_eqn1;
2919 int *nb_pts_on_conic1;
2920
2921 Pts_on_conic1 = NEW_plint(new_allocation_length);
2922 Conic_eqn1 = NEW_pint(new_allocation_length);
2923 nb_pts_on_conic1 = NEW_int(new_allocation_length);
2924 for (i = 0; i < nb_conics; i++) {
2925 //R1[i] = R[i];
2926 Pts_on_conic1[i] = Pts_on_conic[i];
2927 Conic_eqn1[i] = Conic_eqn[i];
2928 nb_pts_on_conic1[i] = nb_pts_on_conic[i];
2929 }
2930 FREE_plint(Pts_on_conic);
2931 FREE_pint(Conic_eqn);
2932 FREE_int(nb_pts_on_conic);
2933 Pts_on_conic = Pts_on_conic1;
2934 Conic_eqn = Conic_eqn1;
2935 nb_pts_on_conic = nb_pts_on_conic1;
2936 allocation_length = new_allocation_length;
2937 }
2938
2939
2940
2941
2942 }
2943 else {
2944 // we skip this conic:
2945 if (f_v) {
2946 cout << "projective_space::conic_type we skip this conic" << endl;
2947 }
2948 FREE_lint(pts_on_conic);
2949 }
2950 } // else
2951 } // next rk
2952
2953 FREE_int(coords);
2954
2955 if (f_v) {
2956 cout << "projective_space::conic_type we found " << nb_conics
2957 << " conics intersecting in at least "
2958 << threshold << " many points" << endl;
2959 }
2960
2961 if (f_v) {
2962 cout << "projective_space::conic_type done" << endl;
2963 }
2964}
2965
2967 int *set, int set_size, int &nucleus,
2968 int verbose_level)
2969{
2970 int f_v = (verbose_level >= 1);
2971 int i, j, a, b, l, sz, idx, t1, t2;
2972 int *Lines;
2974
2975 if (f_v) {
2976 cout << "projective_space::find_nucleus" << endl;
2977 }
2978
2979 if (n != 2) {
2980 cout << "projective_space::find_nucleus n != 2" << endl;
2981 exit(1);
2982 }
2983 if (set_size != F->q + 1) {
2984 cout << "projective_space::find_nucleus "
2985 "set_size != F->q + 1" << endl;
2986 exit(1);
2987 }
2988
2989 if (Implementation->Lines_on_point == NULL) {
2990 init_incidence_structure(verbose_level);
2991 }
2992
2993 Lines = NEW_int(r);
2994 a = set[0];
2995 for (i = 0; i < r; i++) {
2996 Lines[i] = Implementation->Lines_on_point[a * r + i];
2997 }
2998 sz = r;
2999 Sorting.int_vec_heapsort(Lines, r);
3000
3001 for (i = 0; i < set_size - 1; i++) {
3002 b = set[1 + i];
3003 l = line_through_two_points(a, b);
3004 if (!Sorting.int_vec_search(Lines, sz, l, idx)) {
3005 cout << "projective_space::find_nucleus "
3006 "cannot find secant in pencil" << endl;
3007 exit(1);
3008 }
3009 for (j = idx + 1; j < sz; j++) {
3010 Lines[j - 1] = Lines[j];
3011 }
3012 sz--;
3013 }
3014 if (sz != 1) {
3015 cout << "projective_space::find_nucleus sz != 1" << endl;
3016 exit(1);
3017 }
3018 t1 = Lines[0];
3019 if (f_v) {
3020 cout << "projective_space::find_nucleus t1 = " << t1 << endl;
3021 }
3022
3023
3024
3025 a = set[1];
3026 for (i = 0; i < r; i++) {
3027 Lines[i] = Implementation->Lines_on_point[a * r + i];
3028 }
3029 sz = r;
3030 Sorting.int_vec_heapsort(Lines, r);
3031
3032 for (i = 0; i < set_size - 1; i++) {
3033 if (i == 0) {
3034 b = set[0];
3035 }
3036 else {
3037 b = set[1 + i];
3038 }
3039 l = line_through_two_points(a, b);
3040 if (!Sorting.int_vec_search(Lines, sz, l, idx)) {
3041 cout << "projective_space::find_nucleus "
3042 "cannot find secant in pencil" << endl;
3043 exit(1);
3044 }
3045 for (j = idx + 1; j < sz; j++) {
3046 Lines[j - 1] = Lines[j];
3047 }
3048 sz--;
3049 }
3050 if (sz != 1) {
3051 cout << "projective_space::find_nucleus sz != 1" << endl;
3052 exit(1);
3053 }
3054 t2 = Lines[0];
3055 if (f_v) {
3056 cout << "projective_space::find_nucleus t2 = " << t2 << endl;
3057 }
3058
3059 nucleus = intersection_of_two_lines(t1, t2);
3060 if (f_v) {
3061 cout << "projective_space::find_nucleus "
3062 "nucleus = " << nucleus << endl;
3063 int v[3];
3064 unrank_point(v, nucleus);
3065 cout << "nucleus = ";
3066 Int_vec_print(cout, v, 3);
3067 cout << endl;
3068 }
3069
3070
3071
3072 if (f_v) {
3073 cout << "projective_space::find_nucleus done" << endl;
3074 }
3075}
3076
3078 long int *&set, int &set_size, long int *three_points,
3079 int verbose_level)
3080{
3081 int f_v = (verbose_level >= 1);
3082 long int three_lines[3];
3083 long int *Pts;
3084 int sz, h, i, a;
3086
3087 if (f_v) {
3088 cout << "projective_space::points_on_projective_triangle" << endl;
3089 }
3090 set_size = 3 * (q - 1);
3091 set = NEW_lint(set_size);
3092 sz = 3 * (q + 1);
3093 Pts = NEW_lint(sz);
3094 three_lines[0] = line_through_two_points(three_points[0], three_points[1]);
3095 three_lines[1] = line_through_two_points(three_points[0], three_points[2]);
3096 three_lines[2] = line_through_two_points(three_points[1], three_points[2]);
3097
3098 create_points_on_line(three_lines[0], Pts, 0 /* verbose_level */);
3099 create_points_on_line(three_lines[1], Pts + (q + 1), 0 /* verbose_level */);
3100 create_points_on_line(three_lines[2], Pts + 2 * (q + 1), 0 /* verbose_level */);
3101 h = 0;
3102 for (i = 0; i < sz; i++) {
3103 a = Pts[i];
3104 if (a == three_points[0]) {
3105 continue;
3106 }
3107 if (a == three_points[1]) {
3108 continue;
3109 }
3110 if (a == three_points[2]) {
3111 continue;
3112 }
3113 set[h++] = a;
3114 }
3115 if (h != set_size) {
3116 cout << "projective_space::points_on_projective_triangle "
3117 "h != set_size" << endl;
3118 exit(1);
3119 }
3120 Sorting.lint_vec_heapsort(set, set_size);
3121
3122 FREE_lint(Pts);
3123 if (f_v) {
3124 cout << "projective_space::points_on_projective_triangle "
3125 "done" << endl;
3126 }
3127}
3128
3130 int *A6, int *Pts, int nb_pts, int *&Table,
3131 int verbose_level)
3132{
3133 int f_v = (verbose_level >= 1);
3134 int i, j, k;
3135 int pi, pj, pk;
3137
3138 if (f_v) {
3139 cout << "projective_space::elliptic_curve_addition_table" << endl;
3140 }
3141 Table = NEW_int(nb_pts * nb_pts);
3142 for (i = 0; i < nb_pts; i++) {
3143 pi = Pts[i];
3144 for (j = 0; j < nb_pts; j++) {
3145 pj = Pts[j];
3146 pk = elliptic_curve_addition(A6, pi, pj,
3147 0 /* verbose_level */);
3148 if (!Sorting.int_vec_search(Pts, nb_pts, pk, k)) {
3149 cout << "projective_space::elliptic_curve_addition_table cannot find point pk" << endl;
3150 cout << "i=" << i << " pi=" << pi << " j=" << j
3151 << " pj=" << pj << " pk=" << pk << endl;
3152 cout << "Pts: ";
3153 Int_vec_print(cout, Pts, nb_pts);
3154 cout << endl;
3155 exit(1);
3156 }
3157 Table[i * nb_pts + j] = k;
3158 }
3159 }
3160 if (f_v) {
3161 cout << "projective_space::elliptic_curve_addition_table done" << endl;
3162 }
3163}
3164
3166 int *A6, int p1_rk, int p2_rk,
3167 int verbose_level)
3168{
3169 int f_v = (verbose_level >= 1);
3170 int f_vv = (verbose_level >= 2);
3171 int p1[3];
3172 int p2[3];
3173 int p3[3];
3174 int x1, y1, z1;
3175 int x2, y2, z2;
3176 int x3, y3, z3;
3177 int a1, a2, a3, a4, a6;
3178 int p3_rk;
3179
3180 if (f_v) {
3181 cout << "projective_space::elliptic_curve_addition" << endl;
3182 }
3183
3184 a1 = A6[0];
3185 a2 = A6[1];
3186 a3 = A6[2];
3187 a4 = A6[3];
3188 a6 = A6[5];
3189
3190 unrank_point(p1, p1_rk);
3191 unrank_point(p2, p2_rk);
3192 F->PG_element_normalize(p1, 1, 3);
3193 F->PG_element_normalize(p2, 1, 3);
3194
3195 x1 = p1[0];
3196 y1 = p1[1];
3197 z1 = p1[2];
3198 x2 = p2[0];
3199 y2 = p2[1];
3200 z2 = p2[2];
3201 if (f_vv) {
3202 cout << "projective_space::elliptic_curve_addition "
3203 "x1=" << x1 << " y1=" << y1 << " z1=" << z1 << endl;
3204 cout << "projective_space::elliptic_curve_addition "
3205 "x2=" << x2 << " y2=" << y2 << " z2=" << z2 << endl;
3206 }
3207 if (z1 == 0) {
3208 if (p1_rk != 1) {
3209 cout << "projective_space::elliptic_curve_addition "
3210 "z1 == 0 && p1_rk != 1" << endl;
3211 exit(1);
3212 }
3213 x3 = x2;
3214 y3 = y2;
3215 z3 = z2;
3216#if 0
3217 if (z2 == 0) {
3218 if (p2_rk != 1) {
3219 cout << "projective_space::elliptic_curve_addition "
3220 "z2 == 0 && p2_rk != 1" << endl;
3221 exit(1);
3222 }
3223 x3 = 0;
3224 y3 = 1;
3225 z3 = 0;
3226 }
3227 else {
3228 x3 = x2;
3229 y3 = F->negate(F->add3(y2, F->mult(a1, x2), a3));
3230 z3 = 1;
3231 }
3232#endif
3233
3234 }
3235 else if (z2 == 0) {
3236 if (p2_rk != 1) {
3237 cout << "projective_space::elliptic_curve_addition "
3238 "z2 == 0 && p2_rk != 1" << endl;
3239 exit(1);
3240 }
3241 x3 = x1;
3242 y3 = y1;
3243 z3 = z1;
3244
3245#if 0
3246 // at this point, we know that z1 is not zero.
3247 x3 = x1;
3248 y3 = F->negate(F->add3(y1, F->mult(a1, x1), a3));
3249 z3 = 1;
3250#endif
3251
3252 }
3253 else {
3254 // now both points are affine.
3255
3256
3257 int lambda_top, lambda_bottom, lambda, nu_top, nu_bottom, nu;
3258 int three, two; //, m_one;
3259 int c;
3260
3261 c = F->add4(y1, y2, F->mult(a1, x2), a3);
3262
3263 if (x1 == x2 && c == 0) {
3264 x3 = 0;
3265 y3 = 1;
3266 z3 = 0;
3267 }
3268 else {
3269
3270 two = F->add(1, 1);
3271 three = F->add(two, 1);
3272 //m_one = F->negate(1);
3273
3274
3275
3276 if (x1 == x2) {
3277
3278 // point duplication:
3279 lambda_top = F->add4(F->mult3(three, x1, x1),
3280 F->mult3(two, a2, x1), a4,
3281 F->negate(F->mult(a1, y1)));
3282 lambda_bottom = F->add3(F->mult(two, y1),
3283 F->mult(a1, x1), a3);
3284
3285 nu_top = F->add4(F->negate(F->mult3(x1, x1, x1)),
3286 F->mult(a4, x1), F->mult(two, a6),
3287 F->negate(F->mult(a3, y1)));
3288 nu_bottom = F->add3(F->mult(two, y1),
3289 F->mult(a1, x1), a3);
3290
3291 }
3292 else {
3293 // adding different points:
3294 lambda_top = F->add(y2, F->negate(y1));
3295 lambda_bottom = F->add(x2, F->negate(x1));
3296
3297 nu_top = F->add(F->mult(y1, x2), F->negate(F->mult(y2, x1)));
3298 nu_bottom = lambda_bottom;
3299 }
3300
3301
3302 if (lambda_bottom == 0) {
3303 cout << "projective_space::elliptic_curve_addition "
3304 "lambda_bottom == 0" << endl;
3305 cout << "projective_space::elliptic_curve_addition "
3306 "x1=" << x1 << " y1=" << y1 << " z1=" << z1 << endl;
3307 cout << "projective_space::elliptic_curve_addition "
3308 "x2=" << x2 << " y2=" << y2 << " z2=" << z2 << endl;
3309 cout << "projective_space::elliptic_curve_addition "
3310 "a1=" << a1 << endl;
3311 cout << "projective_space::elliptic_curve_addition "
3312 "a2=" << a2 << endl;
3313 cout << "projective_space::elliptic_curve_addition "
3314 "a3=" << a3 << endl;
3315 cout << "projective_space::elliptic_curve_addition "
3316 "a4=" << a4 << endl;
3317 cout << "projective_space::elliptic_curve_addition "
3318 "a6=" << a6 << endl;
3319 exit(1);
3320 }
3321 lambda = F->mult(lambda_top, F->inverse(lambda_bottom));
3322
3323 if (nu_bottom == 0) {
3324 cout << "projective_space::elliptic_curve_addition "
3325 "nu_bottom == 0" << endl;
3326 exit(1);
3327 }
3328 nu = F->mult(nu_top, F->inverse(nu_bottom));
3329
3330 if (f_vv) {
3331 cout << "projective_space::elliptic_curve_addition "
3332 "a1=" << a1 << endl;
3333 cout << "projective_space::elliptic_curve_addition "
3334 "a2=" << a2 << endl;
3335 cout << "projective_space::elliptic_curve_addition "
3336 "a3=" << a3 << endl;
3337 cout << "projective_space::elliptic_curve_addition "
3338 "a4=" << a4 << endl;
3339 cout << "projective_space::elliptic_curve_addition "
3340 "a6=" << a6 << endl;
3341 cout << "projective_space::elliptic_curve_addition "
3342 "three=" << three << endl;
3343 cout << "projective_space::elliptic_curve_addition "
3344 "lambda_top=" << lambda_top << endl;
3345 cout << "projective_space::elliptic_curve_addition "
3346 "lambda=" << lambda << " nu=" << nu << endl;
3347 }
3348 x3 = F->add3(F->mult(lambda, lambda), F->mult(a1, lambda),
3349 F->negate(F->add3(a2, x1, x2)));
3350 y3 = F->negate(F->add3(F->mult(F->add(lambda, a1), x3), nu, a3));
3351 z3 = 1;
3352 }
3353 }
3354 p3[0] = x3;
3355 p3[1] = y3;
3356 p3[2] = z3;
3357 if (f_vv) {
3358 cout << "projective_space::elliptic_curve_addition "
3359 "x3=" << x3 << " y3=" << y3 << " z3=" << z3 << endl;
3360 }
3361 p3_rk = rank_point(p3);
3362 if (f_v) {
3363 cout << "projective_space::elliptic_curve_addition "
3364 "done" << endl;
3365 }
3366 return p3_rk;
3367}
3368
3369
3371 long int *Lines, int nb_lines, int *&M, int &nb_planes,
3372 int verbose_level)
3373{
3374 int f_v = (verbose_level >= 1);
3375 int *the_lines;
3376 int line_sz;
3377 int *Basis; // 3 * (n + 1)
3378 int *Work; // 5 * (n + 1)
3379 int i, j;
3380
3381 if (f_v) {
3382 cout << "projective_space::line_plane_incidence_matrix_restricted" << endl;
3383 }
3384 if (n <= 2) {
3385 cout << "projective_space::line_plane_incidence_matrix_"
3386 "restricted n <= 2" << endl;
3387 exit(1);
3388 }
3389 line_sz = 2 * (n + 1);
3390 nb_planes = Nb_subspaces[2];
3391
3392 M = NEW_int(nb_lines * nb_planes);
3393 Basis = NEW_int(3 * (n + 1));
3394 Work = NEW_int(5 * (n + 1));
3395 the_lines = NEW_int(nb_lines * line_sz);
3396
3397
3398 Int_vec_zero(M, nb_lines * nb_planes);
3399 for (i = 0; i < nb_lines; i++) {
3400 unrank_line(the_lines + i * line_sz, Lines[i]);
3401 }
3402 for (j = 0; j < nb_planes; j++) {
3403 unrank_plane(Basis, j);
3404 for (i = 0; i < nb_lines; i++) {
3405 Int_vec_copy(Basis, Work, 3 * (n + 1));
3406 Int_vec_copy(the_lines + i * line_sz,
3407 Work + 3 * (n + 1), line_sz);
3408 if (F->Linear_algebra->Gauss_easy(Work, 5, n + 1) == 3) {
3409 M[i * nb_planes + j] = 1;
3410 }
3411 }
3412 }
3413 FREE_int(Work);
3414 FREE_int(Basis);
3415 FREE_int(the_lines);
3416 if (f_v) {
3417 cout << "projective_space::line_plane_incidence_matrix_restricted done" << endl;
3418 }
3419}
3420
3422 int line1, int line2, int verbose_level)
3423{
3424 int f_v = (verbose_level >= 1);
3425 int Basis1[4 * 4];
3426 int Basis2[4 * 4];
3427 int rk;
3428 int M[16];
3429
3430 if (f_v) {
3431 cout << "projective_space::test_if_lines_are_skew" << endl;
3432 }
3433 if (n != 3) {
3434 cout << "projective_space::test_if_lines_are_skew "
3435 "n != 3" << endl;
3436 exit(1);
3437 }
3438 if (f_v) {
3439 cout << "line1=" << line1 << " line2=" << line2 << endl;
3440 }
3441 unrank_line(Basis1, line1);
3442 if (f_v) {
3443 cout << "line1:" << endl;
3444 Int_matrix_print(Basis1, 2, 4);
3445 }
3446 unrank_line(Basis2, line2);
3447 if (f_v) {
3448 cout << "line2:" << endl;
3449 Int_matrix_print(Basis2, 2, 4);
3450 }
3451 F->Linear_algebra->intersect_subspaces(4, 2, Basis1, 2, Basis2,
3452 rk, M, 0 /* verbose_level */);
3453
3454 if (f_v) {
3455 cout << "projective_space::test_if_lines_are_skew done" << endl;
3456 }
3457
3458 if (rk == 0) {
3459 return TRUE;
3460 }
3461 else {
3462 return FALSE;
3463 }
3464}
3465
3467 long int line1, long int line2, int verbose_level)
3468{
3469 int f_v = (verbose_level >= 1);
3470 int Basis1[4 * 4];
3471 int Basis2[4 * 4];
3472 int rk, a;
3473 int M[16];
3474
3475 if (f_v) {
3476 cout << "projective_space::point_of_intersection_of_a_line_and_a_line_in_three_space" << endl;
3477 }
3478 if (n != 3) {
3479 cout << "projective_space::point_of_intersection_of_a_line_and_a_line_in_three_space n != 3" << endl;
3480 exit(1);
3481 }
3482 if (f_v) {
3483 cout << "line1=" << line1 << " line2=" << line2 << endl;
3484 }
3485 unrank_line(Basis1, line1);
3486 if (f_v) {
3487 cout << "line1:" << endl;
3488 Int_matrix_print(Basis1, 2, 4);
3489 }
3490 unrank_line(Basis2, line2);
3491 if (f_v) {
3492 cout << "line2:" << endl;
3493 Int_matrix_print(Basis2, 2, 4);
3494 }
3495 F->Linear_algebra->intersect_subspaces(4, 2, Basis1, 2, Basis2,
3496 rk, M, 0 /* verbose_level */);
3497 if (rk != 1) {
3498 cout << "projective_space::point_of_intersection_of_a_line_and_a_line_in_three_space intersection "
3499 "is not a point" << endl;
3500 cout << "line1:" << endl;
3501 Int_matrix_print(Basis1, 2, 4);
3502 cout << "line2:" << endl;
3503 Int_matrix_print(Basis2, 2, 4);
3504 cout << "rk = " << rk << endl;
3505 exit(1);
3506 }
3507 if (f_v) {
3508 cout << "intersection:" << endl;
3509 Int_matrix_print(M, 1, 4);
3510 }
3511 a = rank_point(M);
3512 if (f_v) {
3513 cout << "point rank = " << a << endl;
3514 }
3515 if (f_v) {
3516 cout << "projective_space::point_of_intersection_of_a_line_and_a_line_in_three_space done" << endl;
3517 }
3518 return a;
3519}
3520
3522 long int line, int plane, int verbose_level)
3523{
3524 int f_v = (verbose_level >= 1);
3525 int Basis1[4 * 4];
3526 int Basis2[4 * 4];
3527 int rk, a;
3528 int M[16];
3529
3530 if (f_v) {
3531 cout << "projective_space::point_of_intersection_of_a_line_and_a_plane_in_three_space" << endl;
3532 }
3533 if (n != 3) {
3534 cout << "projective_space::point_of_intersection_of_a_line_and_a_plane_in_three_space n != 3" << endl;
3535 exit(1);
3536 }
3537 if (f_v) {
3538 cout << "line=" << line << " plane=" << plane << endl;
3539 }
3540 unrank_line(Basis1, line);
3541 if (f_v) {
3542 cout << "line:" << endl;
3543 Int_matrix_print(Basis1, 2, 4);
3544 }
3545 unrank_plane(Basis2, plane);
3546 if (f_v) {
3547 cout << "plane:" << endl;
3548 Int_matrix_print(Basis2, 3, 4);
3549 }
3550 F->Linear_algebra->intersect_subspaces(4, 2, Basis1, 3, Basis2,
3551 rk, M, 0 /* verbose_level */);
3552 if (rk != 1) {
3553 cout << "projective_space::point_of_intersection_of_a_line_and_a_plane_in_three_space intersection "
3554 "is not a point" << endl;
3555 }
3556 if (f_v) {
3557 cout << "intersection:" << endl;
3558 Int_matrix_print(M, 1, 4);
3559 }
3560 a = rank_point(M);
3561 if (f_v) {
3562 cout << "point rank = " << a << endl;
3563 }
3564 if (f_v) {
3565 cout << "projective_space::point_of_intersection_of_a_line_and_a_plane_in_three_space done" << endl;
3566 }
3567 return a;
3568}
3569
3571 long int plane1, long int plane2, int verbose_level)
3572{
3573 int f_v = (verbose_level >= 1);
3574 int Basis1[3 * 4];
3575 int Basis2[3 * 4];
3576 int rk, a;
3577 int M[16];
3578
3579 if (f_v) {
3580 cout << "projective_space::line_of_intersection_of_two_planes_in_three_space" << endl;
3581 }
3582 if (n != 3) {
3583 cout << "projective_space::line_of_intersection_of_"
3584 "two_planes_in_three_space n != 3" << endl;
3585 exit(1);
3586 }
3587 unrank_plane(Basis1, plane1);
3588 unrank_plane(Basis2, plane2);
3589 F->Linear_algebra->intersect_subspaces(4, 3, Basis1, 3, Basis2,
3590 rk, M, 0 /* verbose_level */);
3591 if (rk != 2) {
3592 cout << "projective_space::line_of_intersection_of_two_planes_in_three_space intersection is not a line" << endl;
3593 }
3594 a = rank_line(M);
3595 if (f_v) {
3596 cout << "projective_space::line_of_intersection_of_two_planes_in_three_space done" << endl;
3597 }
3598 return a;
3599}
3600
3602 long int plane1, long int plane2, int verbose_level)
3603{
3604 int f_v = (verbose_level >= 1);
3605 int Plane1[4];
3606 int Plane2[4];
3607 int Basis[16];
3608 long int rk;
3609
3610 if (f_v) {
3611 cout << "projective_space::line_of_intersection_of_two_planes_in_three_space_using_dual_coordinates" << endl;
3612 }
3613 if (n != 3) {
3614 cout << "projective_space::line_of_intersection_of_two_planes_in_three_space_using_dual_coordinates "
3615 "n != 3" << endl;
3616 exit(1);
3617 }
3618
3619 unrank_point(Plane1, plane1);
3620 unrank_point(Plane2, plane2);
3621
3622 Int_vec_copy(Plane1, Basis, 4);
3623 Int_vec_copy(Plane2, Basis + 4, 4);
3624 F->Linear_algebra->RREF_and_kernel(4, 2, Basis, 0 /* verbose_level */);
3625 rk = Grass_lines->rank_lint_here(Basis + 8, 0 /* verbose_level */);
3626 if (f_v) {
3627 cout << "projective_space::line_of_intersection_of_two_planes_in_three_space_using_dual_coordinates done" << endl;
3628 }
3629 return rk;
3630}
3631
3633 long int line1, long int line2, int pt, int verbose_level)
3634{
3635 int f_v = (verbose_level >= 1);
3636 int Basis1[4 * 4];
3637 int Basis2[4 * 4];
3638 int Basis3[4 * 4];
3639 long int a;
3640
3641 if (f_v) {
3642 cout << "projective_space::transversal_to_two_skew_lines_through_a_point" << endl;
3643 }
3644 if (n != 3) {
3645 cout << "projective_space::transversal_to_two_skew_lines_through_a_point "
3646 "n != 3" << endl;
3647 exit(1);
3648 }
3649 unrank_line(Basis1, line1);
3650 unrank_point(Basis1 + 8, pt);
3651 unrank_line(Basis2, line2);
3652 unrank_point(Basis2 + 8, pt);
3653 F->Linear_algebra->RREF_and_kernel(4, 3, Basis1, 0 /* verbose_level */);
3654 F->Linear_algebra->RREF_and_kernel(4, 3, Basis2, 0 /* verbose_level */);
3655 Int_vec_copy(Basis1 + 12, Basis3, 4);
3656 Int_vec_copy(Basis2 + 12, Basis3 + 4, 4);
3657 F->Linear_algebra->RREF_and_kernel(4, 2, Basis3, 0 /* verbose_level */);
3658 a = rank_line(Basis3 + 8);
3659 if (f_v) {
3660 cout << "projective_space::transversal_to_two_skew_lines_through_a_point "
3661 "done" << endl;
3662 }
3663 return a;
3664}
3665
3666
3667
3669 long int *Planes, int nb_planes, int *&Intersection_matrix,
3670 int verbose_level)
3671{
3672 int f_v = (verbose_level >= 1);
3673 int i, j, a, b, rk;
3674
3675 if (f_v) {
3676 cout << "projective_space::plane_intersection_matrix_in_three_space" << endl;
3677 }
3678 Intersection_matrix = NEW_int(nb_planes * nb_planes);
3679 for (i = 0; i < nb_planes; i++) {
3680 a = Planes[i];
3681 for (j = i + 1; j < nb_planes; j++) {
3682 b = Planes[j];
3683 Intersection_matrix[i * nb_planes + j] = -1;
3685 a, b, 0 /* verbose_level */);
3686 Intersection_matrix[i * nb_planes + j] = rk;
3687 Intersection_matrix[j * nb_planes + i] = rk;
3688 }
3689 }
3690 for (i = 0; i < nb_planes; i++) {
3691 Intersection_matrix[i * nb_planes + i] = -1;
3692 }
3693
3694 if (f_v) {
3695 cout << "projective_space::plane_intersection_matrix_in_three_space done" << endl;
3696 }
3697}
3698
3700 int *eqn3, int verbose_level)
3701{
3702 int f_v = (verbose_level >= 1);
3703 int Basis[3 * 3];
3704 int rk;
3705 long int line_rk;
3706
3707 if (f_v) {
3708 cout << "projective_space::line_rank_using_dual_coordinates_in_plane" << endl;
3709 }
3710 Int_vec_copy(eqn3, Basis, 3);
3711 rk = F->Linear_algebra->RREF_and_kernel(3, 1, Basis, 0 /* verbose_level*/);
3712 if (rk != 1) {
3713 cout << "projective_space::line_rank_using_dual_coordinates_in_plane rk != 1" << endl;
3714 exit(1);
3715 }
3716 line_rk = rank_line(Basis + 1 * 3);
3717 if (f_v) {
3718 cout << "projective_space::line_rank_using_dual_coordinates_in_plane" << endl;
3719 }
3720 return line_rk;
3721}
3722
3724 long int line_rank, int verbose_level)
3725{
3726 int f_v = (verbose_level >= 1);
3727 int Basis[3 * 3];
3728 int rk;
3729 long int dual_rk;
3730
3731 if (f_v) {
3732 cout << "projective_space::dual_rank_of_line_in_plane" << endl;
3733 }
3734 unrank_line(Basis, line_rank);
3735 rk = F->Linear_algebra->RREF_and_kernel(3, 2, Basis, 0 /* verbose_level*/);
3736 if (rk != 2) {
3737 cout << "projective_space::dual_rank_of_line_in_plane rk != 2" << endl;
3738 exit(1);
3739 }
3740 dual_rk = rank_point(Basis + 2 * 3);
3741 if (f_v) {
3742 cout << "projective_space::dual_rank_of_line_in_plane done" << endl;
3743 }
3744 return dual_rk;
3745}
3746
3747
3748
3750 int *eqn4, int verbose_level)
3751{
3752 int f_v = (verbose_level >= 1);
3753 int Basis[4 * 4];
3754 int rk;
3755 long int plane_rk;
3756
3757 if (f_v) {
3758 cout << "projective_space::plane_rank_using_dual_coordinates_in_three_space" << endl;
3759 }
3760 Int_vec_copy(eqn4, Basis, 4);
3761 rk = F->Linear_algebra->RREF_and_kernel(4, 1, Basis, 0 /* verbose_level*/);
3762 if (rk != 1) {
3763 cout << "projective_space::plane_rank_using_dual_coordinates_in_three_space rk != 1" << endl;
3764 exit(1);
3765 }
3766 plane_rk = rank_plane(Basis + 1 * 4);
3767 if (f_v) {
3768 cout << "projective_space::plane_rank_using_dual_coordinates_in_three_space" << endl;
3769 }
3770 return plane_rk;
3771}
3772
3774 long int plane_rank, int verbose_level)
3775{
3776 int f_v = (verbose_level >= 1);
3777 int Basis[4 * 4];
3778 int rk;
3779 long int dual_rk;
3780
3781 if (f_v) {
3782 cout << "projective_space::dual_rank_of_plane_in_three_space" << endl;
3783 }
3784 unrank_plane(Basis, plane_rank);
3785 rk = F->Linear_algebra->RREF_and_kernel(4, 3, Basis, 0 /* verbose_level*/);
3786 if (rk != 3) {
3787 cout << "projective_space::dual_rank_of_plane_"
3788 "in_three_space rk != 3" << endl;
3789 exit(1);
3790 }
3791 dual_rk = rank_point(Basis + 3 * 4);
3792 if (f_v) {
3793 cout << "projective_space::dual_rank_of_plane_in_three_space done" << endl;
3794 }
3795 return dual_rk;
3796}
3797
3799 long int *three_lines, int *plane_eqn4, int verbose_level)
3800{
3801 int f_v = (verbose_level >= 1);
3802 int Basis[6 * 4];
3803 int rk;
3804
3805 if (f_v) {
3806 cout << "projective_space::plane_equation_from_three_lines_in_three_space" << endl;
3807 }
3808 unrank_lines(Basis, three_lines, 3);
3809 rk = F->Linear_algebra->RREF_and_kernel(4, 6, Basis, 0 /* verbose_level*/);
3810 if (rk != 3) {
3811 cout << "projective_space::plane_equation_from_three_lines_in_three_space rk != 3" << endl;
3812 exit(1);
3813 }
3814 Int_vec_copy(Basis + 3 * 4, plane_eqn4, 4);
3815
3816 if (f_v) {
3817 cout << "projective_space::plane_equation_from_three_lines_in_three_space done" << endl;
3818 }
3819}
3820
3822 int nb_subsets, int *sz, int **subsets,
3823 incidence_structure *&Inc,
3825 int verbose_level)
3826// this function is not used
3827// this function used to be called decomposition
3828{
3829 int f_v = (verbose_level >= 1);
3830 int nb_pts, nb_lines;
3831 int *Mtx;
3832 int *part;
3833 int i, j, level;
3834
3835 if (f_v) {
3836 cout << "projective_space::decomposition_from_set_partition" << endl;
3837 }
3838 nb_pts = N_points;
3839 nb_lines = N_lines;
3840 if (f_v) {
3841 cout << "m = N_points = " << nb_pts << endl;
3842 cout << "n = N_lines = " << nb_lines << endl;
3843 }
3844 part = NEW_int(nb_subsets);
3845 Mtx = NEW_int(nb_pts * nb_lines);
3846 for (i = 0; i < nb_pts; i++) {
3847 for (j = 0; j < nb_lines; j++) {
3848 Mtx[i * nb_lines + j] = is_incident(i, j);
3849 }
3850 }
3852 Inc->init_by_matrix(nb_pts, nb_lines, Mtx, verbose_level - 2);
3853
3854
3855
3856
3857 int /*ht0,*/ c, l;
3858
3860 Stack->allocate(nb_pts + nb_lines, 0);
3861 Stack->subset_continguous(Inc->nb_points(), Inc->nb_lines());
3862 Stack->split_cell(0);
3863
3864
3865
3866 for (level = 0; level < nb_subsets; level++) {
3867
3868
3869 //ht0 = Stack->ht;
3870
3871 if (sz[level]) {
3872 c = Stack->cellNumber[Stack->invPointList[subsets[level][0]]];
3873 l = Stack->cellSize[c];
3874 if (sz[level] < l) {
3875 Stack->split_cell(subsets[level], sz[level], 0);
3876 part[level] = Stack->ht - 1;
3877 }
3878 else {
3879 part[level] = c;
3880 }
3881 }
3882 else {
3883 part[level] = -1;
3884 }
3885
3886
3887 if (f_v) {
3888 cout << "projective_space::decomposition level " << level
3889 << " : partition stack after splitting:" << endl;
3890 Stack->print(cout);
3891 cout << "i : part[i]" << endl;
3892 for (i = 0; i < nb_subsets; i++) {
3893 cout << setw(3) << i << " : " << setw(3) << part[i] << endl;
3894 }
3895 }
3896
3897
3898#if 0
3899 int hash;
3900 int TDO_depth;
3901 int f_labeled = TRUE;
3902 int f_vv = (verbose_level >= 2);
3903
3904
3905 TDO_depth = nb_pts + nb_lines;
3906
3907 if (f_vv) {
3908 cout << "projective_space::decomposition_from_set_partition "
3909 "before compute_TDO" << endl;
3910 }
3911 hash = Inc->compute_TDO(*Stack, ht0, TDO_depth, verbose_level + 2);
3912 if (f_vv) {
3913 cout << "projective_space::decomposition_from_set_partition "
3914 "after compute_TDO" << endl;
3915 }
3916
3917 if (FALSE) {
3918 Inc->print_partitioned(cout, *Stack, f_labeled);
3919 }
3920 if (f_v) {
3922 Stack->print_classes(cout);
3923 }
3924#endif
3925
3926 }
3927
3928
3929 FREE_int(part);
3930 FREE_int(Mtx);
3931 if (f_v) {
3932 cout << "projective_space::decomposition_from_set_partition done" << endl;
3933 }
3934}
3935
3936
3937
3939 long int line_rk, std::vector<long int> &plane_ranks,
3940 int verbose_level)
3941{
3942 int f_v = (verbose_level >= 1);
3943 long int rk;
3944 int h, d, j, r;
3945 int *M1;
3946 int *M2;
3947 int *base_cols;
3948 int *embedding;
3949 int *w;
3950 int *v;
3951 int N;
3952 geometry_global Gg;
3953
3954 if (f_v) {
3955 cout << "projective_space::planes_through_a_line" << endl;
3956 }
3957 d = n + 1;
3958 M1 = NEW_int(3 * d);
3959 M2 = NEW_int(3 * d);
3960 base_cols = NEW_int(d);
3961 embedding = NEW_int(d);
3962 w = NEW_int(d);
3963 v = NEW_int(d);
3964 Grass_lines->unrank_lint_here(M1, line_rk, 0 /* verbose_level */);
3965 if (f_v) {
3966 cout << "projective_space::planes_through_a_line M1=" << endl;
3967 Int_matrix_print(M1, 2, d);
3968 }
3969
3971 base_cols, embedding, 0 /* verbose_level */);
3972 if (r != 2) {
3973 cout << "projective_space::planes_through_a_line r != 2" << endl;
3974 exit(1);
3975 }
3976 if (f_v) {
3977 cout << "projective_space::planes_through_a_line after RREF, M1=" << endl;
3978 Int_matrix_print(M1, 2, d);
3979 }
3980 N = Gg.nb_PG_elements(n - 2, F->q);
3981
3982 for (h = 0; h < N; h++) {
3983
3984 F->PG_element_unrank_modified(w, 1, d - 2, h);
3985 Int_vec_zero(v, d);
3986 for (j = 0; j < d - 2; j++) {
3987 v[embedding[j]] = w[j];
3988 }
3989 Int_vec_copy(M1, M2, 2 * d);
3990 Int_vec_copy(v, M2 + 2 * d, d);
3991 if (f_v) {
3992 cout << "projective_space::planes_through_a_line h = " << h << ", M2=" << endl;
3993 Int_matrix_print(M2, 3, d);
3994 }
3995 if (F->Linear_algebra->rank_of_rectangular_matrix(M2, 3, d, 0 /*verbose_level*/) == 3) {
3996
3997 // here, rank means the rank in the sense of linear algebra
3998
3999 if (f_v) {
4000 cout << "projective_space::planes_through_a_line h = " << h << ", M2=" << endl;
4001 Int_matrix_print(M2, 3, d);
4002 }
4003 rk = Grass_planes->rank_lint_here(M2, 0 /* verbose_level */);
4004
4005 // here rank is in the sense of indexing
4006
4007 if (f_v) {
4008 cout << "projective_space::planes_through_a_line h = " << h << " rk=" << rk << endl;
4009 }
4010 plane_ranks.push_back(rk);
4011 }
4012 } // next h
4013 FREE_int(M1);
4014 FREE_int(M2);
4015 FREE_int(base_cols);
4016 FREE_int(embedding);
4017 FREE_int(w);
4018 FREE_int(v);
4019 if (f_v) {
4020 cout << "projective_space::planes_through_a_line done" << endl;
4021 }
4022}
4023
4024
4026 long int line1_from, long int line2_from,
4027 long int line1_to, long int line2_to, int verbose_level)
4028{
4029 int f_v = (verbose_level >= 1);
4030
4031 if (f_v) {
4032 cout << "projective_space::do_move_two_lines_in_hyperplane_stabilizer" << endl;
4033 }
4034
4035 if (n != 3) {
4036 cout << "projective_space::do_move_two_lines_in_hyperplane_stabilizer n != 3" << endl;
4037 exit(1);
4038 }
4039 geometry_global Gg;
4040 int A4[16];
4041
4042
4044 line1_from, line1_to,
4045 line2_from, line2_to,
4046 A4,
4047 verbose_level);
4048
4049 cout << "projective_space::do_move_two_lines_in_hyperplane_stabilizer A4=" << endl;
4050 Int_matrix_print(A4, 4, 4);
4051
4052 if (f_v) {
4053 cout << "projective_space::do_move_two_lines_in_hyperplane_stabilizer done" << endl;
4054 }
4055}
4056
4058 std::string line1_from_text, std::string line2_from_text,
4059 std::string line1_to_text, std::string line2_to_text,
4060 int verbose_level)
4061{
4062 int f_v = (verbose_level >= 1);
4063
4064 if (f_v) {
4065 cout << "projective_space::do_move_two_lines_in_hyperplane_stabilizer_text" << endl;
4066 }
4067 if (n != 3) {
4068 cout << "projective_space::do_move_two_lines_in_hyperplane_stabilizer n != 3" << endl;
4069 exit(1);
4070 }
4071
4072 geometry_global Gg;
4073 int A4[16];
4074
4075
4076 int *line1_from_data;
4077 int *line2_from_data;
4078 int *line1_to_data;
4079 int *line2_to_data;
4080 int sz;
4081
4082 Int_vec_scan(line1_from_text.c_str(), line1_from_data, sz);
4083 if (sz != 8) {
4084 cout << "line1_from_text must contain exactly 8 integers" << endl;
4085 exit(1);
4086 }
4087 Int_vec_scan(line2_from_text.c_str(), line2_from_data, sz);
4088 if (sz != 8) {
4089 cout << "line2_from_text must contain exactly 8 integers" << endl;
4090 exit(1);
4091 }
4092 Int_vec_scan(line1_to_text.c_str(), line1_to_data, sz);
4093 if (sz != 8) {
4094 cout << "line1_to_text must contain exactly 8 integers" << endl;
4095 exit(1);
4096 }
4097 Int_vec_scan(line2_to_text.c_str(), line2_to_data, sz);
4098 if (sz != 8) {
4099 cout << "line2_to_text must contain exactly 8 integers" << endl;
4100 exit(1);
4101 }
4102
4103 long int line1_from;
4104 long int line2_from;
4105 long int line1_to;
4106 long int line2_to;
4107
4108 line1_from = rank_line(line1_from_data);
4109 line2_from = rank_line(line2_from_data);
4110 line1_to = rank_line(line1_to_data);
4111 line2_to = rank_line(line2_to_data);
4112
4113
4115 line1_from, line1_to,
4116 line2_from, line2_to,
4117 A4,
4118 verbose_level);
4119
4120 cout << "projective_space::do_move_two_lines_in_hyperplane_stabilizer_text A4=" << endl;
4121 Int_matrix_print(A4, 4, 4);
4122
4123 if (f_v) {
4124 cout << "projective_space::do_move_two_lines_in_hyperplane_stabilizer_text done" << endl;
4125 }
4126}
4127
4128
4129
4130}}}
4131
4132
data structure for set partitions following Jeffrey Leon
void init_basic_constant_size(int underlying_set_size, int nb_sets, int constant_size, int verbose_level)
void init_with_Sz_in_int(int underlying_set_size, int nb_sets, long int **Pts, int *Sz, int verbose_level)
a collection of functions related to sorted vectors
int int_vec_search(int *v, int len, int a, int &idx)
Definition: sorting.cpp:1094
int test_if_set_with_return_value_lint(long int *set, int set_size)
Definition: sorting.cpp:586
void int_vec_heapsort_with_log(int *v, int *w, int len)
Definition: sorting.cpp:1967
int longinteger_vec_search(ring_theory::longinteger_object *v, int len, ring_theory::longinteger_object &a, int &idx)
Definition: sorting.cpp:1394
int lint_vec_search(long int *v, int len, long int a, int &idx, int verbose_level)
Definition: sorting.cpp:1157
int lint_vec_is_subset_of(int *set, int sz, long int *big_set, int big_set_sz, int verbose_level)
Definition: sorting.cpp:125
a statistical analysis of data consisting of single integers
void print_file_tex(std::ostream &ost, int f_backwards)
Definition: tally.cpp:338
void init(int *data, int data_length, int f_second, int verbose_level)
Definition: tally.cpp:72
void get_class_by_value(int *&Pts, int &nb_pts, int value, int verbose_level)
Definition: tally.cpp:644
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 int_vec_print_elements_exponential(std::ostream &ost, int *v, int len, std::string &symbol_for_print)
void int_vec_print_field_elements(std::ostream &ost, int *v, int len)
void latex_matrix(std::ostream &f, int f_elements_exponential, std::string &symbol_for_print, int *M, int m, int n)
various functions related to geometries
Definition: geometry.h:721
void hyperplane_lifting_with_two_lines_moved(projective_space *P, long int line1_from, long int line1_to, long int line2_from, long int line2_to, int *A4, int verbose_level)
void AG_element_rank_longinteger(int q, int *v, int stride, int len, ring_theory::longinteger_object &a)
to rank and unrank subspaces of a fixed dimension in F_q^n
Definition: geometry.h:892
void unrank_longinteger(ring_theory::longinteger_object &rk, int verbose_level)
Definition: grassmann.cpp:627
void unrank_longinteger_here(int *Mtx, ring_theory::longinteger_object &rk, int verbose_level)
Definition: grassmann.cpp:613
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 rank_longinteger_here(int *Mtx, ring_theory::longinteger_object &rk, int verbose_level)
Definition: grassmann.cpp:620
void unrank_lint_here(int *Mtx, long int rk, int verbose_level)
Definition: grassmann.cpp:269
void init(int n, int k, field_theory::finite_field *F, int verbose_level)
Definition: grassmann.cpp:70
interface for various incidence geometries
Definition: geometry.h:1099
void get_and_print_decomposition_schemes(data_structures::partitionstack &PStack)
int compute_TDO(data_structures::partitionstack &PStack, int ht0, int depth, int verbose_level)
void print_partitioned(std::ostream &ost, data_structures::partitionstack &P, int f_labeled)
void init_by_matrix(int m, int n, int *M, int verbose_level)
projective space PG(n,q) of dimension n over Fq
Definition: geometry.h:1916
void find_nucleus(int *set, int set_size, int &nucleus, int verbose_level)
void cheat_sheet_line_intersection(std::ostream &f, int verbose_level)
long int line_of_intersection_of_two_planes_in_three_space_using_dual_coordinates(long int plane1, long int plane2, int verbose_level)
void do_move_two_lines_in_hyperplane_stabilizer_text(std::string line1_from_text, std::string line2_from_text, std::string line1_to_text, std::string line2_to_text, int verbose_level)
void plane_intersection(int plane_rank, long int *set, int set_size, std::vector< int > &point_indices, std::vector< int > &point_local_coordinates, int verbose_level)
void plane_intersection_type_fast(grassmann *G, long int *set, int set_size, ring_theory::longinteger_object *&R, long int **&Pts_on_plane, int *&nb_pts_on_plane, int &len, int verbose_level)
int point_of_intersection_of_a_line_and_a_plane_in_three_space(long int line, int plane, int verbose_level)
long int transversal_to_two_skew_lines_through_a_point(long int line1, long int line2, int pt, int verbose_level)
void plane_equation_from_three_lines_in_three_space(long int *three_lines, int *plane_eqn4, int verbose_level)
void print_set_numerical(std::ostream &ost, long int *set, int set_size)
void conic_type(long int *set, int set_size, int threshold, long int **&Pts_on_conic, int **&Conic_eqn, int *&nb_pts_on_conic, int &nb_conics, int verbose_level)
void line_intersection(int line_rank, long int *set, int set_size, std::vector< int > &point_indices, int verbose_level)
void elliptic_curve_addition_table(int *A6, int *Pts, int nb_pts, int *&Table, int verbose_level)
void plane_intersection_invariant(grassmann *G, long int *set, int set_size, int *&intersection_type, int &highest_intersection_number, int *&intersection_matrix, int &nb_planes, int verbose_level)
int determine_conic_in_plane(long int *input_pts, int nb_pts, int *six_coeffs, int verbose_level)
int is_contained_in_Baer_subline(long int *pts, int nb_pts, int verbose_level)
void do_move_two_lines_in_hyperplane_stabilizer(long int line1_from, long int line2_from, long int line1_to, long int line2_to, int verbose_level)
void klein_correspondence(projective_space *P5, long int *set_in, int set_size, long int *set_out, int verbose_level)
void find_planes_which_intersect_in_at_least_s_points(long int *set, int set_size, int s, std::vector< int > &plane_ranks, int verbose_level)
long int dual_rank_of_line_in_plane(long int line_rank, int verbose_level)
void create_points_on_line(long int line_rk, long int *line, int verbose_level)
projective_space_implementation * Implementation
Definition: geometry.h:1940
long int line_rank_using_dual_coordinates_in_plane(int *eqn3, int verbose_level)
void planes_through_a_line(long int line_rk, std::vector< long int > &plane_ranks, int verbose_level)
void intersection_of_subspace_with_point_set(grassmann *G, int rk, long int *set, int set_size, long int *&intersection_set, int &intersection_set_size, int verbose_level)
void points_on_projective_triangle(long int *&set, int &set_size, long int *three_points, int verbose_level)
void Pluecker_coordinates(int line_rk, int *v6, int verbose_level)
void cheat_sheet_point_table(std::ostream &f, int verbose_level)
long int plane_rank_using_dual_coordinates_in_three_space(int *eqn4, int verbose_level)
void plane_intersections(grassmann *G, long int *set, int set_size, ring_theory::longinteger_object *&R, data_structures::set_of_sets &SoS, int verbose_level)
void cheat_sheet_points_on_lines(std::ostream &f, int verbose_level)
void determine_nonconical_six_subsets(long int *set, int set_size, std::vector< int > &Rk, int verbose_level)
void print_line_set_numerical(long int *set, int set_size)
int nonconical_six_arc_get_nb_Eckardt_points(long int *Arc6, int verbose_level)
int test_if_lines_are_skew(int line1, int line2, int verbose_level)
void cheat_sheet_lines_on_points(std::ostream &f, int verbose_level)
void circle_type_of_line_subset(int *pts, int nb_pts, int *circle_type, int verbose_level)
int point_of_intersection_of_a_line_and_a_line_in_three_space(long int line1, long int line2, int verbose_level)
void cheat_polarity(std::ostream &f, int verbose_level)
void line_plane_incidence_matrix_restricted(long int *Lines, int nb_lines, int *&M, int &nb_planes, int verbose_level)
void do_pluecker_reverse(std::ostream &ost, grassmann *Gr, int k, int nb_k_subspaces, int verbose_level)
void decomposition_from_set_partition(int nb_subsets, int *sz, int **subsets, incidence_structure *&Inc, data_structures::partitionstack *&Stack, int verbose_level)
int determine_hermitian_form_in_plane(int *pts, int nb_pts, int *six_coeffs, int verbose_level)
void create_unital_XXq_YZq_ZYq_brute_force(long int *U, int &sz, int verbose_level)
void klein_correspondence_special_model(projective_space *P5, int *table, int verbose_level)
void plane_intersection_matrix_in_three_space(long int *Planes, int nb_planes, int *&Intersection_matrix, int verbose_level)
void cheat_sheet_subspaces(std::ostream &f, int k, int verbose_level)
void cheat_sheet_points(std::ostream &f, int verbose_level)
void Baer_subline(long int *pts3, long int *&pts, int &nb_pts, int verbose_level)
void cheat_sheet_line_through_pairs_of_points(std::ostream &f, int verbose_level)
void conic_type_randomized(int nb_times, long int *set, int set_size, long int **&Pts_on_conic, int *&nb_pts_on_conic, int &len, int verbose_level)
void plane_intersection_type(grassmann *G, long int *set, int set_size, int *&intersection_type, int &highest_intersection_number, int verbose_level)
void conic_intersection_type(int f_randomized, int nb_times, long int *set, int set_size, int threshold, int *&intersection_type, int &highest_intersection_number, int f_save_largest_sets, data_structures::set_of_sets *&largest_sets, int verbose_level)
int elliptic_curve_addition(int *A6, int p1_rk, int p2_rk, int verbose_level)
void plane_intersection_type_slow(grassmann *G, long int *set, int set_size, ring_theory::longinteger_object *&R, long int **&Pts_on_plane, int *&nb_pts_on_plane, int &len, int verbose_level)
long int line_of_intersection_of_two_planes_in_three_space(long int plane1, long int plane2, int verbose_level)
void intersection_of_subspace_with_point_set_rank_is_longinteger(grassmann *G, ring_theory::longinteger_object &rk, long int *set, int set_size, long int *&intersection_set, int &intersection_set_size, int verbose_level)
long int dual_rank_of_plane_in_three_space(long int plane_rank, int verbose_level)
long int line_through_two_points(long int p1, long int p2)
void reduce_mod_subspace_and_get_coefficient_vector(int k, int len, int *basis, int *base_cols, int *v, int *coefficients, int verbose_level)
int base_cols_and_embedding(int m, int n, int *A, int *base_cols, int *embedding, int verbose_level)
int RREF_and_kernel(int n, int k, int *A, int verbose_level)
int rank_of_rectangular_matrix(int *A, int m, int n, int verbose_level)
int Gauss_simple(int *A, int m, int n, int *base_cols, int verbose_level)
void matrix_get_kernel(int *M, int m, int n, int *base_cols, int nb_base_cols, int &kernel_m, int &kernel_n, int *kernel, int verbose_level)
int intersect_subspaces(int n, int k1, int *A, int k2, int *B, int &k3, int *intersection, int verbose_level)
void int_matrix_write_csv(std::string &fname, int *M, int m, int n)
Definition: file_io.cpp:1300
void print_integer_matrix_with_labels(std::ostream &ost, int *p, int m, int n, int *row_labels, int *col_labels, int f_tex)
a class to represent arbitrary precision integers
Definition: ring_theory.h:366
void create(long int i, const char *file, int line)
#define Lint_vec_copy(A, B, C)
Definition: foundations.h:694
#define FREE_OBJECTS(p)
Definition: foundations.h:652
#define Int_vec_scan(A, B, C)
Definition: foundations.h:716
#define NEW_plint(n)
Definition: foundations.h:629
#define Int_vec_print_integer_matrix(A, B, C, D)
Definition: foundations.h:690
#define MINIMUM(x, y)
Definition: foundations.h:216
#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 FREE_plint(p)
Definition: foundations.h:643
#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_vec_print_integer_matrix_width(A, B, C, D, E, F)
Definition: foundations.h:691
#define Int_matrix_print(A, B, C)
Definition: foundations.h:707
#define NEW_OBJECTS(type, n)
Definition: foundations.h:639
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define ODD(x)
Definition: foundations.h:222
#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 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