X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=blobdiff_plain;ds=sidebyside;f=ginac%2Fex.h;h=2447c3f268061bd77ab59f58f5f01c21777c5be0;hb=f78b1f296310b5f1c01b74c9fb10dd33af2a8f4a;hp=1d9fa8794c9b70012d66765755ff1d946478359a;hpb=e8c9b4a51a1c8f1230b023b0af6a708881ef23d3;p=ginac.git diff --git a/ginac/ex.h b/ginac/ex.h index 1d9fa879..2447c3f2 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -170,8 +170,10 @@ public: // rational functions ex normal(int level = 0) const; - ex to_rational(lst &repl_lst) const; - ex to_polynomial(lst &repl_lst) const; + ex to_rational(exmap & repl) const; + ex to_rational(lst & repl_lst) const; + ex to_polynomial(exmap & repl) const; + ex to_polynomial(lst & repl_lst) const; ex numer() const; ex denom() const; ex numer_denom() const; @@ -187,8 +189,8 @@ public: // indexed objects exvector get_free_indices() const { return bp->get_free_indices(); } - ex simplify_indexed() const; - ex simplify_indexed(const scalar_products & sp) const; + ex simplify_indexed(unsigned options = 0) const; + ex simplify_indexed(const scalar_products & sp, unsigned options = 0) const; // comparison int compare(const ex & other) const; @@ -528,8 +530,8 @@ class const_preorder_iterator : public std::iterator operator->() const @@ -562,7 +563,7 @@ public: bool operator==(const const_preorder_iterator &other) const throw() { - return s == other.s; + return s.top() == other.s.top(); } bool operator!=(const const_preorder_iterator &other) const throw() @@ -571,22 +572,21 @@ public: } private: - std::stack s; + std::stack > s; void increment() { - internal::_iter_rep & current = s.top(); - const ex & child = current.e.op(current.i); - size_t n = child.nops(); - if (n) - s.push(internal::_iter_rep(child, 0, n)); - else - ++current.i; - while (s.top().i == s.top().i_end && s.size() > 1) { s.pop(); ++s.top().i; } + + internal::_iter_rep & current = s.top(); + + if (current.i != current.i_end) { + const ex & child = current.e.op(current.i); + s.push(internal::_iter_rep(child, 0, child.nops())); + } } }; @@ -595,19 +595,21 @@ class const_postorder_iterator : public std::iterator operator->() const @@ -639,12 +641,12 @@ public: } private: - std::stack s; + std::stack > s; void descend() { - while (s.top().i != s.top().i_end && s.top().e.op(s.top().i).nops() > 0) { - const internal::_iter_rep & current = s.top(); + while (s.top().i != s.top().i_end) { + internal::_iter_rep & current = s.top(); const ex & child = current.e.op(current.i); s.push(internal::_iter_rep(child, 0, child.nops())); } @@ -652,10 +654,12 @@ private: void increment() { - ++s.top().i; - descend(); - if (s.top().i == s.top().i_end && s.size() > 1) + if (s.top().i == s.top().i_end) s.pop(); + if (s.size() > 0) { + ++s.top().i; + descend(); + } } }; @@ -681,6 +685,23 @@ inline bool are_ex_trivially_equal(const ex &e1, const ex &e2) return e1.bp == e2.bp; } +/* Function objects for STL sort() etc. */ +struct ex_is_less : public std::binary_function { + bool operator() (const ex &lh, const ex &rh) const { return lh.compare(rh) < 0; } +}; + +struct ex_is_equal : public std::binary_function { + bool operator() (const ex &lh, const ex &rh) const { return lh.is_equal(rh); } +}; + +struct op0_is_equal : public std::binary_function { + bool operator() (const ex &lh, const ex &rh) const { return lh.op(0).is_equal(rh.op(0)); } +}; + +struct ex_swap : public std::binary_function { + void operator() (ex &lh, ex &rh) const { lh.swap(rh); } +}; + // wrapper functions around member functions inline size_t nops(const ex & thisex) { return thisex.nops(); } @@ -718,6 +739,12 @@ inline ex normal(const ex & thisex, int level=0) inline ex to_rational(const ex & thisex, lst & repl_lst) { return thisex.to_rational(repl_lst); } +inline ex to_rational(const ex & thisex, exmap & repl) +{ return thisex.to_rational(repl); } + +inline ex to_polynomial(const ex & thisex, exmap & repl) +{ return thisex.to_polynomial(repl); } + inline ex to_polynomial(const ex & thisex, lst & repl_lst) { return thisex.to_polynomial(repl_lst); } @@ -742,11 +769,11 @@ inline ex series(const ex & thisex, const ex & r, int order, unsigned options = inline bool match(const ex & thisex, const ex & pattern, lst & repl_lst) { return thisex.match(pattern, repl_lst); } -inline ex simplify_indexed(const ex & thisex) -{ return thisex.simplify_indexed(); } +inline ex simplify_indexed(const ex & thisex, unsigned options = 0) +{ return thisex.simplify_indexed(options); } -inline ex simplify_indexed(const ex & thisex, const scalar_products & sp) -{ return thisex.simplify_indexed(sp); } +inline ex simplify_indexed(const ex & thisex, const scalar_products & sp, unsigned options = 0) +{ return thisex.simplify_indexed(sp, options); } inline ex symmetrize(const ex & thisex) { return thisex.symmetrize(); } @@ -781,23 +808,6 @@ inline bool is_zero(const ex & thisex) inline void swap(ex & e1, ex & e2) { e1.swap(e2); } -/* Function objects for STL sort() etc. */ -struct ex_is_less : public std::binary_function { - bool operator() (const ex &lh, const ex &rh) const { return lh.compare(rh) < 0; } -}; - -struct ex_is_equal : public std::binary_function { - bool operator() (const ex &lh, const ex &rh) const { return lh.is_equal(rh); } -}; - -struct op0_is_equal : public std::binary_function { - bool operator() (const ex &lh, const ex &rh) const { return lh.op(0).is_equal(rh.op(0)); } -}; - -struct ex_swap : public std::binary_function { - void operator() (ex &lh, ex &rh) const { lh.swap(rh); } -}; - inline ex ex::subs(const exmap & m, unsigned options) const { return bp->subs(m, options);