+class scalar_products;
+class const_iterator;
+class const_preorder_iterator;
+class const_postorder_iterator;
+
+
+/** Lightweight wrapper for GiNaC's symbolic objects. It holds a pointer to
+ * the other object in order to do garbage collection by the method of
+ * reference counting. I.e., it is a smart pointer. Also, the constructor
+ * ex::ex(const basic & other) calls the methods that do automatic
+ * evaluation. E.g., x-x turns automatically into 0. */
+class ex {
+ friend class archive_node;
+ friend inline bool are_ex_trivially_equal(const ex &, const ex &);
+ template<class T> friend inline const T &ex_to(const ex &);
+ template<class T> friend inline bool is_a(const ex &);
+ template<class T> friend inline bool is_exactly_a(const ex &);
+
+ // default constructor, copy constructor and assignment operator
+public:
+ ex() throw();
+
+ // other constructors
+public:
+ ex(const basic & other);
+ ex(int i);
+ ex(unsigned int i);
+ ex(long i);
+ ex(unsigned long i);
+ ex(double const d);
+
+ /** Construct ex from string and a list of symbols. The input grammar is
+ * similar to the GiNaC output format. All symbols and indices to be used
+ * in the expression must be specified in a lst in the second argument.
+ * Undefined symbols and other parser errors will throw an exception. */
+ ex(const std::string &s, const ex &l);
+
+public:
+ // non-virtual functions in this class
+public:
+ /** Efficiently swap the contents of two expressions. */
+ void swap(ex & other) throw()
+ {
+ GINAC_ASSERT(bp->flags & status_flags::dynallocated);
+ GINAC_ASSERT(other.bp->flags & status_flags::dynallocated);
+ bp.swap(other.bp);
+ }
+
+ // iterators
+ const_iterator begin() const throw();
+ const_iterator end() const throw();
+ const_preorder_iterator preorder_begin() const;
+ const_preorder_iterator preorder_end() const throw();
+ const_postorder_iterator postorder_begin() const;
+ const_postorder_iterator postorder_end() const throw();
+
+ // evaluation
+ ex eval(int level = 0) const { return bp->eval(level); }
+ ex evalf(int level = 0) const { return bp->evalf(level); }
+ ex evalm() const { return bp->evalm(); }
+ ex eval_ncmul(const exvector & v) const { return bp->eval_ncmul(v); }
+ ex eval_integ() const { return bp->eval_integ(); }
+
+ // printing
+ void print(const print_context & c, unsigned level = 0) const;
+ void dbgprint() const;
+ void dbgprinttree() const;
+
+ // info
+ bool info(unsigned inf) const { return bp->info(inf); }
+
+ // operand access
+ size_t nops() const { return bp->nops(); }
+ ex op(size_t i) const { return bp->op(i); }
+ ex operator[](const ex & index) const { return (*bp)[index]; }
+ ex operator[](size_t i) const { return (*bp)[i]; }
+ ex & let_op(size_t i);
+ ex & operator[](const ex & index);
+ ex & operator[](size_t i);
+ ex lhs() const;
+ ex rhs() const;
+
+ // function for complex expressions
+ ex conjugate() const { return bp->conjugate(); }
+ ex real_part() const { return bp->real_part(); }
+ ex imag_part() const { return bp->imag_part(); }
+
+ // pattern matching
+ bool has(const ex & pattern, unsigned options = 0) const { return bp->has(pattern, options); }
+ bool find(const ex & pattern, lst & found) const;
+ bool match(const ex & pattern) const;
+ bool match(const ex & pattern, lst & repl_lst) const { return bp->match(pattern, repl_lst); }
+
+ // substitutions
+ ex subs(const exmap & m, unsigned options = 0) const;
+ ex subs(const lst & ls, const lst & lr, unsigned options = 0) const;
+ ex subs(const ex & e, unsigned options = 0) const;
+
+ // function mapping
+ ex map(map_function & f) const { return bp->map(f); }
+ ex map(ex (*f)(const ex & e)) const;
+
+ // visitors and tree traversal
+ void accept(visitor & v) const { bp->accept(v); }
+ void traverse_preorder(visitor & v) const;
+ void traverse_postorder(visitor & v) const;
+ void traverse(visitor & v) const { traverse_preorder(v); }
+
+ // degree/coeff
+ bool is_polynomial(const ex & vars) 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)); }
+
+ // expand/collect
+ ex expand(unsigned options=0) const;
+ ex collect(const ex & s, bool distributed = false) const { return bp->collect(s, distributed); }
+
+ // differentiation and series expansion
+ ex diff(const symbol & s, unsigned nth = 1) const;
+ ex series(const ex & r, int order, unsigned options = 0) const;
+
+ // rational functions
+ ex normal(int level = 0) 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;
+
+ // polynomial algorithms
+ ex unit(const ex &x) const;
+ ex content(const ex &x) const;
+ numeric integer_content() const;
+ ex primpart(const ex &x) const;
+ ex primpart(const ex &x, const ex &cont) const;
+ void unitcontprim(const ex &x, ex &u, ex &c, ex &p) const;
+ ex smod(const numeric &xi) const { return bp->smod(xi); }
+ numeric max_coefficient() const;
+
+ // indexed objects
+ exvector get_free_indices() const { return bp->get_free_indices(); }
+ 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;
+ bool is_equal(const ex & other) const;
+ bool is_zero() const { extern const ex _ex0; return is_equal(_ex0); }
+ bool is_zero_matrix() const;
+
+ // symmetry
+ ex symmetrize() const;
+ ex symmetrize(const lst & l) const;
+ ex antisymmetrize() const;
+ ex antisymmetrize(const lst & l) const;
+ ex symmetrize_cyclic() const;
+ ex symmetrize_cyclic(const lst & l) const;
+
+ // noncommutativity
+ unsigned return_type() const { return bp->return_type(); }
+ tinfo_t return_type_tinfo() const { return bp->return_type_tinfo(); }
+
+ unsigned gethash() const { return bp->gethash(); }