Orbiter 2022
Combinatorial Objects
cubic_curve.cpp
Go to the documentation of this file.
1/*
2 * cubic_curve.cpp
3 *
4 * Created on: Mar 7, 2019
5 * Author: betten
6 */
7
8#include "foundations.h"
9
10
11using namespace std;
12
13
14namespace orbiter {
15namespace layer1_foundations {
16namespace algebraic_geometry {
17
18
20{
21 q = 0;
22 F = NULL;
23 P = NULL;
24
25
26 nb_monomials = 0;
27
28
29 Poly = NULL;
30 Poly2 = NULL;
31
32 Partials = NULL;
33
34 gradient = NULL;
35
36}
37
39{
40 freeself();
41}
42
43
45{
46 int f_v = FALSE;
47
48 if (f_v) {
49 cout << "cubic_curve::freeself" << endl;
50 }
51 if (P) {
53 }
54 if (Poly) {
56 }
57 if (Poly2) {
59 }
60 if (Partials) {
62 }
63 if (gradient) {
65 }
66}
67
69{
70 int f_v = (verbose_level >= 1);
71 int i;
72
73 if (f_v) {
74 cout << "cubic_curve::init" << endl;
75 }
76
78 q = F->q;
79 if (f_v) {
80 cout << "cubic_curve::init q = " << q << endl;
81 }
82
84 if (f_v) {
85 cout << "cubic_curve::init before P->projective_space_init" << endl;
86 }
88 TRUE /*f_init_incidence_structure */,
89 verbose_level - 2);
90 if (f_v) {
91 cout << "cubic_curve::init after P->projective_space_init" << endl;
92 }
93
95
96 Poly->init(F,
97 3 /* nb_vars */, 3 /* degree */,
98 FALSE /* f_init_incidence_structure */,
99 t_PART,
100 verbose_level);
101
103
104 Poly2->init(F,
105 3 /* nb_vars */, 2 /* degree */,
106 FALSE /* f_init_incidence_structure */,
107 t_PART,
108 verbose_level);
109
111 if (f_v) {
112 cout << "cubic_curve::init nb_monomials = " << nb_monomials << endl;
113 }
114
116 for (i = 0; i < 3; i++) {
117 Partials[i].init(Poly, Poly2, i, verbose_level);
118 }
119
121
122 if (f_v) {
123 cout << "cubic_curve::init done" << endl;
124 }
125}
126
127
129 int nb_pts, long int *pt_list, int verbose_level)
130{
131 //verbose_level = 1;
132 int f_v = (verbose_level >= 1);
133 int i, j, r;
134 int *Pts;
135 int *System;
136 int *base_cols;
137
138 if (f_v) {
139 cout << "cubic_curve::compute_system_in_RREF" << endl;
140 }
141 Pts = NEW_int(nb_pts * 3);
142 System = NEW_int(nb_pts * nb_monomials);
143 base_cols = NEW_int(nb_monomials);
144
145 if (FALSE) {
146 cout << "cubic_curve::compute_system_in_RREF list of "
147 "covered points by lines:" << endl;
149 }
150 for (i = 0; i < nb_pts; i++) {
151 P->unrank_point(Pts + i * 3, pt_list[i]);
152 }
153 if (f_v && FALSE) {
154 cout << "cubic_curve::compute_system_in_RREF list of "
155 "covered points in coordinates:" << endl;
157 }
158
159 for (i = 0; i < nb_pts; i++) {
160 for (j = 0; j < nb_monomials; j++) {
161 System[i * nb_monomials + j] =
162 Poly->evaluate_monomial(j, Pts + i * 3);
163 }
164 }
165 if (f_v && FALSE) {
166 cout << "cubic_curve::compute_system_in_RREF "
167 "The system:" << endl;
169 }
170 r = F->Linear_algebra->Gauss_simple(System, nb_pts, nb_monomials,
171 base_cols, 0 /* verbose_level */);
172 if (FALSE) {
173 cout << "cubic_curve::compute_system_in_RREF "
174 "The system in RREF:" << endl;
176 }
177 if (f_v) {
178 cout << "cubic_curve::compute_system_in_RREF "
179 "The system has rank " << r << endl;
180 }
181 FREE_int(Pts);
182 FREE_int(System);
183 FREE_int(base_cols);
184 return r;
185}
186
187void cubic_curve::compute_gradient(int *eqn_in, int verbose_level)
188{
189 int f_v = (verbose_level >= 1);
190 int i;
191
192 if (f_v) {
193 cout << "cubic_curve::compute_gradient" << endl;
194 }
195 for (i = 0; i < 3; i++) {
196 if (f_v) {
197 cout << "cubic_curve::compute_gradient i=" << i << endl;
198 }
199 if (f_v) {
200 cout << "cubic_curve::compute_gradient eqn_in=";
201 Int_vec_print(cout, eqn_in, Poly->get_nb_monomials());
202 cout << " = ";
203 Poly->print_equation(cout, eqn_in);
204 cout << endl;
205 }
206 Partials[i].apply(eqn_in,
208 verbose_level - 2);
209 if (f_v) {
210 cout << "cubic_curve::compute_gradient partial=";
213 cout << " = ";
215 cout << endl;
216 }
217 }
218 if (f_v) {
219 cout << "cubic_curve::compute_gradient done" << endl;
220 }
221}
222
224 int *eqn_in,
225 long int *Pts_on_curve, int nb_pts_on_curve,
226 long int *Pts, int &nb_pts,
227 int verbose_level)
228// a singular point is a point where all partials vanish
229// We compute the set of singular points into Pts[nb_pts]
230{
231 int f_v = (verbose_level >= 1);
232 int f_vv = FALSE; //(verbose_level >= 2);
233 int h, i, a, rk;
234 int nb_eqns = 3;
235 int v[3];
236
237 if (f_v) {
238 cout << "cubic_curve::compute_singular_points" << endl;
239 }
240 compute_gradient(eqn_in, verbose_level);
241
242 nb_pts = 0;
243
244 for (h = 0; h < nb_pts_on_curve; h++) {
245 if (f_vv) {
246 cout << "cubic_curve::compute_singular_points "
247 "h=" << h << " / " << nb_pts_on_curve << endl;
248 }
249 rk = Pts_on_curve[h];
250 if (f_vv) {
251 cout << "cubic_curve::compute_singular_points "
252 "rk=" << rk << endl;
253 }
254 Poly->unrank_point(v, rk);
255 if (f_vv) {
256 cout << "cubic_curve::compute_singular_points "
257 "v=";
258 Int_vec_print(cout, v, 3);
259 cout << endl;
260 }
261 for (i = 0; i < nb_eqns; i++) {
262 if (f_vv) {
263 cout << "cubic_curve::compute_singular_points "
264 "gradient i=" << i << " / " << nb_eqns << endl;
265 }
266 if (f_vv) {
267 cout << "cubic_curve::compute_singular_points "
268 "gradient " << i << " = ";
269 Int_vec_print(cout,
272 cout << endl;
273 }
275 gradient + i * Poly2->get_nb_monomials(), v);
276 if (f_vv) {
277 cout << "cubic_curve::compute_singular_points "
278 "value = " << a << endl;
279 }
280 if (a) {
281 break;
282 }
283 }
284 if (i == nb_eqns) {
285 Pts[nb_pts++] = rk;
286 }
287 }
288 if (f_v) {
289 cout << "cubic_curve::compute_singular_points done" << endl;
290 }
291}
292
294 int *eqn_in,
295 long int *Pts_on_curve, int nb_pts_on_curve,
296 long int *Pts, int &nb_pts,
297 int verbose_level)
298{
299 int f_v = (verbose_level >= 1);
300 int i, h, a;
301 int T[3];
302 int v[3];
303 int w[3];
304 int Basis[9];
305 int Basis2[6];
306 int eqn_restricted_to_line[4];
307
308 if (f_v) {
309 cout << "cubic_curve::compute_inflexion_points" << endl;
310 }
311 compute_gradient(eqn_in, verbose_level - 2);
312
313
314 nb_pts = 0;
315
316 for (h = 0; h < nb_pts_on_curve; h++) {
317 a = Pts_on_curve[h];
318 Poly->unrank_point(v, a);
319
320 if (f_v) {
321 cout << "cubic_curve::compute_inflexion_points testing point "
322 << h << " / " << nb_pts_on_curve << " = " << a << " = ";
323 Int_vec_print(cout, v, 3);
324 cout << endl;
325 }
326 for (i = 0; i < 3; i++) {
328 gradient + i * Poly2->get_nb_monomials(), v);
329 }
330 for (i = 0; i < 3; i++) {
331 if (T[i]) {
332 break;
333 }
334 }
335 if (i < 3) {
336 // now we know that the tangent line at point a exists:
337
338 //int_vec_copy(v, Basis, 3);
339 Int_vec_copy(T, Basis, 3);
340 if (f_v) {
341 cout << "cubic_curve::compute_inflexion_points "
342 "before F->perp_standard:" << endl;
344 }
345 F->Linear_algebra->perp_standard(3, 1, Basis, 0 /*verbose_level*/);
346 if (f_v) {
347 cout << "cubic_curve::compute_inflexion_points "
348 "after F->perp_standard:" << endl;
350 }
351 // test if the first basis vector is a multiple of v:
352 Int_vec_copy(v, Basis2, 3);
353 Int_vec_copy(Basis + 3, Basis2 + 3, 3);
355 2, 3, 0 /*verbose_level*/) == 1) {
356 Int_vec_copy(Basis + 6, w, 3);
357 }
358 else {
359 Int_vec_copy(Basis + 3, w, 3);
360 }
361 Int_vec_copy(v, Basis2, 3);
362 Int_vec_copy(w, Basis2 + 3, 3);
364 2, 3, 0 /*verbose_level*/) != 2) {
365 cout << "cubic_curve::compute_inflexion_points rank of "
366 "line spanned by v and w is not two" << endl;
367 exit(1);
368 }
370 eqn_in, eqn_restricted_to_line,
371 v /*int *Pt1_coeff*/, w /*int *Pt2_coeff*/,
372 0 /*verbose_level*/);
373 // coeff_in[nb_monomials], coeff_out[degree + 1]
374 if (f_v) {
375 cout << "cubic_curve::compute_inflexion_points "
376 "after Poly->substitute_line:" << endl;
377 Int_vec_print(cout, eqn_restricted_to_line, 4);
378 cout << endl;
379 }
380 if (eqn_restricted_to_line[0] == 0 &&
381 eqn_restricted_to_line[1] == 0 &&
382 eqn_restricted_to_line[2] == 0) {
383 if (f_v) {
384 cout << "cubic_curve::compute_inflexion_points "
385 "found an inflexion point " << a << endl;
386 }
387 Pts[nb_pts++] = a;
388 }
389 }
390 else {
391 if (f_v) {
392 cout << "cubic_curve::compute_inflexion_points "
393 "the tangent line does not exist" << endl;
394 }
395 }
396 } // next h
397
398 if (f_v) {
399 cout << "cubic_curve::compute_inflexion_points "
400 "we found " << nb_pts << " inflexion points" << endl;
401 }
402
403 if (f_v) {
404 cout << "cubic_curve::compute_inflexion_points done" << endl;
405 }
406}
407
408
409
410}}}
411
void compute_gradient(int *eqn_in, int verbose_level)
ring_theory::homogeneous_polynomial_domain * Poly
void init(field_theory::finite_field *F, int verbose_level)
Definition: cubic_curve.cpp:68
void compute_inflexion_points(int *eqn_in, long int *Pts_on_curve, int nb_pts_on_curve, long int *Pts, int &nb_pts, int verbose_level)
ring_theory::homogeneous_polynomial_domain * Poly2
void compute_singular_points(int *eqn_in, long int *Pts_on_curve, int nb_pts_on_curve, long int *Pts, int &nb_pts, int verbose_level)
int compute_system_in_RREF(int nb_pts, long int *pt_list, int verbose_level)
void matrix_print(long int *p, int m, int n)
Definition: lint_vec.cpp:203
projective space PG(n,q) of dimension n over Fq
Definition: geometry.h:1916
void projective_space_init(int n, field_theory::finite_field *F, int f_init_incidence_structure, int verbose_level)
int rank_of_rectangular_matrix(int *A, int m, int n, int verbose_level)
int perp_standard(int n, int k, int *A, int verbose_level)
int Gauss_simple(int *A, int m, int n, int *base_cols, int verbose_level)
homogeneous polynomials of a given degree in a given number of variables over a finite field GF(q)
Definition: ring_theory.h:88
void init(field_theory::finite_field *F, int nb_vars, int degree, int f_init_incidence_structure, monomial_ordering_type Monomial_ordering_type, int verbose_level)
void substitute_line(int *coeff_in, int *coeff_out, int *Pt1_coeff, int *Pt2_coeff, int verbose_level)
partial derivative connects two homogeneous polynomial domains
Definition: ring_theory.h:432
void apply(int *eqn_in, int *eqn_out, int verbose_level)
void init(homogeneous_polynomial_domain *H, homogeneous_polynomial_domain *Hd, int variable_idx, int verbose_level)
#define FREE_OBJECTS(p)
Definition: foundations.h:652
#define FREE_int(p)
Definition: foundations.h:640
#define NEW_OBJECT(type)
Definition: foundations.h:638
#define FREE_OBJECT(p)
Definition: foundations.h:651
#define NEW_int(n)
Definition: foundations.h:625
#define NEW_OBJECTS(type, n)
Definition: foundations.h:639
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define Int_vec_copy(A, B, C)
Definition: foundations.h:693
#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