22#ifndef GINAC_CONTAINER_H
23#define GINAC_CONTAINER_H
41template <
template <
class T,
class = std::allocator<T>>
class C>
71template <
template <
class T,
class = std::allocator<T>>
class C>
101 container(exvector::const_iterator b, exvector::const_iterator e)
115 bool info(
unsigned inf)
const override {
return inherited::info(inf); }
117 size_t nops()
const override {
return this->
seq.size(); }
118 ex op(
size_t i)
const override;
124 inherited::read_archive(n, sym_lst);
128 this->
reserve(this->
seq, range.end - range.begin);
132 this->
seq.emplace_back(e);
139 inherited::archive(n);
140 for (
auto & i : this->
seq) {
148 STLT *newcont =
nullptr;
151 newcont->push_back(i->conjugate());
154 ex x = i->conjugate();
161 newcont->push_back(*j);
163 newcont->push_back(x);
180 cont.push_back(i->real_part());
191 cont.push_back(i->imag_part());
208 char closebracket,
unsigned this_precedence,
209 unsigned upper_precedence = 0)
const;
213 void sort_(std::random_access_iterator_tag)
225 typename STLT::iterator p = std::unique(this->
seq.begin(), this->seq.end(),
ex_is_equal());
226 this->
seq.erase(p, this->
seq.end());
252template <
template <
class T,
class = std::allocator<T>>
class C>
255 setflag(get_default_flags());
258template <
template <
class T,
class = std::allocator<T>>
class C>
265template <
template <
class T,
class = std::allocator<T>>
class C>
268 c.
s << std::string(level,
' ') << class_name() <<
" @" <<
this
269 << std::hex <<
", hash=0x" <<
hashvalue <<
", flags=0x" <<
flags << std::dec
270 <<
", nops=" <<
nops()
277 c.
s << std::string(level + c.
delta_indent,
' ') <<
"=====" << std::endl;
280template <
template <
class T,
class = std::allocator<T>>
class C>
286template <
template <
class T,
class = std::allocator<T>>
class C>
293template <
template <
class T,
class = std::allocator<T>>
class C>
303template <
template <
class T,
class = std::allocator<T>>
class C>
309 typename STLT::iterator it = this->
seq.begin();
314template <
template <
class T,
class = std::allocator<T>>
class C>
326 if (!subsed.empty()) {
341template <
template <
class T,
class = std::allocator<T>>
class C>
348 it2 = o.
seq.begin(), it2end = o.
seq.end();
350 while (it1 != it1end && it2 != it2end) {
351 int cmpval = it1->compare(*it2);
357 return (it1 == it1end) ? (it2 == it2end ? 0 : -1) : 1;
360template <
template <
class T,
class = std::allocator<T>>
class C>
366 if (this->
seq.size() != o.
seq.size())
370 while (it1 != it1end) {
371 if (!it1->is_equal(*it2))
380template <
template <
class T,
class = std::allocator<T>>
class C>
384 this->
seq.push_front(b);
389template <
template <
class T,
class = std::allocator<T>>
class C>
393 this->
seq.push_back(b);
398template <
template <
class T,
class = std::allocator<T>>
class C>
402 this->
seq.pop_front();
407template <
template <
class T,
class = std::allocator<T>>
class C>
411 this->
seq.pop_back();
416template <
template <
class T,
class = std::allocator<T>>
class C>
425template <
template <
class T,
class = std::allocator<T>>
class C>
429 sort_(
typename std::iterator_traits<typename STLT::iterator>::iterator_category());
440template <
template <
class T,
class = std::allocator<T>>
class C>
449template <
template <
class T,
class = std::allocator<T>>
class C>
451 char closebracket,
unsigned this_precedence,
452 unsigned upper_precedence)
const
454 if (this_precedence <= upper_precedence)
457 if (!this->
seq.empty()) {
460 while (it != itend) {
461 it->print(c, this_precedence);
465 it->print(c, this_precedence);
468 if (this_precedence <= upper_precedence)
472template <
template <
class T,
class = std::allocator<T>>
class C>
480 const ex & subsed_ex = cit->subs(m, options);
484 STLT s(this->
seq.begin(), cit);
488 s.push_back(subsed_ex);
493 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.