From 65be01649217ecb037fa2c77e2502481b573fc34 Mon Sep 17 00:00:00 2001 From: Gustavo Rama Date: Thu, 11 Sep 2014 08:37:17 -0300 Subject: [PATCH] Add a hash function for the class TernaryQF. --- src/sage/quadratic_forms/ternary_qf.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/sage/quadratic_forms/ternary_qf.py b/src/sage/quadratic_forms/ternary_qf.py index 6a08d00f26c..da5da5f3e5b 100644 --- a/src/sage/quadratic_forms/ternary_qf.py +++ b/src/sage/quadratic_forms/ternary_qf.py @@ -116,6 +116,19 @@ 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 + """ + + return hash(self.coefficients()) + def coefficient(self, n): r""" Return the `n`-th coefficient of the ternary quadratic form.