99 return bp->
match(pattern, repl_lst);
108 if (
match(pattern)) {
112 bool any_found =
false;
113 for (
size_t i=0; i<
nops(); i++)
114 if (
op(i).
find(pattern, found))
127 for (
auto its = ls.
begin(), itr =
lr.begin(); its != ls.
end(); ++its, ++itr) {
128 m.insert(std::make_pair(*its, *itr));
132 if (is_exactly_a<mul>(*its) || is_exactly_a<power>(*its))
151 const ex & s = e.
op(0);
152 m.insert(std::make_pair(s, e.
op(1)));
154 if (is_exactly_a<mul>(s) || is_exactly_a<power>(s))
166 for (
auto &
r : ex_to<lst>(e)) {
168 throw(std::invalid_argument(
"basic::subs(ex): argument must be a list of equations"));
169 const ex & s =
r.
op(0);
170 m.insert(std::make_pair(s,
r.
op(1)));
174 if (is_exactly_a<mul>(s) || is_exactly_a<power>(s))
183 throw(std::invalid_argument(
"ex::subs(ex): argument must be a relation_equal or a list"));
192 for (
size_t i = 0; i <
n; ++i)
200 for (
size_t i = 0; i <
n; ++i)
210 return bp->let_op(i);
228 if (!is_a<relational>(*
this))
229 throw std::runtime_error(
"ex::lhs(): not a relation");
236 if (!is_a<relational>(*
this))
237 throw std::runtime_error(
"ex::rhs(): not a relation");
244 if (is_a<lst>(vars)) {
245 const lst & varlst = ex_to<lst>(vars);
246 for (
auto & it : varlst)
247 if (!
bp->is_polynomial(it))
252 return bp->is_polynomial(vars);
262 return is_a<matrix>(e) && ex_to<matrix>(e).is_zero_matrix();
284 if (
bp->get_refcount() <= other.
bp->get_refcount())
310 const ex & tmpex = other.
eval();
405 return dynallocate<numeric>(i);
439 return dynallocate<numeric>(i);
497 return dynallocate<numeric>(i);
531 return dynallocate<numeric>(i);
537 if (i >= -12 && i <= 12) {
540 return dynallocate<numeric>(i);
549 return dynallocate<numeric>(i);
555 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.
const basic & setflag(unsigned f) const
Set some status_flags.
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...