X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fex.h;h=95115a30fbbc6b35375329ca9c5989418d11808b;hp=2f5e8fe9d851a6e4c4e70964b2339f4b32f98794;hb=646d0ad9d3f64b2437f2f55fbc007fad1cbedf86;hpb=dfa384d36f986f5f8d7dbb5e20c0d3a63af42cd9 diff --git a/ginac/ex.h b/ginac/ex.h index 2f5e8fe9..95115a30 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -3,7 +3,7 @@ * Interface to GiNaC's light-weight expression handles. */ /* - * GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2004 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -132,6 +132,9 @@ public: ex lhs() const; ex rhs() const; + // complex conjugation + ex conjugate() const { return bp->conjugate(); } + // pattern matching bool has(const ex & pattern) const { return bp->has(pattern); } bool find(const ex & pattern, lst & found) const; @@ -189,8 +192,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; @@ -530,8 +533,8 @@ class const_preorder_iterator : public std::iterator operator->() const @@ -564,7 +566,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() @@ -573,22 +575,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())); + } } }; @@ -597,19 +598,21 @@ class const_postorder_iterator : public std::iterator operator->() const @@ -641,12 +644,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())); } @@ -654,10 +657,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(); + } } }; @@ -767,11 +772,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(); }