49typedef std::set<ex, ex_is_less>
exset;
50typedef std::map<ex, ex, ex_is_less>
exmap;
53#undef GINAC_COMPARE_STATISTICS
55#ifdef GINAC_COMPARE_STATISTICS
56class compare_statistics_t {
58 compare_statistics_t()
59 : total_compares(0), nontrivial_compares(0), total_basic_compares(0), compare_same_hashvalue(0), compare_same_type(0),
60 total_is_equals(0), nontrivial_is_equals(0), total_basic_is_equals(0), is_equal_same_hashvalue(0), is_equal_same_type(0),
61 total_gethash(0), gethash_cached(0) {}
62 ~compare_statistics_t();
64 unsigned long total_compares;
65 unsigned long nontrivial_compares;
66 unsigned long total_basic_compares;
67 unsigned long compare_same_hashvalue;
68 unsigned long compare_same_type;
70 unsigned long total_is_equals;
71 unsigned long nontrivial_is_equals;
72 unsigned long total_basic_is_equals;
73 unsigned long is_equal_same_hashvalue;
74 unsigned long is_equal_same_type;
76 unsigned long total_gethash;
77 unsigned long gethash_cached;
80extern compare_statistics_t compare_statistics;
155 virtual bool info(
unsigned inf)
const;
158 virtual size_t nops()
const;
159 virtual ex op(
size_t i)
const;
167 virtual bool has(
const ex & other,
unsigned options = 0)
const;
168 virtual bool match(
const ex & pattern,
exmap & repls)
const;
188 virtual int degree(
const ex & s)
const;
190 virtual ex coeff(
const ex & s,
int n = 1)
const;
194 virtual ex collect(
const ex & s,
bool distributed =
false)
const;
274#ifdef GINAC_COMPARE_STATISTICS
275 compare_statistics.total_gethash++;
278#ifdef GINAC_COMPARE_STATISTICS
279 compare_statistics.gethash_cached++;
315 return dynamic_cast<const T *
>(&obj) !=
nullptr;
322 return typeid(T) ==
typeid(obj);
333template<
class B,
typename... Args>
Assertion macro definition.
#define GINAC_ASSERT(X)
Assertion macro for checking invariances.
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
This class holds archived versions of GiNaC expressions (class ex).
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
virtual return_type_t return_type_tinfo() const
virtual size_t nops() const
Number of operands/members.
virtual ex eval_integ() const
Evaluate integrals, if result is known.
const basic & clearflag(unsigned f) const
Clear some status_flags.
virtual bool match_same_type(const basic &other) const
Returns true if the attributes of two objects are similar enough for a match.
virtual bool match(const ex &pattern, exmap &repls) const
Check whether the expression matches a given pattern.
virtual void dbgprinttree() const
Little wrapper around printtree to be called within a debugger.
void print_dispatch(const print_context &c, unsigned level) const
Like print(), but dispatch to the specified class.
virtual ex imag_part() const
virtual ex eval() const
Perform automatic non-interruptive term rewriting rules.
virtual numeric integer_content() const
const basic & setflag(unsigned f) const
Set some status_flags.
virtual bool info(unsigned inf) const
Information about the object.
virtual bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const
Try to contract two indexed expressions that appear in the same product.
ex diff(const symbol &s, unsigned nth=1) const
Default interface of nth derivative ex::diff(s, n).
virtual ex scalar_mul_indexed(const ex &self, const numeric &other) const
Multiply an indexed expression with a scalar.
virtual numeric max_coefficient() const
Implementation ex::max_coefficient().
unsigned hashvalue
hash value
void ensure_if_modifiable() const
Ensure the object may be modified without hurting others, throws if this is not the case.
virtual bool is_equal_same_type(const basic &other) const
Returns true if two objects of same type are equal.
virtual bool has(const ex &other, unsigned options=0) const
Test for occurrence of a pattern.
virtual ex evalm() const
Evaluate sums, products and integer powers of matrices.
virtual ex eval_indexed(const basic &i) const
Perform automatic symbolic evaluations on indexed expression that contains this object as the base ex...
virtual int degree(const ex &s) const
Return degree of highest power in object s.
virtual ex conjugate() const
virtual unsigned precedence() const
Return relative operator precedence (for parenthezing output).
virtual ex op(size_t i) const
Return operand/member at position i.
unsigned flags
of type status_flags
virtual ex add_indexed(const ex &self, const ex &other) const
Add two indexed expressions.
const basic & operator=(const basic &other)
basic assignment operator: the other object might be of a derived class.
virtual void print(const print_context &c, unsigned level=0) const
Output to stream.
void do_print(const print_context &c, unsigned level) const
Default output to stream.
virtual void read_archive(const archive_node &n, lst &syms)
Load (deserialize) the object from an archive node.
ex subs_one_level(const exmap &m, unsigned options) const
Helper function for subs().
const basic & hold() const
Stop further evaluation.
virtual ex series(const relational &r, int order, unsigned options=0) const
Default implementation of ex::series().
virtual void accept(GiNaC::visitor &v) const
bool is_equal(const basic &other) const
Test for syntactic equality.
virtual ex collect(const ex &s, bool distributed=false) const
Sort expanded expression in terms of powers of some object(s).
virtual ex to_polynomial(exmap &repl) const
virtual ex subs(const exmap &m, unsigned options=0) const
Substitute a set of objects by arbitrary expressions.
virtual ex real_part() const
virtual int compare_same_type(const basic &other) const
Returns order relation between two objects of same type.
virtual ex & let_op(size_t i)
Return modifiable operand/member at position i.
virtual basic * duplicate() const
Create a clone of this object on the heap.
virtual void dbgprint() const
Little wrapper around print to be called within a debugger.
virtual ex to_rational(exmap &repl) const
Default implementation of ex::to_rational().
void do_print_tree(const print_tree &c, unsigned level) const
Tree output to stream.
virtual ex coeff(const ex &s, int n=1) const
Return coefficient of degree n in object s.
virtual unsigned return_type() const
virtual ex eval_ncmul(const exvector &v) const
void do_print_python_repr(const print_python_repr &c, unsigned level) const
Python parsable output to stream.
virtual ex derivative(const symbol &s) const
Default implementation of ex::diff().
virtual int ldegree(const ex &s) const
Return degree of lowest power in object s.
virtual ex smod(const numeric &xi) const
Apply symmetric modular homomorphism to an expanded multivariate polynomial.
virtual ex expand(unsigned options=0) const
Expand expression, i.e.
virtual ex normal(exmap &repl, exmap &rev_lookup, lst &modifier) const
Default implementation of ex::normal().
basic(const basic &other)
int compare(const basic &other) const
Compare objects syntactically to establish canonical ordering.
virtual ~basic()
basic destructor, virtual because class ex will delete objects of derived classes via a basic*.
virtual ex evalf() const
Evaluate object numerically.
virtual ex operator[](const ex &index) const
virtual unsigned calchash() const
Compute the hash value of an object and if it makes sense to store it in the objects status_flags,...
virtual exvector get_free_indices() const
Return a vector containing the free indices of an expression.
virtual bool is_polynomial(const ex &var) const
Check whether this is a polynomial in the given variables.
virtual ex map(map_function &f) const
Construct new expression by applying the specified function to all sub-expressions (one level only,...
Wrapper template for making GiNaC classes out of STL containers.
Lightweight wrapper for GiNaC's symbolic objects.
This class is a wrapper around CLN-numbers within the GiNaC class hierarchy.
Base class for print_contexts.
Context for python-parsable output.
Context for tree-like output for debugging.
Base class for reference-counted objects.
unsigned int get_refcount() const noexcept
This class holds a relation consisting of two expressions and a logical relation between them.
@ dynallocated
heap-allocated (i.e. created by new if we want to be clever and bypass the stack,
@ hash_calculated
.calchash() has already done its job
Degenerate base class for visitors.
Collection of all flags used through the GiNaC framework.
std::map< ex, ex, ex_is_less > exmap
std::set< ex, ex_is_less > exset
B & dynallocate(Args &&... args)
Constructs a new (class basic or derived) B object on the heap.
bool is_a(const basic &obj)
Check if obj is a T, including base classes.
bool is_exactly_a(const basic &obj)
Check if obj is a T, not including base classes.
std::vector< ex > exvector
Reference-counted pointer template.
GiNaC's class registrar (for class basic and all classes derived from it).
#define GINAC_DECLARE_REGISTERED_CLASS_NO_CTORS(classname, supername)
Primary macro for inclusion in the declaration of each registered class.
Function object for map().
virtual ex operator()(const ex &e)=0
To distinguish between different kinds of non-commutative objects.