From 79e49016f3a732fe1758bc3efd10f0727862017c Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Thu, 11 Dec 2003 18:57:50 +0000 Subject: [PATCH] hash keys of indices must not depend on the index dimension; doing so breaks the ordering of dummy indices that simplify_index() depends on --- ginac/idx.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ginac/idx.cpp b/ginac/idx.cpp index 67603cf2..5739f80e 100644 --- a/ginac/idx.cpp +++ b/ginac/idx.cpp @@ -325,11 +325,17 @@ bool spinidx::match_same_type(const basic & other) const unsigned idx::calchash() const { + // NOTE: The code in simplify_indexed() assumes that canonically + // ordered sequences of indices have the two members of dummy index + // pairs lying next to each other. The hash values for indices must + // be devised accordingly. The easiest (only?) way to guarantee the + // desired ordering is to make indices with the same value have equal + // hash keys. That is, the hash values must not depend on the index + // dimensions or other attributes (variance etc.). + // The compare_same_type() methods will take care of the rest. unsigned v = golden_ratio_hash(tinfo()); v = rotate_left(v); v ^= value.gethash(); - v = rotate_left(v); - v ^= dim.gethash(); // Store calculated hash value only if object is already evaluated if (flags & status_flags::evaluated) { -- 2.44.0