93 return bp->diff(s, nth);
100 return bp->match(pattern, repl_lst);
109 if (
match(pattern)) {
113 bool any_found =
false;
114 for (
size_t i=0; i<
nops(); i++)
115 if (
op(i).
find(pattern, found))
128 for (
auto its = ls.
begin(), itr =
lr.begin(); its != ls.
end(); ++its, ++itr) {
129 m.insert(std::make_pair(*its, *itr));
133 if (is_exactly_a<mul>(*its) || is_exactly_a<power>(*its))
152 const ex & s = e.
op(0);
153 m.insert(std::make_pair(s, e.
op(1)));
155 if (is_exactly_a<mul>(s) || is_exactly_a<power>(s))
167 for (
auto &
r : ex_to<lst>(e)) {
169 throw(std::invalid_argument(
"basic::subs(ex): argument must be a list of equations"));
170 const ex & s =
r.op(0);
171 m.insert(std::make_pair(s,
r.op(1)));
175 if (is_exactly_a<mul>(s) || is_exactly_a<power>(s))
184 throw(std::invalid_argument(
"ex::subs(ex): argument must be a relation_equal or a list"));
193 for (
size_t i = 0; i <
n; ++i)
201 for (
size_t i = 0; i <
n; ++i)
211 return bp->let_op(i);
229 if (!is_a<relational>(*
this))
230 throw std::runtime_error(
"ex::lhs(): not a relation");
237 if (!is_a<relational>(*
this))
238 throw std::runtime_error(
"ex::rhs(): not a relation");
245 if (is_a<lst>(vars)) {
246 const lst & varlst = ex_to<lst>(vars);
247 for (
auto & it : varlst)
248 if (!
bp->is_polynomial(it))
253 return bp->is_polynomial(vars);
263 return is_a<matrix>(e) && ex_to<matrix>(e).is_zero_matrix();
285 if (
bp->get_refcount() <= other.
bp->get_refcount())
311 const ex & tmpex = other.
eval();
406 return dynallocate<numeric>(i);
440 return dynallocate<numeric>(i);
498 return dynallocate<numeric>(i);
532 return dynallocate<numeric>(i);
538 if (i >= -12 && i <= 12) {
541 return dynallocate<numeric>(i);
550 return dynallocate<numeric>(i);
556 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
Expand an expression.
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...