Skip to content

Commit

Permalink
working on L-function
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Feb 18, 2025
1 parent dde296e commit b60e42a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 34 deletions.
12 changes: 10 additions & 2 deletions src/sage/lfunctions/pari.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,19 @@ def lfun_hecke(chi):
sage: L = LFunction(lfun_hecke(chi))

Check failure on line 270 in src/sage/lfunctions/pari.py

View workflow job for this annotation

GitHub Actions / test-new

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 728, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1152, in compile_and_execute exec(compiled, globs) File "<doctest sage.lfunctions.pari.lfun_hecke[4]>", line 1, in <module> L = LFunction(lfun_hecke(chi)) File "/sage/src/sage/lfunctions/pari.py", line 285, in lfun_hecke return pari.lfuncreate(Gv) File "cypari2/auto_instance.pxi", line 18782, in cypari2.pari_instance.Pari_auto.lfuncreate File "cypari2/handle_error.pyx", line 211, in cypari2.handle_error._pari_err_handle raise PariError(errnum, pari_error_string, clone_gen_noclear(E)) cypari2.handle_error.PariError: incorrect type in check_gchar [chi] (t_VEC)
sage: L(3)

Check failure on line 271 in src/sage/lfunctions/pari.py

View workflow job for this annotation

GitHub Actions / test-new

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 728, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1152, in compile_and_execute exec(compiled, globs) File "<doctest sage.lfunctions.pari.lfun_hecke[5]>", line 1, in <module> L(Integer(3)) NameError: name 'L' is not defined
?
sage: F.<a> = NumberField(x^2 - 5)
sage: mf = F.modulus(F.ideal(4), [0, 1])
sage: H = HeckeCharacterGroup(mf)
sage: chi = H.gens()[1]
sage: L = LFunction(lfun_hecke(chi))

Check failure on line 278 in src/sage/lfunctions/pari.py

View workflow job for this annotation

GitHub Actions / test-new

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 728, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1152, in compile_and_execute exec(compiled, globs) File "<doctest sage.lfunctions.pari.lfun_hecke[10]>", line 1, in <module> L = LFunction(lfun_hecke(chi)) File "/sage/src/sage/lfunctions/pari.py", line 285, in lfun_hecke return pari.lfuncreate(Gv) File "cypari2/auto_instance.pxi", line 18782, in cypari2.pari_instance.Pari_auto.lfuncreate File "cypari2/handle_error.pyx", line 211, in cypari2.handle_error._pari_err_handle raise PariError(errnum, pari_error_string, clone_gen_noclear(E)) cypari2.handle_error.PariError: incorrect type in check_gchar [chi] (t_VEC)
sage: [L(-n) for n in range(3)]

Check failure on line 279 in src/sage/lfunctions/pari.py

View workflow job for this annotation

GitHub Actions / test-new

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 728, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1152, in compile_and_execute exec(compiled, globs) File "<doctest sage.lfunctions.pari.lfun_hecke[11]>", line 1, in <module> [L(-n) for n in range(Integer(3))] File "<doctest sage.lfunctions.pari.lfun_hecke[11]>", line 1, in <listcomp> [L(-n) for n in range(Integer(3))] NameError: name 'L' is not defined
[1.00000000000000, 0.000000000000000, 15.0000000000000]
"""
if not chi.is_primitive():
chi = chi.primitive_character()
G, v = chi._pari_init_()
return pari.lfuncreate([G, v])
Gv = chi._pari_init_()
return pari.lfuncreate(Gv)


def lfun_hgm(motif, t):
Expand Down
66 changes: 34 additions & 32 deletions src/sage/modular/hecke_character.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def dirichlet_series_coefficients(self, max_n):
ans[n - 1] = sum(self(I) for I in Is)
return ans

def Lfunction(self, prec=53):
def lfunction(self, prec=53):
r"""
Return this character's L-function.
Expand All @@ -395,46 +395,48 @@ def Lfunction(self, prec=53):
sage: mf = F.modulus(F.ideal(4), [0, 1])
sage: H = HeckeCharacterGroup(mf)
sage: chi = H.gens()[1]
sage: L = chi.Lfunction(); L
sage: L = chi.lfunction(); L

Check failure on line 398 in src/sage/modular/hecke_character.py

View workflow job for this annotation

