]> www.ginac.de Git - ginac.git/blobdiff - ginac/ex.cpp
- matrix::pow(): omit last big multiplication if it's not needed.
[ginac.git] / ginac / ex.cpp
index 02d20e8894f1308e14850fced01d4cd43a8f0c68..b8a35d3a67c78b98843906ae17b14cda9627c0a5 100644 (file)
@@ -29,8 +29,8 @@
 #include "ncmul.h"
 #include "numeric.h"
 #include "power.h"
+#include "lst.h"
 #include "relational.h"
-#include "indexed.h"
 #include "input_lexer.h"
 #include "debugmsg.h"
 #include "utils.h"
@@ -136,26 +136,11 @@ ex ex::diff(const symbol & s, unsigned nth) const
                return bp->diff(s, nth);
 }
 
-/** Simplify/canonicalize expression containing indexed objects. This
- *  performs contraction of dummy indices where possible and checks whether
- *  the free indices in sums are consistent.
- *
- *  @return simplified expression */
-ex ex::simplify_indexed(void) const
-{
-       return GiNaC::simplify_indexed(*this);
-}
-
-/** Simplify/canonicalize expression containing indexed objects. This
- *  performs contraction of dummy indices where possible, checks whether
- *  the free indices in sums are consistent, and automatically replaces
- *  scalar products by known values if desired.
- *
- *  @param sp Scalar products to be replaced automatically
- *  @return simplified expression */
-ex ex::simplify_indexed(const scalar_products & sp) const
+/** Check whether expression matches a specified pattern. */
+bool ex::match(const ex & pattern) const
 {
-       return GiNaC::simplify_indexed(*this, sp);
+       lst repl_lst;
+       return bp->match(pattern, repl_lst);
 }
 
 ex ex::operator[](const ex & index) const
@@ -222,14 +207,12 @@ void ex::makewriteable()
  *  @see ex::ex(const basic &) */
 void ex::construct_from_basic(const basic & other)
 {
-       if ((other.flags & status_flags::evaluated)==0) {
-               // cf. copy ctor
-               const ex & tmpex = other.eval(1); // evaluate only one (top) level
+       if (!(other.flags & status_flags::evaluated)) {
+               const ex & tmpex(other.eval(1)); // evaluate only one (top) level
                bp = tmpex.bp;
-               GINAC_ASSERT(bp!=0);
                GINAC_ASSERT(bp->flags & status_flags::dynallocated);
                ++bp->refcount;
-               if ((other.flags & status_flags::dynallocated)&&(other.refcount==0))
+               if ((other.refcount==0) && (other.flags & status_flags::dynallocated))
                        delete &const_cast<basic &>(other);
        } else {
                if (other.flags & status_flags::dynallocated) {