]> www.ginac.de Git - ginac.git/commitdiff
hash keys of indices must not depend on the index dimension; doing so breaks
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Thu, 11 Dec 2003 18:57:50 +0000 (18:57 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Thu, 11 Dec 2003 18:57:50 +0000 (18:57 +0000)
the ordering of dummy indices that simplify_index() depends on

ginac/idx.cpp

index 67603cf271fb7efca16b0e76d8f1420fe53af2b2..5739f80e492faa28999a78cae4fc85efed393065 100644 (file)
@@ -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) {