23#ifndef GINAC_CONTAINER_H
24#define GINAC_CONTAINER_H
42template <
template <
class T,
class = std::allocator<T>>
class C>
72template <
template <
class T,
class = std::allocator<T>>
class C>
102 container(exvector::const_iterator b, exvector::const_iterator e)
116 bool info(
unsigned inf)
const override {
return inherited::info(inf); }
118 size_t nops()
const override {
return this->
seq.size(); }
119 ex op(
size_t i)
const override;
125 inherited::read_archive(n, sym_lst);
129 this->
reserve(this->
seq, range.end - range.begin);
133 this->
seq.emplace_back(e);
140 inherited::archive(n);
141 for (
auto & i : this->
seq) {
149 STLT *newcont =
nullptr;
152 newcont->push_back(i->conjugate());
155 ex x = i->conjugate();
162 newcont->push_back(*j);
164 newcont->push_back(x);
181 cont.push_back(i->real_part());
192 cont.push_back(i->imag_part());
209 char closebracket,
unsigned this_precedence,
210 unsigned upper_precedence = 0)
const;
214 void sort_(std::random_access_iterator_tag)
226 typename STLT::iterator p = std::unique(this->
seq.begin(), this->seq.end(),
ex_is_equal());
227 this->
seq.erase(p, this->
seq.end());
253template <
template <
class T,
class = std::allocator<T>>
class C>
256 setflag(get_default_flags());
259template <
template <
class T,
class = std::allocator<T>>
class C>
266template <
template <
class T,
class = std::allocator<T>>
class C>
269 c.
s << std::string(level,
' ') << class_name() <<
" @" <<
this
270 << std::hex <<
", hash=0x" <<
hashvalue <<
", flags=0x" <<
flags << std::dec
271 <<
", nops=" <<
nops()
278 c.
s << std::string(level + c.
delta_indent,
' ') <<
"=====" << std::endl;
281template <
template <
class T,
class = std::allocator<T>>
class C>
287template <
template <
class T,
class = std::allocator<T>>
class C>
294template <
template <
class T,
class = std::allocator<T>>
class C>
304template <
template <
class T,
class = std::allocator<T>>
class C>
310 typename STLT::iterator it = this->
seq.begin();
315template <
template <
class T,
class = std::allocator<T>>
class C>
327 if (!subsed.empty()) {
342template <
template <
class T,
class = std::allocator<T>>
class C>
349 it2 = o.
seq.begin(), it2end = o.
seq.end();
351 while (it1 != it1end && it2 != it2end) {
352 int cmpval = it1->compare(*it2);
358 return (it1 == it1end) ? (it2 == it2end ? 0 : -1) : 1;
361template <
template <
class T,
class = std::allocator<T>>
class C>
367 if (this->
seq.size() != o.
seq.size())
371 while (it1 != it1end) {
372 if (!it1->is_equal(*it2))
381template <
template <
class T,
class = std::allocator<T>>
class C>
385 this->
seq.push_front(b);
390template <
template <
class T,
class = std::allocator<T>>
class C>
394 this->
seq.push_back(b);
399template <
template <
class T,
class = std::allocator<T>>
class C>
403 this->
seq.pop_front();
408template <
template <
class T,
class = std::allocator<T>>
class C>
412 this->
seq.pop_back();
417template <
template <
class T,
class = std::allocator<T>>
class C>
426template <
template <
class T,
class = std::allocator<T>>
class C>
430 sort_(
typename std::iterator_traits<typename STLT::iterator>::iterator_category());
441template <
template <
class T,
class = std::allocator<T>>
class C>
450template <
template <
class T,
class = std::allocator<T>>
class C>
452 char closebracket,
unsigned this_precedence,
453 unsigned upper_precedence)
const
455 if (this_precedence <= upper_precedence)
458 if (!this->
seq.empty()) {
461 while (it != itend) {
462 it->print(c, this_precedence);
466 it->print(c, this_precedence);
469 if (this_precedence <= upper_precedence)
473template <
template <
class T,
class = std::allocator<T>>
class C>
481 const ex & subsed_ex = cit->subs(m, options);
485 STLT s(this->
seq.begin(), cit);
489 s.push_back(subsed_ex);
494 s.push_back(cit->subs(m, options));
Archiving of GiNaC expressions.
Assertion macro definition.
#define GINAC_ASSERT(X)
Assertion macro for checking invariances.
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
void find_ex_by_loc(archive_node_cit loc, ex &ret, lst &sym_lst) const
Retrieve property of type "ex" from the node if it is known that this node in fact contains such a pr...
std::vector< property >::const_iterator archive_node_cit
void add_ex(const std::string &name, const ex &value)
Add property of type "ex" to node.
archive_node_cit_range find_property_range(const std::string &name1, const std::string &name2) const
Find a range of locations in the vector of properties.
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
const basic & setflag(unsigned f) const
Set some status_flags.
unsigned hashvalue
hash value
void ensure_if_modifiable() const
Ensure the object may be modified without hurting others, throws if this is not the case.
unsigned flags
of type status_flags
ex subs_one_level(const exmap &m, unsigned options) const
Helper function for subs().
virtual int compare_same_type(const basic &other) const
Returns order relation between two objects of same type.
container_storage(In b, In e)
static void reserve(STLT &, size_t)
container_storage(std::initializer_list< ex > il)
container_storage(size_t n, const ex &e)
Wrapper template for making GiNaC classes out of STL containers.
const_reverse_iterator rend() const
static char get_open_delim()
container(exvector::const_iterator b, exvector::const_iterator e)
STLT subschildren(const exmap &m, unsigned options=0) const
container(std::initializer_list< ex > il)
ex real_part() const override
const_reverse_iterator rbegin() const
bool is_equal_same_type(const basic &other) const override
Returns true if two objects of same type are equal.
static char get_close_delim()
virtual void printseq(const print_context &c, char openbracket, char delim, char closebracket, unsigned this_precedence, unsigned upper_precedence=0) const
Print sequence of contained elements.
const_iterator end() const
container & prepend(const ex &b)
Add element at front.
STLT::const_iterator const_iterator
ex conjugate() const override
void read_archive(const archive_node &n, lst &sym_lst) override
Load (deserialize) the object from an archive node.
const_iterator begin() const
void archive(archive_node &n) const override
Archive the object.
bool info(unsigned inf) const override
Information about the object.
size_t nops() const override
Number of operands/members.
void do_print_python_repr(const print_python_repr &c, unsigned level) const
container & remove_last()
Remove last element.
virtual ex thiscontainer(STLT &&v) const
Similar to duplicate(), but with a preset sequence (which gets pilfered).
STLT::const_reverse_iterator const_reverse_iterator
void sort_(std::random_access_iterator_tag)
container_storage< C >::STLT STLT
ex op(size_t i) const override
Return operand/member at position i.
container & sort()
Sort elements.
void sort_(std::input_iterator_tag)
unsigned precedence() const override
Return relative operator precedence (for parenthezing output).
container & unique()
Remove adjacent duplicate elements.
void do_print(const print_context &c, unsigned level) const
container & remove_all()
Remove all elements.
ex subs(const exmap &m, unsigned options=0) const override
Substitute a set of objects by arbitrary expressions.
static unsigned get_default_flags()
ex & let_op(size_t i) override
Return modifiable operand/member at position i.
container & remove_first()
Remove first element.
virtual ex thiscontainer(const STLT &v) const
Similar to duplicate(), but with a preset sequence.
void do_print_tree(const print_tree &c, unsigned level) const
container & append(const ex &b)
Add element at back.
void do_print_python(const print_python &c, unsigned level) const
ex imag_part() const override
Lightweight wrapper for GiNaC's symbolic objects.
Base class for print_contexts.
std::ostream & s
stream to output to
Context for python-parsable output.
Context for python pretty-print output.
Context for tree-like output for debugging.
const unsigned delta_indent
size of indentation step
Definition of optimizing macros.
Interface to GiNaC's light-weight expression handles.
container< std::list > lst
std::map< ex, ex, ex_is_less > exmap
bool are_ex_trivially_equal(const ex &e1, const ex &e2)
Compare two objects of class quickly without doing a deep tree traversal.
attribute_pure const T & ex_to(const ex &e)
Return a reference to the basic-derived class T object embedded in an expression.
bool is_a(const basic &obj)
Check if obj is a T, including base classes.
size_t nops(const ex &thisex)
Definition of helper classes for expression output.
#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the declaration of each registered class.