Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Construct a genus from a symbol list
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Brandhorst committed Jul 18, 2018
1 parent de444a0 commit bba1834
Showing 1 changed file with 59 additions and 40 deletions.
99 changes: 59 additions & 40 deletions src/sage/quadratic_forms/genera/genus.py
Expand Up @@ -21,13 +21,16 @@
from sage.misc.misc import verbose
import copy

def Genus(A):
def Genus(A, max_elem_divisors=None):
r"""
Given a nonsingular symmetric matrix `A`, return the genus of `A`.
INPUT:
- ``A`` -- a symmetric matrix with coefficients in `\ZZ`
- ``A`` -- a symmetric matrix with integer coefficients
- ``max_elem_divisors`` -- the input precision for the valuation of a
maximal p-elementary divisor. (OPTIONAL)
OUTPUT:
Expand All @@ -44,8 +47,18 @@ def Genus(A):
[1 2]
Genus symbol at 2: [1^2]_2
"""
return GenusSymbol_global_ring(A)

D = A.determinant()
D = 2*D
prms = [p[0] for p in D.factor()]
signature_pair = signature_pair_of_matrix(A)
local_symbols = []
for p in prms:
if max_elem_divisors is None:
val = D.valuation(p)
symbol = p_adic_symbol(A, p, val = val)
G = Genus_Symbol_p_adic_ring(p, symbol)
local_symbols.append(G)
return GenusSymbol_global_ring(signature_pair, local_symbols, representative=A)

def LocalGenusSymbol(A, p):
"""
Expand Down Expand Up @@ -98,7 +111,6 @@ def is_GlobalGenus(G):
EXAMPLES::
sage: from sage.quadratic_forms.genera.genus import GenusSymbol_global_ring
sage: from sage.quadratic_forms.genera.genus import Genus, is_GlobalGenus
sage: A = Matrix(ZZ, 2, 2, [1,1,1,2])
Expand Down Expand Up @@ -1585,12 +1597,17 @@ class GenusSymbol_global_ring(object):
INPUT:
- ``A`` -- a symmetric matrix with integer coefficients
- ``max_elem_divisors`` -- the input precision for the valuation of a
maximal p-elementary divisor. (OPTIONAL)
- ``signature_pair`` -- a tuple of two non-negative integers
- ``local_symbols`` -- a list of :class:`Genus_Symbol_p_adic_ring`` instances
- ``representative`` -- (default: ``None``) integer symmetric matrix
the gram matrix of a representative of this genus
- ``check`` -- (default: ``True``) a boolean; checks the input
"""

def __init__(self, A, max_elem_divisors=None):
def __init__(self, signature_pair, local_symbols, representative=None, check=True):
"""
Initialize a global genus symbol from a non-degenerate
integral gram matrix (and possibly information about its
Expand All @@ -1599,10 +1616,11 @@ def __init__(self, A, max_elem_divisors=None):
EXAMPLES::
sage: from sage.quadratic_forms.genera.genus import GenusSymbol_global_ring
sage: from sage.quadratic_forms.genera.genus import GenusSymbol_global_ring, LocalGenusSymbol
sage: A = DiagonalQuadraticForm(ZZ, [1,2,3,4]).Hessian_matrix()
sage: G = GenusSymbol_global_ring(A);G
sage: A = matrix.diagonal(ZZ, [2,4,6,8])
sage: local_symbols = [LocalGenusSymbol(A, p) for p in (2*A.det()).prime_divisors()]
sage: G = GenusSymbol_global_ring((4,0),local_symbols, representative=A);G
Genus of
[2 0 0 0]
[0 4 0 0]
Expand All @@ -1614,18 +1632,19 @@ def __init__(self, A, max_elem_divisors=None):
True
"""
D = A.determinant()
D = 2*D
prms = [ p[0] for p in D.factor() ]
self._representative = A
self._signature = signature_pair_of_matrix(A)
self._local_symbols = []
for p in prms:
if max_elem_divisors is None:
val = D.valuation(p)
symbol = p_adic_symbol(A, p, val = val)
G = Genus_Symbol_p_adic_ring(p, symbol)
self._local_symbols.append(G)
if check:
if not all([type(sym)==Genus_Symbol_p_adic_ring for sym in local_symbols]):
raise TypeError("local symbols must be a list of local genus symbols")
n = signature_pair[0] + signature_pair[1]
if not all([sym.dimension()==n for sym in local_symbols]):
raise TypeError("all local symbols must be of the same dimension")
if representative is not None:
representative.is_symmetric()

