#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"
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
* @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) {