17namespace layer1_foundations {
18namespace number_theory {
53 int f_v = (verbose_level >= 1);
56 cout <<
"elliptic_curve::init q=" <<
F->
q
57 <<
" b=" <<
b <<
" c=" <<
c << endl;
68 cout <<
"elliptic_curve::init before compute_points" << endl;
74 cout <<
"elliptic_curve::init after compute_points" << endl;
79 print_integer_matrix_width(cout, E.A, E.nb, E.nb, E.nb, 3);
87 cout <<
"point : order" << endl;
88 for (i = 0; i < E.nb; i++) {
90 cout << setw(4) << i <<
" : " << setw(4) << j << endl;
93 cout <<
"the curve has " << E.nb <<
" points" << endl;
101 c = E.A[a * E.nb +
b];
102 cout <<
"P_" << a <<
" + P_" <<
b <<
" = P_" <<
c << endl;
105 j = multiple_of_point(E, 0, 37);
106 cout <<
"37 * P_0 = P_" << j << endl;
109 cout <<
"elliptic_curve::init done" << endl;
116 int f_v = (verbose_level >= 1);
122 cout <<
"elliptic_curve::compute_points" << endl;
124 bound =
q + 1 + 2 * ((int)(sqrt(
q)) + 1);
136 for (x = 0; x <
q; x++) {
141 cout <<
"elliptic_curve::compute_points The number of points exceeds the bound" << endl;
156 cout <<
"elliptic_curve::compute_points The number of points "
157 "exceeds the bound" << endl;
168 cout <<
"elliptic_curve::compute_points The number of points "
169 "exceeds the bound" << endl;
174 cout <<
"elliptic_curve::compute_points The number of points "
175 "exceeds the bound" << endl;
186 l = Legendre(r,
q, 0);
192 if (
F->
mult(y, y) != r) {
193 cout <<
"elliptic_curve::compute_points There is a problem "
194 "with the square root" << endl;
205 cout <<
"elliptic_curve::compute_points The number of points "
206 "exceeds the bound" << endl;
211 cout <<
"elliptic_curve::compute_points The number of points "
212 "exceeds the bound" << endl;
225 cout <<
"elliptic_curve::compute_points The number of points exceeds "
239 cout <<
"elliptic_curve::compute_points The number of points exceeds the bound" << endl;
245 cout <<
"elliptic_curve::compute_points done, "
246 "we found " <<
nb <<
" points" << endl;
274 cout <<
"i : point (x,y,z)" << endl;
275 for (i = 0; i <
nb; i++) {
276 cout << setw(4) << i <<
" & " <<
T[i * 3 + 0] <<
","
277 <<
T[i * 3 + 1] <<
"," <<
T[i * 3 + 2] <<
"\\\\" << endl;
285 cout <<
"i : point (x,y,z)" << endl;
286 for (i = 0; i <
nb; i++) {
287 cout << setw(4) << i <<
" & ";
288 if (
T[i * 3 + 2] == 0) {
292 cout <<
"(" <<
T[i * 3 + 0] <<
"," <<
T[i * 3 + 1] <<
")";
294 cout <<
"\\\\" << endl;
300 int x1,
int y1,
int z1,
301 int x2,
int y2,
int z2,
302 int &x3,
int &y3,
int &z3,
int verbose_level)
304 int f_v = (verbose_level >= 1);
307 cout <<
"elliptic_curve::addition: ";
308 cout <<
"(" << x1 <<
"," << y1 <<
"," << z1 <<
")";
310 cout <<
"(" << x2 <<
"," << y2 <<
"," << z2 <<
")";
319 x3, y3, z3, verbose_level);
322 cout <<
"elliptic_curve::addition done";
329 int f_v = (verbose_level >= 1);
335 cout <<
"elliptic_curve::save_incidence_matrix" << endl;
339 for (i = 0; i <
nb; i++) {
347 cout <<
"elliptic_curve::save_incidence_matrix point is not normalized" << endl;
350 M[(
q - 1 - y) *
q + x] = 1;
354 cout <<
"elliptic_curve::save_incidence_matrix written file "
355 << fname <<
" of size " << Fio.
file_size(fname) << endl;
359 cout <<
"elliptic_curve::save_incidence_matrix done" << endl;
366 int f_with_grid,
int f_with_points,
int point_density,
367 int f_path,
int start_idx,
int nb_steps,
370 int f_v = (verbose_level >= 1);
371 int factor_1000 = 1000;
375 cout <<
"draw_grid" << endl;
377 fname_full.assign(fname);
378 fname_full.append(
".mp");
384 G.
init(fname_full, Draw_options, verbose_level - 1);
389 draw_grid2(G, f_with_grid, f_with_points, point_density,
390 f_path, start_idx, nb_steps,
399 cout <<
"written file " << fname_full <<
" of size "
402 cout <<
"draw_grid done" << endl;
409 int f_with_grid,
int f_with_points,
int point_density,
410 int f_path,
int start_idx,
int nb_steps,
413 int f_v = (verbose_level >= 1);
434 cout <<
"elliptic_curve::draw_grid2" << endl;
435 cout <<
"dx=" << dx <<
" dy=" << dy << endl;
442 cout <<
"elliptic_curve::draw_grid2 drawing grid" << endl;
449 0., (
double)(
q - 1), 0., (
double)(
q - 1),
450 x_stretch, y_stretch,
464 0., (
double)(
q - 1), 0., (
double)(
q - 1),
465 x_stretch, y_stretch,
486 cout <<
"drawing points, nb=" <<
nb << endl;
492 for (h = 0; h <
nb; h++) {
511 for (i = 0; i < 5; i++) {
516 cout <<
"point " << h <<
" : "
517 << x1 <<
", " << x2 <<
", " << x3
518 <<
" : " << a <<
", " <<
b
519 <<
" : " << Px[0] <<
"," << Py[0]
530 cout <<
"drawing point labels" << endl;
533 for (i = 0; i <
nb; i++) {
535 sprintf(str,
"%d", i);
539 get_ab(
q, x1, x2, x3, a,
b);
547 cout <<
"elliptic_curve::draw_grid2 not drawing any points" << endl;
560 cout <<
"drawing multiples of point" << endl;
563 for (h = 0; h < nb_steps; h++) {
567 j =
A[i *
nb + start_idx];
579 for (i = 0; i < 2; i++) {
580 Px[i] = Dx[i] * dx + dx / 2;
581 Py[i] = Dy[i] * dy + dy / 2;
606 for (i = 0; i < 5; i++) {
622 cout << a <<
"," <<
b <<
"," <<
c <<
"," << d << endl;
628 cout << a <<
"," <<
b <<
"," <<
c <<
"," << d << endl;
642 cout << a <<
"," <<
b <<
"," <<
c <<
"," << d << endl;
649 cout << a <<
"," <<
b <<
"," <<
c <<
"," << d << endl;
662 cout <<
"draw_grid2 done" << endl;
667 int &a,
int &b,
int verbose_level)
675 cout <<
"x3 != 1" << endl;
691 for (j = 0; j < n; j++) {
692 a = E.
A[a * E.
nb + i];
700 int f_v = (verbose_level >= 1);
708 cout <<
"elliptic_curve::compute_addition_table" << endl;
712 for (i = 0; i <
nb; i++) {
716 for (j = 0; j <
nb; j++) {
721 cout <<
"add " << i <<
" " << j << endl;
734 cout <<
"elliptic_curve::compute_addition_table done" << endl;
760 for (i = 1; i <
nb; i++) {
761 if (
T[3 * i + 0] == x1 &&
T[3 * i + 1] == x2) {
765 cout <<
"did not find point "
766 << x1 <<
"," << x2 <<
"," << x3 <<
" in table" << endl;
784 cout <<
"elliptic_curve::index_of_point "
809 if (
T[3 * m + 0] > x1) {
812 else if (
T[3 * m + 0] < x1) {
816 if (
T[3 * m + 1] > x2) {
819 else if (
T[3 * m + 1] < x2) {
828 cout <<
"l=" << l <<
" r=" << r<<
" m=" << m
829 <<
" T[3 * m + 0]=" <<
T[3 * m + 0]
830 <<
" T[3 * m + 1]=" <<
T[3 * m + 1]
831 <<
" res=" << res << endl;
843 cout <<
"elliptic_curve::index_of_point "
844 "moving to the right" << endl;
852 cout <<
"elliptic_curve::index_of_point "
853 "moving to the left" << endl;
861 cout <<
"elliptic_curve::index_of_point "
862 "did not find point" << endl;
863 cout <<
"x1=" << x1 <<
" x2=" << x2 <<
" x3=" << x3 << endl;
883 for (i = 0; i < (int) Ord.size(); i++) {
888 ost <<
"\\begin{array}{|r|r|r|}" << endl;
890 ost <<
"\\hline" << endl;
891 for (i = 0; i <
nb; i++) {
894 ost <<
"(" <<
T[3 * i + 0] <<
"," <<
T[3 * i + 1] <<
")";
899 ost <<
" & " <<
p[i];
903 ost <<
"\\end{array}" << endl;
916 for (i = 0; i < (int) Ord.size(); i++) {
920 p, Ord.size(), 1,
TRUE );
929 for (i = 0; i <
nb; i++) {
958 cout << ord <<
" & " << j <<
" & (" <<
T[3 * j + 0]
959 <<
", " <<
T[3 * j + 1] <<
", " <<
T[3 * j + 2]
int frobenius_power(int a, int frob_power)
options for drawing an object of type layered_graph
a general 2D graphical output interface (metapost, tikz, postscript)
void sl_udsty(int line_dashing)
void aligned_text(int x, int y, const char *alignment, const char *p)
void polygon2(int *Px, int *Py, int i1, int i2)
void sl_thickness(int line_thickness)
void init(std::string &file_name, layered_graph_draw_options *Draw_options, int verbose_level)
void draw_axes_and_grid(layered_graph_draw_options *O, double x_min, double x_max, double y_min, double y_max, double dx, double dy, int f_x_axis_at_y_min, int f_y_axis_at_x_min, int x_mod, int y_mod, int x_tick_mod, int y_tick_mod, double x_labels_offset, double y_labels_offset, double x_tick_half_width, double y_tick_half_width, int f_v_lines, int subdivide_v, int f_h_lines, int subdivide_h, int verbose_level)
void sl_ends(int line_beg_style, int line_end_style)
void sf_color(int fill_color)
void polygon5(int *Px, int *Py, int i1, int i2, int i3, int i4, int i5)
void begin_figure(int factor_1000)
void fill_polygon5(int *Px, int *Py, int i1, int i2, int i3, int i4, int i5)
void sf_interior(int fill_interior)
a fixed elliptic curve in Weierstrass form
int index_of_point(int x1, int x2, int x3)
void print_all_powers(int i)
void print_points_affine()
void latex_points_with_order(std::ostream &ost)
void compute_addition_table(int verbose_level)
void init(field_theory::finite_field *F, int b, int c, int verbose_level)
void save_incidence_matrix(std::string &fname, int verbose_level)
void add_point_to_table(int x, int y, int z)
void latex_order_of_all_points(std::ostream &ost)
void draw_grid(std::string &fname, graphics::layered_graph_draw_options *Draw_options, int f_with_grid, int f_with_points, int point_density, int f_path, int start_idx, int nb_steps, int verbose_level)
void make_affine_point(int x1, int x2, int x3, int &a, int &b, int verbose_level)
void addition(int x1, int y1, int z1, int x2, int y2, int z2, int &x3, int &y3, int &z3, int verbose_level)
void order_of_all_points(std::vector< int > &Ord)
int order_of_point(int i)
void draw_grid2(graphics::mp_graphics &G, int f_with_grid, int f_with_points, int point_density, int f_path, int start_idx, int nb_steps, int verbose_level)
field_theory::finite_field * F
void print_addition_table()
void compute_points(int verbose_level)
basic number theoretic functions
void elliptic_curve_addition(field_theory::finite_field *F, int b, int c, int x1, int x2, int x3, int y1, int y2, int y3, int &z1, int &z2, int &z3, int verbose_level)
a collection of functions related to file io
void int_matrix_write_csv(std::string &fname, int *M, int m, int n)
long int file_size(std::string &fname)
interface to create latex output files
void int_matrix_print_tex(std::ostream &ost, int *p, int m, int n)
void print_integer_matrix_with_standard_labels(std::ostream &ost, int *p, int m, int n, int f_tex)
#define Int_vec_zero(A, B)
#define Int_matrix_print(A, B, C)
int sqrt_mod_involved(int a, int p, int verbose_level)
the orbiter library for the classification of combinatorial objects