48typedef std::set<ex, ex_is_less>
exset;
49typedef std::map<ex, ex, ex_is_less>
exmap;
52#undef GINAC_COMPARE_STATISTICS
54#ifdef GINAC_COMPARE_STATISTICS
55class compare_statistics_t {
57 compare_statistics_t()
58 : total_compares(0), nontrivial_compares(0), total_basic_compares(0), compare_same_hashvalue(0), compare_same_type(0),
59 total_is_equals(0), nontrivial_is_equals(0), total_basic_is_equals(0), is_equal_same_hashvalue(0), is_equal_same_type(0),
60 total_gethash(0), gethash_cached(0) {}
61 ~compare_statistics_t();
63 unsigned long total_compares;
64 unsigned long nontrivial_compares;
65 unsigned long total_basic_compares;
66 unsigned long compare_same_hashvalue;
67 unsigned long compare_same_type;
69 unsigned long total_is_equals;
70 unsigned long nontrivial_is_equals;
71 unsigned long total_basic_is_equals;
72 unsigned long is_equal_same_hashvalue;
73 unsigned long is_equal_same_type;
75 unsigned long total_gethash;
76 unsigned long gethash_cached;
79extern compare_statistics_t compare_statistics;
154 virtual bool info(
unsigned inf)
const;
157 virtual size_t nops()
const;
158 virtual ex op(
size_t i)
const;
166 virtual bool has(
const ex & other,
unsigned options = 0)
const;
167 virtual bool match(
const ex & pattern,
exmap & repls)
const;
173 virtual ex subs(
const exmap & m,
unsigned options = 0)
const;
187 virtual int degree(
const ex & s)
const;
189 virtual ex coeff(
const ex & s,
int n = 1)
const;
192 virtual ex expand(
unsigned options = 0)
const;
193 virtual ex collect(
const ex & s,
bool distributed =
false)
const;
273#ifdef GINAC_COMPARE_STATISTICS
274 compare_statistics.total_gethash++;
277#ifdef GINAC_COMPARE_STATISTICS
278 compare_statistics.gethash_cached++;
314 return dynamic_cast<const T *
>(&obj) !=
nullptr;
321 return typeid(T) ==
typeid(obj);
332template<
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 is the ABC (abstract base class) of GiNaC's class hierarchy.
virtual return_type_t return_type_tinfo() const
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 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 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.
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 ex eval_indexed(const basic &i) const
Perform automatic symbolic evaluations on indexed expression that contains this object as the base ex...
virtual unsigned precedence() const
Return relative operator precedence (for parenthezing output).
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 void accept(GiNaC::visitor &v) const
bool is_equal(const basic &other) const
Test for syntactic equality.
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.
void do_print_tree(const print_tree &c, unsigned level) const
Tree output to stream.
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().
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 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 ex map(map_function &f) const
Construct new expression by applying the specified function to all sub-expressions (one level only,...
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.
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.
ex real_part(const ex &thisex)
bool is_polynomial(const ex &thisex, const ex &vars)
container< std::list > lst
ex to_rational(const ex &thisex, exmap &repl)
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.
class_info< registered_class_options > registered_class_info
ex series(const ex &thisex, const ex &r, int order, unsigned options=0)
ex conjugate(const ex &thisex)
ex diff(const ex &thisex, const symbol &s, unsigned nth=1)
ex subs(const ex &thisex, const exmap &m, unsigned options=0)
const numeric smod(const numeric &a_, const numeric &b_)
Modulus (in symmetric representation).
ex eval(const ex &thisex)
int degree(const ex &thisex, const ex &s)
bool match(const ex &thisex, const ex &pattern, exmap &repl_lst)
int ldegree(const ex &thisex, const ex &s)
bool is_a(const basic &obj)
Check if obj is a T, including base classes.
ex evalf(const ex &thisex)
ex normal(const ex &thisex)
ex op(const ex &thisex, size_t i)
ex coeff(const ex &thisex, const ex &s, int n=1)
ex collect(const ex &thisex, const ex &s, bool distributed=false)
ex eval_integ(const ex &thisex)
ex evalm(const ex &thisex)
bool is_exactly_a(const basic &obj)
Check if obj is a T, not including base classes.
bool has(const ex &thisex, const ex &pattern, unsigned options=0)
std::vector< ex > exvector
size_t nops(const ex &thisex)
ex imag_part(const ex &thisex)
ex to_polynomial(const ex &thisex, exmap &repl)
ex expand(const ex &thisex, unsigned options=0)
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.