From bcd4b9f3e77e468f9540d61b6de98ac671359542 Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Mon, 21 Jul 2003 19:46:33 +0000 Subject: [PATCH] synced to 1.2 --- ginac/idx.cpp | 17 +++++++++++++++++ ginac/idx.h | 1 + 2 files changed, 18 insertions(+) diff --git a/ginac/idx.cpp b/ginac/idx.cpp index 35952871..16e0f0b1 100644 --- a/ginac/idx.cpp +++ b/ginac/idx.cpp @@ -364,6 +364,23 @@ bool spinidx::match_same_type(const basic & other) const return inherited::match_same_type(other); } +unsigned idx::calchash() const +{ + 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) { + setflag(status_flags::hash_calculated); + hashvalue = v; + } + + return v; +} + /** By default, basic::evalf would evaluate the index value but we don't want * a.1 to become a.(1.0). */ ex idx::evalf(int level) const diff --git a/ginac/idx.h b/ginac/idx.h index e9587e42..01638fb4 100644 --- a/ginac/idx.h +++ b/ginac/idx.h @@ -59,6 +59,7 @@ public: protected: ex derivative(const symbol & s) const; bool match_same_type(const basic & other) const; + unsigned calchash() const; // new virtual functions in this class public: -- 2.49.0