Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
241818 views
1
#ifndef _POINTCOUNT_INCLUDE_
2
#define _POINTCOUNT_INCLUDE_
3
4
#include "ff.h"
5
6
/*
7
Copyright 2007 Andrew V. Sutherland
8
9
This file is part of smalljac.
10
11
smalljac is free software: you can redistribute it and/or modify
12
it under the terms of the GNU General Public License as published by
13
the Free Software Foundation, either version 2 of the License, or
14
(at your option) any later version.
15
16
smalljac is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
GNU General Public License for more details.
20
21
You should have received a copy of the GNU General Public License
22
along with smalljac. If not, see <http://www.gnu.org/licenses/>.
23
*/
24
25
/*
26
This module implements pointcounting over prime fields based on finite differences,
27
as described in [KedlayaSutherland2007]
28
*/
29
30
#define POINTCOUNT_MULTI_X 32
31
32
// Allocates memory for map of residues - must call first
33
void pointcount_init (unsigned maxp);
34
35
// Note that precompute returns integer values, independent of p
36
// These need to be reduced mod p prior to calling any of the functions below
37
void pointcount_precompute (mpz_t D[], mpz_t f[], int degree);
38
void pointcount_precompute_long (long D[], long f[], int degree);
39
40
// handy inline for doing reduction (note sign handling, d[i] must have nonnegative values)
41
static inline void pointcount_reduce (unsigned long d[], long D[], int degree, long p)
42
{ register long x; register int i; for ( i = 0 ; i <= degree ; i++ ) { x=D[i]%p; d[i] = (x < 0 ? x+p : x); } }
43
44
// Standard hyperelliptic point counting functions for curves of the form y^2=f(x) - default is degree 2g+1
45
unsigned pointcount_g1 (unsigned long D[4], unsigned p);
46
unsigned pointcount_g2 (unsigned long D[6], unsigned p);
47
unsigned pointcount_g2d6 (unsigned long D[7], unsigned p, unsigned long f6);
48
unsigned pointcount_g3 (unsigned long D[8], unsigned p);
49
unsigned pointcount_g3d8 (unsigned long D[9], unsigned p, unsigned long f8);
50
unsigned pointcount_g4 (unsigned long D[10], unsigned p);
51
52
// Point counting over Picard curves y^3 = f(x)
53
unsigned pointcount_pd4 (unsigned long D[5], unsigned p);
54
55
// Point counting in F_p^2
56
unsigned pointcount_g2_d2 (unsigned long f[6], unsigned p);
57
58
// This use half as much memory but are slower - use when p/8 > L2 cache
59
unsigned pointcount_big_g1 (unsigned long D[4], unsigned p);
60
unsigned pointcount_big_g2 (unsigned long D[6], unsigned p);
61
unsigned pointcount_big_g2d6 (unsigned long D[7], unsigned p, unsigned long f6);
62
unsigned pointcount_big_g3 (unsigned long D[8], unsigned p);
63
unsigned pointcount_big_g4 (unsigned long D[10], unsigned p);
64
65
// These routines return point counts on 32 curves f(x), f(x)+1, ..., f(x)+32
66
int pointcount_multi_g2 (unsigned pts[], unsigned long D[6], unsigned p);
67
int pointcount_multi_g2d6 (unsigned pts[], unsigned long D[6], unsigned p, unsigned long f6);
68
int pointcount_multi_g3 (unsigned pts[], unsigned long D[8], unsigned p);
69
int pointcount_multi_g3d8 (unsigned pts[], unsigned long D[6], unsigned p, unsigned long f8);
70
71
// naive polynomial evaluation, provided for comparison
72
unsigned pointcount_slow (ff_t f[], int d, unsigned p);
73
unsigned pointcount_tiny (unsigned long f[], int d, unsigned p);
74
75
// naive polynomial evaluation for pointcounting over F_p^2 - only used for small p
76
unsigned pointcount_slow_d2 (ff_t f[], int d, unsigned p);
77
unsigned pointcount_tiny_d2 (unsigned long f[], int d, unsigned p);
78
79
// naive polynomial evaluation for pointcounting over F_p^3 - only used for small p
80
unsigned pointcount_tiny_d3 (unsigned long f[], int d, unsigned p);
81
82
#endif
83
84