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

Commit 5b720f4

Browse files
committedDec 17, 2016
21745: fix quadratic_forms
1 parent 2d78c1d commit 5b720f4

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed
 

‎src/sage/quadratic_forms/quadratic_form__local_representation_conditions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ def is_locally_represented_at_place(self, m, p):
607607
for s in sqclass:
608608
#print "m =", m, " s =", s, " m/s =", (QQ(m)/s)
609609
if (QQ(m)/s).is_padic_square(p):
610-
nu = valuation(m//s, p)
610+
nu = valuation(m/s, p)
611611
return local_vec[sqclass.index(s) + 1] <= (nu / 2)
612612

613613

‎src/sage/quadratic_forms/quadratic_form__neighbors.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def find_p_neighbor_from_vec(self, p, v):
214214
## Lift the vector v to a vector v1 s.t. Q(v1) = 0 (mod p^2)
215215
s = self(v)
216216
if (s % p**2 != 0):
217-
al = (-s / (p * vw_prod)) % p
217+
al = (((-s // p) % p) * vw_prod.inverse_mod(p)) % p
218218
v1 = v + p * al * w
219219
v1w_prod = (v1 * self.matrix()).dot_product(w)
220220
else:
@@ -232,7 +232,7 @@ def find_p_neighbor_from_vec(self, p, v):
232232
good_basis = extend_to_primitive([v1, w])
233233
for i in range(2,n):
234234
ith_prod = (good_basis[i] * self.matrix()).dot_product(v)
235-
c = (ith_prod / v1w_prod) % p
235+
c = ((ith_prod % p) * v1w_prod.inverse_mod(p)) % p
236236
good_basis[i] = good_basis[i] - c * w ## Ensures that this extension has <v_i, v> = 0 (mod p)
237237

238238
## DIAGNOSTIC

‎src/sage/quadratic_forms/ternary.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1008,8 +1008,8 @@ def _find_p_neighbor_from_vec(a, b, c, r, s, t, p, v, mat = False):
10081008

10091009
if m02%p!=0:
10101010

1011-
m0 = (-m00/m02/2) % p**2
1012-
m1 = (-m01/m02) % p
1011+
m0 = (((-m00//2) % p**2) * m02.inverse_mod(p**2)) % p**2
1012+
m1 = ((-m01 % p) * (m02.inverse_mod(p))) % p
10131013

10141014
b00 = m0**2*m22/p**2 + 2*m0*m02/p**2 + m00/p**2
10151015
b11 = m1**2*m22 + 2*m1*m12 + m11
@@ -1036,8 +1036,8 @@ def _find_p_neighbor_from_vec(a, b, c, r, s, t, p, v, mat = False):
10361036

10371037
if m01%p!=0:
10381038

1039-
m0 = (-m00/m01/2) % p**2
1040-
m1 = (-m02/m01) % p
1039+
m0 = (((-m00//2) % p**2) * m01.inverse_mod(p**2)) % p**2
1040+
m1 = ((-m02 % p) * m01.inverse_mod(p)) % p
10411041

10421042
b00 = m0**2*m11/p**2 + 2*m0*m01/p**2 + m00/p**2
10431043
b11 = m1**2*m11 + 2*m1*m12 + m22

‎src/sage/quadratic_forms/ternary_qf.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ def __call__(self, v):
224224
## Check if v has 3 cols
225225
if v.ncols() == 3:
226226
M = v.transpose() * self.matrix() * v
227-
return TernaryQF([M[0,0]//2, M[1,1]//2, M[2,2]//2, M[1,2], M[0,2], M[0,1]])
227+
# NOTE: as soon as the deprecation from #21745 is over we can move the code below to a floordiv
228+
return TernaryQF([(M[0,0]/2).floor(), (M[1,1]/2).floor(), (M[2,2]/2).floor(), M[1,2], M[0,2], M[0,1]])
228229
else:
229230
return QuadraticForm(ZZ, v.transpose() * self.matrix() * v)
230231
elif (is_Vector(v) or isinstance(v, (list, tuple))):

0 commit comments

Comments
 (0)
This repository has been archived.