Skip to content

Commit f5bdda9

Browse files
author
Release Manager
committed
gh-36553: Add a hash function for the class TernaryQF. PR from #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: #36553 Reported by: Gonzalo Tornaría Reviewer(s):
2 parents 37f7f5d + f6fee14 commit f5bdda9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/sage/quadratic_forms/ternary_qf.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,20 @@ def coefficients(self):
116116
"""
117117
return self._a, self._b, self._c, self._r, self._s, self._t
118118

119+
def __hash__(self):
120+
"""
121+
Returns a hash for self.
122+
123+
EXAMPLES::
124+
125+
sage: Q = TernaryQF([1, 2, 3, 4, 5, 6])
126+
sage: Q.__hash__()
127+
5881802312257552497 # 64-bit
128+
1770036893 # 32-bit
129+
"""
130+
131+
return hash(self.coefficients())
132+
119133
def coefficient(self, n):
120134
r"""
121135
Return the `n`-th coefficient of the ternary quadratic form.

0 commit comments

Comments
 (0)