- void swap(ex & other);
- void printraw(ostream & os) const;
- void printtree(ostream & os, unsigned indent=0) const;
- void print(ostream & os, unsigned upper_precedence=0) const;
- void printcsrc(ostream & os, unsigned type, const char *var_name) const;
- void dbgprint(void) const;
- void dbgprinttree(void) const;
- bool info(unsigned inf) const;
- int nops() const;
- ex expand(unsigned options=0) const;
- bool has(ex const & other) const;
- int degree(symbol const & s) const;
- int ldegree(symbol const & s) const;
- ex coeff(symbol const & s, int const n=1) const;
- ex lcoeff(symbol const & s) const { return coeff(s, degree(s)); }
- ex tcoeff(symbol const & s) const { return coeff(s, ldegree(s)); }
- ex numer(bool normalize = true) const;
- ex denom(bool normalize = true) const;
- ex unit(const symbol &x) const;
- ex content(const symbol &x) const;
- numeric integer_content(void) const;
- ex primpart(const symbol &x) const;
- ex primpart(const symbol &x, const ex &cont) const;
- ex normal(int level = 0) const;
- ex smod(const numeric &xi) const;
- numeric max_coefficient(void) const;
- ex collect(symbol const & s) const;
- ex eval(int level = 0) const;
- ex evalf(int level = 0) const;
- ex diff(symbol const & s, unsigned nth = 1) const;
- ex series(symbol const & s, ex const & point, int order = 6) const;
- ex subs(lst const & ls, lst const & lr) const;
- ex subs(ex const & e) const;
- exvector get_indices(void) const;
- ex simplify_ncmul(exvector const & v) const;
- ex operator[](ex const & index) const;
- ex operator[](int const i) const;
- ex op(int const i) const;
- ex & let_op(int const i);
- int compare(ex const & other) const
-#ifdef INLINE_EX_CONSTRUCTORS
- {
- GINAC_ASSERT(bp!=0);
- GINAC_ASSERT(other.bp!=0);
- if (bp==other.bp) {
- // special case: both expression point to same basic, trivially equal
- return 0;
- }
- return bp->compare(*other.bp);
- }
-#else
-;
-#endif // def INLINE_EX_CONSTRUCTORS
- bool is_equal(ex const & other) const
-#ifdef INLINE_EX_CONSTRUCTORS
- {
- GINAC_ASSERT(bp!=0);
- GINAC_ASSERT(other.bp!=0);
- if (bp==other.bp) {
- // special case: both expression point to same basic, trivially equal
- return true;
- }
- return bp->is_equal(*other.bp);
- }
-#else
-;
-#endif // def INLINE_EX_CONSTRUCTORS
- bool is_zero(void) const {return compare(exZERO()) == 0;};
-
- unsigned return_type(void) const;
- unsigned return_type_tinfo(void) const;
- unsigned gethash(void) const;
-
- ex exadd(ex const & rh) const;
- ex exmul(ex const & rh) const;
- ex exncmul(ex const & rh) const;
+ /** Efficiently swap the contents of two expressions. */
+ void swap(ex & other)
+ {
+ GINAC_ASSERT(bp!=0);
+ GINAC_ASSERT(bp->flags & status_flags::dynallocated);
+ GINAC_ASSERT(other.bp!=0);
+ GINAC_ASSERT(other.bp->flags & status_flags::dynallocated);
+
+ basic * tmpbp = bp;
+ bp = other.bp;
+ other.bp = tmpbp;
+ }
+
+ void print(const print_context & c, unsigned level = 0) const;
+ void printtree(std::ostream & os) const;
+ void dbgprint(void) const;
+ void dbgprinttree(void) const;
+ bool info(unsigned inf) const { return bp->info(inf); }
+ unsigned nops() const { return bp->nops(); }
+ ex expand(unsigned options=0) const;
+ bool has(const ex & pattern) const { return bp->has(pattern); }
+ ex map(map_function & f) const { return bp->map(f); }
+ ex map(ex (*f)(const ex & e)) const;
+ bool find(const ex & pattern, lst & found) const;
+ int degree(const ex & s) const { return bp->degree(s); }
+ int ldegree(const ex & s) const { return bp->ldegree(s); }
+ ex coeff(const ex & s, int n = 1) const { return bp->coeff(s, n); }
+ ex lcoeff(const ex & s) const { return coeff(s, degree(s)); }
+ ex tcoeff(const ex & s) const { return coeff(s, ldegree(s)); }
+ ex numer(void) const;
+ ex denom(void) const;
+ ex numer_denom(void) const;
+ ex unit(const symbol &x) const;
+ ex content(const symbol &x) const;
+ numeric integer_content(void) const;
+ ex primpart(const symbol &x) const;
+ ex primpart(const symbol &x, const ex &cont) const;
+ ex normal(int level = 0) const;
+ ex to_rational(lst &repl_lst) const { return bp->to_rational(repl_lst); }
+ ex smod(const numeric &xi) const { return bp->smod(xi); }
+ numeric max_coefficient(void) const;
+ ex collect(const ex & s, bool distributed = false) const { return bp->collect(s, distributed); }
+ ex eval(int level = 0) const { return bp->eval(level); }
+ ex evalf(int level = 0) const { return bp->evalf(level); }
+ ex evalm(void) const { return bp->evalm(); }
+ ex diff(const symbol & s, unsigned nth = 1) const;
+ ex series(const ex & r, int order, unsigned options = 0) const;
+ 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;
+ ex symmetrize(void) const;
+ ex symmetrize(const lst & l) const;
+ ex antisymmetrize(void) const;
+ ex antisymmetrize(const lst & l) const;
+ ex symmetrize_cyclic(void) const;
+ ex symmetrize_cyclic(const lst & l) const;
+ ex simplify_ncmul(const exvector & v) const { return bp->simplify_ncmul(v); }
+ ex operator[](const ex & index) const;
+ ex operator[](int i) const;
+ ex op(int i) const { return bp->op(i); }
+ ex & let_op(int i);
+ ex lhs(void) const;
+ ex rhs(void) const;
+ int compare(const ex & other) const;
+ bool is_equal(const ex & other) const;
+ bool is_zero(void) const { extern const ex _ex0; return is_equal(_ex0); }
+
+ 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(); }