GitHub Actions / test-new

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 728, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1152, in compile_and_execute exec(compiled, globs) File "<doctest sage.modular.hecke_character.HeckeCharacter.lfunction[4]>", line 1, in <module> L = chi.lfunction(); L File "/sage/src/sage/modular/hecke_character.py", line 439, in lfunction L = LFunction(lfun_hecke(self), prec=prec) File "/sage/src/sage/lfunctions/pari.py", line 285, in lfun_hecke return pari.lfuncreate(Gv) File "cypari2/auto_instance.pxi", line 18782, in cypari2.pari_instance.Pari_auto.lfuncreate File "cypari2/handle_error.pyx", line 211, in cypari2.handle_error._pari_err_handle raise PariError(errnum, pari_error_string, clone_gen_noclear(E)) cypari2.handle_error.PariError: incorrect type in check_gchar [chi] (t_VEC)
Hecke L-function of χ1
sage: [L(-n) for n in range(3)]

Check failure on line 400 in src/sage/modular/hecke_character.py

View workflow job for this annotation

GitHub Actions / test-new

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 728, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1152, in compile_and_execute exec(compiled, globs) File "<doctest sage.modular.hecke_character.HeckeCharacter.lfunction[5]>", line 1, in <module> [L(-n) for n in range(Integer(3))] File "<doctest sage.modular.hecke_character.HeckeCharacter.lfunction[5]>", line 1, in <listcomp> [L(-n) for n in range(Integer(3))] NameError: name 'L' is not defined
[1.00000000000000, 0.000000000000000, 15.0000000000000]
"""
# Figure out Gamma factors for more general characters
gamma_factors = [0] * self.parent().number_field().degree()
for i in self.conductor().infinite_part():
gamma_factors[i] = 1
ana_cond = self.analytic_conductor()
rn = self.root_number()
# gamma_factors = [0] * self.parent().number_field().degree()
# for i in self.conductor().infinite_part():
# gamma_factors[i] = 1
# ana_cond = self.analytic_conductor()
# rn = self.root_number()

# OLD Dokchitser version, to be removed
# Dokchitser(conductor, gammaV, weight, eps, poles, residues, init,
# prec)
it_worked = False
number_of_allocs = 0
while not it_worked:
# Sage automatically ups the memory allocation, but this
# messes with L.num_coeffs for some reason I have yet to
# figure out, so L needs to be remade completely every
# time memory is auto-allocated. If we can control the
# auto-allocation process/rewrite the Dokchitser code,
# then we can remove the extra stuff here.
L = Dokchitser(ana_cond, gamma_factors, 1, rn, prec=prec)
for n in range(number_of_allocs):
L.gp().eval('allocatemem()')
try:
L.init_coeffs(self.dirichlet_series_coefficients(L.num_coeffs()))
it_worked = True
except RuntimeError:
number_of_allocs += 1

# NEW version, TODO: make correct lines below
lf = lfun_generic(conductor=ana_cond, gammaV=gamma_factors,
weight=1, eps=rn)
# how to pick the correct number of coefficients ?
lf.init_coeffs(self.dirichlet_series_coefficients(L.num_coeffs()))

L = LFunction(lf, prec=prec)
# it_worked = False
# number_of_allocs = 0
# while not it_worked:
# # Sage automatically ups the memory allocation, but this
# # messes with L.num_coeffs for some reason I have yet to
# # figure out, so L needs to be remade completely every
# # time memory is auto-allocated. If we can control the
# # auto-allocation process/rewrite the Dokchitser code,
# # then we can remove the extra stuff here.
# L = Dokchitser(ana_cond, gamma_factors, 1, rn, prec=prec)
# for n in range(number_of_allocs):
# L.gp().eval('allocatemem()')
# try:
# L.init_coeffs(self.dirichlet_series_coefficients(L.num_coeffs()))
# it_worked = True
# except RuntimeError:
# number_of_allocs += 1

# # NEW version, TODO: make correct lines below
# lf = lfun_generic(conductor=ana_cond, gammaV=gamma_factors,
# weight=1, eps=rn)
# # how to pick the correct number of coefficients ?
# lf.init_coeffs(self.dirichlet_series_coefficients(L.num_coeffs()))

# instead use Pari directly:
from sage.lfunctions.pari import lfun_hecke
L = LFunction(lfun_hecke(self), prec=prec)
L.rename(f'Hecke L-function of {self}')
return L

Expand Down

0 comments on commit b60e42a

Please sign in to comment.