Skip to content

Commit f6fee14

Browse files
Gustavo Ramatornaria
authored andcommitted
Add a hash function for the class TernaryQF.
1 parent 07a2afd commit f6fee14

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)