passagemath-schemes 10.8.1a4__cp314-cp314t-macosx_13_0_arm64.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.
Files changed (312) hide show
  1. passagemath_schemes/.dylibs/libflint.22.0.dylib +0 -0
  2. passagemath_schemes/.dylibs/libgmp.10.dylib +0 -0
  3. passagemath_schemes/.dylibs/libgmpxx.4.dylib +0 -0
  4. passagemath_schemes/.dylibs/libmpfr.6.dylib +0 -0
  5. passagemath_schemes/__init__.py +3 -0
  6. passagemath_schemes-10.8.1a4.dist-info/METADATA +203 -0
  7. passagemath_schemes-10.8.1a4.dist-info/METADATA.bak +204 -0
  8. passagemath_schemes-10.8.1a4.dist-info/RECORD +312 -0
  9. passagemath_schemes-10.8.1a4.dist-info/WHEEL +6 -0
  10. passagemath_schemes-10.8.1a4.dist-info/top_level.txt +3 -0
  11. sage/all__sagemath_schemes.py +23 -0
  12. sage/databases/all__sagemath_schemes.py +7 -0
  13. sage/databases/cremona.py +1723 -0
  14. sage/dynamics/all__sagemath_schemes.py +2 -0
  15. sage/dynamics/arithmetic_dynamics/affine_ds.py +1083 -0
  16. sage/dynamics/arithmetic_dynamics/all.py +14 -0
  17. sage/dynamics/arithmetic_dynamics/berkovich_ds.py +1101 -0
  18. sage/dynamics/arithmetic_dynamics/dynamical_semigroup.py +1543 -0
  19. sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py +2426 -0
  20. sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py +1169 -0
  21. sage/dynamics/arithmetic_dynamics/generic_ds.py +663 -0
  22. sage/dynamics/arithmetic_dynamics/product_projective_ds.py +339 -0
  23. sage/dynamics/arithmetic_dynamics/projective_ds.py +9556 -0
  24. sage/dynamics/arithmetic_dynamics/projective_ds_helper.cpython-314t-darwin.so +0 -0
  25. sage/dynamics/arithmetic_dynamics/projective_ds_helper.pyx +301 -0
  26. sage/dynamics/arithmetic_dynamics/wehlerK3.py +2578 -0
  27. sage/lfunctions/all.py +18 -0
  28. sage/lfunctions/dokchitser.py +727 -0
  29. sage/lfunctions/pari.py +971 -0
  30. sage/lfunctions/zero_sums.cpython-314t-darwin.so +0 -0
  31. sage/lfunctions/zero_sums.pyx +1847 -0
  32. sage/modular/abvar/abvar.py +5132 -0
  33. sage/modular/abvar/abvar_ambient_jacobian.py +414 -0
  34. sage/modular/abvar/abvar_newform.py +246 -0
  35. sage/modular/abvar/all.py +8 -0
  36. sage/modular/abvar/constructor.py +187 -0
  37. sage/modular/abvar/cuspidal_subgroup.py +371 -0
  38. sage/modular/abvar/finite_subgroup.py +896 -0
  39. sage/modular/abvar/homology.py +721 -0
  40. sage/modular/abvar/homspace.py +989 -0
  41. sage/modular/abvar/lseries.py +415 -0
  42. sage/modular/abvar/morphism.py +935 -0
  43. sage/modular/abvar/torsion_point.py +274 -0
  44. sage/modular/abvar/torsion_subgroup.py +741 -0
  45. sage/modular/all.py +43 -0
  46. sage/modular/arithgroup/all.py +20 -0
  47. sage/modular/arithgroup/arithgroup_element.cpython-314t-darwin.so +0 -0
  48. sage/modular/arithgroup/arithgroup_element.pyx +474 -0
  49. sage/modular/arithgroup/arithgroup_generic.py +1406 -0
  50. sage/modular/arithgroup/arithgroup_perm.py +2692 -0
  51. sage/modular/arithgroup/congroup.cpython-314t-darwin.so +0 -0
  52. sage/modular/arithgroup/congroup.pyx +334 -0
  53. sage/modular/arithgroup/congroup_gamma.py +361 -0
  54. sage/modular/arithgroup/congroup_gamma0.py +692 -0
  55. sage/modular/arithgroup/congroup_gamma1.py +659 -0
  56. sage/modular/arithgroup/congroup_gammaH.py +1491 -0
  57. sage/modular/arithgroup/congroup_generic.py +630 -0
  58. sage/modular/arithgroup/congroup_sl2z.py +266 -0
  59. sage/modular/arithgroup/farey_symbol.cpython-314t-darwin.so +0 -0
  60. sage/modular/arithgroup/farey_symbol.pyx +1067 -0
  61. sage/modular/arithgroup/tests.py +425 -0
  62. sage/modular/btquotients/all.py +4 -0
  63. sage/modular/btquotients/btquotient.py +3736 -0
  64. sage/modular/btquotients/pautomorphicform.py +2564 -0
  65. sage/modular/buzzard.py +100 -0
  66. sage/modular/congroup.py +29 -0
  67. sage/modular/congroup_element.py +13 -0
  68. sage/modular/cusps.py +1107 -0
  69. sage/modular/cusps_nf.py +1270 -0
  70. sage/modular/dims.py +571 -0
  71. sage/modular/dirichlet.py +3310 -0
  72. sage/modular/drinfeld_modform/all.py +2 -0
  73. sage/modular/drinfeld_modform/element.py +446 -0
  74. sage/modular/drinfeld_modform/ring.py +773 -0
  75. sage/modular/drinfeld_modform/tutorial.py +236 -0
  76. sage/modular/etaproducts.py +1076 -0
  77. sage/modular/hecke/algebra.py +725 -0
  78. sage/modular/hecke/all.py +19 -0
  79. sage/modular/hecke/ambient_module.py +994 -0
  80. sage/modular/hecke/degenmap.py +119 -0
  81. sage/modular/hecke/element.py +302 -0
  82. sage/modular/hecke/hecke_operator.py +736 -0
  83. sage/modular/hecke/homspace.py +185 -0
  84. sage/modular/hecke/module.py +1744 -0
  85. sage/modular/hecke/morphism.py +139 -0
  86. sage/modular/hecke/submodule.py +970 -0
  87. sage/modular/hypergeometric_misc.cpython-314t-darwin.so +0 -0
  88. sage/modular/hypergeometric_misc.pxd +4 -0
  89. sage/modular/hypergeometric_misc.pyx +166 -0
  90. sage/modular/hypergeometric_motive.py +2020 -0
  91. sage/modular/local_comp/all.py +2 -0
  92. sage/modular/local_comp/liftings.py +292 -0
  93. sage/modular/local_comp/local_comp.py +1070 -0
  94. sage/modular/local_comp/smoothchar.py +1825 -0
  95. sage/modular/local_comp/type_space.py +748 -0
  96. sage/modular/modform/all.py +30 -0
  97. sage/modular/modform/ambient.py +817 -0
  98. sage/modular/modform/ambient_R.py +177 -0
  99. sage/modular/modform/ambient_eps.py +306 -0
  100. sage/modular/modform/ambient_g0.py +120 -0
  101. sage/modular/modform/ambient_g1.py +199 -0
  102. sage/modular/modform/constructor.py +545 -0
  103. sage/modular/modform/cuspidal_submodule.py +708 -0
  104. sage/modular/modform/defaults.py +14 -0
  105. sage/modular/modform/eis_series.py +487 -0
  106. sage/modular/modform/eisenstein_submodule.py +663 -0
  107. sage/modular/modform/element.py +4105 -0
  108. sage/modular/modform/half_integral.py +154 -0
  109. sage/modular/modform/hecke_operator_on_qexp.py +247 -0
  110. sage/modular/modform/j_invariant.py +47 -0
  111. sage/modular/modform/l_series_gross_zagier.py +127 -0
  112. sage/modular/modform/l_series_gross_zagier_coeffs.cpython-314t-darwin.so +0 -0
  113. sage/modular/modform/l_series_gross_zagier_coeffs.pyx +177 -0
  114. sage/modular/modform/notes.py +45 -0
  115. sage/modular/modform/numerical.py +514 -0
  116. sage/modular/modform/periods.py +14 -0
  117. sage/modular/modform/ring.py +1257 -0
  118. sage/modular/modform/space.py +1859 -0
  119. sage/modular/modform/submodule.py +118 -0
  120. sage/modular/modform/tests.py +64 -0
  121. sage/modular/modform/theta.py +110 -0
  122. sage/modular/modform/vm_basis.py +380 -0
  123. sage/modular/modform/weight1.py +221 -0
  124. sage/modular/modform_hecketriangle/abstract_ring.py +1932 -0
  125. sage/modular/modform_hecketriangle/abstract_space.py +2527 -0
  126. sage/modular/modform_hecketriangle/all.py +30 -0
  127. sage/modular/modform_hecketriangle/analytic_type.py +590 -0
  128. sage/modular/modform_hecketriangle/constructor.py +416 -0
  129. sage/modular/modform_hecketriangle/element.py +351 -0
  130. sage/modular/modform_hecketriangle/functors.py +752 -0
  131. sage/modular/modform_hecketriangle/graded_ring.py +541 -0
  132. sage/modular/modform_hecketriangle/graded_ring_element.py +2225 -0
  133. sage/modular/modform_hecketriangle/hecke_triangle_group_element.py +3349 -0
  134. sage/modular/modform_hecketriangle/hecke_triangle_groups.py +1426 -0
  135. sage/modular/modform_hecketriangle/readme.py +1214 -0
  136. sage/modular/modform_hecketriangle/series_constructor.py +580 -0
  137. sage/modular/modform_hecketriangle/space.py +1037 -0
  138. sage/modular/modform_hecketriangle/subspace.py +423 -0
  139. sage/modular/modsym/all.py +17 -0
  140. sage/modular/modsym/ambient.py +3844 -0
  141. sage/modular/modsym/boundary.py +1420 -0
  142. sage/modular/modsym/element.py +336 -0
  143. sage/modular/modsym/g1list.py +178 -0
  144. sage/modular/modsym/ghlist.py +182 -0
  145. sage/modular/modsym/hecke_operator.py +73 -0
  146. sage/modular/modsym/manin_symbol.cpython-314t-darwin.so +0 -0
  147. sage/modular/modsym/manin_symbol.pxd +5 -0
  148. sage/modular/modsym/manin_symbol.pyx +497 -0
  149. sage/modular/modsym/manin_symbol_list.py +1291 -0
  150. sage/modular/modsym/modsym.py +400 -0
  151. sage/modular/modsym/modular_symbols.py +384 -0
  152. sage/modular/modsym/p1list_nf.py +1241 -0
  153. sage/modular/modsym/relation_matrix.py +591 -0
  154. sage/modular/modsym/relation_matrix_pyx.cpython-314t-darwin.so +0 -0
  155. sage/modular/modsym/relation_matrix_pyx.pyx +108 -0
  156. sage/modular/modsym/space.py +2468 -0
  157. sage/modular/modsym/subspace.py +455 -0
  158. sage/modular/modsym/tests.py +376 -0
  159. sage/modular/multiple_zeta.py +2635 -0
  160. sage/modular/multiple_zeta_F_algebra.py +789 -0
  161. sage/modular/overconvergent/all.py +6 -0
  162. sage/modular/overconvergent/genus0.py +1879 -0
  163. sage/modular/overconvergent/hecke_series.py +1187 -0
  164. sage/modular/overconvergent/weightspace.py +776 -0
  165. sage/modular/pollack_stevens/all.py +4 -0
  166. sage/modular/pollack_stevens/distributions.py +874 -0
  167. sage/modular/pollack_stevens/fund_domain.py +1572 -0
  168. sage/modular/pollack_stevens/manin_map.py +856 -0
  169. sage/modular/pollack_stevens/modsym.py +1590 -0
  170. sage/modular/pollack_stevens/padic_lseries.py +417 -0
  171. sage/modular/pollack_stevens/sigma0.py +534 -0
  172. sage/modular/pollack_stevens/space.py +1078 -0
  173. sage/modular/quasimodform/all.py +3 -0
  174. sage/modular/quasimodform/element.py +846 -0
  175. sage/modular/quasimodform/ring.py +826 -0
  176. sage/modular/quatalg/all.py +3 -0
  177. sage/modular/quatalg/brandt.py +1642 -0
  178. sage/modular/ssmod/all.py +8 -0
  179. sage/modular/ssmod/ssmod.py +827 -0
  180. sage/rings/all__sagemath_schemes.py +1 -0
  181. sage/rings/polynomial/all__sagemath_schemes.py +1 -0
  182. sage/rings/polynomial/binary_form_reduce.py +585 -0
  183. sage/schemes/all.py +41 -0
  184. sage/schemes/berkovich/all.py +6 -0
  185. sage/schemes/berkovich/berkovich_cp_element.py +2582 -0
  186. sage/schemes/berkovich/berkovich_space.py +700 -0
  187. sage/schemes/curves/affine_curve.py +2924 -0
  188. sage/schemes/curves/all.py +33 -0
  189. sage/schemes/curves/closed_point.py +434 -0
  190. sage/schemes/curves/constructor.py +397 -0
  191. sage/schemes/curves/curve.py +542 -0
  192. sage/schemes/curves/plane_curve_arrangement.py +1283 -0
  193. sage/schemes/curves/point.py +463 -0
  194. sage/schemes/curves/projective_curve.py +3203 -0
  195. sage/schemes/curves/weighted_projective_curve.py +106 -0
  196. sage/schemes/curves/zariski_vankampen.py +1931 -0
  197. sage/schemes/cyclic_covers/all.py +2 -0
  198. sage/schemes/cyclic_covers/charpoly_frobenius.py +320 -0
  199. sage/schemes/cyclic_covers/constructor.py +137 -0
  200. sage/schemes/cyclic_covers/cycliccover_finite_field.py +1309 -0
  201. sage/schemes/cyclic_covers/cycliccover_generic.py +310 -0
  202. sage/schemes/elliptic_curves/BSD.py +991 -0
  203. sage/schemes/elliptic_curves/Qcurves.py +592 -0
  204. sage/schemes/elliptic_curves/addition_formulas_ring.py +94 -0
  205. sage/schemes/elliptic_curves/all.py +49 -0
  206. sage/schemes/elliptic_curves/cardinality.py +609 -0
  207. sage/schemes/elliptic_curves/cm.py +1103 -0
  208. sage/schemes/elliptic_curves/constructor.py +1530 -0
  209. sage/schemes/elliptic_curves/ec_database.py +175 -0
  210. sage/schemes/elliptic_curves/ell_curve_isogeny.py +3971 -0
  211. sage/schemes/elliptic_curves/ell_egros.py +457 -0
  212. sage/schemes/elliptic_curves/ell_field.py +2837 -0
  213. sage/schemes/elliptic_curves/ell_finite_field.py +3249 -0
  214. sage/schemes/elliptic_curves/ell_generic.py +3760 -0
  215. sage/schemes/elliptic_curves/ell_local_data.py +1207 -0
  216. sage/schemes/elliptic_curves/ell_modular_symbols.py +775 -0
  217. sage/schemes/elliptic_curves/ell_number_field.py +4220 -0
  218. sage/schemes/elliptic_curves/ell_padic_field.py +107 -0
  219. sage/schemes/elliptic_curves/ell_point.py +4944 -0
  220. sage/schemes/elliptic_curves/ell_rational_field.py +7184 -0
  221. sage/schemes/elliptic_curves/ell_tate_curve.py +671 -0
  222. sage/schemes/elliptic_curves/ell_torsion.py +436 -0
  223. sage/schemes/elliptic_curves/ell_wp.py +352 -0
  224. sage/schemes/elliptic_curves/formal_group.py +760 -0
  225. sage/schemes/elliptic_curves/gal_reps.py +1459 -0
  226. sage/schemes/elliptic_curves/gal_reps_number_field.py +1663 -0
  227. sage/schemes/elliptic_curves/gp_simon.py +152 -0
  228. sage/schemes/elliptic_curves/heegner.py +7328 -0
  229. sage/schemes/elliptic_curves/height.py +2108 -0
  230. sage/schemes/elliptic_curves/hom.py +1788 -0
  231. sage/schemes/elliptic_curves/hom_composite.py +1084 -0
  232. sage/schemes/elliptic_curves/hom_fractional.py +544 -0
  233. sage/schemes/elliptic_curves/hom_frobenius.py +522 -0
  234. sage/schemes/elliptic_curves/hom_scalar.py +531 -0
  235. sage/schemes/elliptic_curves/hom_sum.py +681 -0
  236. sage/schemes/elliptic_curves/hom_velusqrt.py +1290 -0
  237. sage/schemes/elliptic_curves/homset.py +271 -0
  238. sage/schemes/elliptic_curves/isogeny_class.py +1523 -0
  239. sage/schemes/elliptic_curves/isogeny_small_degree.py +2797 -0
  240. sage/schemes/elliptic_curves/jacobian.py +247 -0
  241. sage/schemes/elliptic_curves/kodaira_symbol.py +344 -0
  242. sage/schemes/elliptic_curves/kraus.py +1014 -0
  243. sage/schemes/elliptic_curves/lseries_ell.py +915 -0
  244. sage/schemes/elliptic_curves/mod5family.py +105 -0
  245. sage/schemes/elliptic_curves/mod_poly.py +197 -0
  246. sage/schemes/elliptic_curves/mod_sym_num.cpython-314t-darwin.so +0 -0
  247. sage/schemes/elliptic_curves/mod_sym_num.pyx +3796 -0
  248. sage/schemes/elliptic_curves/modular_parametrization.py +305 -0
  249. sage/schemes/elliptic_curves/padic_lseries.py +1793 -0
  250. sage/schemes/elliptic_curves/padics.py +1816 -0
  251. sage/schemes/elliptic_curves/period_lattice.py +2234 -0
  252. sage/schemes/elliptic_curves/period_lattice_region.cpython-314t-darwin.so +0 -0
  253. sage/schemes/elliptic_curves/period_lattice_region.pyx +722 -0
  254. sage/schemes/elliptic_curves/saturation.py +716 -0
  255. sage/schemes/elliptic_curves/sha_tate.py +1158 -0
  256. sage/schemes/elliptic_curves/weierstrass_morphism.py +1117 -0
  257. sage/schemes/elliptic_curves/weierstrass_transform.py +200 -0
  258. sage/schemes/hyperelliptic_curves/all.py +6 -0
  259. sage/schemes/hyperelliptic_curves/constructor.py +369 -0
  260. sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py +1948 -0
  261. sage/schemes/hyperelliptic_curves/hyperelliptic_g2.py +192 -0
  262. sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py +936 -0
  263. sage/schemes/hyperelliptic_curves/hyperelliptic_padic_field.py +1332 -0
  264. sage/schemes/hyperelliptic_curves/hyperelliptic_rational_field.py +84 -0
  265. sage/schemes/hyperelliptic_curves/invariants.py +410 -0
  266. sage/schemes/hyperelliptic_curves/jacobian_endomorphism_utils.py +312 -0
  267. sage/schemes/hyperelliptic_curves/jacobian_g2.py +32 -0
  268. sage/schemes/hyperelliptic_curves/jacobian_generic.py +437 -0
  269. sage/schemes/hyperelliptic_curves/jacobian_homset.py +186 -0
  270. sage/schemes/hyperelliptic_curves/jacobian_morphism.py +878 -0
  271. sage/schemes/hyperelliptic_curves/kummer_surface.py +99 -0
  272. sage/schemes/hyperelliptic_curves/mestre.py +302 -0
  273. sage/schemes/hyperelliptic_curves/monsky_washnitzer.py +3863 -0
  274. sage/schemes/jacobians/abstract_jacobian.py +277 -0
  275. sage/schemes/jacobians/all.py +2 -0
  276. sage/schemes/overview.py +161 -0
  277. sage/schemes/plane_conics/all.py +22 -0
  278. sage/schemes/plane_conics/con_field.py +1296 -0
  279. sage/schemes/plane_conics/con_finite_field.py +158 -0
  280. sage/schemes/plane_conics/con_number_field.py +456 -0
  281. sage/schemes/plane_conics/con_rational_field.py +406 -0
  282. sage/schemes/plane_conics/con_rational_function_field.py +581 -0
  283. sage/schemes/plane_conics/constructor.py +249 -0
  284. sage/schemes/plane_quartics/all.py +2 -0
  285. sage/schemes/plane_quartics/quartic_constructor.py +71 -0
  286. sage/schemes/plane_quartics/quartic_generic.py +53 -0
  287. sage/schemes/riemann_surfaces/all.py +1 -0
  288. sage/schemes/riemann_surfaces/riemann_surface.py +4177 -0
  289. sage_wheels/share/cremona/cremona_mini.db +0 -0
  290. sage_wheels/share/ellcurves/rank0 +30427 -0
  291. sage_wheels/share/ellcurves/rank1 +31871 -0
  292. sage_wheels/share/ellcurves/rank10 +6 -0
  293. sage_wheels/share/ellcurves/rank11 +6 -0
  294. sage_wheels/share/ellcurves/rank12 +1 -0
  295. sage_wheels/share/ellcurves/rank14 +1 -0
  296. sage_wheels/share/ellcurves/rank15 +1 -0
  297. sage_wheels/share/ellcurves/rank17 +1 -0
  298. sage_wheels/share/ellcurves/rank19 +1 -0
  299. sage_wheels/share/ellcurves/rank2 +2388 -0
  300. sage_wheels/share/ellcurves/rank20 +1 -0
  301. sage_wheels/share/ellcurves/rank21 +1 -0
  302. sage_wheels/share/ellcurves/rank22 +1 -0
  303. sage_wheels/share/ellcurves/rank23 +1 -0
  304. sage_wheels/share/ellcurves/rank24 +1 -0
  305. sage_wheels/share/ellcurves/rank28 +1 -0
  306. sage_wheels/share/ellcurves/rank3 +836 -0
  307. sage_wheels/share/ellcurves/rank4 +10 -0
  308. sage_wheels/share/ellcurves/rank5 +5 -0
  309. sage_wheels/share/ellcurves/rank6 +5 -0
  310. sage_wheels/share/ellcurves/rank7 +5 -0
  311. sage_wheels/share/ellcurves/rank8 +6 -0
  312. sage_wheels/share/ellcurves/rank9 +7 -0
