]> www.ginac.de Git - ginac.git/blobdiff - ginac/function.pl
- subs() can be used to substitute functions, tensors and indexed objects
[ginac.git] / ginac / function.pl
index b36df872337b225da8534ed867741009e6d92347..f6e7b33276ea306d6bd6c7df7d2a46d26962c539 100755 (executable)
@@ -345,6 +345,7 @@ public:
        ex evalf(int level=0) const;
        unsigned calchash(void) const;
        ex series(const relational & r, int order, unsigned options = 0) const;
+       ex subs(const lst & ls, const lst & lr) const;
        ex thisexprseq(const exvector & v) const;
        ex thisexprseq(exvector * vp) const;
 protected:
@@ -821,6 +822,19 @@ ${series_switch_statement}
        throw(std::logic_error("function::series(): invalid nparams"));
 }
 
+ex function::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), function) &&
+                   compare_same_type(ex_to_function(ls.op(i)))==0)
+                       return lr.op(i);
+       }
+
+       return inherited::subs(ls, lr);
+}
+
 // protected