* Interface to GiNaC's light-weight expression handles. */
/*
- * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2007 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
/** For construction of flyweights, etc. */
static library_init library_initializer;
-
class scalar_products;
class const_iterator;
class const_preorder_iterator;
class const_postorder_iterator;
-/** Lightweight wrapper for GiNaC's symbolic objects. Basically all it does is
- * to hold a pointer to the other objects, manage the reference counting and
- * provide methods for manipulation of these objects. (Some people call such
- * a thing a proxy class.) */
+/** 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 &);
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;
void operator() (ex &lh, ex &rh) const { lh.swap(rh); }
};
+// Make it possible to print exvectors and exmaps
+std::ostream & operator<<(std::ostream & os, const exvector & e);
+std::ostream & operator<<(std::ostream & os, const exset & e);
+std::ostream & operator<<(std::ostream & os, const exmap & e);
+
// wrapper functions around member functions
inline size_t nops(const ex & thisex)
{ return thisex.nops(); }
};
template<class C>
-class pointer_to_member_to_map_function_0args : public map_function {
+class pointer_to_member_to_map_function : public map_function {
protected:
ex (C::*ptr)(const ex &);
C &c;
public:
- explicit pointer_to_member_to_map_function_0args(ex (C::*member)(const ex &), C &obj) : ptr(member), c(obj) {}
+ explicit pointer_to_member_to_map_function(ex (C::*member)(const ex &), C &obj) : ptr(member), c(obj) {}
ex operator()(const ex & e) { return (c.*ptr)(e); }
};
template<class C, class T1>
-class pointer_to_member_to_map_function_1args : public map_function {
+class pointer_to_member_to_map_function_1arg : public map_function {
protected:
ex (C::*ptr)(const ex &, T1);
C &c;
T1 arg1;
public:
- explicit pointer_to_member_to_map_function_1args(ex (C::*member)(const ex &, T1), C &obj, T1 a1) : ptr(member), c(obj), arg1(a1) {}
+ explicit pointer_to_member_to_map_function_1arg(ex (C::*member)(const ex &, T1), C &obj, T1 a1) : ptr(member), c(obj), arg1(a1) {}
ex operator()(const ex & e) { return (c.*ptr)(e, arg1); }
};