Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/sage/combinat/sf/classical.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# https://www.gnu.org/licenses/
# ****************************************************************************
from sage.rings.integer import Integer
from sage.rings.integer_ring import IntegerRing
from sage.rings.rational_field import RationalField
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.combinat.partition import _Partitions


Expand All @@ -29,9 +29,6 @@
from . import jack
from . import orthotriang

ZZ = IntegerRing()
QQ = RationalField()

translate = {'monomial':'MONOMIAL', 'homogeneous':'HOMSYM', 'powersum':'POWSYM', 'elementary':'ELMSYM', 'Schur':'SCHUR'}

conversion_functions = {}
Expand Down
3 changes: 1 addition & 2 deletions src/sage/crypto/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def gen_lattice(type='modular', n=4, m=8, q=11, seed=None,
from sage.rings.finite_rings.integer_mod_ring import IntegerModRing
from sage.matrix.constructor import identity_matrix, block_matrix
from sage.matrix.matrix_space import MatrixSpace
from sage.rings.integer_ring import IntegerRing
from sage.rings.integer_ring import ZZ
if seed is not None:
from sage.misc.randstate import set_random_seed
set_random_seed(seed)
Expand All @@ -227,7 +227,6 @@ def gen_lattice(type='modular', n=4, m=8, q=11, seed=None,
if n != 1:
raise ValueError('random bases require n = 1')

ZZ = IntegerRing()
ZZ_q = IntegerModRing(q)
A = identity_matrix(ZZ_q, n)

Expand Down
2 changes: 1 addition & 1 deletion src/sage/quadratic_forms/binary_qf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ def solve_integer(self, n, *, algorithm="general"):
w = self.discriminant().sqrt()
r = (-self._b + (w if w != self._b else -w)) / (2*self._a)
p, q = r.as_integer_ratio()
g, u, v = p.xgcd(q)
_, u, v = p.xgcd(q)
M = Matrix(ZZ, [[v, p], [-u, q]])
elif self._c:
M = Matrix(ZZ, [[0, 1], [1, 0]])
Expand Down
55 changes: 27 additions & 28 deletions src/sage/quadratic_forms/genera/genus.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
r"""
Genus


AUTHORS:

- David Kohel & Gabriele Nebe (2007): First created
Expand All @@ -20,17 +19,18 @@
# https://www.gnu.org/licenses/
# ****************************************************************************

from copy import copy, deepcopy

from sage.misc.lazy_import import lazy_import
from sage.misc.misc_c import prod
from sage.misc.cachefunc import cached_method
from sage.arith.functions import lcm as LCM
from sage.arith.misc import fundamental_discriminant
from sage.matrix.matrix_space import MatrixSpace
from sage.matrix.constructor import matrix
from sage.rings.integer_ring import IntegerRing, ZZ
from sage.rings.rational_field import RationalField, QQ
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.rings.integer import Integer
from copy import copy, deepcopy
from sage.misc.verbose import verbose
from sage.quadratic_forms.special_values import quadratic_L_function__exact
lazy_import('sage.quadratic_forms.genera.normal_form', '_min_nonsquare')
Expand Down Expand Up @@ -81,7 +81,6 @@ def genera(sig_pair, determinant, max_scale=None, even=False):
"""
from sage.misc.mrange import mrange_iter
# input checks
ZZ = IntegerRing()
determinant = ZZ(determinant)
sig_pair = (ZZ(sig_pair[0]), ZZ(sig_pair[1]))
even = bool(even)
Expand Down Expand Up @@ -440,7 +439,7 @@ def is_GlobalGenus(G):
sym = loc._symbol
v = sum([ss[0] * ss[1] for ss in sym])
a = D // (p**v)
b = Integer(prod([ss[2] for ss in sym]))
b = ZZ.prod(ss[2] for ss in sym)
if p == 2:
if not is_2_adic_genus(sym):
verbose(mesg="False in is_2_adic_genus(sym)", level=2)
Expand Down Expand Up @@ -906,10 +905,10 @@ def p_adic_symbol(A, p, val):

from sage.rings.finite_rings.finite_field_constructor import FiniteField

m0 = min([ c.valuation(p) for c in A.list() ])
m0 = min(c.valuation(p) for c in A.list())
q = p**m0
n = A.nrows()
A = MatrixSpace(IntegerRing(), n, n)([ c // q for c in A.list() ])
A = MatrixSpace(ZZ, n, n)([ c // q for c in A.list() ])
A_p = MatrixSpace(FiniteField(p), n, n)(A)
B_p = A_p.kernel().echelonized_basis_matrix()
if B_p.nrows() == 0:
Expand All @@ -922,16 +921,16 @@ def p_adic_symbol(A, p, val):
n0 = C_p.nrows()
sym = [ [0, n0, e0] ]
r = B_p.nrows()
B = MatrixSpace(IntegerRing(), r, n)(B_p)
C = MatrixSpace(IntegerRing(), n - r, n)(C_p)
B = MatrixSpace(ZZ, r, n)(B_p)
C = MatrixSpace(ZZ, n - r, n)(C_p)
# Construct the blocks for the Jordan decomposition [F,X;X,A_new]
F = MatrixSpace(RationalField(), n - r, n - r)(C * A * C.transpose())
F = MatrixSpace(QQ, n - r, n - r)(C * A * C.transpose())
U = F**-1
d = LCM([ c.denominator() for c in U.list() ])
R = IntegerRing().quotient_ring(Integer(p)**(val + 3))
R = ZZ.quotient_ring(Integer(p)**(val + 3))
u = R(d)**-1
MatR = MatrixSpace(R, n - r , n - r)
MatZ = MatrixSpace(IntegerRing(), n - r, n - r)
MatZ = MatrixSpace(ZZ, n - r, n - r)
U = MatZ(MatR(MatZ(U * d)) * u)
# X = C*A*B.transpose()
# A = B*A*B.transpose() - X.transpose()*U*X
Expand Down Expand Up @@ -1017,7 +1016,7 @@ def split_odd(A):
"""
n0 = A.nrows()
if n0 == 1:
return A[0, 0], MatrixSpace(IntegerRing(), 0, A.ncols())([])
return A[0, 0], MatrixSpace(ZZ, 0, A.ncols())([])
even, i = is_even_matrix(A)
R = A.parent().base_ring()
C = MatrixSpace(R, n0 - 1, n0)(0)
Expand Down Expand Up @@ -1098,7 +1097,7 @@ def trace_diag_mod_8(A):
while A.nrows():
u, A = split_odd(A)
tr += u
return IntegerRing()(tr)
return ZZ(tr)


def two_adic_symbol(A, val):
Expand Down Expand Up @@ -1141,7 +1140,6 @@ def two_adic_symbol(A, val):
m0 = min([ c.valuation(2) for c in A.list() ])
q = 2**m0
A = A.parent()([ c // q for c in A.list() ])
ZZ = IntegerRing()
A_2 = MatrixSpace(FiniteField(2), n, n)(A)
K_2 = A_2.kernel()
R_8 = ZZ.quotient_ring(Integer(8))
Expand All @@ -1156,7 +1154,7 @@ def two_adic_symbol(A, val):
print("A:")
print(A)
assert False
even, i = is_even_matrix(A_2) # Determine whether the matrix is even or odd.
even, _ = is_even_matrix(A_2) # Determine whether the matrix is even or odd.
if even:
return [[m0, n0, d0, 0, 0]]
else:
Expand All @@ -1178,22 +1176,22 @@ def two_adic_symbol(A, val):
print("A:")
print(A_new)
assert False
even, i = is_even_matrix(A_new)
even, _ = is_even_matrix(A_new)
if even:
sym = [[0, n0, d0, 0, 0]]
else:
tr8 = trace_diag_mod_8(A_8)
sym = [[0, n0, d0, 1, tr8]]
r = B_2.nrows()
B = MatrixSpace(ZZ,r,n)(B_2)
C = MatrixSpace(IntegerRing(), n - r, n)(C_2)
F = MatrixSpace(RationalField(), n - r, n - r)(C * A * C.transpose())
C = MatrixSpace(ZZ, n - r, n)(C_2)
F = MatrixSpace(QQ, n - r, n - r)(C * A * C.transpose())
U = F**-1
d = LCM([ c.denominator() for c in U.list() ])
R = IntegerRing().quotient_ring(Integer(2)**(val + 3))
R = ZZ.quotient_ring(Integer(2)**(val + 3))
u = R(d)**-1
MatR = MatrixSpace(R, n - r, n - r)
MatZ = MatrixSpace(IntegerRing(), n - r, n - r)
MatZ = MatrixSpace(ZZ, n - r, n - r)
U = MatZ(MatR(MatZ(U * d)) * u)
X = C * A
A = B * (A - X.transpose()*U*X) * B.transpose()
Expand Down Expand Up @@ -2757,10 +2755,11 @@ def signature(self):

def determinant(self):
r"""
Return the determinant of this genus, where the determinant
is the Hessian determinant of the quadratic form whose Gram
matrix is the Gram matrix giving rise to this global genus
symbol.
Return the determinant of this genus.

The determinant is the Hessian determinant of the quadratic
form whose Gram matrix is the Gram matrix giving rise to this
global genus symbol.

OUTPUT: an integer

Expand All @@ -2771,8 +2770,8 @@ def determinant(self):
sage: GS.determinant()
-24
"""
p, n = self.signature_pair()
return (-1)**n*prod([ G.determinant() for G in self._local_symbols ])
_, n = self.signature_pair()
return (-1)**n * ZZ.prod(G.determinant() for G in self._local_symbols)

det = determinant

Expand Down
2 changes: 1 addition & 1 deletion src/sage/quadratic_forms/genera/normal_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ def _relations(G, n):
e1 = G[0, 0].unit_part()
e2 = G[1, 1].unit_part()
B = Matrix(R, 2, 2, [1, 1, -4 * e2, e1])
D, B1 = _normalize(B * G * B.T)
_, B1 = _normalize(B * G * B.T)
return B1 * B


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,8 @@ def signature(self):
[ * * * 9 ]
sage: Q.signature()
2

"""
(p, n, z) = self.signature_vector()
p, n, _ = self.signature_vector()
return p - n


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def representation_vector_list(self, B, maxvectors=10**8):
...
PariError: domain error in minim0: form is not positive definite
"""
n, m, vs = self.__pari__().qfminim(2 * (B - 1), maxvectors)
n, _, vs = self.__pari__().qfminim(2 * (B - 1), maxvectors)

if n != 2 * len(vs):
raise RuntimeError("insufficient number of vectors")
Expand Down