Fixed bug in substituion of clifford objects.
authorChris Dams <Chris.Dams@mi.infn.it>
Wed, 4 Jan 2006 18:33:30 +0000 (18:33 +0000)
committerChris Dams <Chris.Dams@mi.infn.it>
Wed, 4 Jan 2006 18:33:30 +0000 (18:33 +0000)
ginac/clifford.cpp
ginac/clifford.h

index 67aa2c97343fe4d643fd36e4b86edd4284036c33..d25047ac27444db2904aab46543ddeebfa929265 100644 (file)
@@ -206,6 +206,21 @@ ex & clifford::let_op(size_t i)
                return inherited::let_op(i);
 }
 
+ex clifford::subs(const exmap & m, unsigned options) const
+{
+       ex subsed = inherited::subs(m, options);
+       if(is_a<clifford>(subsed)) {
+               ex prevmetric = ex_to<clifford>(subsed).metric;
+               ex newmetric = prevmetric.subs(m, options);
+               if(!are_ex_trivially_equal(prevmetric, newmetric)) {
+                       clifford c = ex_to<clifford>(subsed);
+                       c.metric = newmetric;
+                       subsed = c;
+               }
+       }
+       return subsed;
+}
+
 int clifford::compare_same_type(const basic & other) const
 {
        GINAC_ASSERT(is_a<clifford>(other));
index 18ef03c2209fd073778c90b9e9d1644a392e7820..4fb5fad57c9aec73e34428b6efc306ed299182a0 100644 (file)
@@ -74,16 +74,11 @@ public:
        inline size_t nops() const {return inherited::nops() + 1; }
        ex op(size_t i) const;
        ex & let_op(size_t i);
-       ex subs(const exmap & m, unsigned options = 0) const { clifford c = ex_to<clifford>(inherited::subs(m, options)); c.metric_subs(m, options); return c;}
-       ex subs(const lst & ls, const lst & lr, unsigned options = 0) const { clifford c = ex_to<clifford>(ex(*this).subs(ls, lr, options)); c.metric_subs(ls, lr, options); return c;}
-       ex subs(const ex & e, unsigned options = 0) const{ clifford c = ex_to<clifford>(ex(*this).subs(e, options)); c.metric_subs(e, options); return c;};
+       ex subs(const exmap & m, unsigned options = 0) const;
 
 protected:
        void do_print_dflt(const print_dflt & c, unsigned level) const;
        void do_print_latex(const print_latex & c, unsigned level) const;
-       void metric_subs(const exmap & m, unsigned options = 0) { metric = metric.subs(m, options); }
-       void metric_subs(const lst & ls, const lst & lr, unsigned options = 0) { metric = metric.subs(ls, lr, options); }
-       void metric_subs(const ex & e, unsigned options = 0) { metric = metric.subs(e, options); }
 
        // member variables
 protected: