91 return bp->diff(s, nth);
98 return bp->match(pattern, repl_lst);
107 if (
match(pattern)) {
111 bool any_found =
false;
112 for (
size_t i=0; i<
nops(); i++)
113 if (
op(i).
find(pattern, found))
126 for (
auto its = ls.
begin(), itr =
lr.begin(); its != ls.
end(); ++its, ++itr) {
127 m.insert(std::make_pair(*its, *itr));
131 if (is_exactly_a<mul>(*its) || is_exactly_a<power>(*its))
150 const ex & s = e.
op(0);
151 m.insert(std::make_pair(s, e.
op(1)));
153 if (is_exactly_a<mul>(s) || is_exactly_a<power>(s))
165 for (
auto &
r : ex_to<lst>(e)) {
167 throw(std::invalid_argument(
"basic::subs(ex): argument must be a list of equations"));
168 const ex & s =
r.op(0);
169 m.insert(std::make_pair(s,
r.op(1)));
173 if (is_exactly_a<mul>(s) || is_exactly_a<power>(s))
182 throw(std::invalid_argument(
"ex::subs(ex): argument must be a relation_equal or a list"));
191 for (
size_t i = 0; i <
n; ++i)
199 for (
size_t i = 0; i <
n; ++i)
209 return bp->let_op(i);
227 if (!is_a<relational>(*
this))
228 throw std::runtime_error(
"ex::lhs(): not a relation");
235 if (!is_a<relational>(*
this))
236 throw std::runtime_error(
"ex::rhs(): not a relation");
243 if (is_a<lst>(vars)) {
244 const lst & varlst = ex_to<lst>(vars);
245 for (
auto & it : varlst)
246 if (!
bp->is_polynomial(it))
251 return bp->is_polynomial(vars);
261 return is_a<matrix>(e) && ex_to<matrix>(e).is_zero_matrix();
283 if (
bp->get_refcount() <= other.
bp->get_refcount())
309 const ex & tmpex = other.
eval();
404 return dynallocate<numeric>(i);
438 return dynallocate<numeric>(i);
496 return dynallocate<numeric>(i);
530 return dynallocate<numeric>(i);
536 if (i >= -12 && i <= 12) {
539 return dynallocate<numeric>(i);
548 return dynallocate<numeric>(i);
554 return dynallocate<numeric>(d);
Interface to GiNaC's sums of expressions.
#define GINAC_ASSERT(X)
Assertion macro for checking invariances.
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
virtual ex eval() const
Perform automatic non-interruptive term rewriting rules.
unsigned flags
of type status_flags
virtual basic * duplicate() const
Create a clone of this object on the heap.
Wrapper template for making GiNaC classes out of STL containers.
const_iterator end() const
const_iterator begin() const
size_t nops() const override
Number of operands/members.
Lightweight wrapper for GiNaC's symbolic objects.
static basic & construct_from_ulonglong(unsigned long long i)
static basic & construct_from_longlong(long long i)
void traverse_preorder(visitor &v) const
Traverse expression tree with given visitor, preorder traversal.
ex operator[](const ex &index) const
static basic & construct_from_int(int i)
static basic & construct_from_uint(unsigned int i)
bool match(const ex &pattern) const
Check whether expression matches a specified pattern.
bool is_polynomial(const ex &vars) const
Check whether expression is a polynomial.
static ptr< basic > construct_from_basic(const basic &other)
Helper function for the ex-from-basic constructor.
bool find(const ex &pattern, exset &found) const
Find all occurrences of a pattern.
void accept(visitor &v) const
ex diff(const symbol &s, unsigned nth=1) const
Compute partial derivative of an expression.
ex expand(unsigned options=0) const
static basic & construct_from_double(double d)
ptr< basic > bp
pointer to basic object managed by this
ex & let_op(size_t i)
Return modifiable operand/member at position i.
bool is_zero_matrix() const
Check whether expression is zero or zero matrix.
static basic & construct_from_ulong(unsigned long i)
void share(const ex &other) const
Share equal objects between expressions.
static basic & construct_from_long(long i)
ex subs(const exmap &m, unsigned options=0) const
bool info(unsigned inf) const
ex lhs() const
Left hand side of relational expression.
void print(const print_context &c, unsigned level=0) const
Print expression to stream.
void dbgprinttree() const
Little wrapper arount printtree to be called within a debugger.
ex rhs() const
Right hand side of relational expression.
void dbgprint() const
Little wrapper arount print to be called within a debugger.
void traverse_postorder(visitor &v) const
Traverse expression tree with given visitor, postorder traversal.
void makewriteable()
Make this ex writable (if more than one ex handle the same basic) by unlinking the object and creatin...
This class is a wrapper around CLN-numbers within the GiNaC class hierarchy.
Base class for print_contexts.
Class of (intrusively) reference-counted pointers that support copy-on-write semantics.
unsigned int get_refcount() const noexcept
@ expanded
.expand(0) has already done its job (other expand() options ignore this flag)
@ evaluated
.eval() has already done its job
@ dynallocated
heap-allocated (i.e. created by new if we want to be clever and bypass the stack,
@ not_shareable
don't share instances of this object between different expressions unless explicitly asked to (used b...
@ pattern_is_not_product
used internally by expairseq::subschildren()
@ pattern_is_product
used internally by expairseq::subschildren()
Degenerate base class for visitors.
Interface to GiNaC's light-weight expression handles.
Definition of GiNaC's lst.
Interface to symbolic matrices.
Interface to GiNaC's products of expressions.
std::map< ex, ex, ex_is_less > exmap
std::set< ex, ex_is_less > exset
const numeric * _num_10_p
const numeric * _num_11_p
const numeric * _num_12_p
Interface to GiNaC's non-commutative products of expressions.
Makes the interface to the underlying bignum package available.
Interface to GiNaC's symbolic exponentiation (basis^exponent).
Interface to relations between expressions.
Interface to several small and furry utilities needed within GiNaC but not of any interest to the use...