passagemath-eclib 10.6.40__cp314-cp314t-macosx_13_0_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of passagemath-eclib might be problematic. Click here for more details.

@@ -0,0 +1,158 @@
1
+ # sage_setup: distribution = sagemath-eclib
2
+ # distutils: language = c++
3
+ # distutils: libraries = ec NTL_LIBRARIES pari gmp M_LIBRARIES
4
+ # distutils: extra_compile_args = NTL_CFLAGS
5
+ # distutils: include_dirs = NTL_INCDIR
6
+ # distutils: library_dirs = NTL_LIBDIR
7
+ # distutils: extra_link_args = NTL_LIBEXTRA
8
+
9
+
10
+ from libcpp.map cimport map
11
+ from libcpp.vector cimport vector
12
+ from libcpp.pair cimport pair
13
+ from sage.libs.ntl.types cimport ZZ_c
14
+
15
+
16
+ # NOTE: eclib used to have specific dependencies, so that they had to
17
+ # be included in a specific order. Although this is no longer the
18
+ # case, we start by listing all relevant include files in the correct
19
+ # order.
20
+
21
+ cdef extern from "eclib/vector.h": pass
22
+ cdef extern from "eclib/xmod.h": pass
23
+ cdef extern from "eclib/svector.h": pass
24
+ cdef extern from "eclib/matrix.h": pass
25
+ cdef extern from "eclib/smatrix.h": pass
26
+ cdef extern from "eclib/interface.h": pass
27
+ cdef extern from "eclib/rat.h": pass
28
+ cdef extern from "eclib/bigrat.h": pass
29
+ cdef extern from "eclib/isogs.h": pass
30
+ cdef extern from "eclib/curve.h": pass
31
+ cdef extern from "eclib/descent.h": pass
32
+ cdef extern from "eclib/egr.h": pass
33
+ cdef extern from "eclib/htconst.h": pass
34
+ cdef extern from "eclib/moddata.h": pass
35
+ cdef extern from "eclib/symb.h": pass
36
+ cdef extern from "eclib/homspace.h": pass
37
+ cdef extern from "eclib/oldforms.h": pass
38
+ cdef extern from "eclib/newforms.h": pass
39
+
40
+
41
+ # Now the actual declarations, where the order no longer matters
42
+ cdef extern from "eclib/vector.h":
43
+ ctypedef int scalar
44
+
45
+ cdef cppclass vec:
46
+ scalar operator[](long)
47
+
48
+ cdef extern from "eclib/svector.h":
49
+ cdef cppclass svec:
50
+ vec as_vec()
51
+ scalar elem(int) const
52
+ map[int,scalar].iterator begin()
53
+ map[int,scalar].iterator end()
54
+
55
+ cdef extern from "eclib/matrix.h":
56
+ cdef cppclass mat:
57
+ mat()
58
+ mat(mat m)
59
+ scalar sub(long, long)
60
+ long nrows()
61
+ long ncols()
62
+ long rank()
63
+
64
+ mat addscalar(mat M, scalar)
65
+
66
+ cdef extern from "eclib/smatrix.h":
67
+ cdef cppclass smat:
68
+ smat()
69
+ smat(smat m)
70
+ scalar sub(long, long)
71
+ long nrows()
72
+ long ncols()
73
+ long rank()
74
+ scalar elem(int, int) const
75
+ svec row(int) const
76
+
77
+ cdef extern from "eclib/interface.h":
78
+ ctypedef ZZ_c bigint
79
+ int I2int(bigint)
80
+
81
+ cdef extern from "eclib/rat.h":
82
+ cdef cppclass rational:
83
+ rational()
84
+ rational(long num, long den)
85
+ cdef long rational_num "num"(rational q)
86
+ cdef long rational_den "den"(rational q)
87
+
88
+ cdef extern from "eclib/bigrat.h":
89
+ cdef cppclass bigrational:
90
+ pass
91
+ cdef bigint bigrational_num "num"(bigrational q)
92
+ cdef bigint bigrational_den "den"(bigrational q)
93
+
94
+ cdef extern from "eclib/curve.h":
95
+ cdef cppclass Curve:
96
+ Curve()
97
+ Curve(bigint aa1, bigint aa2, bigint aa3, bigint aa4, bigint aa6)
98
+ void getai(bigint a1, bigint a2, bigint a3, bigint a4, bigint a6)
99
+
100
+ cdef cppclass Curvedata:
101
+ Curvedata()
102
+ Curvedata(Curve C, int m)
103
+ Curvedata(bigint a1, bigint a2, bigint a3, bigint a4, bigint a6,
104
+ int min_on_init)
105
+ void getai(bigint a1, bigint a2, bigint a3, bigint a4, bigint a6)
106
+
107
+ cdef cppclass CurveRed:
108
+ CurveRed()
109
+ CurveRed(Curvedata CD)
110
+
111
+ bigint getconductor(CurveRed CR)
112
+
113
+ cdef extern from "eclib/descent.h":
114
+ cdef cppclass two_descent:
115
+ two_descent(Curvedata* curve,
116
+ int verb, int sel,
117
+ long firstlim, long secondlim,
118
+ long n_aux, int second_descent)
119
+
120
+ cdef cppclass mw:
121
+ mw(Curvedata* curve, int verb, int pp, int maxr)
122
+
123
+ cdef extern from "eclib/homspace.h":
124
+ cdef cppclass homspace:
125
+ long modulus
126
+ int plusflag # sign
127
+ int cuspidal
128
+
129
+ homspace(long n, int hp, int hcusp, int verbose)
130
+
131
+ int h1dim()
132
+ int h1cuspdim()
133
+ mat heckeop(long p, int dual, int display)
134
+ vec heckeop_col(long p, int j, int display)
135
+ smat s_heckeop(long p, int dual, int display)
136
+ long h1ncusps()
137
+
138
+ cdef extern from "eclib/newforms.h":
139
+ cdef cppclass newforms:
140
+ vector[newform] nflist
141
+ int verbose
142
+ int basisflag
143
+ long maxdepth
144
+ long cuspidal
145
+ long sign
146
+
147
+ newforms(long n, int disp)
148
+
149
+ void createfromcurve(int sign, CurveRed CR, int nap)
150
+ void display()
151
+ # Here i is the index of the relevant newform in the space,
152
+ # which for us will always be 0:
153
+ rational plus_modular_symbol(rational r, int i, int base_at_infinity)
154
+ rational minus_modular_symbol(rational r, int i, int base_at_infinity)
155
+ pair[rational,rational] full_modular_symbol(rational r, int i, int base_at_infinity)
156
+
157
+ cdef cppclass newform:
158
+ newforms* nf
@@ -0,0 +1 @@
1
+ # sage_setup: distribution = sagemath-eclib
sage/libs/eclib/all.py ADDED
@@ -0,0 +1,5 @@
1
+ # sage_setup: distribution = sagemath-eclib
2
+ from sage.libs.eclib.constructor import CremonaModularSymbols
3
+ from sage.libs.eclib.interface import mwrank_EllipticCurve, mwrank_MordellWeil
4
+ from sage.libs.eclib.mwrank import get_precision, set_precision
5
+ from sage.libs.eclib.mwrank import initprimes as mwrank_initprimes
@@ -0,0 +1,75 @@
1
+ # sage_setup: distribution = sagemath-eclib
2
+ "Cremona modular symbols"
3
+
4
+
5
+ def CremonaModularSymbols(level, sign=0, cuspidal=False, verbose=0):
6
+ """
7
+ Return the space of Cremona modular symbols with given level, sign, etc.
8
+
9
+ INPUT:
10
+
11
+ - ``level`` -- integer; at least 2, not just positive!
12
+ - ``sign`` -- integer (default: 0); either 0 or 1 or -1
13
+ - ``cuspidal`` -- boolean (default: ``False``); if ``True``, compute only
14
+ the cuspidal subspace
15
+ - ``verbose`` -- boolean (default: ``False``); if ``True``, print verbose
16
+ information while creating space
17
+
18
+ EXAMPLES::
19
+
20
+ sage: M = CremonaModularSymbols(43); M
21
+ Cremona Modular Symbols space of dimension 7 for Gamma_0(43) of weight 2 with sign 0
22
+ sage: M = CremonaModularSymbols(43, sign=1); M
23
+ Cremona Modular Symbols space of dimension 4 for Gamma_0(43) of weight 2 with sign 1
24
+ sage: M = CremonaModularSymbols(43, cuspidal=True); M
25
+ Cremona Cuspidal Modular Symbols space of dimension 6 for Gamma_0(43) of weight 2 with sign 0
26
+ sage: M = CremonaModularSymbols(43, cuspidal=True, sign=1); M
27
+ Cremona Cuspidal Modular Symbols space of dimension 3 for Gamma_0(43) of weight 2 with sign 1
28
+
29
+ When run interactively, the following command will display verbose output::
30
+
31
+ sage: M = CremonaModularSymbols(43, verbose=1)
32
+ After 2-term relations, ngens = 22
33
+ ngens = 22
34
+ maxnumrel = 32
35
+ relation matrix has = 704 entries...
36
+ Finished 3-term relations: numrel = 16 ( maxnumrel = 32)
37
+ relmat has 42 nonzero entries (density = 0.0596591)
38
+ Computing kernel...
39
+ time to compute kernel = (... seconds)
40
+ rk = 7
41
+ Number of cusps is 2
42
+ ncusps = 2
43
+ About to compute matrix of delta
44
+ delta matrix done: size 2x7.
45
+ About to compute kernel of delta
46
+ done
47
+ Finished constructing homspace.
48
+ sage: M
49
+ Cremona Modular Symbols space of dimension 7 for Gamma_0(43) of weight 2 with sign 0
50
+
51
+ The input must be valid or a :exc:`ValueError` is raised::
52
+
53
+ sage: M = CremonaModularSymbols(-1)
54
+ Traceback (most recent call last):
55
+ ...
56
+ ValueError: the level (= -1) must be at least 2
57
+ sage: M = CremonaModularSymbols(0)
58
+ Traceback (most recent call last):
59
+ ...
60
+ ValueError: the level (= 0) must be at least 2
61
+
62
+ The sign can only be 0 or 1 or -1::
63
+
64
+ sage: M = CremonaModularSymbols(10, sign = -2)
65
+ Traceback (most recent call last):
66
+ ...
67
+ ValueError: sign (= -2) is not supported; use 0, +1 or -1
68
+
69
+ We do allow -1 as a sign (see :issue:`9476`)::
70
+
71
+ sage: CremonaModularSymbols(10, sign = -1)
72
+ Cremona Modular Symbols space of dimension 0 for Gamma_0(10) of weight 2 with sign -1
73
+ """
74
+ from .homspace import ModularSymbols
75
+ return ModularSymbols(level=level, sign=sign, cuspidal=cuspidal, verbose=verbose)
@@ -0,0 +1,5 @@
1
+ # sage_setup: distribution = sagemath-eclib
2
+ from sage.libs.eclib cimport homspace
3
+
4
+ cdef class ModularSymbols:
5
+ cdef homspace* H
@@ -0,0 +1,285 @@
1
+ # sage_setup: distribution = sagemath-eclib
2
+ "Cremona modular symbols"
3
+
4
+ from cysignals.signals cimport sig_on, sig_off
5
+ from cython.operator cimport dereference as deref
6
+ from cython.operator cimport preincrement as inc
7
+
8
+ from sage.libs.eclib cimport svec, mat, smat
9
+ from sage.libs.eclib.mat cimport MatrixFactory
10
+
11
+ from sage.matrix.matrix_space import MatrixSpace
12
+ from sage.rings.integer_ring import ZZ
13
+
14
+ cdef MatrixFactory MF = MatrixFactory()
15
+
16
+
17
+ cdef class ModularSymbols:
18
+ """
19
+ Class of Cremona Modular Symbols of given level and sign (and weight 2).
20
+
21
+ EXAMPLES::
22
+
23
+ sage: M = CremonaModularSymbols(225)
24
+ sage: type(M)
25
+ <class 'sage.libs.eclib.homspace.ModularSymbols'>
26
+ """
27
+ def __init__(self, long level, int sign=0, bint cuspidal=False, int verbose=0):
28
+ """
29
+ Called when creating a space of Cremona modular symbols.
30
+
31
+ INPUT:
32
+
33
+ - ``level`` -- integer; the level: at least 2
34
+ - ``sign`` -- integer (default: 0); the sign: 0, +1 or -1
35
+ - ``cuspidal`` -- boolean (default: ``False``); ``True`` for cuspidal homology
36
+ - ``verbose`` -- integer (default: 0); verbosity level
37
+
38
+ EXAMPLES::
39
+
40
+ sage: CremonaModularSymbols(123, sign=1, cuspidal=True)
41
+ Cremona Cuspidal Modular Symbols space of dimension 13 for Gamma_0(123) of weight 2 with sign 1
42
+ sage: CremonaModularSymbols(123, sign=-1, cuspidal=True)
43
+ Cremona Cuspidal Modular Symbols space of dimension 13 for Gamma_0(123) of weight 2 with sign -1
44
+ sage: CremonaModularSymbols(123, sign=0, cuspidal=True)
45
+ Cremona Cuspidal Modular Symbols space of dimension 26 for Gamma_0(123) of weight 2 with sign 0
46
+ sage: CremonaModularSymbols(123, sign=0, cuspidal=False)
47
+ Cremona Modular Symbols space of dimension 29 for Gamma_0(123) of weight 2 with sign 0
48
+ """
49
+ if not (sign == 0 or sign == 1 or sign == -1):
50
+ raise ValueError("sign (= %s) is not supported; use 0, +1 or -1" % sign)
51
+ if level <= 1:
52
+ raise ValueError("the level (= %s) must be at least 2" % level)
53
+ sig_on()
54
+ self.H = new homspace(level, sign, cuspidal, verbose)
55
+ sig_off()
56
+
57
+ def __dealloc__(self):
58
+ del self.H
59
+
60
+ def __repr__(self):
61
+ """
62
+ String representation of space of Cremona modular symbols.
63
+
64
+ EXAMPLES:
65
+
66
+ We test various types of spaces that impact printing::
67
+
68
+ sage: M = CremonaModularSymbols(37, sign=1)
69
+ sage: M.__repr__()
70
+ 'Cremona Modular Symbols space of dimension 3 for Gamma_0(37) of weight 2 with sign 1'
71
+
72
+ sage: CremonaModularSymbols(37, cuspidal=True).__repr__()
73
+ 'Cremona Cuspidal Modular Symbols space of dimension 4 for Gamma_0(37) of weight 2 with sign 0'
74
+ """
75
+ return "Cremona %sModular Symbols space of dimension %s for Gamma_0(%s) of weight 2 with sign %s" % (
76
+ 'Cuspidal ' if self.is_cuspidal() else '',
77
+ self.dimension(), self.level(), self.sign())
78
+
79
+ #cpdef long level(self):
80
+ def level(self):
81
+ """
82
+ Return the level of this modular symbols space.
83
+
84
+ EXAMPLES::
85
+
86
+ sage: M = CremonaModularSymbols(1234, sign=1)
87
+ sage: M.level()
88
+ 1234
89
+ """
90
+ return self.H.modulus
91
+
92
+ #cpdef int dimension(self):
93
+ def dimension(self):
94
+ """
95
+ Return the dimension of this modular symbols space.
96
+
97
+ EXAMPLES::
98
+
99
+ sage: M = CremonaModularSymbols(1234, sign=1)
100
+ sage: M.dimension()
101
+ 156
102
+ """
103
+ if self.is_cuspidal():
104
+ return self.H.h1cuspdim()
105
+ else:
106
+ return self.H.h1dim()
107
+
108
+ def number_of_cusps(self):
109
+ r"""
110
+ Return the number of cusps for `\Gamma_0(N)`, where `N` is the
111
+ level.
112
+
113
+ EXAMPLES::
114
+
115
+ sage: M = CremonaModularSymbols(225)
116
+ sage: M.number_of_cusps()
117
+ 24
118
+ """
119
+ return self.H.h1ncusps()
120
+
121
+ #cpdef int sign(self):
122
+ def sign(self):
123
+ """
124
+ Return the sign of this Cremona modular symbols space. The sign is either 0, +1 or -1.
125
+
126
+ EXAMPLES::
127
+
128
+ sage: M = CremonaModularSymbols(1122, sign=1); M
129
+ Cremona Modular Symbols space of dimension 224 for Gamma_0(1122) of weight 2 with sign 1
130
+ sage: M.sign()
131
+ 1
132
+ sage: M = CremonaModularSymbols(1122); M
133
+ Cremona Modular Symbols space of dimension 433 for Gamma_0(1122) of weight 2 with sign 0
134
+ sage: M.sign()
135
+ 0
136
+ sage: M = CremonaModularSymbols(1122, sign=-1); M
137
+ Cremona Modular Symbols space of dimension 209 for Gamma_0(1122) of weight 2 with sign -1
138
+ sage: M.sign()
139
+ -1
140
+ """
141
+ return self.H.plusflag
142
+
143
+ #cpdef bint is_cuspidal(self):
144
+ def is_cuspidal(self):
145
+ """
146
+ Return whether or not this space is cuspidal.
147
+
148
+ EXAMPLES::
149
+
150
+ sage: M = CremonaModularSymbols(1122); M.is_cuspidal()
151
+ 0
152
+ sage: M = CremonaModularSymbols(1122, cuspidal=True); M.is_cuspidal()
153
+ 1
154
+ """
155
+ return self.H.cuspidal
156
+
157
+ def hecke_matrix(self, long p, dual=False, verbose=False):
158
+ """
159
+ Return the matrix of the ``p``-th Hecke operator acting on
160
+ this space of modular symbols.
161
+
162
+ The result of this command is not cached.
163
+
164
+ INPUT:
165
+
166
+ - ``p`` -- a prime number
167
+
168
+ - ``dual`` -- boolean (default: ``False``); whether to compute the
169
+ Hecke operator acting on the dual space, i.e., the transpose of the
170
+ Hecke operator
171
+
172
+ - ``verbose`` -- boolean (default: ``False``); print verbose output
173
+
174
+ OUTPUT:
175
+
176
+ (matrix) If ``p`` divides the level, the matrix of the
177
+ Atkin-Lehner involution `W_p` at ``p``; otherwise the matrix of the
178
+ Hecke operator `T_p`,
179
+
180
+ EXAMPLES::
181
+
182
+ sage: M = CremonaModularSymbols(37)
183
+ sage: t = M.hecke_matrix(2); t
184
+ 5 x 5 Cremona matrix over Rational Field
185
+ sage: print(t.str())
186
+ [ 3 0 0 0 0]
187
+ [-1 -1 1 1 0]
188
+ [ 0 0 -1 0 1]
189
+ [-1 1 0 -1 -1]
190
+ [ 0 0 1 0 -1]
191
+ sage: t.charpoly().factor()
192
+ (x - 3) * x^2 * (x + 2)^2
193
+ sage: print(M.hecke_matrix(2, dual=True).str())
194
+ [ 3 -1 0 -1 0]
195
+ [ 0 -1 0 1 0]
196
+ [ 0 1 -1 0 1]
197
+ [ 0 1 0 -1 0]
198
+ [ 0 0 1 -1 -1]
199
+ sage: w = M.hecke_matrix(37); w
200
+ 5 x 5 Cremona matrix over Rational Field
201
+ sage: w.charpoly().factor()
202
+ (x - 1)^2 * (x + 1)^3
203
+ sage: sw = w.sage_matrix_over_ZZ()
204
+ sage: st = t.sage_matrix_over_ZZ()
205
+ sage: sw^2 == sw.parent()(1)
206
+ True
207
+ sage: st*sw == sw*st
208
+ True
209
+ """
210
+ sig_on()
211
+ cdef mat M = self.H.heckeop(p, dual, verbose)
212
+ sig_off()
213
+ return MF.new_matrix(M)
214
+
215
+ def sparse_hecke_matrix(self, long p, dual=False, verbose=False, base_ring=ZZ):
216
+ """
217
+ Return the matrix of the ``p``-th Hecke operator acting on
218
+ this space of modular symbols as a sparse Sage matrix over
219
+ ``base_ring``. This is more memory-efficient than creating a
220
+ Cremona matrix and then applying sage_matrix_over_ZZ with sparse=True.
221
+
222
+ The result of this command is not cached.
223
+
224
+ INPUT:
225
+
226
+ - ``p`` -- a prime number
227
+
228
+ - ``dual`` -- boolean (default: ``False``); whether to compute the
229
+ Hecke operator acting on the dual space, i.e., the transpose of the Hecke
230
+ operator
231
+
232
+ - ``verbose`` -- boolean (default: ``False``); print verbose output
233
+
234
+ OUTPUT:
235
+
236
+ (matrix) If ``p`` divides the level, the matrix of the
237
+ Atkin-Lehner involution `W_p` at ``p``; otherwise the matrix of the
238
+ Hecke operator `T_p`,
239
+
240
+ EXAMPLES::
241
+
242
+ sage: M = CremonaModularSymbols(37)
243
+ sage: t = M.sparse_hecke_matrix(2); type(t)
244
+ <class 'sage.matrix.matrix_integer_sparse.Matrix_integer_sparse'>
245
+ sage: print(t)
246
+ [ 3 0 0 0 0]
247
+ [-1 -1 1 1 0]
248
+ [ 0 0 -1 0 1]
249
+ [-1 1 0 -1 -1]
250
+ [ 0 0 1 0 -1]
251
+ sage: M = CremonaModularSymbols(5001)
252
+ sage: T = M.sparse_hecke_matrix(2)
253
+ sage: U = M.hecke_matrix(2).sage_matrix_over_ZZ(sparse=True)
254
+ sage: print(T == U)
255
+ True
256
+ sage: T = M.sparse_hecke_matrix(2, dual=True)
257
+ sage: print(T == U.transpose())
258
+ True
259
+ sage: T = M.sparse_hecke_matrix(2, base_ring=GF(7))
260
+ sage: print(T == U.change_ring(GF(7)))
261
+ True
262
+
263
+ This concerns an issue reported on :issue:`21303`::
264
+
265
+ sage: C = CremonaModularSymbols(45, cuspidal=True,sign=-1)
266
+ sage: T2a = C.hecke_matrix(2).sage_matrix_over_ZZ()
267
+ sage: T2b = C.sparse_hecke_matrix(2)
268
+ sage: print(T2a == T2b)
269
+ True
270
+ """
271
+ cdef long i, n = self.dimension()
272
+ cdef svec sv
273
+ d = {}
274
+ sig_on()
275
+ cdef smat M = self.H.s_heckeop(p, dual, verbose)
276
+ sig_off()
277
+ for i in range(n):
278
+ sv = M.row(i+1)
279
+ iter = sv.begin()
280
+ while iter != sv.end():
281
+ d[(i,deref(iter).first-1)] = deref(iter).second
282
+ inc(iter)
283
+ MS = MatrixSpace(base_ring, n, sparse=True)
284
+ # The next step is the bottleneck.
285
+ return MS(d)