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

Commit

Permalink
code style tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
yyyyx4 committed Jul 27, 2022
1 parent 0eb89f0 commit e1e17f3
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/sage/quadratic_forms/binary_qf.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,11 @@ def __mul__(self, right):
# ...or a 2x2 matrix...
if (isinstance(right.parent(), MatrixSpace)
and right.nrows() == right.ncols() == 2):
aa = right[0, 0]
bb = right[0, 1]
cc = right[1, 0]
dd = right[1, 1]
aa,bb,cc,dd = right.list()
A = self.polynomial()(aa, cc)
C = self.polynomial()(bb, dd)
B = self.polynomial()(aa + bb, cc + dd) - A - C
qf = BinaryQF(A, B, C)
return qf
return BinaryQF(A, B, C)
raise TypeError("right operand must be a binary quadratic form or 2x2 matrix")

def __getitem__(self, n):
Expand Down Expand Up @@ -846,17 +842,18 @@ def reduced_form(self, transformation=False, algorithm="default"):
"""
if self.is_reduced():
if transformation:
return self, Matrix(ZZ, 2, 2, [1, 0, 0, 1])
else:
return self
return self, Matrix.identity(2)
return self

if algorithm == "default":
algorithm = 'sage' if self.is_reducible() else 'pari'

if algorithm == 'sage':
if self.discriminant() <= 0:
raise NotImplementedError('reduction of definite binary '
'quadratic forms is not implemented in Sage')
return self._reduce_indef(transformation)

elif algorithm == 'pari':
# Negative definite forms are not supported by PARI. We can
# work around this by reducing [-a,b,-c] instead of [a,b,c].
Expand All @@ -866,13 +863,16 @@ def reduced_form(self, transformation=False, algorithm="default"):
if transformation:
return (-r[0]*M, M*r[1]*M)
return -r*M

if self.is_reducible():
raise NotImplementedError('reducible forms are not '
'supported using PARI')

if transformation:
y,g = self.__pari__().qfbredsl2()
return BinaryQF(y), Matrix(ZZ, g)
elif self.is_reducible():
raise NotImplementedError('reducible forms are not '
'supported using PARI')
return BinaryQF(self.__pari__().qfbred())

else:
raise ValueError('unknown implementation for binary quadratic form '
'reduction: %s' % algorithm)
Expand Down

0 comments on commit e1e17f3

Please sign in to comment.