Skip to content

Commit 81e5bba

Browse files
committed
some suggested fixes
1 parent 61d781a commit 81e5bba

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/sage/quadratic_forms/ternary_qf.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ def disc(self):
308308
sage: Q.matrix().det()
309309
-50
310310
"""
311-
return 4*self._a*self._b*self._c + self._r*self._s*self._t - self._a*self._r**2 - self._b*self._s**2 - self._c*self._t**2
311+
return (4*self._a*self._b*self._c + self._r*self._s*self._t
312+
- self._a*self._r**2 - self._b*self._s**2 - self._c*self._t**2)
312313

313314
def is_definite(self) -> bool:
314315
"""
@@ -329,18 +330,12 @@ def is_definite(self) -> bool:
329330
if d1 == 0:
330331
return False
331332
d2 = 4 * self._a * self._b - self._t**2
332-
if d2 == 0:
333+
if d2 <= 0:
333334
return False
334335
d3 = self.disc()
335336
if d3 == 0:
336337
return False
337-
if d1 > 0:
338-
if d2 > 0:
339-
return d3 > 0
340-
return False
341-
if d2 > 0:
342-
return d3 < 0
343-
return False
338+
return (d1 > 0) == (d3 > 0)
344339

345340
def is_positive_definite(self) -> bool:
346341
"""
@@ -366,12 +361,12 @@ def is_positive_definite(self) -> bool:
366361
if d1 == 0:
367362
return False
368363
d2 = 4 * self._a * self._b - self._t**2
369-
if d2 == 0:
364+
if d2 <= 0:
370365
return False
371366
d3 = self.disc()
372367
if d3 == 0:
373368
return False
374-
return d1 > 0 and d2 > 0 and d3 > 0
369+
return d1 > 0 and d3 > 0
375370

376371
def is_negative_definite(self) -> bool:
377372
"""
@@ -1091,11 +1086,13 @@ def automorphism_spin_norm(self, A):
10911086
s = self(b1) * self(b2)
10921087
return s.squarefree_part()
10931088

1094-
def _border(self, n):
1089+
def _border(self, n) -> bool:
10951090
"""
10961091
Auxiliary function to find the automorphisms of a positive definite ternary quadratic form.
10971092
1098-
It returns a boolean whether the n-condition is true. If Q = TernaryQF([a,b,c,r,s,t]), the conditions are:
1093+
It returns a boolean whether the n-condition is true.
1094+
1095+
If Q = TernaryQF([a,b,c,r,s,t]), the conditions are:
10991096
11001097
1. a = t, s = 2r.
11011098
2. a = s, t = 2r.

0 commit comments

Comments
 (0)