]> www.ginac.de Git - ginac.git/blobdiff - ginac/ex.h
- removed debugging code in match()
[ginac.git] / ginac / ex.h
index 8ade899b06136f1479a982834547fae35503a3ba..34ce8b8c489634528271e1612585d734f12036c5 100644 (file)
@@ -52,7 +52,7 @@ public:
        ex();
        ~ex();
        ex(const ex & other);
-       const ex & operator=(const ex & other);
+       ex & operator=(const ex & other);
        // other ctors
 public:
        ex(const basic & other);
@@ -105,8 +105,10 @@ public:
        ex evalf(int level = 0) const { return bp->evalf(level); }
        ex diff(const symbol & s, unsigned nth = 1) const;
        ex series(const ex & r, int order, unsigned options = 0) const;
-       ex subs(const lst & ls, const lst & lr) const { return bp->subs(ls, lr); }
-       ex subs(const ex & e) const { return bp->subs(e); }
+       bool match(const ex & pattern) const;
+       bool match(const ex & pattern, lst & repl_lst) const { return bp->match(pattern, repl_lst); }
+       ex subs(const lst & ls, const lst & lr, bool no_pattern = false) const { return bp->subs(ls, lr, no_pattern); }
+       ex subs(const ex & e, bool no_pattern = false) const { return bp->subs(e, no_pattern); }
        exvector get_free_indices(void) const { return bp->get_free_indices(); }
        ex simplify_indexed(void) const;
        ex simplify_indexed(const scalar_products & sp) const;
@@ -124,9 +126,6 @@ public:
        unsigned return_type(void) const { return bp->return_type(); }
        unsigned return_type_tinfo(void) const { return bp->return_type_tinfo(); }
        unsigned gethash(void) const { return bp->gethash(); }
-       
-       ex exadd(const ex & rh) const;
-       ex exmul(const ex & rh) const;
 private:
        void construct_from_basic(const basic & other);
        void construct_from_int(int i);
@@ -212,16 +211,17 @@ ex::ex(const ex & other) : bp(other.bp)
 }
 
 inline
-const ex & ex::operator=(const ex & other)
+ex & ex::operator=(const ex & other)
 {
        /*debugmsg("ex operator=",LOGLEVEL_ASSIGNMENT);*/
        GINAC_ASSERT(bp!=0);
        GINAC_ASSERT(bp->flags & status_flags::dynallocated);
        GINAC_ASSERT(other.bp!=0);
        GINAC_ASSERT(other.bp->flags & status_flags::dynallocated);
+       // NB: must first increment other.bp->refcount, since other might be *this.
+       ++other.bp->refcount;
        if (--bp->refcount==0)
                delete bp;
-       ++other.bp->refcount;
        bp = other.bp;
 #ifdef OBSCURE_CINT_HACK
        update_last_created_or_assigned_bp();
@@ -372,6 +372,9 @@ inline ex diff(const ex & thisex, const symbol & s, unsigned nth = 1)
 inline ex series(const ex & thisex, const ex & r, int order, unsigned options = 0)
 { return thisex.series(r, order, options); }
 
+inline bool match(const ex & thisex, const ex & pattern, lst & repl_lst)
+{ return thisex.match(pattern, repl_lst); }
+
 inline ex subs(const ex & thisex, const ex & e)
 { return thisex.subs(e); }