forked from sanni85/Mod-l-galois-representations
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcharacter.sage
41 lines (33 loc) · 1.03 KB
/
character.sage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from dual_pairs.dual_pair_import import dual_pair_import
def dirichlet_character_label(chi):
r"""
Return the LMFDB label of :math:`\chi`.
INPUT:
- ``chi`` -- a :class:`DirichletCharacter` with values in a finite
field
EXAMPLES::
sage: G = DirichletGroup(39, GF(3))
sage: chi = G([2, 2])
sage: dirichlet_character_label(chi)
'3-39.38'
sage: G = DirichletGroup(55, GF(11))
sage: chi = G([1, 2])
sage: dirichlet_character_label(chi)
'11-55.46'
"""
G = chi.parent()
m = G.modulus()
l = G.base_ring().characteristic()
z = G.zeta()
o = G.zeta_order()
H = pari('znstar({},1)'.format(m))
cyc = H.getattr('cyc')
gen = H.getattr('gen')
v = [chi(g).log(z) * c/o for c, g in zip(cyc, gen)]
c = H.znconreyexp(v)
return "{}-{}.{}".format(l, m, c)
if len(sys.argv) != 2:
raise RuntimeError('usage: character.sage FILE')
D = dual_pair_import(sys.argv[1])
chi = D.dirichlet_character()
print(dirichlet_character_label(chi))