]> www.ginac.de Git - ginac.git/commitdiff
synced to 1.2
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Mon, 21 Jul 2003 19:46:33 +0000 (19:46 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Mon, 21 Jul 2003 19:46:33 +0000 (19:46 +0000)
ginac/idx.cpp
ginac/idx.h

index 35952871213136d76f20adfd033cdea757031ff4..16e0f0b1fa691e7dce53057130129d496160be00 100644 (file)
@@ -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
index e9587e426fc3ce38b1f386e2fd7980c4e6b69bd0..01638fb47d15683d74def5cc50a8c1c48d4126c6 100644 (file)
@@ -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: