23#ifndef GINAC_STRUCTURE_H
24#define GINAC_STRUCTURE_H
56 return std::equal_to<T>()(*t1, *t2);
61 if (std::less<T>()(*t1, *t2))
63 else if (std::less<T>()(*t2, *t1))
81 const char * cp1 =
reinterpret_cast<const char *
>(t1);
82 const char * cp2 =
reinterpret_cast<const char *
>(t2);
84 return std::equal(cp1, cp1 +
sizeof(T), cp2);
89 const unsigned char * cp1 =
reinterpret_cast<const unsigned char *
>(t1);
90 const unsigned char * cp2 =
reinterpret_cast<const unsigned char *
>(t2);
91 typedef std::pair<const unsigned char *, const unsigned char *> cppair;
93 cppair res = std::mismatch(cp1, cp1 +
sizeof(T), cp2);
95 if (res.first == cp1 +
sizeof(T))
97 else if (*res.first < *res.second)
110template <
class T,
template <
class>
class ComparisonPolicy = compare_all_equal>
class structure;
114template <
class T,
template <
class>
class ComparisonPolicy>
141 bool info(
unsigned inf)
const override {
return false; }
144 size_t nops()
const override {
return 0; }
146 ex operator[](
const ex & index)
const override {
return inherited::operator[](index); }
147 ex operator[](
size_t i)
const override {
return inherited::operator[](i); }
148 ex &
let_op(
size_t i)
override {
return inherited::let_op(i); }
149 ex &
operator[](
const ex & index)
override {
return inherited::operator[](index); }
150 ex &
operator[](
size_t i)
override {
return inherited::operator[](i); }
194 bool contract_with(exvector::iterator self, exvector::iterator other,
exvector & v)
const override {
return false; }
202 r.tinfo = &
typeid(*this);
212 return this->struct_is_equal(&
obj, &o.
obj);
215 unsigned calchash()
const override {
return inherited::calchash(); }
229template <
class T,
template <
class>
class CP>
233template <
class T,
template <
class>
class CP>
237 const structure & o =
static_cast<const structure &
>(other);
239 return this->struct_compare(&obj, &o.obj);
242template <
class T,
template <
class>
class CP>
#define GINAC_ASSERT(X)
Assertion macro for checking invariances.
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
const basic & hold() const
Stop further evaluation.
virtual int compare_same_type(const basic &other) const
Returns order relation between two objects of same type.
Comparison policy: all structures of one type are equal.
static bool struct_is_equal(const T *t1, const T *t2)
static int struct_compare(const T *t1, const T *t2)
Comparison policy: use bit-wise comparison to compare structures.
static bool struct_is_equal(const T *t1, const T *t2)
static int struct_compare(const T *t1, const T *t2)
Comparison policy: use std::equal_to/std::less (defaults to operators == and <) to compare structures...
static bool struct_is_equal(const T *t1, const T *t2)
static int struct_compare(const T *t1, const T *t2)
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.
This class holds a relation consisting of two expressions and a logical relation between them.
Wrapper template for making GiNaC classes out of C++ structures.
size_t nops() const override
Number of operands/members.
bool info(unsigned inf) const override
Information about the object.
const T & get_struct() const
int ldegree(const ex &s) const override
Return degree of lowest power in object s.
exvector get_free_indices() const override
Return a vector containing the free indices of an expression.
numeric integer_content() const override
ex collect(const ex &s, bool distributed=false) const override
Sort expanded expression in terms of powers of some object(s).
ex eval_indexed(const basic &i) const override
Perform automatic symbolic evaluations on indexed expression that contains this object as the base ex...
numeric max_coefficient() const override
Implementation ex::max_coefficient().
ex to_rational(exmap &repl) const override
Default implementation of ex::to_rational().
ex derivative(const symbol &s) const override
Default implementation of ex::diff().
ex operator[](size_t i) const override
ex evalm() const override
Evaluate sums, products and integer powers of matrices.
static const char * get_class_name()
ex to_polynomial(exmap &repl) const override
bool match(const ex &pattern, exmap &repl_lst) const override
Check whether the expression matches a given pattern.
ex series(const relational &r, int order, unsigned options=0) const override
Default implementation of ex::series().
ex eval_ncmul(const exvector &v) const override
unsigned calchash() const override
Compute the hash value of an object and if it makes sense to store it in the objects status_flags,...
ex expand(unsigned options=0) const override
Expand expression, i.e.
ex & operator[](size_t i) override
ex add_indexed(const ex &self, const ex &other) const override
Add two indexed expressions.
structure(const T &t)
Construct structure as a copy of a given C++ structure.
bool match_same_type(const basic &other) const override
Returns true if the attributes of two objects are similar enough for a match.
unsigned return_type() const override
unsigned precedence() const override
Return relative operator precedence (for parenthezing output).
ex smod(const numeric &xi) const override
Apply symmetric modular homomorphism to an expanded multivariate polynomial.
return_type_t return_type_tinfo() const override
int degree(const ex &s) const override
Return degree of highest power in object s.
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Try to contract two indexed expressions that appear in the same product.
ex operator[](const ex &index) const override
ex & let_op(size_t i) override
Return modifiable operand/member at position i.
ex scalar_mul_indexed(const ex &self, const numeric &other) const override
Multiply an indexed expression with a scalar.
ex normal(exmap &repl, exmap &rev_lookup, lst &modifier) const override
Default implementation of ex::normal().
void print(const print_context &c, unsigned level=0) const override
Output to stream.
bool is_equal_same_type(const basic &other) const override
Returns true if two objects of same type are equal.
ex eval() const override
Perform automatic non-interruptive term rewriting rules.
ex op(size_t i) const override
Return operand/member at position i.
ex coeff(const ex &s, int n=1) const override
Return coefficient of degree n in object s.
const T * operator->() const
ex subs(const exmap &m, unsigned options=0) const override
Substitute a set of objects by arbitrary expressions.
bool has(const ex &other, unsigned options=0) const override
Test for occurrence of a pattern.
ex map(map_function &f) const override
Construct new expression by applying the specified function to all sub-expressions (one level only,...
ex & operator[](const ex &index) override
Interface to GiNaC's light-weight expression handles.
ex hold_ncmul(const exvector &v)
ex to_rational(const ex &thisex, exmap &repl)
std::map< ex, ex, ex_is_less > exmap
class_info< registered_class_options > registered_class_info
ex series(const ex &thisex, const ex &r, int order, unsigned options=0)
ex subs(const ex &thisex, const exmap &m, unsigned options=0)
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)
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 evalm(const ex &thisex)
bool has(const ex &thisex, const ex &pattern, unsigned options=0)
std::vector< ex > exvector
ex to_polynomial(const ex &thisex, exmap &repl)
ex expand(const ex &thisex, unsigned options=0)
Interface to GiNaC's non-commutative products of expressions.
Makes the interface to the underlying bignum package available.
Interface to GiNaC's overloaded operators.
Definition of helper classes for expression output.
#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the declaration of each registered class.
Function object for map().
To distinguish between different kinds of non-commutative objects.