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

Commit

Permalink
discriminants that are a square
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveWitteMorris committed Jan 16, 2020
1 parent 6ac626a commit 2c2bc7a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/doc/en/reference/references/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ REFERENCES:
MOG. *Computational group theory*, ed. M. Atkinson,
Academic Press, 1984.
.. [Co1999] John Conway, Neil Sloan. *Sphere Packings, Lattices and Groups*,
.. [Co1999] \J. H. Conway, N. J. A. Sloane. *Sphere Packings, Lattices and Groups*,
Springer Verlag 1999.
.. [CO2010] Jonathan Comes, Viktor Ostrik.
Expand Down
48 changes: 43 additions & 5 deletions src/sage/quadratic_forms/binary_qf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,15 @@ def is_equivalent(self, other, proper=True):
sage: Q1.is_equivalent(Q2, proper=True)
True
# :trac:`29028`
sage: Q = BinaryQF(0, 2, 0)
sage: Q.discriminant()
4
sage: Q.is_equivalent(Q, proper=True)
True
sage: Q.is_equivalent(Q, proper=False)
True
A test for rational forms::
sage: Q1 = BinaryQF(0, 4, 2)
Expand Down Expand Up @@ -1218,12 +1227,15 @@ def is_equivalent(self, other, proper=True):
b = selfred._b
a = selfred._a
ao = otherred._a
# Conway Sloane p. 359
assert otherred._b == b
# p. 359 of Conway-Sloane [Co1999]_
# but `2b` in their notation is `b` in our notation
is_properly_equiv = ((a-ao) % b == 0)
if proper:
return (a-ao) % (2*b) == 0
return is_properly_equiv
else:
g = gcd(a,b)
return (a*ao - g**2) % (2*b*g) == 0
return is_properly_equiv or ((gcd(ao,b) == g) and ((a*ao - g**2) % (b*g) == 0))

proper_cycle = otherred.cycle(proper=True)

Expand Down Expand Up @@ -1569,6 +1581,32 @@ def BinaryQF_reduced_representatives(D, primitive_only=False, proper=True):
x^2 + 12*x*y - y^2,
4*x^2 + 6*x*y - 7*y^2,
6*x^2 + 2*x*y - 6*y^2]
# :trac:`29028`
sage: BinaryQF_reduced_representatives(10^2, proper=False, primitive_only=False)
[-4*x^2 + 10*x*y,
-3*x^2 + 10*x*y,
-2*x^2 + 10*x*y,
-x^2 + 10*x*y,
10*x*y,
x^2 + 10*x*y,
2*x^2 + 10*x*y,
5*x^2 + 10*x*y]
sage: BinaryQF_reduced_representatives(10^2, proper=False, primitive_only=True)
[-3*x^2 + 10*x*y, -x^2 + 10*x*y, x^2 + 10*x*y]
sage: BinaryQF_reduced_representatives(10^2, proper=True, primitive_only=True)
[-3*x^2 + 10*x*y, -x^2 + 10*x*y, x^2 + 10*x*y, 3*x^2 + 10*x*y]
sage: BinaryQF_reduced_representatives(10^2, proper=True, primitive_only=False)
[-4*x^2 + 10*x*y,
-3*x^2 + 10*x*y,
-2*x^2 + 10*x*y,
-x^2 + 10*x*y,
10*x*y,
x^2 + 10*x*y,
2*x^2 + 10*x*y,
3*x^2 + 10*x*y,
4*x^2 + 10*x*y,
5*x^2 + 10*x*y]
"""
D = ZZ(D)

Expand All @@ -1589,8 +1627,8 @@ def BinaryQF_reduced_representatives(D, primitive_only=False, proper=True):
c = ZZ(0)
# -b/2 < a <= b/2
for a in xsrange((-b/2).floor() + 1, (b/2).floor() + 1):
Q = BinaryQF(a, b, c)
form_list.append(Q)
if (not primitive_only) or (gcd([a,b,c]) == 1):
form_list.append(BinaryQF(a, b, c))
# We follow the description of Buchmann/Vollmer 6.7.1. They
# enumerate all reduced forms. We only want representatives.
else:
Expand Down

0 comments on commit 2c2bc7a

Please sign in to comment.