Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/quadratic_forms/quadratic_form__genus.py
4100 views
1
"""
2
Local and Global Genus Symbols
3
4
"""
5
6
7
#############################################################
8
## ##
9
## Wrappers for the Genus/Genus Symbol Code in ../genera/ ##
10
## ##
11
#############################################################
12
13
from sage.quadratic_forms.genera.genus import Genus, LocalGenusSymbol, \
14
is_GlobalGenus, is_2_adic_genus, canonical_2_adic_compartments, \
15
canonical_2_adic_trains, canonical_2_adic_reduction, \
16
basis_complement, p_adic_symbol, is_even_matrix, \
17
split_odd, trace_diag_mod_8, two_adic_symbol
18
#is_trivial_symbol
19
#GenusSymbol_p_adic_ring, GenusSymbol_global_ring
20
21
## Removed signature_pair_of_matrix due to a circular import issue.
22
23
## NOTE: Removed the signature routine here... and rewrote it for now.
24
25
26
from sage.rings.integer_ring import IntegerRing
27
from sage.rings.arith import is_prime, prime_divisors
28
29
30
31
def global_genus_symbol(self):
32
"""
33
Returns the genus of a two times a quadratic form over ZZ. These
34
are defined by a collection of local genus symbols (a la Chapter
35
15 of Conway-Sloane), and a signature.
36
37
EXAMPLES::
38
39
sage: Q = DiagonalQuadraticForm(ZZ, [1,2,3,4])
40
sage: Q.global_genus_symbol()
41
Genus of [2 0 0 0]
42
[0 4 0 0]
43
[0 0 6 0]
44
[0 0 0 8]
45
46
::
47
48
sage: Q = QuadraticForm(ZZ, 4, range(10))
49
sage: Q.global_genus_symbol()
50
Genus of [ 0 1 2 3]
51
[ 1 8 5 6]
52
[ 2 5 14 8]
53
[ 3 6 8 18]
54
55
"""
56
## Check that the form is defined over ZZ
57
if not self.base_ring() == IntegerRing():
58
raise TypeError, "Oops! The quadratic form is not defined over the integers."
59
60
## Return the result
61
try:
62
return Genus(self.Hessian_matrix())
63
except:
64
raise TypeError, "Oops! There is a problem computing the genus symbols for this form."
65
66
67
68
def local_genus_symbol(self, p):
69
"""
70
Returns the Conway-Sloane genus symbol of 2 times a quadratic form
71
defined over ZZ at a prime number p. This is defined (in the
72
Genus_Symbol_p_adic_ring() class in the quadratic_forms/genera
73
subfolder) to be a list of tuples (one for each Jordan component
74
p^m*A at p, where A is a unimodular symmetric matrix with
75
coefficients the p-adic integers) of the following form:
76
77
1. If p>2 then return triples of the form [`m`, `n`, `d`] where
78
`m` = valuation of the component
79
80
`n` = rank of A
81
82
`d` = det(A) in {1,u} for normalized quadratic non-residue u.
83
84
2. If p=2 then return quintuples of the form [`m`,`n`,`s`, `d`, `o`] where
85
`m` = valuation of the component
86
87
`n` = rank of A
88
89
`d` = det(A) in {1,3,5,7}
90
91
`s` = 0 (or 1) if A is even (or odd)
92
93
`o` = oddity of A (= 0 if s = 0) in Z/8Z
94
= the trace of the diagonalization of A
95
96
NOTE: The Conway-Sloane convention for describing the prime 'p =
97
-1' is not supported here, and neither is the convention for
98
including the 'prime' Infinity. See note on p370 of Conway-Sloane
99
(3rd ed) for a discussion of this convention.
100
101
INPUT:
102
103
-`p` -- a prime number > 0
104
105
OUTPUT:
106
Returns a Conway-Sloane genus symbol at p, which is an
107
instance of the Genus_Symbol_p_adic_ring class.
108
109
EXAMPLES::
110
111
sage: Q = DiagonalQuadraticForm(ZZ, [1,2,3,4])
112
sage: Q.local_genus_symbol(2)
113
Genus symbol at 2 : [[1, 2, 3, 1, 4], [2, 1, 1, 1, 1], [3, 1, 1, 1, 1]]
114
sage: Q.local_genus_symbol(3)
115
Genus symbol at 3 : [[0, 3, 1], [1, 1, -1]]
116
sage: Q.local_genus_symbol(5)
117
Genus symbol at 5 : [[0, 4, 1]]
118
119
"""
120
## Check that p is prime and that the form is defined over ZZ.
121
if not is_prime(p):
122
raise TypeError, "Oops! The number " + str(p) + " isn't prime."
123
if not self.base_ring() == IntegerRing():
124
raise TypeError, "Oops! The quadratic form is not defined over the integers."
125
126
## Return the result
127
try:
128
M = self.Hessian_matrix()
129
return LocalGenusSymbol(M, p)
130
except:
131
raise TypeError, "Oops! There is a problem computing the local genus symbol at the prime " + str(p) + " for this form."
132
133
134
135
136
137
138
def CS_genus_symbol_list(self, force_recomputation=False):
139
"""
140
Returns the list of Conway-Sloane genus symbols in increasing order of primes dividing 2*det.
141
142
EXAMPLES::
143
144
sage: Q = DiagonalQuadraticForm(ZZ, [1,2,3,4])
145
sage: Q.CS_genus_symbol_list()
146
[Genus symbol at 2 : [[1, 2, 3, 1, 4], [2, 1, 1, 1, 1], [3, 1, 1, 1, 1]],
147
Genus symbol at 3 : [[0, 3, 1], [1, 1, -1]]]
148
149
"""
150
## Try to use the cached list
151
if force_recomputation == False:
152
try:
153
return self.__CS_genus_symbol_list
154
except:
155
pass
156
157
## Otherwise recompute and cache the list
158
list_of_CS_genus_symbols = [ ]
159
160
for p in prime_divisors(2 * self.det()):
161
list_of_CS_genus_symbols.append(self.local_genus_symbol(p))
162
163
self.__CS_genus_symbol_list = list_of_CS_genus_symbols
164
return list_of_CS_genus_symbols
165
166