@@ -0,0 +1,1744 @@
1
+ # sage_setup: distribution = sagemath-schemes
2
+ # sage.doctest: needs sage.libs.flint sage.libs.pari
3
+ """
4
+ Hecke modules
5
+ """
6
+
7
+ # ****************************************************************************
8
+ # Copyright (C) 2004,2005,2006 William Stein <wstein@gmail.com>
9
+ #
10
+ # This program is free software: you can redistribute it and/or modify
11
+ # it under the terms of the GNU General Public License as published by
12
+ # the Free Software Foundation, either version 2 of the License, or
13
+ # (at your option) any later version.
14
+ # https://www.gnu.org/licenses/
15
+ # ****************************************************************************
16
+
17
+ import sage.misc.prandom as random
18
+
19
+ from sage.arith.misc import is_prime, factor, prime_divisors, gcd, primes, valuation, GCD, next_prime
20
+ from sage.matrix.matrix_space import MatrixSpace
21
+ from sage.misc.verbose import verbose
22
+ from sage.modules.free_module import FreeModule
23
+ from sage.modules.module import Module
24
+ from sage.rings.integer_ring import ZZ
25
+ from sage.rings.rational_field import QQ
26
+ from sage.categories.commutative_rings import CommutativeRings
27
+ from sage.structure.sequence import Sequence
28
+
29
+ from . import algebra
30
+ from . import element
31
+ from . import hecke_operator
32
+
33
+
34
+ class HeckeModule_generic(Module):
35
+ r"""
36
+ A very general base class for Hecke modules.
37
+
38
+ We define a Hecke module of weight `k` to be a module over a commutative
39
+ ring equipped with an action of operators `T_m` for all positive integers `m`
40
+ coprime to some integer `n`(the level), which satisfy `T_r T_s = T_{rs}` for
41
+ `r,s` coprime, and for powers of a prime `p`, `T_{p^r} = T_{p} T_{p^{r-1}} -
42
+ \varepsilon(p) p^{k-1} T_{p^{r-2}}`, where `\varepsilon(p)` is some
43
+ endomorphism of the module which commutes with the `T_m`.
44
+
45
+ We distinguish between *full* Hecke modules, which also have an action of
46
+ operators `T_m` for `m` not assumed to be coprime to the level, and
47
+ *anemic* Hecke modules, for which this does not hold.
48
+ """
49
+
50
+ Element = element.HeckeModuleElement
51
+
52
+ def __init__(self, base_ring, level, category=None) -> None:
53
+ r"""
54
+ Create a Hecke module. Not intended to be called directly.
55
+
56
+ EXAMPLES::
57
+
58
+ sage: CuspForms(Gamma0(17),2) # indirect doctest
59
+ Cuspidal subspace of dimension 1 of Modular Forms space of dimension 2 for Congruence Subgroup Gamma0(17) of weight 2 over Rational Field
60
+ sage: ModularForms(3, 3).category()
61
+ Category of Hecke modules over Rational Field
62
+ """
63
+ if base_ring not in CommutativeRings():
64
+ raise TypeError("base_ring must be commutative ring")
65
+
66
+ from sage.categories.hecke_modules import HeckeModules
67
+ default_category = HeckeModules(base_ring)
68
+ if category is None:
69
+ category = default_category
70
+ else:
71
+ assert category.is_subcategory(default_category), "%s is not a subcategory of %s" % (category, default_category)
72
+
73
+ Module.__init__(self, base_ring, category=category)
74
+
75
+ level = ZZ(level)
76
+ if level <= 0:
77
+ raise ValueError("level (=%s) must be positive" % level)
78
+ self.__level = level
79
+ self._hecke_matrices = {}
80
+ self._diamond_matrices = {}
81
+
82
+ def __setstate__(self, state):
83
+ r"""
84
+ Ensure that the category is initialized correctly on unpickling.
85
+
86
+ EXAMPLES::
87
+
88
+ sage: loads(dumps(ModularSymbols(11))).category() # indirect doctest
89
+ Category of Hecke modules over Rational Field
90
+ """
91
+ if not self._is_category_initialized():
92
+ from sage.categories.hecke_modules import HeckeModules
93
+ self._init_category_(HeckeModules(state['_base']))
94
+ Module.__setstate__(self, state)
95
+
96
+ def __hash__(self):
97
+ r"""
98
+ The hash is determined by the base ring and the level.
99
+
100
+ EXAMPLES::
101
+
102
+ sage: MS = sage.modular.hecke.module.HeckeModule_generic(QQ,1)
103
+ sage: hash(MS) == hash((MS.base_ring(), MS.level()))
104
+ True
105
+ """
106
+ return hash((self.base_ring(), self.__level))
107
+
108
+ def _compute_hecke_matrix_prime_power(self, p, r, **kwds):
109
+ r"""
110
+ Compute the Hecke matrix T_{p^r}, where `p` is prime and `r \ge 2`, assuming that
111
+ `T_p` is known.
112
+
113
+ This is carried out by recursion.
114
+
115
+ All derived classes must override either this function or
116
+ ``self.character()``.
117
+
118
+ EXAMPLES::
119
+
120
+ sage: M = ModularForms(SL2Z, 24)
121
+ sage: M._compute_hecke_matrix_prime_power(3, 3)
122
+ [ -4112503986561480 53074162446443642880 0]
123
+ [ 2592937954080 -1312130996155080 0]
124
+ [ 0 0 834385168339943471891603972970040]
125
+ """
126
+ # convert input arguments to int's.
127
+ p, r = (int(p), int(r))
128
+ if not is_prime(p):
129
+ raise ArithmeticError("p must be a prime")
130
+ # T_{p^r} := T_p * T_{p^{r-1}} - eps(p)p^{k-1} T_{p^{r-2}}.
131
+ pow = p**(r - 1)
132
+ if pow not in self._hecke_matrices:
133
+ # The following will force computation of T_{p^s}
134
+ # for all s<=r-1, except possibly s=0.
135
+ self._hecke_matrices[pow] = self._compute_hecke_matrix(pow)
136
+ if 1 not in self._hecke_matrices:
137
+ self._hecke_matrices[1] = self._compute_hecke_matrix(1)
138
+ Tp = self._hecke_matrices[p]
139
+ Tpr1 = self._hecke_matrices[pow]
140
+ eps = self.character()
141
+ if eps is None:
142
+ raise NotImplementedError("either character or _compute_hecke_matrix_prime_power must be overloaded in a derived class")
143
+ k = self.weight()
144
+ Tpr2 = self._hecke_matrices[pow // p]
145
+ return Tp * Tpr1 - eps(p) * (p**(k - 1)) * Tpr2
146
+
147
+ def _compute_hecke_matrix_general_product(self, F, **kwds):
148
+ r"""
149
+ Compute the matrix of a general Hecke operator acting on this space, by
150
+ factorising n into prime powers and multiplying together the Hecke
151
+ operators for each of these.
152
+
153
+ EXAMPLES::
154
+
155
+ sage: M = ModularSymbols(Gamma0(3), 4)
156
+ sage: M._compute_hecke_matrix_general_product(factor(10))
157
+ [1134 0]
158
+ [ 0 1134]
159
+ """
160
+ prod = None
161
+ for p, r in F:
162
+ pow = int(p**r)
163
+ if pow not in self._hecke_matrices:
164
+ self._hecke_matrices[pow] = self._compute_hecke_matrix(pow)
165
+ if prod is None:
166
+ prod = self._hecke_matrices[pow]
167
+ else:
168
+ prod *= self._hecke_matrices[pow]
169
+ return prod
170
+
171
+ def _compute_dual_hecke_matrix(self, n):
172
+ r"""
173
+ Compute the matrix of the Hecke operator `T_n` acting on the dual of ``self``.
174
+
175
+ EXAMPLES::
176
+
177
+ sage: M = ModularSymbols(Gamma0(3), 4)
178
+ sage: M._compute_dual_hecke_matrix(10)
179
+ [1134 0]
180
+ [ 0 1134]
181
+ """
182
+ return self.hecke_matrix(n).transpose()
183
+
184
+ def _compute_hecke_matrix(self, n, **kwds):
185
+ r"""
186
+ Compute the matrix of the Hecke operator `T_n` acting on ``self``.
187
+
188
+ EXAMPLES::
189
+
190
+ sage: M = EisensteinForms(DirichletGroup(3).0, 3)
191
+ sage: M._compute_hecke_matrix(16)
192
+ [205 0]
193
+ [ 0 205]
194
+ """
195
+ n = int(n)
196
+ if n < 1:
197
+ raise ValueError("Hecke operator T_%s is not defined." % n)
198
+ if n == 1:
199
+ Mat = MatrixSpace(self.base_ring(), self.rank())
200
+ return Mat(1)
201
+
202
+ if is_prime(n):
203
+ return self._compute_hecke_matrix_prime(n, **kwds)
204
+
205
+ F = factor(n)
206
+ if len(F) == 1: # nontrivial prime power case
207
+ return self._compute_hecke_matrix_prime_power(F[0][0], F[0][1], **kwds)
208
+
209
+ else:
210
+ return self._compute_hecke_matrix_general_product(F, **kwds)
211
+
212
+ def _compute_hecke_matrix_prime(self, p, **kwds):
213
+ """
214
+ Compute and return the matrix of the `p`-th Hecke operator for `p` prime.
215
+
216
+ Derived classes should overload this function, and they will inherit
217
+ the machinery for calculating general Hecke operators.
218
+
219
+ EXAMPLES::
220
+
221
+ sage: M = EisensteinForms(DirichletGroup(3).0, 3)
222
+ sage: sage.modular.hecke.module.HeckeModule_generic._compute_hecke_matrix_prime(M, 3)
223
+ Traceback (most recent call last):
224
+ ...
225
+ NotImplementedError: All subclasses must implement _compute_hecke_matrix_prime
226
+ """
227
+ raise NotImplementedError("All subclasses must implement _compute_hecke_matrix_prime")
228
+
229
+ def _compute_diamond_matrix(self, d):
230
+ r"""
231
+ Compute the matrix of the diamond bracket operator `\langle d \rangle` on this space,
232
+ in cases where this is not self-evident (i.e. when this is not a space
233
+ with fixed character).
234
+
235
+ EXAMPLES::
236
+
237
+ sage: M = EisensteinForms(Gamma1(5), 3)
238
+ sage: sage.modular.hecke.module.HeckeModule_generic._compute_diamond_matrix(M, 2)
239
+ Traceback (most recent call last):
240
+ ...
241
+ NotImplementedError: All subclasses without fixed character must implement _compute_diamond_matrix
242
+ """
243
+ raise NotImplementedError("All subclasses without fixed character must implement _compute_diamond_matrix")
244
+
245
+ def _hecke_operator_class(self):
246
+ """
247
+ Return the class to be used for instantiating Hecke operators
248
+ acting on ``self``.
249
+
250
+ EXAMPLES::
251
+
252
+ sage: sage.modular.hecke.module.HeckeModule_generic(QQ,1)._hecke_operator_class()
253
+ <class 'sage.modular.hecke.hecke_operator.HeckeOperator'>
254
+ sage: ModularSymbols(1,12)._hecke_operator_class()
255
+ <class 'sage.modular.modsym.hecke_operator.HeckeOperator'>
256
+ """
257
+ return hecke_operator.HeckeOperator
258
+
259
+ def _diamond_operator_class(self):
260
+ r"""
261
+ Return the class to be used for instantiating diamond bracket operators
262
+ acting on ``self``.
263
+
264
+ EXAMPLES::
265
+
266
+ sage: sage.modular.hecke.module.HeckeModule_generic(QQ,1)._diamond_operator_class()
267
+ <class 'sage.modular.hecke.hecke_operator.DiamondBracketOperator'>
268
+ sage: ModularSymbols(1,12)._diamond_operator_class()
269
+ <class 'sage.modular.hecke.hecke_operator.DiamondBracketOperator'>
270
+ """
271
+ return hecke_operator.DiamondBracketOperator
272
+
273
+ def anemic_hecke_algebra(self):
274
+ """
275
+ Return the Hecke algebra associated to this Hecke module.
276
+
277
+ EXAMPLES::
278
+
279
+ sage: T = ModularSymbols(1,12).hecke_algebra()
280
+ sage: A = ModularSymbols(1,12).anemic_hecke_algebra()
281
+ sage: T == A
282
+ False
283
+ sage: A
284
+ Anemic Hecke algebra acting on Modular Symbols space of dimension 3 for Gamma_0(1) of weight 12 with sign 0 over Rational Field
285
+ sage: A.is_anemic()
286
+ True
287
+ """
288
+ return algebra.AnemicHeckeAlgebra(self)
289
+
290
+ def character(self):
291
+ r"""
292
+ Return the character of this space.
293
+
294
+ As this is an abstract base class, return ``None``.
295
+
296
+ EXAMPLES::
297
+
298
+ sage: sage.modular.hecke.module.HeckeModule_generic(QQ, 10).character() is None
299
+ True
300
+ """
301
+ return
302
+
303
+ def dimension(self):
304
+ r"""
305
+ Synonym for :meth:`rank`.
306
+
307
+ EXAMPLES::
308
+
309
+ sage: M = sage.modular.hecke.module.HeckeModule_generic(QQ, 10).dimension()
310
+ Traceback (most recent call last):
311
+ ...
312
+ NotImplementedError: Derived subclasses must implement rank
313
+ """
314
+ return self.rank()
315
+
316
+ def hecke_algebra(self):
317
+ """
318
+ Return the Hecke algebra associated to this Hecke module.
319
+
320
+ EXAMPLES::
321
+
322
+ sage: T = ModularSymbols(Gamma1(5),3).hecke_algebra()
323
+ sage: T
324
+ Full Hecke algebra acting on Modular Symbols space of dimension 4 for Gamma_1(5) of weight 3 with sign 0 over Rational Field
325
+ sage: T.is_anemic()
326
+ False
327
+
328
+ ::
329
+
330
+ sage: M = ModularSymbols(37,sign=1)
331
+ sage: E, A, B = M.decomposition()
332
+ sage: A.hecke_algebra() == B.hecke_algebra()
333
+ False
334
+ """
335
+ return algebra.HeckeAlgebra(self)
336
+
337
+ def is_zero(self) -> bool:
338
+ """
339
+ Return ``True`` if this Hecke module has dimension 0.
340
+
341
+ EXAMPLES::
342
+
343
+ sage: ModularSymbols(11).is_zero()
344
+ False
345
+ sage: ModularSymbols(11).old_submodule().is_zero()
346
+ True
347
+ sage: CuspForms(10).is_zero()
348
+ True
349
+ sage: CuspForms(1,12).is_zero()
350
+ False
351
+ """
352
+ return self.dimension() == 0
353
+
354
+ def is_full_hecke_module(self) -> bool:
355
+ """
356
+ Return ``True`` if this space is invariant under all Hecke operators.
357
+
358
+ Since ``self`` is guaranteed to be an anemic Hecke module, the
359
+ significance of this function is that it also ensures
360
+ invariance under Hecke operators of index that divide the level.
361
+
362
+ EXAMPLES::
363
+
364
+ sage: M = ModularSymbols(22); M.is_full_hecke_module()
365
+ True
366
+ sage: M.submodule(M.free_module().span([M.0.list()]), check=False).is_full_hecke_module()
367
+ False
368
+ """
369
+ try:
370
+ return self._is_full_hecke_module
371
+ except AttributeError:
372
+ pass
373
+
374
+ # now compute whether invariant under Hecke operators of index
375
+ # dividing the level
376
+ verbose("Determining if Hecke module is full.")
377
+ N = self.level()
378
+ for p in prime_divisors(N):
379
+ if not self.is_hecke_invariant(p):
380
+ self._is_full_hecke_module = False
381
+ return False
382
+ self._is_full_hecke_module = True
383
+ return True
384
+
385
+ def is_hecke_invariant(self, n) -> bool:
386
+ """
387
+ Return ``True`` if ``self`` is invariant under the Hecke operator `T_n`.
388
+
389
+ Since ``self`` is guaranteed to be an anemic Hecke module it is only
390
+ interesting to call this function when `n` is not coprime
391
+ to the level.
392
+
393
+ EXAMPLES::
394
+
395
+ sage: M = ModularSymbols(22).cuspidal_subspace()
396
+ sage: M.is_hecke_invariant(2)
397
+ True
398
+
399
+ We use ``check=False`` to create a nasty "module" that is not invariant
400
+ under `T_2`::
401
+
402
+ sage: S = M.submodule(M.free_module().span([M.0.list()]), check=False); S
403
+ Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 7 for Gamma_0(22) of weight 2 with sign 0 over Rational Field
404
+ sage: S.is_hecke_invariant(2)
405
+ False
406
+ sage: [n for n in range(1,12) if S.is_hecke_invariant(n)]
407
+ [1, 3, 5, 7, 9, 11]
408
+ """
409
+ if gcd(n, self.level()) == 1:
410
+ return True
411
+ if self.is_ambient():
412
+ return True
413
+ try:
414
+ self.hecke_operator(n).matrix()
415
+ except ArithmeticError:
416
+ return False
417
+ return True
418
+
419
+ def level(self):
420
+ """
421
+ Return the level of this modular symbols space.
422
+
423
+ INPUT:
424
+
425
+ - ``ModularSymbols self`` -- an arbitrary space of modular symbols
426
+
427
+ OUTPUT: integer; the level
428
+
429
+ EXAMPLES::
430
+
431
+ sage: m = ModularSymbols(20)
432
+ sage: m.level()
433
+ 20
434
+ """
435
+ return self.__level
436
+
437
+ def rank(self):
438
+ r"""
439
+ Return the rank of this module over its base ring.
440
+
441
+ This raises a :exc:`NotImplementedError`, since this is an
442
+ abstract base class.
443
+
444
+ EXAMPLES::
445
+
446
+ sage: sage.modular.hecke.module.HeckeModule_generic(QQ, 10).rank()
447
+ Traceback (most recent call last):
448
+ ...
449
+ NotImplementedError: Derived subclasses must implement rank
450
+ """
451
+ raise NotImplementedError("Derived subclasses must implement rank")
452
+
453
+ def submodule(self, X):
454
+ r"""
455
+ Return the submodule of ``self`` corresponding to ``X``.
456
+
457
+ As this is an abstract base class, this raises a
458
+ :exc:`NotImplementedError`.
459
+
460
+ EXAMPLES::
461
+
462
+ sage: sage.modular.hecke.module.HeckeModule_generic(QQ, 10).submodule(0)
463
+ Traceback (most recent call last):
464
+ ...
465
+ NotImplementedError: Derived subclasses should implement submodule
466
+ """
467
+ raise NotImplementedError("Derived subclasses should implement submodule")
468
+
469
+
470
+ class HeckeModule_free_module(HeckeModule_generic):
471
+ """
472
+ A Hecke module modeled on a free module over a commutative ring.
473
+ """
474
+ def __init__(self, base_ring, level, weight, category=None):
475
+ r"""
476
+ Initialise a module.
477
+
478
+ EXAMPLES::
479
+
480
+ sage: M = sage.modular.hecke.module.HeckeModule_free_module(QQ, 12, -4); M
481
+ <class 'sage.modular.hecke.module.HeckeModule_free_module_with_category'>
482
+ sage: skipped = ["_test_additive_associativity",
483
+ ....: "_test_an_element", "_test_elements",
484
+ ....: "_test_elements_eq_reflexive",
485
+ ....: "_test_elements_eq_symmetric",
486
+ ....: "_test_elements_eq_transitive", "_test_elements_neq",
487
+ ....: "_test_pickling", "_test_some_elements",
488
+ ....: "_test_zero", "_test_eq"]
489
+ sage: TestSuite(M).run(skip=skipped)
490
+
491
+ .. NOTE:: Is this supposed to be an abstract parent without elements?
492
+ """
493
+ HeckeModule_generic.__init__(self, base_ring, level, category=category)
494
+ self.__weight = weight
495
+
496
+ def _repr_(self):
497
+ r"""
498
+
499
+ EXAMPLES::
500
+
501
+ sage: M = sage.modular.hecke.module.HeckeModule_free_module(QQ, 12, -4); M
502
+ <class 'sage.modular.hecke.module.HeckeModule_free_module_with_category'>
503
+
504
+ .. TODO::
505
+
506
+ Implement a nicer repr, or implement the methods required
507
+ by :class:`ModulesWithBasis` to benefit from
508
+ :meth:`ModulesWithBasis.ParentMethods._repr_`.
509
+ """
510
+ return repr(type(self))
511
+
512
+ def __getitem__(self, n):
513
+ r"""
514
+ Return the `n`-th term in the decomposition of ``self``.
515
+
516
+ See the docstring for :meth:`decomposition` for further information.
517
+
518
+ EXAMPLES::
519
+
520
+ sage: ModularSymbols(22)[0]
521
+ Modular Symbols subspace of dimension 3 of Modular Symbols space of dimension 7 for Gamma_0(22) of weight 2 with sign 0 over Rational Field
522
+ """
523
+ n = int(n)
524
+ D = self.decomposition()
525
+ if n < 0 or n >= len(D):
526
+ raise IndexError("index (=%s) must be between 0 and %s" % (n, len(D) - 1))
527
+ return D[n]
528
+
529
+ def __hash__(self):
530
+ r"""
531
+ The hash is determined by the weight, the level and the base ring.
532
+
533
+ EXAMPLES::
534
+
535
+ sage: MS = ModularSymbols(22)
536
+ sage: hash(MS) == hash((MS.weight(), MS.level(), MS.base_ring()))
537
+ True
538
+ """
539
+ return hash((self.__weight, self.level(), self.base_ring()))
540
+
541
+ def __len__(self):
542
+ r"""
543
+ Return the number of factors in the decomposition of ``self``.
544
+
545
+ EXAMPLES::
546
+
547
+ sage: len(ModularSymbols(22))
548
+ 2
549
+ """
550
+ return len(self.decomposition())
551
+
552
+ def _eigen_nonzero(self):
553
+ """
554
+ Return the smallest integer `i` such that the `i`-th entries of
555
+ the entries of a basis for the dual vector space are not all 0.
556
+
557
+ EXAMPLES::
558
+
559
+ sage: M = ModularSymbols(31,2)
560
+ sage: M._eigen_nonzero()
561
+ 0
562
+ sage: M.dual_free_module().basis()
563
+ [(1, 0, 0, 0, 0),
564
+ (0, 1, 0, 0, 0),
565
+ (0, 0, 1, 0, 0),
566
+ (0, 0, 0, 1, 0),
567
+ (0, 0, 0, 0, 1)]
568
+ sage: M.cuspidal_submodule().minus_submodule()._eigen_nonzero()
569
+ 1
570
+ sage: M.cuspidal_submodule().minus_submodule().dual_free_module().basis()
571
+ [(0, 1, 0, 0, 0), (0, 0, 1, 0, 0)]
572
+ """
573
+ try:
574
+ return self.__eigen_nonzero
575
+ except AttributeError:
576
+ pass
577
+ V = self.dual_free_module()
578
+ B = V.basis()
579
+ for i in range(V.degree()):
580
+ for b in B:
581
+ if b[i] != 0:
582
+ self.__eigen_nonzero = i
583
+ return i
584
+ assert False, 'bug in _eigen_nonzero'
585
+
586
+ def _eigen_nonzero_element(self, n=1):
587
+ r"""
588
+ Return `T_n(x)` where `x` is a sparse modular
589
+ symbol such that the image of `x` is nonzero under the dual
590
+ projection map associated to this space, and `T_n` is the
591
+ `n`-th Hecke operator.
592
+
593
+ Used in the :meth:`dual_eigenvector` and :meth:`eigenvalue` methods.
594
+
595
+ EXAMPLES::
596
+
597
+ sage: ModularSymbols(22)._eigen_nonzero_element(3)
598
+ 4*(1,0) + (2,21) - (11,1) + (11,2)
599
+ """
600
+ if self.rank() == 0:
601
+ raise ArithmeticError("the rank of self must be positive")
602
+ A = self.ambient_hecke_module()
603
+ i = self._eigen_nonzero()
604
+ return A._hecke_image_of_ith_basis_vector(n, i)
605
+
606
+ def _hecke_image_of_ith_basis_vector(self, n, i):
607
+ r"""
608
+ Return `T_n(e_i)`, where `e_i` is the `i`-th basis vector
609
+ of the ambient space.
610
+
611
+ EXAMPLES::
612
+
613
+ sage: ModularSymbols(Gamma0(3))._hecke_image_of_ith_basis_vector(4, 0)
614
+ 7*(1,0)
615
+ sage: ModularForms(Gamma0(3))._hecke_image_of_ith_basis_vector(4, 0)
616
+ 7 + 84*q + 252*q^2 + 84*q^3 + 588*q^4 + 504*q^5 + O(q^6)
617
+ """
618
+ T = self.hecke_operator(n)
619
+ return T.apply_sparse(self.gen(i))
620
+
621
+ def _element_eigenvalue(self, x, name='alpha'):
622
+ r"""
623
+ Return the dot product of ``self`` with the eigenvector returned by dual_eigenvector.
624
+
625
+ EXAMPLES::
626
+
627
+ sage: M = ModularSymbols(11)[0]
628
+ sage: M._element_eigenvalue(M.0)
629
+ 1
630
+ """
631
+ if not isinstance(x, element.HeckeModuleElement):
632
+ raise TypeError("x must be a Hecke module element.")
633
+ if x not in self.ambient_hecke_module():
634
+ raise ArithmeticError("x must be in the ambient Hecke module.")
635
+ v = self.dual_eigenvector(names=name)
636
+ return v.dot_product(x.element())
637
+
638
+ def _is_hecke_equivariant_free_module(self, submodule):
639
+ """
640
+ Return ``True`` if the given free submodule of the ambient free module
641
+ is invariant under all Hecke operators.
642
+
643
+ EXAMPLES::
644
+
645
+ sage: M = ModularSymbols(11); V = M.free_module()
646
+ sage: M._is_hecke_equivariant_free_module(V.span([V.0]))
647
+ False
648
+ sage: M._is_hecke_equivariant_free_module(V)
649
+ True
650
+ sage: M._is_hecke_equivariant_free_module(M.cuspidal_submodule().free_module())
651
+ True
652
+
653
+ We do the same as above, but with a modular forms space::
654
+
655
+ sage: M = ModularForms(11); V = M.free_module()
656
+ sage: M._is_hecke_equivariant_free_module(V.span([V.0 + V.1]))
657
+ False
658
+ sage: M._is_hecke_equivariant_free_module(V)
659
+ True
660
+ sage: M._is_hecke_equivariant_free_module(M.cuspidal_submodule().free_module())
661
+ True
662
+ """
663
+ verbose("Determining if free module is Hecke equivariant.")
664
+ bound = self.hecke_bound()
665
+ for p in primes(bound + 1):
666
+ try:
667
+ self.T(p).matrix().restrict(submodule, check=True)
668
+ except ArithmeticError:
669
+ return False
670
+ return True
671
+
672
+ def _set_factor_number(self, i):
673
+ r"""
674
+ For internal use. If this Hecke module was computed via a decomposition of another
675
+ Hecke module, this method stores the index of this space in that decomposition.
676
+
677
+ EXAMPLES::
678
+
679
+ sage: ModularSymbols(Gamma0(3))[0].factor_number() # indirect doctest
680
+ 0
681
+ """
682
+ self.__factor_number = i
683
+
684
+ def ambient(self):
685
+ r"""
686
+ Return the ambient module associated to this module.
687
+
688
+ Synonym for :meth:`ambient_hecke_module`.
689
+
690
+ EXAMPLES::
691
+
692
+ sage: CuspForms(1, 12).ambient()
693
+ Modular Forms space of dimension 2 for Modular Group SL(2,Z) of weight 12 over Rational Field
694
+ """
695
+ return self.ambient_hecke_module()
696
+
697
+ def ambient_module(self):
698
+ r"""
699
+ Return the ambient module associated to this module.
700
+
701
+ Synonym for :meth:`ambient_hecke_module`.
702
+
703
+ EXAMPLES::
704
+
705
+ sage: CuspForms(1, 12).ambient_module()
706
+ Modular Forms space of dimension 2 for Modular Group SL(2,Z) of weight 12 over Rational Field
707
+ sage: sage.modular.hecke.module.HeckeModule_free_module(QQ, 10, 3).ambient_module()
708
+ Traceback (most recent call last):
709
+ ...
710
+ NotImplementedError
711
+ """
712
+ return self.ambient_hecke_module()
713
+
714
+ def ambient_hecke_module(self):
715
+ r"""
716
+ Return the ambient module associated to this module.
717
+
718
+ As this is an abstract base class, raise :exc:`NotImplementedError`.
719
+
720
+ EXAMPLES::
721
+
722
+ sage: sage.modular.hecke.module.HeckeModule_free_module(QQ, 10, 3).ambient_hecke_module()
723
+ Traceback (most recent call last):
724
+ ...
725
+ NotImplementedError
726
+ """
727
+ raise NotImplementedError
728
+
729
+ def atkin_lehner_operator(self, d=None):
730
+ r"""
731
+ Return the Atkin-Lehner operator `W_d` on this space, if defined, where
732
+ `d` is a divisor of the level `N` such that `N/d` and `d` are coprime.
733
+ If `d` is not given, we take `d = N`. If `N/d` is not coprime to `d`,
734
+ then we replace `d` with the unique integer having this property which
735
+ has the same prime factors as `d`.
736
+
737
+ .. NOTE::
738
+
739
+ The operator `W_d` is given by the action of any matrix of the form
740
+
741
+ .. math::
742
+
743
+ W_d = \begin{pmatrix} dx & y \\ Nz & dw \end{pmatrix}
744
+
745
+ with `\det W_d = d` and such that `x = 1 \bmod N/d`, `y = 1 \bmod
746
+ d`, as in [AL1978]_. However, our definition of the weight `k`
747
+ action differs from theirs by a power of the determinant, so our
748
+ operator `W_d` is `d^{k/2 - 1}` times the operator of Atkin-Li. In
749
+ particular, if `k = 2` our conventions are identical to Atkin and
750
+ Li's.
751
+
752
+ With Sage's conventions, the operator `W_d` satisfies
753
+
754
+ .. math::
755
+
756
+ W_d^2 = d^{k - 2} \langle x^{-1} \rangle
757
+
758
+ where `x` is congruent to `d` modulo `N/d` and to `-1` modulo `d`.
759
+ In particular, the operator is an involution in weight 2 and
760
+ trivial character (but not in most other situations).
761
+
762
+ EXAMPLES::
763
+
764
+ sage: M = ModularSymbols(11)
765
+ sage: w = M.atkin_lehner_operator()
766
+ sage: w
767
+ Hecke module morphism Atkin-Lehner operator W_11 defined by the matrix
768
+ [-1 0 0]
769
+ [ 0 -1 0]
770
+ [ 0 0 -1]
771
+ Domain: Modular Symbols space of dimension 3 for Gamma_0(11) of weight ...
772
+ Codomain: Modular Symbols space of dimension 3 for Gamma_0(11) of weight ...
773
+ sage: M = ModularSymbols(Gamma1(13))
774
+ sage: w = M.atkin_lehner_operator()
775
+ sage: w.fcp('x')
776
+ (x - 1)^7 * (x + 1)^8
777
+
778
+ ::
779
+
780
+ sage: M = ModularSymbols(33)
781
+ sage: S = M.cuspidal_submodule()
782
+ sage: S.atkin_lehner_operator()
783
+ Hecke module morphism Atkin-Lehner operator W_33 defined by the matrix
784
+ [ 0 -1 0 1 -1 0]
785
+ [ 0 -1 0 0 0 0]
786
+ [ 0 -1 0 0 -1 1]
787
+ [ 1 -1 0 0 -1 0]
788
+ [ 0 0 0 0 -1 0]
789
+ [ 0 -1 1 0 -1 0]
790
+ Domain: Modular Symbols subspace of dimension 6 of Modular Symbols space ...
791
+ Codomain: Modular Symbols subspace of dimension 6 of Modular Symbols space ...
792
+
793
+ ::
794
+
795
+ sage: S.atkin_lehner_operator(3)
796
+ Hecke module morphism Atkin-Lehner operator W_3 defined by the matrix
797
+ [ 0 1 0 -1 1 0]
798
+ [ 0 1 0 0 0 0]
799
+ [ 0 1 0 0 1 -1]
800
+ [-1 1 0 0 1 0]
801
+ [ 0 0 0 0 1 0]
802
+ [ 0 1 -1 0 1 0]
803
+ Domain: Modular Symbols subspace of dimension 6 of Modular Symbols space ...
804
+ Codomain: Modular Symbols subspace of dimension 6 of Modular Symbols space ...
805
+
806
+ ::
807
+
808
+ sage: N = M.new_submodule()
809
+ sage: N.atkin_lehner_operator()
810
+ Hecke module morphism Atkin-Lehner operator W_33 defined by the matrix
811
+ [ 1 2/5 4/5]
812
+ [ 0 -1 0]
813
+ [ 0 0 -1]
814
+ Domain: Modular Symbols subspace of dimension 3 of Modular Symbols space ...
815
+ Codomain: Modular Symbols subspace of dimension 3 of Modular Symbols space ...
816
+ """
817
+ if d is None:
818
+ d = self.level()
819
+ d = int(d)
820
+ if self.level() % d:
821
+ raise ArithmeticError("d (=%s) must be a divisor of the level (=%s)" % (d, self.level()))
822
+
823
+ N = self.level()
824
+ for p, e in factor(d):
825
+ v = valuation(N, p)
826
+ if e < v:
827
+ d *= p**(v - e)
828
+ d = int(d)
829
+ try:
830
+ return self.__atkin_lehner_operator[d]
831
+ except AttributeError:
832
+ self.__atkin_lehner_operator = {}
833
+ except KeyError:
834
+ pass
835
+ Wmat = self._compute_atkin_lehner_matrix(d)
836
+ H = self.endomorphism_ring()
837
+ W = H(Wmat, "Atkin-Lehner operator W_%s" % d)
838
+ self.__atkin_lehner_operator[d] = W
839
+ return W
840
+
841
+ def basis(self):
842
+ """
843
+ Return a basis for ``self``.
844
+
845
+ EXAMPLES::
846
+
847
+ sage: m = ModularSymbols(43)
848
+ sage: m.basis()
849
+ ((1,0), (1,31), (1,32), (1,38), (1,39), (1,40), (1,41))
850
+ """
851
+ try:
852
+ return self.__basis
853
+ except AttributeError:
854
+ self.__basis = self.gens()
855
+ return self.__basis
856
+
857
+ def basis_matrix(self):
858
+ r"""
859
+ Return the matrix of the basis vectors of ``self`` (as vectors in some
860
+ ambient module)
861
+
862
+ EXAMPLES::
863
+
864
+ sage: CuspForms(1, 12).basis_matrix()
865
+ [1 0]
866
+ """
867
+ return self.free_module().basis_matrix()
868
+
869
+ def coordinate_vector(self, x):
870
+ """
871
+ Write ``x`` as a vector with respect to the basis given by
872
+ self.basis().
873
+
874
+ EXAMPLES::
875
+
876
+ sage: S = ModularSymbols(11,2).cuspidal_submodule()
877
+ sage: S.0
878
+ (1,8)
879
+ sage: S.basis()
880
+ ((1,8), (1,9))
881
+ sage: S.coordinate_vector(S.0)
882
+ (1, 0)
883
+ """
884
+ return self.free_module().coordinate_vector(x.element())
885
+
886
+ def decomposition(self, bound=None, anemic=True, height_guess=1,
887
+ sort_by_basis=False, proof=None):
888
+ """
889
+ Return the maximal decomposition of this Hecke module under the
890
+ action of Hecke operators of index coprime to the level.
891
+
892
+ This is the finest decomposition of ``self`` that we can obtain
893
+ using factors obtained by taking kernels of Hecke operators.
894
+
895
+ Each factor in the decomposition is a Hecke submodule obtained as
896
+ the kernel of `f(T_n)^r` acting on self, where n is
897
+ coprime to the level and `r=1`. If anemic is False, instead
898
+ choose `r` so that `f(X)^r` exactly divides the
899
+ characteristic polynomial.
900
+
901
+ INPUT:
902
+
903
+ - ``anemic`` -- boolean (default: ``True``); if ``True``, use only
904
+ Hecke operators of index coprime to the level
905
+
906
+ - ``bound`` -- integer or ``None`` (default: ``None``); if ``None``,
907
+ use all Hecke operators up to the Sturm bound, and hence obtain the
908
+ same result as one would obtain by using every element of the Hecke
909
+ ring. If a fixed integer, decompose using only Hecke operators
910
+ `T_p`, with `p` prime, up to bound.
911
+ - ``sort_by_basis`` -- boolean (default: ``False``); if ``True`` the
912
+ resulting decomposition will be sorted as if it was free modules,
913
+ ignoring the Hecke module structure. This will save a lot of time.
914
+
915
+ OUTPUT: list of subspaces of ``self``
916
+
917
+ EXAMPLES::
918
+
919
+ sage: ModularSymbols(17,2).decomposition()
920
+ [Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 3 for Gamma_0(17) of weight 2 with sign 0 over Rational Field,
921
+ Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 3 for Gamma_0(17) of weight 2 with sign 0 over Rational Field]
922
+ sage: ModularSymbols(Gamma1(10),4).decomposition()
923
+ [Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 18 for Gamma_1(10) of weight 4 with sign 0 over Rational Field,
924
+ Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 18 for Gamma_1(10) of weight 4 with sign 0 over Rational Field,
925
+ Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 18 for Gamma_1(10) of weight 4 with sign 0 over Rational Field,
926
+ Modular Symbols subspace of dimension 4 of Modular Symbols space of dimension 18 for Gamma_1(10) of weight 4 with sign 0 over Rational Field,
927
+ Modular Symbols subspace of dimension 4 of Modular Symbols space of dimension 18 for Gamma_1(10) of weight 4 with sign 0 over Rational Field,
928
+ Modular Symbols subspace of dimension 4 of Modular Symbols space of dimension 18 for Gamma_1(10) of weight 4 with sign 0 over Rational Field]
929
+ sage: ModularSymbols(GammaH(12, [11])).decomposition()
930
+ [Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 9 for Congruence Subgroup Gamma_H(12) with H generated by [11] of weight 2 with sign 0 over Rational Field,
931
+ Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 9 for Congruence Subgroup Gamma_H(12) with H generated by [11] of weight 2 with sign 0 over Rational Field,
932
+ Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 9 for Congruence Subgroup Gamma_H(12) with H generated by [11] of weight 2 with sign 0 over Rational Field,
933
+ Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 9 for Congruence Subgroup Gamma_H(12) with H generated by [11] of weight 2 with sign 0 over Rational Field,
934
+ Modular Symbols subspace of dimension 5 of Modular Symbols space of dimension 9 for Congruence Subgroup Gamma_H(12) with H generated by [11] of weight 2 with sign 0 over Rational Field]
935
+
936
+ TESTS::
937
+
938
+ sage: M = ModularSymbols(1000,2,sign=1).new_subspace().cuspidal_subspace()
939
+ sage: M.decomposition(3, sort_by_basis = True)
940
+ [Modular Symbols subspace of dimension 4 of Modular Symbols space of dimension 154 for Gamma_0(1000) of weight 2 with sign 1 over Rational Field,
941
+ Modular Symbols subspace of dimension 4 of Modular Symbols space of dimension 154 for Gamma_0(1000) of weight 2 with sign 1 over Rational Field,
942
+ Modular Symbols subspace of dimension 4 of Modular Symbols space of dimension 154 for Gamma_0(1000) of weight 2 with sign 1 over Rational Field,
943
+ Modular Symbols subspace of dimension 4 of Modular Symbols space of dimension 154 for Gamma_0(1000) of weight 2 with sign 1 over Rational Field,
944
+ Modular Symbols subspace of dimension 4 of Modular Symbols space of dimension 154 for Gamma_0(1000) of weight 2 with sign 1 over Rational Field,
945
+ Modular Symbols subspace of dimension 4 of Modular Symbols space of dimension 154 for Gamma_0(1000) of weight 2 with sign 1 over Rational Field]
946
+ """
947
+ if not isinstance(anemic, bool):
948
+ raise TypeError("anemic must be of type bool.")
949
+
950
+ key = (bound, anemic)
951
+
952
+ try:
953
+ if self.__decomposition[key] is not None:
954
+ return self.__decomposition[key]
955
+ except AttributeError:
956
+ self.__decomposition = {}
957
+ except KeyError:
958
+ pass
959
+ if self.rank() == 0:
960
+ self.__decomposition[key] = Sequence([], immutable=True, cr=True)
961
+ return self.__decomposition[key]
962
+
963
+ is_rational = self.base_ring() == QQ
964
+
965
+ time = verbose("Decomposing %s" % self)
966
+ T = self.ambient_hecke_module().hecke_algebra()
967
+ if bound is None:
968
+ bound = self.ambient_hecke_module().hecke_bound()
969
+ D = Sequence([], cr=True)
970
+ U = [self.free_module()]
971
+ p = 2
972
+ while U and p <= bound:
973
+ verbose(mesg="p=%s" % p, t=time)
974
+ if anemic:
975
+ while GCD(p, self.level()) != 1:
976
+ p = next_prime(p)
977
+ verbose("Decomposition using p=%s" % p)
978
+ t = T.hecke_operator(p).matrix()
979
+ Uprime = []
980
+ for i in range(len(U)):
981
+ is_diagonalizable = (not self.base_ring().characteristic() and
982
+ self.level() % p)
983
+ if is_rational:
984
+ X = t.decomposition_of_subspace(U[i], check_restrict=False,
985
+ algorithm='multimodular',
986
+ height_guess=height_guess, proof=proof)
987
+ else:
988
+ X = t.decomposition_of_subspace(U[i], check_restrict=False,
989
+ is_diagonalizable=is_diagonalizable)
990
+ for Xi in X:
991
+ W, is_irred = Xi
992
+ if is_irred:
993
+ A = self.submodule(W, check=False)
994
+ D.append(A)
995
+ else:
996
+ Uprime.append(W)
997
+ # end for
998
+ p = next_prime(p)
999
+ U = Uprime
1000
+ # end while
1001
+ for i in range(len(U)):
1002
+ A = self.submodule(U[i], check=False)
1003
+ D.append(A)
1004
+ for A in D:
1005
+ if anemic:
1006
+ A.__is_splittable_anemic = False
1007
+ A.__is_splittable = False
1008
+ else:
1009
+ A.__is_splittable = False
1010
+ self.__is_splittable = len(D) > 1
1011
+ if anemic:
1012
+ self.__is_splittable_anemic = len(D) > 1
1013
+ from sage.modules.free_module import EchelonMatrixKey
1014
+ D.sort(key=None if not sort_by_basis
1015
+ else lambda ss: EchelonMatrixKey(ss.free_module()))
1016
+ D.set_immutable()
1017
+ self.__decomposition[key] = D
1018
+ for i in range(len(D)):
1019
+ self.__decomposition[key][i]._set_factor_number(i)
1020
+ return self.__decomposition[key]
1021
+
1022
+ def degree(self):
1023
+ r"""
1024
+ Return the degree of this Hecke module.
1025
+
1026
+ This is the rank of the ambient free module.
1027
+
1028
+ EXAMPLES::
1029
+
1030
+ sage: CuspForms(1, 12).degree()
1031
+ 2
1032
+ """
1033
+ return self.free_module().degree()
1034
+
1035
+ def dual_eigenvector(self, names='alpha', lift=True, nz=None):
1036
+ """
1037
+ Return an eigenvector for the Hecke operators acting on the linear
1038
+ dual of this space.
1039
+
1040
+ This eigenvector will have entries in an extension of the base
1041
+ ring of degree equal to the dimension of this space.
1042
+
1043
+ .. WARNING::
1044
+
1045
+ The input space must be simple.
1046
+
1047
+ INPUT:
1048
+
1049
+ - ``name`` -- print name of generator for eigenvalue
1050
+ field
1051
+
1052
+ - ``lift`` -- boolean (default: ``True``)
1053
+
1054
+ - ``nz`` -- if not ``None``, then normalize vector so dot
1055
+ product with this basis vector of ambient space is 1
1056
+
1057
+ OUTPUT:
1058
+
1059
+ A vector with entries possibly in an extension of the base
1060
+ ring. This vector is an eigenvector for all Hecke operators acting
1061
+ via their transpose.
1062
+
1063
+ If lift = False, instead return an eigenvector in the subspace for
1064
+ the Hecke operators on the dual space. I.e., this is an eigenvector
1065
+ for the restrictions of Hecke operators to the dual space.
1066
+
1067
+ .. NOTE::
1068
+
1069
+ #. The answer is cached so subsequent calls always return
1070
+ the same vector. However, the algorithm is randomized,
1071
+ so calls during another session may yield a different
1072
+ eigenvector. This function is used mainly for computing
1073
+ systems of Hecke eigenvalues.
1074
+
1075
+ #. One can also view a dual eigenvector as defining (via
1076
+ dot product) a functional phi from the ambient space of
1077
+ modular symbols to a field. This functional phi is an
1078
+ eigenvector for the dual action of Hecke operators on
1079
+ functionals.
1080
+
1081
+ EXAMPLES::
1082
+
1083
+ sage: SF = ModularSymbols(14).cuspidal_subspace().simple_factors()
1084
+ sage: sorted([u.dual_eigenvector() for u in SF])
1085
+ [(0, 1, 0, 0, 0), (1, 0, -3, 2, -1)]
1086
+ """
1087
+ # TODO -- optimize by computing the answer for i not None in terms
1088
+ # of the answer for a given i if known !!
1089
+ try:
1090
+ w, w_lift = self.__dual_eigenvector[(names, nz)]
1091
+ if lift:
1092
+ return w_lift
1093
+ else:
1094
+ return w
1095
+ except KeyError:
1096
+ pass
1097
+ except AttributeError:
1098
+ self.__dual_eigenvector = {}
1099
+
1100
+ if not self.is_simple():
1101
+ raise ArithmeticError("self must be simple")
1102
+
1103
+ # Find a Hecke operator that acts irreducibly on this space:
1104
+ p = 2
1105
+ t = self.dual_hecke_matrix(p)
1106
+ while True:
1107
+ f = t.charpoly('x')
1108
+ if f.is_irreducible():
1109
+ break
1110
+ p = next_prime(p)
1111
+ t += random.choice([-2, -1, 1, 2]) * self.dual_hecke_matrix(p)
1112
+
1113
+ # Write down the eigenvector.
1114
+ # Write f(x) = (x-alpha)*g(x), where alpha is a root
1115
+ # of f(x).
1116
+ n = f.degree()
1117
+ if n > 1:
1118
+ R = f.parent()
1119
+ K = R.base_ring().extension(f, names=names)
1120
+ alpha = K.gen()
1121
+ beta = ~alpha # multiplicative inverse of alpha
1122
+ c = [-f[0] * beta]
1123
+ for i in range(1, n - 1):
1124
+ c.append((c[i - 1] - f[i]) * beta)
1125
+ c.append(K.one())
1126
+ else:
1127
+ K = self.base_ring()
1128
+ c = [1]
1129
+
1130
+ # The entries of c are the coefficients of g (as stated in
1131
+ # William Stein's Ph.D. thesis, Section 3.5.3). We compute
1132
+ # g(t)v for a some vector v, and get an eigenvector.
1133
+ V = FreeModule(K, n)
1134
+ t = t.change_ring(K) # coerce t to be over K.
1135
+ for j in range(n):
1136
+ v = V.gen(j)
1137
+ I = t.iterates(v, n) # iterates v, v*t, v*t^2, ...
1138
+ w = V(0)
1139
+ for i in range(n):
1140
+ w += c[i] * V(I.row(i).list())
1141
+ if w != 0:
1142
+ break
1143
+
1144
+ # Now w is an eigenvector for the action of the Hecke
1145
+ # operators on the subspace. We need an eigenvector
1146
+ # in the original space, so we take the linear combination
1147
+ # of the basis for the embedded dual vector space given
1148
+ # by the entries of w.
1149
+ Vdual = self.dual_free_module().change_ring(K)
1150
+ w_lift = Vdual.linear_combination_of_basis(w)
1151
+
1152
+ # Finally rescale so the dot product of this vector and
1153
+ # the _eigen_nonzero_element is 1.
1154
+ if nz is not None:
1155
+ x = self.ambient().gen(nz)
1156
+ else:
1157
+ x = self._eigen_nonzero_element()
1158
+ alpha = w_lift.dot_product(x.element())
1159
+ beta = ~alpha
1160
+ w_lift = w_lift * beta
1161
+ w = w * beta
1162
+
1163
+ self.__dual_eigenvector[(names, nz)] = (w, w_lift)
1164
+ if lift:
1165
+ return w_lift
1166
+ else:
1167
+ return w
1168
+
1169
+ def dual_hecke_matrix(self, n):
1170
+ """
1171
+ Return the matrix of the `n`-th Hecke operator acting on the dual
1172
+ embedded representation of ``self``.
1173
+
1174
+ EXAMPLES::
1175
+
1176
+ sage: CuspForms(1, 24).dual_hecke_matrix(5)
1177
+ [ 44656110 -15040]
1178
+ [-307849789440 28412910]
1179
+ """
1180
+ n = int(n)
1181
+ try:
1182
+ self._dual_hecke_matrices
1183
+ except AttributeError:
1184
+ self._dual_hecke_matrices = {}
1185
+ if n not in self._dual_hecke_matrices:
1186
+ T = self._compute_dual_hecke_matrix(n)
1187
+ self._dual_hecke_matrices[n] = T
1188
+ return self._dual_hecke_matrices[n]
1189
+
1190
+ def eigenvalue(self, n, name='alpha'):
1191
+ r"""
1192
+ Assuming that ``self`` is a simple space, return the eigenvalue of the
1193
+ `n`-th Hecke operator on ``self``.
1194
+
1195
+ INPUT:
1196
+
1197
+ - ``n`` -- index of Hecke operator
1198
+
1199
+ - ``name`` -- print representation of generator of
1200
+ eigenvalue field
1201
+
1202
+ EXAMPLES::
1203
+
1204
+ sage: A = ModularSymbols(125,sign=1).new_subspace()[0]
1205
+ sage: A.eigenvalue(7)
1206
+ -3
1207
+ sage: A.eigenvalue(3)
1208
+ -alpha - 2
1209
+ sage: A.eigenvalue(3,'w')
1210
+ -w - 2
1211
+ sage: A.eigenvalue(3,'z').charpoly('x')
1212
+ x^2 + 3*x + 1
1213
+ sage: A.hecke_polynomial(3)
1214
+ x^2 + 3*x + 1
1215
+
1216
+ ::
1217
+
1218
+ sage: M = ModularSymbols(Gamma1(17)).decomposition()[8].plus_submodule()
1219
+ sage: M.eigenvalue(2,'a')
1220
+ a
1221
+ sage: M.eigenvalue(4,'a')
1222
+ 4/3*a^3 + 17/3*a^2 + 28/3*a + 8/3
1223
+
1224
+ .. NOTE::
1225
+
1226
+ #. In fact there are `d` systems of eigenvalues
1227
+ associated to self, where `d` is the rank of
1228
+ ``self``. Each of the systems of eigenvalues is conjugate
1229
+ over the base field. This function chooses one of the
1230
+ systems and consistently returns eigenvalues from that
1231
+ system. Thus these are the coefficients `a_n` for
1232
+ `n\geq 1` of a modular eigenform attached to ``self``.
1233
+
1234
+ #. This function works even for Eisenstein subspaces,
1235
+ though it will not give the constant coefficient of one
1236
+ of the corresponding Eisenstein series (i.e., the
1237
+ generalized Bernoulli number).
1238
+
1239
+ TESTS:
1240
+
1241
+ This checks that :issue:`15201` is fixed::
1242
+
1243
+ sage: M = ModularSymbols(5, 6, sign=1)
1244
+ sage: f = M.decomposition()[0]
1245
+ sage: f.eigenvalue(10)
1246
+ 50
1247
+ """
1248
+ if not self.is_simple():
1249
+ raise ArithmeticError("self must be simple")
1250
+ n = int(n)
1251
+ try:
1252
+ return self.__eigenvalues[n][name]
1253
+ except AttributeError:
1254
+ self.__eigenvalues = {}
1255
+ except KeyError:
1256
+ pass
1257
+ if n <= 0:
1258
+ raise IndexError("n must be a positive integer")
1259
+
1260
+ ev = self.__eigenvalues
1261
+
1262
+ if n == 1 or is_prime(n):
1263
+ Tn_e = self._eigen_nonzero_element(n)
1264
+ an = self._element_eigenvalue(Tn_e, name=name)
1265
+ _dict_set(ev, n, name, an)
1266
+ return an
1267
+
1268
+ # Now use the Hecke eigenvalue recurrence, since arithmetic in
1269
+ # a field is faster than computing Heilbronn matrices for
1270
+ # non-prime n and doing some big sum (i.e., computing T_n(e)).
1271
+ # Also by computing using the recurrence on eigenvalues
1272
+ # we use information about divisors.
1273
+ F = factor(n)
1274
+ prod = None
1275
+ for p, r in F:
1276
+ (p, r) = (int(p), int(r))
1277
+ pow = p**r
1278
+ if not (pow in ev and name in ev[pow]):
1279
+ # TODO: Optimization -- do something much more
1280
+ # intelligent in case character is not defined. For
1281
+ # example, compute it using the diamond operators <d>
1282
+ eps = self.character()
1283
+ if eps is None:
1284
+ Tn_e = self._eigen_nonzero_element(pow)
1285
+ _dict_set(ev, pow, name, self._element_eigenvalue(Tn_e, name=name))
1286
+ else:
1287
+ # a_{p^r} := a_p * a_{p^{r-1}} - eps(p)p^{k-1} a_{p^{r-2}}
1288
+ ap = self.eigenvalue(p, name=name)
1289
+ if r == 1:
1290
+ apow = ap
1291
+ else:
1292
+ apr1 = self.eigenvalue(pow // p, name=name)
1293
+ k = self.weight()
1294
+ apr2 = self.eigenvalue(pow // (p * p), name=name)
1295
+ apow = ap * apr1 - eps(p) * (p**(k - 1)) * apr2
1296
+ _dict_set(ev, pow, name, apow)
1297
+ if prod is None:
1298
+ prod = ev[pow][name]
1299
+ else:
1300
+ prod *= ev[pow][name]
1301
+ _dict_set(ev, n, name, prod)
1302
+ return prod
1303
+
1304
+ def factor_number(self):
1305
+ """
1306
+ If this Hecke module was computed via a decomposition of another
1307
+ Hecke module, this is the corresponding number. Otherwise return
1308
+ -1.
1309
+
1310
+ EXAMPLES::
1311
+
1312
+ sage: ModularSymbols(23)[0].factor_number()
1313
+ 0
1314
+ sage: ModularSymbols(23).factor_number()
1315
+ -1
1316
+ """
1317
+ try:
1318
+ return self.__factor_number
1319
+ except AttributeError:
1320
+ return -1
1321
+
1322
+ def gens(self) -> tuple:
1323
+ """
1324
+ Return a tuple of basis elements of ``self``.
1325
+
1326
+ EXAMPLES::
1327
+
1328
+ sage: ModularSymbols(23).gens()
1329
+ ((1,0), (1,17), (1,19), (1,20), (1,21))
1330
+ """
1331
+ return tuple(self(x) for x in self.free_module().gens())
1332
+
1333
+ def gen(self, n):
1334
+ r"""
1335
+ Return the `n`-th basis vector of the space.
1336
+
1337
+ EXAMPLES::
1338
+
1339
+ sage: ModularSymbols(23).gen(1)
1340
+ (1,17)
1341
+ """
1342
+ return self(self.free_module().gen(n))
1343
+
1344
+ def hecke_matrix(self, n):
1345
+ """
1346
+ Return the matrix of the `n`-th Hecke operator acting on given basis.
1347
+
1348
+ EXAMPLES::
1349
+
1350
+ sage: C = CuspForms(1, 16)
1351
+ sage: C.hecke_matrix(3)
1352
+ [-3348]
1353
+ """
1354
+ n = int(n)
1355
+ if n <= 0:
1356
+ raise IndexError("n must be positive.")
1357
+ if n not in self._hecke_matrices:
1358
+ T = self._compute_hecke_matrix(n)
1359
+ T.set_immutable()
1360
+ self._hecke_matrices[n] = T
1361
+ return self._hecke_matrices[n]
1362
+
1363
+ def hecke_operator(self, n):
1364
+ """
1365
+ Return the `n`-th Hecke operator `T_n`.
1366
+
1367
+ INPUT:
1368
+
1369
+ - ``n`` -- integer at least 1
1370
+
1371
+ EXAMPLES::
1372
+
1373
+ sage: M = ModularSymbols(11,2)
1374
+ sage: T = M.hecke_operator(3) ; T
1375
+ Hecke operator T_3 on Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field
1376
+ sage: T.matrix()
1377
+ [ 4 0 -1]
1378
+ [ 0 -1 0]
1379
+ [ 0 0 -1]
1380
+ sage: T(M.0)
1381
+ 4*(1,0) - (1,9)
1382
+ sage: S = M.cuspidal_submodule()
1383
+ sage: T = S.hecke_operator(3) ; T
1384
+ Hecke operator T_3 on Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field
1385
+ sage: T.matrix()
1386
+ [-1 0]
1387
+ [ 0 -1]
1388
+ sage: T(S.0)
1389
+ -(1,8)
1390
+ """
1391
+ return self.hecke_algebra().hecke_operator(n)
1392
+
1393
+ def diamond_bracket_matrix(self, d):
1394
+ r"""
1395
+ Return the matrix of the diamond bracket operator `\langle d \rangle` on ``self``.
1396
+
1397
+ EXAMPLES::
1398
+
1399
+ sage: M = ModularSymbols(DirichletGroup(5).0, 3)
1400
+ sage: M.diamond_bracket_matrix(3)
1401
+ [-zeta4 0]
1402
+ [ 0 -zeta4]
1403
+ sage: ModularSymbols(Gamma1(5), 3).diamond_bracket_matrix(3)
1404
+ [ 0 1 0 0]
1405
+ [-1 0 0 0]
1406
+ [ 0 0 0 1]
1407
+ [ 0 0 -1 0]
1408
+ """
1409
+ d = int(d) % self.level()
1410
+ if d not in self._diamond_matrices:
1411
+ if self.character() is not None:
1412
+ D = MatrixSpace(self.base_ring(), self.rank())(self.character()(d))
1413
+ else:
1414
+ D = self._compute_diamond_matrix(d)
1415
+ D.set_immutable()
1416
+ self._diamond_matrices[d] = D
1417
+ return self._diamond_matrices[d]
1418
+
1419
+ def diamond_bracket_operator(self, d):
1420
+ r"""
1421
+ Return the diamond bracket operator `\langle d \rangle` on ``self``.
1422
+
1423
+ EXAMPLES::
1424
+
1425
+ sage: M = ModularSymbols(DirichletGroup(5).0, 3)
1426
+ sage: M.diamond_bracket_operator(3)
1427
+ Diamond bracket operator <3> on Modular Symbols space of dimension 2 and level 5, weight 3, character [zeta4], sign 0, over Cyclotomic Field of order 4 and degree 2
1428
+ """
1429
+ return self.hecke_algebra().diamond_bracket_operator(d)
1430
+
1431
+ def T(self, n):
1432
+ r"""
1433
+ Return the `n`-th Hecke operator `T_n`.
1434
+
1435
+ This function is a synonym for :meth:`hecke_operator`.
1436
+
1437
+ EXAMPLES::
1438
+
1439
+ sage: M = ModularSymbols(11,2)
1440
+ sage: M.T(3)
1441
+ Hecke operator T_3 on Modular Symbols ...
1442
+ """
1443
+ return self.hecke_operator(n)
1444
+
1445
+ def hecke_polynomial(self, n, var='x'):
1446
+ """
1447
+ Return the characteristic polynomial of the `n`-th Hecke operator
1448
+ acting on this space.
1449
+
1450
+ INPUT:
1451
+
1452
+ - ``n`` -- integer
1453
+
1454
+ OUTPUT: a polynomial
1455
+
1456
+ EXAMPLES::
1457
+
1458
+ sage: ModularSymbols(11,2).hecke_polynomial(3)
1459
+ x^3 - 2*x^2 - 7*x - 4
1460
+ """
1461
+ return self.hecke_operator(n).charpoly(var)
1462
+
1463
+ def is_simple(self) -> bool:
1464
+ r"""
1465
+ Return ``True`` if this space is simple as a module for the
1466
+ corresponding Hecke algebra.
1467
+
1468
+ This raises :exc:`NotImplementedError`, as this is an abstract base
1469
+ class.
1470
+
1471
+ EXAMPLES::
1472
+
1473
+ sage: sage.modular.hecke.module.HeckeModule_free_module(QQ, 10, 3).is_simple()
1474
+ Traceback (most recent call last):
1475
+ ...
1476
+ NotImplementedError
1477
+ """
1478
+ raise NotImplementedError
1479
+
1480
+ def is_splittable(self) -> bool:
1481
+ """
1482
+ Return ``True`` if and only if only it is possible to split
1483
+ off a nontrivial generalized eigenspace of ``self`` as the
1484
+ kernel of some Hecke operator (not necessarily prime to the level).
1485
+
1486
+ Note that the direct sum of several copies of the same simple
1487
+ module is not splittable in this sense.
1488
+
1489
+ EXAMPLES::
1490
+
1491
+ sage: M = ModularSymbols(Gamma0(64)).cuspidal_subspace()
1492
+ sage: M.is_splittable()
1493
+ True
1494
+ sage: M.simple_factors()[0].is_splittable()
1495
+ False
1496
+ """
1497
+ if not hasattr(self, "__is_splittable"):
1498
+ self.decomposition(anemic=False)
1499
+ return self.__is_splittable
1500
+
1501
+ def is_submodule(self, other) -> bool:
1502
+ r"""
1503
+ Return ``True`` if ``self`` is a submodule of ``other``.
1504
+
1505
+ EXAMPLES::
1506
+
1507
+ sage: M = ModularSymbols(Gamma0(64))
1508
+ sage: M[0].is_submodule(M)
1509
+ True
1510
+ sage: CuspForms(1, 24).is_submodule(ModularForms(1, 24))
1511
+ True
1512
+ sage: CuspForms(1, 12).is_submodule(CuspForms(3, 12))
1513
+ False
1514
+ """
1515
+ if not isinstance(other, HeckeModule_free_module):
1516
+ return False
1517
+ return (self.ambient_free_module() == other.ambient_free_module() and
1518
+ self.free_module().is_submodule(other.free_module()))
1519
+
1520
+ def is_splittable_anemic(self) -> bool:
1521
+ """
1522
+ Return ``True`` if and only if only it is possible to split off a
1523
+ nontrivial generalized eigenspace of ``self`` as the kernel of some
1524
+ Hecke operator of index coprime to the level.
1525
+
1526
+ Note that the direct sum of several copies of the same simple
1527
+ module is not splittable in this sense.
1528
+
1529
+ EXAMPLES::
1530
+
1531
+ sage: M = ModularSymbols(Gamma0(64)).cuspidal_subspace()
1532
+ sage: M.is_splittable_anemic()
1533
+ True
1534
+ sage: M.simple_factors()[0].is_splittable_anemic()
1535
+ False
1536
+ """
1537
+ if not hasattr(self, "__is_splittable_anemic"):
1538
+ self.decomposition(anemic=True)
1539
+ return self.__is_splittable_anemic
1540
+
1541
+ def ngens(self):
1542
+ r"""
1543
+ Return the number of generators of ``self``.
1544
+
1545
+ This is equal to the rank.
1546
+
1547
+ EXAMPLES::
1548
+
1549
+ sage: ModularForms(1, 12).ngens()
1550
+ 2
1551
+ """
1552
+ return self.rank()
1553
+
1554
+ def projection(self):
1555
+ r"""
1556
+ Return the projection map from the ambient space to ``self``.
1557
+
1558
+ ALGORITHM: Let `B` be the matrix whose columns are obtained
1559
+ by concatenating together a basis for the factors of the ambient
1560
+ space. Then the projection matrix onto ``self`` is the submatrix of
1561
+ `B^{-1}` obtained from the rows corresponding to self,
1562
+ i.e., if the basis vectors for ``self`` appear as columns `n`
1563
+ through `m` of `B`, then the projection matrix is
1564
+ got from rows `n` through `m` of `B^{-1}`.
1565
+ This is because projection with respect to the B basis is just
1566
+ given by an `m-n+1` row slice `P` of a diagonal
1567
+ matrix D with 1s in the `n` through `m` positions,
1568
+ so projection with respect to the standard basis is given by
1569
+ `P\cdot B^{-1}`, which is just rows `n`
1570
+ through `m` of `B^{-1}`.
1571
+
1572
+ EXAMPLES::
1573
+
1574
+ sage: # needs database_cremona_mini_ellcurve
1575
+ sage: e = EllipticCurve('34a')
1576
+ sage: m = ModularSymbols(34); s = m.cuspidal_submodule()
1577
+ sage: d = s.decomposition(7)
1578
+ sage: d
1579
+ [Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 9 for Gamma_0(34) of weight 2 with sign 0 over Rational Field,
1580
+ Modular Symbols subspace of dimension 4 of Modular Symbols space of dimension 9 for Gamma_0(34) of weight 2 with sign 0 over Rational Field]
1581
+ sage: a = d[0]; a
1582
+ Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 9 for Gamma_0(34) of weight 2 with sign 0 over Rational Field
1583
+ sage: pi = a.projection()
1584
+ sage: pi(m([0,oo]))
1585
+ -1/6*(2,7) + 1/6*(2,13) - 1/6*(2,31) + 1/6*(2,33)
1586
+ sage: M = ModularSymbols(53,sign=1)
1587
+ sage: S = M.cuspidal_subspace()[1] ; S
1588
+ Modular Symbols subspace of dimension 3 of Modular Symbols space of dimension 5 for Gamma_0(53) of weight 2 with sign 1 over Rational Field
1589
+ sage: p = S.projection()
1590
+ sage: S.basis()
1591
+ ((1,43) - (1,45), (1,47), (1,50))
1592
+ sage: [ p(x) for x in S.basis() ]
1593
+ [(1,43) - (1,45), (1,47), (1,50)]
1594
+ sage: all(p(x)==x for x in S.basis())
1595
+ True
1596
+ """
1597
+
1598
+ # Compute the Hecke-stable projection map pi from the ambient
1599
+ # space of M to M. Computing the projection map is the same
1600
+ # as writing the ambient space as a direct sum of M and its
1601
+ # Hecke-stable complement, which is the old subspace plus the
1602
+ # other new factors, then *inverting*. With the projection
1603
+ # map in hand, we can compute Hecke operators directly on M
1604
+ # fairly quickly without having to compute them on the whole
1605
+ # ambient space. Of course, computing this inverse is way too
1606
+ # much work to be useful in general (!). (I sort of learned
1607
+ # this trick from Joe Wetherell, or at least he was aware of
1608
+ # it when I mentioned it to him in an airport once. It's also
1609
+ # sort of like a trick Cremona uses in his book for elliptic
1610
+ # curves.) It's not a very good trick though.
1611
+
1612
+ try:
1613
+ return self.__projection
1614
+ except AttributeError:
1615
+ i = self.factor_number()
1616
+ if i == -1:
1617
+ raise NotImplementedError("Computation of projection only implemented "
1618
+ "for decomposition factors.")
1619
+ A = self.ambient_hecke_module()
1620
+ B = A.decomposition_matrix_inverse()
1621
+ i = A.decomposition().index(self)
1622
+ n = sum([A[j].rank() for j in range(i)])
1623
+ C = B.matrix_from_columns(range(n, n + self.rank()))
1624
+ H = A.Hom(self)
1625
+ pi = H(C, "Projection" % self)
1626
+ self.__projection = pi
1627
+ return self.__projection
1628
+
1629
+ def system_of_eigenvalues(self, n, name='alpha'):
1630
+ r"""
1631
+ Assuming that ``self`` is a simple space of modular symbols, return the
1632
+ eigenvalues `[a_1, \ldots, a_nmax]` of the Hecke
1633
+ operators on ``self``. See ``self.eigenvalue(n)`` for more
1634
+ details.
1635
+
1636
+ INPUT:
1637
+
1638
+ - ``n`` -- number of eigenvalues
1639
+
1640
+ - ``alpha`` -- name of generate for eigenvalue field
1641
+
1642
+ EXAMPLES:
1643
+
1644
+ The outputs of the following tests are very unstable. The algorithms
1645
+ are randomized and depend on cached results. A slight change in the
1646
+ sequence of pseudo-random numbers or a modification in caching is
1647
+ likely to modify the results. We reset the random number generator and
1648
+ clear some caches for reproducibility::
1649
+
1650
+ sage: set_random_seed(0)
1651
+ sage: ModularSymbols_clear_cache()
1652
+
1653
+ We compute eigenvalues for newforms of level 62::
1654
+
1655
+ sage: M = ModularSymbols(62,2,sign=-1)
1656
+ sage: S = M.cuspidal_submodule().new_submodule()
1657
+ sage: [[o.minpoly() for o in A.system_of_eigenvalues(3)] for A in S.decomposition()]
1658
+ [[x - 1, x - 1, x], [x - 1, x + 1, x^2 - 2*x - 2]]
1659
+
1660
+ Next we define a function that does the above::
1661
+
1662
+ sage: def b(N, k=2):
1663
+ ....: S = ModularSymbols(N,k,sign=-1).cuspidal_submodule().new_submodule()
1664
+ ....: for A in S.decomposition():
1665
+ ....: print("{} {}".format(N, A.system_of_eigenvalues(5)))
1666
+
1667
+ ::
1668
+
1669
+ sage: b(63)
1670
+ 63 [1, 1, 0, -1, 2]
1671
+ 63 [1, alpha, 0, 1, -2*alpha]
1672
+
1673
+ This example illustrates finding field over which the eigenvalues
1674
+ are defined::
1675
+
1676
+ sage: M = ModularSymbols(23,2,sign=1).cuspidal_submodule().new_submodule()
1677
+ sage: v = M.system_of_eigenvalues(10); v
1678
+ [1, alpha, -2*alpha - 1, -alpha - 1, 2*alpha, alpha - 2, 2*alpha + 2, -2*alpha - 1, 2, -2*alpha + 2]
1679
+ sage: v[0].parent()
1680
+ Number Field in alpha with defining polynomial x^2 + x - 1
1681
+
1682
+ This example illustrates setting the print name of the eigenvalue
1683
+ field.
1684
+
1685
+ ::
1686
+
1687
+ sage: A = ModularSymbols(125,sign=1).new_subspace()[0]
1688
+ sage: A.system_of_eigenvalues(10)
1689
+ [1, alpha, -alpha - 2, -alpha - 1, 0, -alpha - 1, -3, -2*alpha - 1, 3*alpha + 2, 0]
1690
+ sage: A.system_of_eigenvalues(10,'x')
1691
+ [1, x, -x - 2, -x - 1, 0, -x - 1, -3, -2*x - 1, 3*x + 2, 0]
1692
+ """
1693
+ return [self.eigenvalue(m, name=name) for m in range(1, n + 1)]
1694
+
1695
+ def weight(self):
1696
+ """
1697
+ Return the weight of this Hecke module.
1698
+
1699
+ INPUT:
1700
+
1701
+ - ``self`` -- an arbitrary Hecke module
1702
+
1703
+ OUTPUT: integer; the weight
1704
+
1705
+ EXAMPLES::
1706
+
1707
+ sage: m = ModularSymbols(20, weight=2)
1708
+ sage: m.weight()
1709
+ 2
1710
+ """
1711
+ return self.__weight
1712
+
1713
+ def zero_submodule(self):
1714
+ """
1715
+ Return the zero submodule of ``self``.
1716
+
1717
+ EXAMPLES::
1718
+
1719
+ sage: ModularSymbols(11,4).zero_submodule()
1720
+ Modular Symbols subspace of dimension 0 of Modular Symbols space of dimension 6 for Gamma_0(11) of weight 4 with sign 0 over Rational Field
1721
+ sage: CuspForms(11,4).zero_submodule()
1722
+ Modular Forms subspace of dimension 0 of Modular Forms space of dimension 4 for Congruence Subgroup Gamma0(11) of weight 4 over Rational Field
1723
+ """
1724
+ return self.submodule(self.free_module().zero_submodule(), check=False)
1725
+
1726
+
1727
+ def _dict_set(v, n, key, val):
1728
+ r"""
1729
+ Rough-and-ready implementation of a two-layer-deep dictionary.
1730
+
1731
+ EXAMPLES::
1732
+
1733
+ sage: from sage.modular.hecke.module import _dict_set
1734
+ sage: v = {}
1735
+ sage: _dict_set(v, 1, 2, 3)
1736
+ sage: v
1737
+ {1: {2: 3}}
1738
+ sage: _dict_set(v, 1, 3, 4); v
1739
+ {1: {2: 3, 3: 4}}
1740
+ """
1741
+ if n in v:
1742
+ v[n][key] = val
1743
+ else:
1744
+ v[n] = {key: val}