Skip to content

Commit

Permalink
sagemathgh-36553: Add a hash function for the class TernaryQF.
Browse files Browse the repository at this point in the history
    
PR from sagemath#16956 (rebased from https://github.com/sagemath/sagetrac-
mirror/commit/091cbbdf6eed2c8bccca407addd07ff08e429c17)

Author: Gustavo Rama

### 📝 Checklist

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation accordingly.
    
URL: sagemath#36553
Reported by: Gonzalo Tornaría
Reviewer(s):
Release Manager committed Oct 29, 2023
2 parents 37f7f5d + f6fee14 commit f5bdda9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/sage/quadratic_forms/ternary_qf.py
Original file line number Diff line number Diff line change
@@ -116,6 +116,20 @@ def coefficients(self):
"""
return self._a, self._b, self._c, self._r, self._s, self._t

def __hash__(self):
"""
Returns a hash for self.
EXAMPLES::
sage: Q = TernaryQF([1, 2, 3, 4, 5, 6])
sage: Q.__hash__()
5881802312257552497 # 64-bit
1770036893 # 32-bit
"""

return hash(self.coefficients())

def coefficient(self, n):
r"""
Return the `n`-th coefficient of the ternary quadratic form.

0 comments on commit f5bdda9

Please sign in to comment.