75 template<
class T>
friend inline const T &
ex_to(
const ex &);
76 template<
class T>
friend inline bool is_a(
const ex &);
91 ex(
unsigned long long i);
98 ex(const
std::
string &s, const
ex &l);
132 bool info(
unsigned inf)
const {
return bp->info(inf); }
135 size_t nops()
const {
return bp->nops(); }
136 ex op(
size_t i)
const {
return bp->op(i); }
153 bool match(
const ex & pattern)
const;
154 bool match(
const ex & pattern,
exmap & repls)
const {
return bp->match(pattern, repls); }
181 ex collect(
const ex & s,
bool distributed =
false)
const {
return bp->collect(s, distributed); }
246 void share(
const ex & other)
const;
274 ex::ex(
int i) : bp(construct_from_int(i))
280 ex::ex(
unsigned int i) : bp(construct_from_uint(i))
286 ex::ex(
long i) : bp(construct_from_long(i))
292 ex::ex(
unsigned long i) : bp(construct_from_ulong(i))
298 ex::ex(
long long i) : bp(construct_from_longlong(i))
304 ex::ex(
unsigned long long i) : bp(construct_from_ulonglong(i))
310 ex::ex(
double const d) : bp(construct_from_double(d))
316 ex::ex(
const std::string &s,
const ex &l) : bp(construct_from_string_and_lst(s, l))
324 #ifdef GINAC_COMPARE_STATISTICS 325 compare_statistics.total_compares++;
329 #ifdef GINAC_COMPARE_STATISTICS 330 compare_statistics.nontrivial_compares++;
332 const int cmpval =
bp->compare(*other.
bp);
347 #ifdef GINAC_COMPARE_STATISTICS 348 compare_statistics.total_is_equals++;
352 #ifdef GINAC_COMPARE_STATISTICS 353 compare_statistics.nontrivial_is_equals++;
355 const bool equal =
bp->is_equal(*other.
bp);
370 class const_iterator :
public std::iterator<std::random_access_iterator_tag, ex, ptrdiff_t, const ex *, const ex &> {
393 return std::unique_ptr<ex>(
new ex(
operator*()));
466 return !(*
this == other);
476 return other < *
this;
481 return !(other < *
this);
486 return !(*
this < other);
506 return !(*
this == other);
556 return !(*
this == other);
560 std::stack<internal::_iter_rep, std::vector<internal::_iter_rep>>
s;
564 while (!
s.empty() &&
s.top().i ==
s.top().i_end) {
573 if (current.
i != current.
i_end) {
574 const ex & child = current.
e.
op(current.
i);
621 return !(*
this == other);
625 std::stack<internal::_iter_rep, std::vector<internal::_iter_rep>>
s;
629 while (
s.top().i !=
s.top().i_end) {
631 const ex & child = current.
e.
op(current.
i);
638 if (
s.top().i ==
s.top().i_end)
686 return e1.
bp == e2.
bp;
713 {
return thisex.
nops(); }
731 {
return thisex.
find(pattern, found); }
737 {
return thisex.
degree(s); }
743 {
return thisex.
coeff(s,
n); }
746 {
return thisex.
numer(); }
749 {
return thisex.
denom(); }
755 {
return thisex.
normal(); }
763 inline ex collect(
const ex & thisex,
const ex & s,
bool distributed =
false)
764 {
return thisex.
collect(s, distributed); }
767 {
return thisex.
eval(); }
770 {
return thisex.
evalf(); }
773 {
return thisex.
evalm(); }
779 {
return thisex.
diff(s, nth); }
785 {
return thisex.
match(pattern, repl_lst); }
811 inline ex op(
const ex & thisex,
size_t i)
812 {
return thisex.
op(i); }
815 {
return thisex.
lhs(); }
818 {
return thisex.
rhs(); }
860 template<
class T1,
class T2>
871 template<
class T1,
class T2,
class T3>
893 template<
class C,
class T1>
904 template<
class C,
class T1,
class T2>
916 template<
class C,
class T1,
class T2,
class T3>
925 explicit pointer_to_member_to_map_function_3args(
ex (C::*member)(
const ex &, T1, T2, T3), C &obj, T1 a1, T2 a2, T3 a3) :
ptr(member),
c(obj),
arg1(a1),
arg2(a2),
arg3(a3) {}
929 inline ex
ex::map(ex f(
const ex &))
const 931 pointer_to_map_function fcn(f);
941 return is_a<T>(*obj.
bp);
948 return is_exactly_a<T>(*obj.
bp);
965 return static_cast<const T &
>(*e.
bp);
997 return e1.is_equal(e2);
1003 #endif // ndef GINAC_EX_H ex content(const ex &x) const
Compute content part (= unit normal GCD of all coefficients) of a multivariate polynomial in Q[x]...
friend bool is_exactly_a(const ex &)
Check if ex is a handle to a T, not including base classes.
size_t nops(const ex &thisex)
ex operator()(const ex &e) override
friend bool is_a(const ex &)
Check if ex is a handle to a T, including base classes.
bool find(const ex &thisex, const ex &pattern, exset &found)
ex collect(const ex &s, bool distributed=false) const
ex to_rational(exmap &repl) const
Rationalization of non-rational functions.
ex normal() const
Normalization of rational functions.
Helper class for storing information about known scalar products which are to be automatically replac...
ex coeff(const ex &s, int n=1) const
const_postorder_iterator(const ex &e, size_t n)
pointer_to_map_function(ex x(const ex &))
const_preorder_iterator operator++(int)
ex eval_integ(const ex &thisex)
pointer_to_map_function_2args(ex x(const ex &, T1, T2), T1 a1, T2 a2)
bool operator>(const const_iterator &other) const noexcept
static ptr< basic > construct_from_basic(const basic &other)
Helper function for the ex-from-basic constructor.
const_iterator end() const noexcept
const_iterator & operator-=(difference_type n) noexcept
Reference-counted pointer template.
ex normal(const ex &thisex)
int compare(const ex &other) const
ex subs(const exmap &m, unsigned options=0) const
static basic & construct_from_long(long i)
friend bool are_ex_trivially_equal(const ex &, const ex &)
Compare two objects of class quickly without doing a deep tree traversal.
ex operator()(const ex &e) override
friend const T & ex_to(const ex &)
Return a reference to the basic-derived class T object embedded in an expression. ...
ex denom() const
Get denominator of an expression.
bool has(const ex &thisex, const ex &pattern, unsigned options=0)
void traverse(visitor &v) const
ex operator()(const ex &e) override
bool is_equal(const ex &other) const
void traverse_preorder(visitor &v) const
Traverse expression tree with given visitor, preorder traversal.
ex expand(unsigned options=0) const
bool operator!=(const const_preorder_iterator &other) const noexcept
ex unit(const ex &x) const
Compute unit part (= sign of leading coefficient) of a multivariate polynomial in Q[x]...
ex symmetrize_cyclic(const ex &thisex)
ex diff(const ex &thisex, const symbol &s, unsigned nth=1)
bool operator()(const GiNaC::ex &e1, const GiNaC::ex &e2) const noexcept
ex denom(const ex &thisex)
ex antisymmetrize(const ex &thisex)
ex primpart(const ex &x) const
Compute primitive part of a multivariate polynomial in Q[x].
const_postorder_iterator postorder_end() const noexcept
const_iterator & operator--() noexcept
bool has(const ex &pattern, unsigned options=0) const
ex eval_ncmul(const exvector &v) const
std::ostream & operator<<(std::ostream &os, const archive_node &n)
Write archive_node to binary data stream.
pointer_to_member_to_map_function_1arg(ex(C::*member)(const ex &, T1), C &obj, T1 a1)
const_postorder_iterator & operator++()
static basic & construct_from_uint(unsigned int i)
const_preorder_iterator() noexcept
bool operator!=(const const_postorder_iterator &other) const noexcept
ex operator()(const ex &e) override
bool operator!=(const _iter_rep &other) const noexcept
ex smod(const numeric &xi) const
int ldegree(const ex &thisex, const ex &s)
void dbgprint() const
Little wrapper arount print to be called within a debugger.
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
library_init()
Ctor of static initialization helpers.
ex collect(const ex &thisex, const ex &s, bool distributed=false)
bool are_ex_trivially_equal(const ex &e1, const ex &e2)
Compare two objects of class quickly without doing a deep tree traversal.
bool is_exactly_a(const basic &obj)
Check if obj is a T, not including base classes.
pointer operator->() const
void swap(ex &e1, ex &e2)
int degree(const ex &s) const
reference operator*() const
const_postorder_iterator() noexcept
Degenerate base class for visitors.
ex evalf(const ex &thisex)
ex symmetrize_cyclic() const
Symmetrize expression by cyclic permutation over its free indices.
bool is_a(const basic &obj)
Check if obj is a T, including base classes.
bool info(unsigned inf) const
const_iterator(const ex &e_, size_t i_) noexcept
bool is_zero(const ex &thisex)
void dbgprinttree() const
Little wrapper arount printtree to be called within a debugger.
const_preorder_iterator(const ex &e, size_t n)
int ldegree(const ex &s) const
bool operator==(const const_postorder_iterator &other) const noexcept
ex numer(const ex &thisex)
static basic & construct_from_double(double d)
int degree(const ex &thisex, const ex &s)
void traverse_postorder(visitor &v) const
Traverse expression tree with given visitor, postorder traversal.
const_iterator begin() const noexcept
ex(* ptr)(const ex &, T1)
This class is a wrapper around CLN-numbers within the GiNaC class hierarchy.
ex numer_denom(const ex &thisex)
bool operator()(const ex &lh, const ex &rh) const
ex conjugate(const ex &thisex)
bool match(const ex &pattern, exmap &repls) const
static basic & construct_from_int(int i)
const_iterator & operator+=(difference_type n) noexcept
ex operator[](const ex &index) const
const_iterator operator++(int) noexcept
bool operator()(const ex &lh, const ex &rh) const
ex tcoeff(const ex &s) const
bool find(const ex &pattern, exset &found) const
Find all occurrences of a pattern.
bool operator<(const const_iterator &other) const noexcept
ex simplify_indexed(const ex &thisex, unsigned options=0)
static ptr< basic > construct_from_string_and_lst(const std::string &s, const ex &l)
bool match(const ex &pattern) const
Check whether expression matches a specified pattern.
_iter_rep(const ex &e_, size_t i_, size_t i_end_)
ex rhs() const
Right hand side of relational expression.
#define GINAC_ASSERT(X)
Assertion macro for checking invariances.
ex operator[](size_t i) const
static basic & construct_from_ulonglong(unsigned long long i)
bool match(const ex &thisex, const ex &pattern, exmap &repl_lst)
const_iterator operator--(int) noexcept
ex imag_part(const ex &thisex)
void accept(visitor &v) const
Helper class to initialize the library.
ex antisymmetrize() const
Antisymmetrize expression over its free indices.
const_iterator operator+(difference_type n) const noexcept
std::set< ex, ex_is_less > exset
ex numer_denom() const
Get numerator and denominator of an expression.
bool operator==(const const_preorder_iterator &other) const noexcept
void makewriteable()
Make this ex writable (if more than one ex handle the same basic) by unlinking the object and creatin...
numeric max_coefficient() const
Return maximum (absolute value) coefficient of a polynomial.
To distinguish between different kinds of non-commutative objects.
void unitcontprim(const ex &x, ex &u, ex &c, ex &p) const
Compute unit part, content part, and primitive part of a multivariate polynomial in Q[x]...
const_iterator() noexcept
ex map(map_function &f) const
ex op(const ex &thisex, size_t i)
ex diff(const symbol &s, unsigned nth=1) const
Compute partial derivative of an expression.
bool operator>=(const const_iterator &other) const noexcept
std::stack< internal::_iter_rep, std::vector< internal::_iter_rep > > s
std::vector< ex > exvector
std::map< ex, ex, ex_is_less > exmap
void operator()(ex &lh, ex &rh) const
pointer operator->() const
const_preorder_iterator preorder_begin() const
bool is_zero_matrix() const
Check whether expression is zero or zero matrix.
std::stack< internal::_iter_rep, std::vector< internal::_iter_rep > > s
bool operator==(const const_iterator &other) const noexcept
const_iterator operator-(difference_type n) const noexcept
static basic & construct_from_ulong(unsigned long i)
reference operator*() const
Function object for map().
ex(* ptr)(const ex &, T1, T2, T3)
bool operator<=(const const_iterator &other) const noexcept
return_type_t return_type_tinfo() const
Base class for print_contexts.
ex series(const ex &r, int order, unsigned options=0) const
Compute the truncated series expansion of an expression.
ex operator()(const ex &e) override
ex operator()(const ex &e) override
ex to_polynomial(exmap &repl) const
~library_init()
Dtor of static initialization helpers.
Interface to GiNaC's ABC.
const_preorder_iterator preorder_end() const noexcept
static basic & construct_from_longlong(long long i)
ex simplify_indexed(unsigned options=0) const
Simplify/canonicalize expression containing indexed objects.
const_postorder_iterator operator++(int)
const T & ex_to(const ex &e)
Return a reference to the basic-derived class T object embedded in an expression. ...
ex numer() const
Get numerator of an expression.
bool operator!=(const const_iterator &other) const noexcept
pointer_to_map_function_1arg(ex x(const ex &, T1), T1 a1)
bool operator()(const ex &lh, const ex &rh) const
ex operator()(const ex &e) override
pointer_to_member_to_map_function_3args(ex(C::*member)(const ex &, T1, T2, T3), C &obj, T1 a1, T2 a2, T3 a3)
void print(const print_context &c, unsigned level=0) const
Print expression to stream.
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.
std::size_t operator()(const GiNaC::ex &e) const noexcept
ex symmetrize() const
Symmetrize expression over its free indices.
static int count
How many static objects were created? Only the first one must create the static flyweights on the hea...
friend const_iterator operator+(difference_type n, const const_iterator &it) noexcept
static library_init library_initializer
For construction of flyweights, etc.
numeric integer_content() const
Compute the integer content (= GCD of all numeric coefficients) of an expanded polynomial.
ex symmetrize(const ex &thisex)
ex evalm(const ex &thisex)
ex coeff(const ex &thisex, const ex &s, int n=1)
ex operator[](difference_type n) const
unsigned return_type() const
std::unique_ptr< ex > operator->() const
Wrapper template for making GiNaC classes out of STL containers.
ex(* ptr)(const ex &, T1, T2)
ex series(const ex &thisex, const ex &r, int order, unsigned options=0)
ex lcoeff(const ex &s) const
ptr< basic > bp
pointer to basic object managed by this
bool is_polynomial(const ex &thisex, const ex &vars)
pointer_to_map_function_3args(ex x(const ex &, T1, T2, T3), T1 a1, T2 a2, T3 a3)
ex & let_op(size_t i)
Return modifiable operand/member at position i.
bool operator==(const _iter_rep &other) const noexcept
heap-allocated (i.e. created by new if we want to be clever and bypass the stack, ...
const_postorder_iterator postorder_begin() const
ex lhs() const
Left hand side of relational expression.
ex to_polynomial(const ex &thisex, exmap &repl)
ex real_part(const ex &thisex)
void share(const ex &other) const
Share equal objects between expressions.
bool is_polynomial(const ex &vars) const
Check whether expression is a polynomial.
ex eval(const ex &thisex)
void swap(ex &other) noexcept
Efficiently swap the contents of two expressions.
pointer_to_member_to_map_function(ex(C::*member)(const ex &), C &obj)
ex to_rational(const ex &thisex, exmap &repl)
friend difference_type operator-(const const_iterator &lhs, const const_iterator &rhs) noexcept
ex subs(const ex &thisex, const exmap &m, unsigned options=0)
Class of (intrusively) reference-counted pointers that support copy-on-write semantics.
void swap(GiNaC::ex &a, GiNaC::ex &b)
Specialization of std::swap() for ex objects.
ex operator()(const ex &e) override
const_iterator & operator++() noexcept
pointer_to_member_to_map_function_2args(ex(C::*member)(const ex &, T1, T2), C &obj, T1 a1, T2 a2)
ex expand(const ex &thisex, unsigned options=0)
exvector get_free_indices() const
const_preorder_iterator & operator++()
static void init_unarchivers()