]> www.ginac.de Git - ginac.git/blobdiff - ginac/indexed.cpp
- subs() can be used to substitute functions, tensors and indexed objects
[ginac.git] / ginac / indexed.cpp
index 833d46c94111db070e6acf0ee34c6e8120e5f9e1..c530c1f4479e4d1e012208c77c40cf6b143a29c0 100644 (file)
@@ -28,6 +28,7 @@
 #include "mul.h"
 #include "ncmul.h"
 #include "power.h"
+#include "lst.h"
 #include "archive.h"
 #include "utils.h"
 #include "debugmsg.h"
@@ -368,6 +369,19 @@ ex indexed::coeff(const ex & s, int n) const
                return n==0 ? ex(*this) : _ex0();
 }
 
+ex indexed::subs(const lst & ls, const lst & lr) const
+{
+       GINAC_ASSERT(ls.nops() == lr.nops());
+
+       for (unsigned i=0; i<ls.nops(); i++) {
+               if (is_ex_of_type(ls.op(i), indexed) &&
+                   compare_same_type(ex_to_indexed(ls.op(i)))==0)
+                       return lr.op(i);
+       }
+
+       return inherited::subs(ls, lr);
+}
+
 ex indexed::thisexprseq(const exvector & v) const
 {
        return indexed(symmetry, v);