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