self._representative = representative
self._signature = signature_pair
self._local_symbols = local_symbols



def __repr__(self):
Expand All @@ -1638,9 +1657,9 @@ def __repr__(self):
EXAMPLES::
sage: from sage.quadratic_forms.genera.genus import GenusSymbol_global_ring
sage: from sage.quadratic_forms.genera.genus import Genus
sage: A = DiagonalQuadraticForm(ZZ, [1,2,3,4]).Hessian_matrix()
sage: GS = GenusSymbol_global_ring(A)
sage: GS = Genus(A)
sage: GS
Genus of
[2 0 0 0]
Expand All @@ -1651,7 +1670,7 @@ def __repr__(self):
Genus symbol at 3: 1^3 3^-1
sage: A2 = Matrix(ZZ,2,2,[2,-1,-1,2])
sage: GenusSymbol_global_ring(A2)
sage: Genus(A2)
Genus of
[ 2 -1]
[-1 2]
Expand Down Expand Up @@ -1696,12 +1715,12 @@ def __eq__(self, other):
EXAMPLES::
sage: from sage.quadratic_forms.genera.genus import GenusSymbol_global_ring
sage: from sage.quadratic_forms.genera.genus import Genus
sage: A1 = DiagonalQuadraticForm(ZZ, [1,2,3,4]).Hessian_matrix()
sage: GS1 = GenusSymbol_global_ring(A1)
sage: GS1 = Genus(A1)
sage: A2 = DiagonalQuadraticForm(ZZ, [1,2,3,5]).Hessian_matrix()
sage: GS2 = GenusSymbol_global_ring(A2)
sage: GS2 = Genus(A2)
sage: GS1 == GS2
False
Expand Down Expand Up @@ -1752,12 +1771,12 @@ def __ne__(self, other):
EXAMPLES::
sage: from sage.quadratic_forms.genera.genus import GenusSymbol_global_ring
sage: from sage.quadratic_forms.genera.genus import Genus
sage: A1 = DiagonalQuadraticForm(ZZ, [1,2,3,4]).Hessian_matrix()
sage: GS1 = GenusSymbol_global_ring(A1)
sage: GS1 = Genus(A1)
sage: A2 = DiagonalQuadraticForm(ZZ, [1,2,3,5]).Hessian_matrix()
sage: GS2 = GenusSymbol_global_ring(A2)
sage: GS2 = Genus(A2)
sage: GS1 != GS2
True
Expand Down Expand Up @@ -1799,10 +1818,10 @@ def signature_pair_of_matrix(self):
EXAMPLES::
sage: from sage.quadratic_forms.genera.genus import GenusSymbol_global_ring
sage: from sage.quadratic_forms.genera.genus import Genus
sage: A = DiagonalQuadraticForm(ZZ, [1,-2,3,4,8,-11]).Hessian_matrix()
sage: GS = GenusSymbol_global_ring(A)
sage: GS = Genus(A)
sage: GS.signature_pair_of_matrix()
(4, 2)
Expand All @@ -1822,9 +1841,9 @@ def determinant(self):
EXAMPLES::
sage: from sage.quadratic_forms.genera.genus import GenusSymbol_global_ring
sage: from sage.quadratic_forms.genera.genus import Genus
sage: A = DiagonalQuadraticForm(ZZ, [1,-2,3,4]).Hessian_matrix()
sage: GS = GenusSymbol_global_ring(A)
sage: GS = Genus(A)
sage: GS.determinant()
-384
Expand All @@ -1847,9 +1866,9 @@ def discriminant_form(self):
EXAMPLES::
sage: from sage.quadratic_forms.genera.genus import GenusSymbol_global_ring
sage: from sage.quadratic_forms.genera.genus import Genus
sage: A = matrix.diagonal(ZZ, [2,-4,6,8])
sage: GS = GenusSymbol_global_ring(A)
sage: GS = Genus(A)
sage: GS.discriminant_form()
Finite quadratic module over Integer Ring with invariants (2, 2, 4, 24)
Gram matrix of the quadratic form with values in Q/2Z:
Expand All @@ -1858,7 +1877,7 @@ def discriminant_form(self):
[ 0 0 7/4 0]
[ 0 0 0 7/24]
sage: A = matrix.diagonal(ZZ, [1,-4,6,8])
sage: GS = GenusSymbol_global_ring(A)
sage: GS = Genus(A)
sage: GS.discriminant_form()
Finite quadratic module over Integer Ring with invariants (2, 4, 24)
Gram matrix of the quadratic form with values in Q/Z:
Expand Down

0 comments on commit bba1834

Please sign in to comment.