From 771ec9a18c5b7458012f285b897b0992112b17e6 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Wed, 10 Apr 2002 18:57:06 +0000 Subject: [PATCH] * numeric::calchash(): Apply golden_ratio_hash() to the value returned by CLN. (Rationale: this populates more bits for the frequent small integers resulting in much less opportunity for funny cancellations in hash-values of monomials.) --- ginac/numeric.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp index 1643eebd..1d9c78ba 100644 --- a/ginac/numeric.cpp +++ b/ginac/numeric.cpp @@ -579,11 +579,13 @@ bool numeric::is_equal_same_type(const basic &other) const unsigned numeric::calchash(void) const { - // Use CLN's hashcode. Warning: It depends only on the number's value, not - // its type or precision (i.e. a true equivalence relation on numbers). As - // a consequence, 3 and 3.0 share the same hashvalue. + // Base computation of hashvalue on CLN's hashcode. Note: That depends + // only on the number's value, not its type or precision (i.e. a true + // equivalence relation on numbers). As a consequence, 3 and 3.0 share + // the same hashvalue. That shouldn't really matter, though. setflag(status_flags::hash_calculated); - return (hashvalue = cln::equal_hashcode(cln::the(value)) | 0x80000000U); + hashvalue = golden_ratio_hash(cln::equal_hashcode(cln::the(value))) | 0x80000000U; + return hashvalue; } -- 2.49.0