Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/schemes/hyperelliptic_curves/hypellfrob.pyx
4126 views
1
r"""
2
Frobenius on Monsky-Washnitzer cohomology of a hyperelliptic curve over GF(p),
3
for largish p
4
5
This is a wrapper for the matrix() function in hypellfrob.cpp.
6
7
AUTHOR:
8
-- David Harvey (2007-05)
9
-- David Harvey (2007-12): rewrote for hypellfrob version 2.0
10
"""
11
12
#################################################################################
13
# Copyright (C) 2007 David Harvey <[email protected]>
14
# William Stein <[email protected]>
15
#
16
# Distributed under the terms of the GNU General Public License (GPL)
17
#
18
# http://www.gnu.org/licenses/
19
#*****************************************************************************
20
21
22
from sage.libs.ntl.ntl_ZZ cimport ntl_ZZ
23
from sage.libs.ntl.ntl_ZZX cimport ntl_ZZX
24
from sage.libs.ntl.ntl_mat_ZZ cimport ntl_mat_ZZ
25
from sage.libs.ntl.all import ZZ, ZZX
26
from sage.matrix.all import Matrix
27
from sage.rings.all import Qp, O as big_oh
28
from sage.rings.arith import is_prime
29
30
include "sage/libs/ntl/decl.pxi"
31
include "sage/ext/interrupt.pxi"
32
33
34
cdef extern from "hypellfrob.h":
35
int hypellfrob_matrix "hypellfrob::matrix" (mat_ZZ_c output, ZZ_c p, int N, ZZX_c Q)
36
37
38
def hypellfrob(p, N, Q):
39
r"""
40
Computes the matrix of Frobenius acting on the Monsky-Washnitzer cohomology
41
of a hyperelliptic curve $y^2 = Q(x)$, with respect to the basis $x^i dx/y$,
42
$0 \leq i < 2g$.
43
44
INPUT:
45
p -- a prime
46
Q -- a monic polynomial in $\Z[x]$ of odd degree. Must have no multiple
47
roots mod p.
48
N -- precision parameter; the output matrix will be correct modulo $p^N$.
49
50
PRECONDITIONS:
51
Must have $p > (2g+1)(2N-1)$, where $g = (\deg(Q)-1)/2$ is the genus
52
of the curve.
53
54
ALGORITHM:
55
Described in ``Kedlaya's algorithm in larger characteristic'' by David
56
Harvey. Running time is theoretically soft-$O(p^{1/2} N^{5/2} g^3)$.
57
58
TODO:
59
Remove the restriction on $p$. Probably by merging in Robert's code,
60
which eventually needs a fast C++/NTL implementation.
61
62
EXAMPLES:
63
sage: from sage.schemes.hyperelliptic_curves.hypellfrob import hypellfrob
64
sage: R.<x> = PolynomialRing(ZZ)
65
sage: f = x^5 + 2*x^2 + x + 1; p = 101
66
sage: M = hypellfrob(p, 4, f); M
67
[ 91844754 + O(101^4) 38295665 + O(101^4) 44498269 + O(101^4) 11854028 + O(101^4)]
68
[ 93514789 + O(101^4) 48987424 + O(101^4) 53287857 + O(101^4) 61431148 + O(101^4)]
69
[ 77916046 + O(101^4) 60656459 + O(101^4) 101244586 + O(101^4) 56237448 + O(101^4)]
70
[ 58643832 + O(101^4) 81727988 + O(101^4) 85294589 + O(101^4) 70104432 + O(101^4)]
71
sage: -M.trace()
72
7 + O(101^4)
73
sage: sum([legendre_symbol(f(i), p) for i in range(p)])
74
7
75
sage: ZZ(M.det())
76
10201
77
sage: M = hypellfrob(p, 1, f); M
78
[ 0 + O(101) 0 + O(101) 93 + O(101) 62 + O(101)]
79
[ 0 + O(101) 0 + O(101) 55 + O(101) 19 + O(101)]
80
[ 0 + O(101) 0 + O(101) 65 + O(101) 42 + O(101)]
81
[ 0 + O(101) 0 + O(101) 89 + O(101) 29 + O(101)]
82
83
AUTHORS:
84
-- David Harvey (2007-05)
85
-- David Harvey (2007-12): updated for hypellfrob version 2.0
86
87
"""
88
89
# Sage objects that wrap the NTL objects
90
cdef ntl_ZZ pp
91
cdef ntl_ZZX QQ
92
cdef ntl_mat_ZZ mm # the result will go in mm
93
cdef int i, j
94
95
if N < 1:
96
raise ValueError, "N must be an integer >= 1"
97
98
Q = Q.list()
99
if len(Q) < 4 or len(Q) % 2 or Q[-1] != 1:
100
raise ValueError, "Q must be a monic polynomial of odd degree >= 3"
101
QQ = ZZX(Q)
102
103
bound = (len(Q) - 1) * (2*N - 1)
104
if p <= bound:
105
raise ValueError, "In the current implementation, p must be greater than (2g+1)(2N-1) = %s" % bound
106
107
if not is_prime(p):
108
raise ValueError, "p (= %s) must be prime" % p
109
110
pp = ZZ(p)
111
112
cdef int g # the genus
113
g = (len(Q) / 2) - 1
114
115
# Note: the C++ code actually resets the size of the matrix, but this seems
116
# to confuse the Sage NTL wrapper. So to be safe I'm setting it ahead of
117
# time.
118
mm = ntl_mat_ZZ(2*g, 2*g)
119
120
cdef int result
121
sig_on()
122
result = hypellfrob_matrix(mm.x, pp.x, N, QQ.x)
123
sig_off()
124
125
if not result:
126
raise ValueError, "Could not compute frobenius matrix, because the curve is singular at p."
127
128
R = Qp(p, N, print_mode="terse")
129
prec = big_oh(p**N)
130
data = [[mm[j, i]._integer_() + prec for i from 0 <= i < 2*g] for j from 0 <= j < 2*g]
131
return Matrix(R, data)
132
133
134
################ end of file
135
136