GiNaC 1.8.7
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Private Member Functions | List of all members
GiNaC::container< C > Class Template Reference

Wrapper template for making GiNaC classes out of STL containers. More...

#include <container.h>

Inheritance diagram for GiNaC::container< C >:
GiNaC::basic GiNaC::container_storage< C > GiNaC::refcounted GiNaC::function GiNaC::indexed GiNaC::ncmul GiNaC::fderivative GiNaC::clifford GiNaC::color

Public Types

typedef STLT::const_iterator const_iterator
 
typedef STLT::const_reverse_iterator const_reverse_iterator
 

Public Member Functions

 container (STLT const &s)
 
 container (STLT &&v)
 
 container (exvector::const_iterator b, exvector::const_iterator e)
 
 container (std::initializer_list< ex > il)
 
bool info (unsigned inf) const override
 Information about the object. More...
 
unsigned precedence () const override
 Return relative operator precedence (for parenthezing output). More...
 
size_t nops () const override
 Number of operands/members. More...
 
ex op (size_t i) const override
 Return operand/member at position i. More...
 
exlet_op (size_t i) override
 Return modifiable operand/member at position i. More...
 
ex subs (const exmap &m, unsigned options=0) const override
 Substitute a set of objects by arbitrary expressions. More...
 
void read_archive (const archive_node &n, lst &sym_lst) override
 Load (deserialize) the object from an archive node. More...
 
void archive (archive_node &n) const override
 Archive the object. More...
 
containerprepend (const ex &b)
 Add element at front. More...
 
containerappend (const ex &b)
 Add element at back. More...
 
containerremove_first ()
 Remove first element. More...
 
containerremove_last ()
 Remove last element. More...
 
containerremove_all ()
 Remove all elements. More...
 
containersort ()
 Sort elements. More...
 
containerunique ()
 Remove adjacent duplicate elements. More...
 
const_iterator begin () const
 
const_iterator end () const
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
- Public Member Functions inherited from GiNaC::basic
virtual ~basic ()
 basic destructor, virtual because class ex will delete objects of derived classes via a basic*. More...
 
 basic (const basic &other)
 
const basicoperator= (const basic &other)
 basic assignment operator: the other object might be of a derived class. More...
 
virtual basicduplicate () const
 Create a clone of this object on the heap. More...
 
virtual ex eval () const
 Perform automatic non-interruptive term rewriting rules. More...
 
virtual ex evalf () const
 Evaluate object numerically. More...
 
virtual ex evalm () const
 Evaluate sums, products and integer powers of matrices. More...
 
virtual ex eval_integ () const
 Evaluate integrals, if result is known. More...
 
virtual ex eval_indexed (const basic &i) const
 Perform automatic symbolic evaluations on indexed expression that contains this object as the base expression. More...
 
virtual void print (const print_context &c, unsigned level=0) const
 Output to stream. More...
 
virtual void dbgprint () const
 Little wrapper around print to be called within a debugger. More...
 
virtual void dbgprinttree () const
 Little wrapper around printtree to be called within a debugger. More...
 
virtual unsigned precedence () const
 Return relative operator precedence (for parenthezing output). More...
 
virtual bool info (unsigned inf) const
 Information about the object. More...
 
virtual size_t nops () const
 Number of operands/members. More...
 
virtual ex op (size_t i) const
 Return operand/member at position i. More...
 
virtual ex operator[] (const ex &index) const
 
virtual ex operator[] (size_t i) const
 
virtual exlet_op (size_t i)
 Return modifiable operand/member at position i. More...
 
virtual exoperator[] (const ex &index)
 
virtual exoperator[] (size_t i)
 
virtual bool has (const ex &other, unsigned options=0) const
 Test for occurrence of a pattern. More...
 
virtual bool match (const ex &pattern, exmap &repls) const
 Check whether the expression matches a given pattern. More...
 
virtual ex subs (const exmap &m, unsigned options=0) const
 Substitute a set of objects by arbitrary expressions. More...
 
virtual ex map (map_function &f) const
 Construct new expression by applying the specified function to all sub-expressions (one level only, not recursively). More...
 
virtual void accept (GiNaC::visitor &v) const
 
virtual bool is_polynomial (const ex &var) const
 Check whether this is a polynomial in the given variables. More...
 
virtual int degree (const ex &s) const
 Return degree of highest power in object s. More...
 
virtual int ldegree (const ex &s) const
 Return degree of lowest power in object s. More...
 
virtual ex coeff (const ex &s, int n=1) const
 Return coefficient of degree n in object s. More...
 
virtual ex expand (unsigned options=0) const
 Expand expression, i.e. More...
 
virtual ex collect (const ex &s, bool distributed=false) const
 Sort expanded expression in terms of powers of some object(s). More...
 
virtual ex series (const relational &r, int order, unsigned options=0) const
 Default implementation of ex::series(). More...
 
virtual ex normal (exmap &repl, exmap &rev_lookup, lst &modifier) const
 Default implementation of ex::normal(). More...
 
virtual ex to_rational (exmap &repl) const
 Default implementation of ex::to_rational(). More...
 
virtual ex to_polynomial (exmap &repl) const
 
virtual numeric integer_content () const
 
virtual ex smod (const numeric &xi) const
 Apply symmetric modular homomorphism to an expanded multivariate polynomial. More...
 
virtual numeric max_coefficient () const
 Implementation ex::max_coefficient(). More...
 
virtual exvector get_free_indices () const
 Return a vector containing the free indices of an expression. More...
 
virtual ex add_indexed (const ex &self, const ex &other) const
 Add two indexed expressions. More...
 
virtual ex scalar_mul_indexed (const ex &self, const numeric &other) const
 Multiply an indexed expression with a scalar. More...
 
virtual bool contract_with (exvector::iterator self, exvector::iterator other, exvector &v) const
 Try to contract two indexed expressions that appear in the same product. More...
 
virtual unsigned return_type () const
 
virtual return_type_t return_type_tinfo () const
 
virtual ex conjugate () const
 
virtual ex real_part () const
 
virtual ex imag_part () const
 
template<class T >
void print_dispatch (const print_context &c, unsigned level) const
 Like print(), but dispatch to the specified class. More...
 
void print_dispatch (const registered_class_info &ri, const print_context &c, unsigned level) const
 Like print(), but dispatch to the specified class. More...
 
virtual void archive (archive_node &n) const
 Save (serialize) the object into archive node. More...
 
virtual void read_archive (const archive_node &n, lst &syms)
 Load (deserialize) the object from an archive node. More...
 
ex subs_one_level (const exmap &m, unsigned options) const
 Helper function for subs(). More...
 
ex diff (const symbol &s, unsigned nth=1) const
 Default interface of nth derivative ex::diff(s, n). More...
 
int compare (const basic &other) const
 Compare objects syntactically to establish canonical ordering. More...
 
bool is_equal (const basic &other) const
 Test for syntactic equality. More...
 
const basichold () const
 Stop further evaluation. More...
 
unsigned gethash () const
 
const basicsetflag (unsigned f) const
 Set some status_flags. More...
 
const basicclearflag (unsigned f) const
 Clear some status_flags. More...
 
- Public Member Functions inherited from GiNaC::refcounted
 refcounted () noexcept
 
unsigned int add_reference () noexcept
 
unsigned int remove_reference () noexcept
 
unsigned int get_refcount () const noexcept
 
void set_refcount (unsigned int r) noexcept
 

Protected Types

typedef container_storage< C >::STLT STLT
 
- Protected Types inherited from GiNaC::container_storage< C >
typedef C< exSTLT
 

Protected Member Functions

ex conjugate () const override
 
ex real_part () const override
 
ex imag_part () const override
 
bool is_equal_same_type (const basic &other) const override
 Returns true if two objects of same type are equal. More...
 
virtual ex thiscontainer (const STLT &v) const
 Similar to duplicate(), but with a preset sequence. More...
 
virtual ex thiscontainer (STLT &&v) const
 Similar to duplicate(), but with a preset sequence (which gets pilfered). More...
 
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. More...
 
void do_print (const print_context &c, unsigned level) const
 
void do_print_tree (const print_tree &c, unsigned level) const
 
void do_print_python (const print_python &c, unsigned level) const
 
void do_print_python_repr (const print_python_repr &c, unsigned level) const
 
STLT subschildren (const exmap &m, unsigned options=0) const
 
- Protected Member Functions inherited from GiNaC::basic
 basic ()
 
virtual ex eval_ncmul (const exvector &v) const
 
virtual bool match_same_type (const basic &other) const
 Returns true if the attributes of two objects are similar enough for a match. More...
 
virtual ex derivative (const symbol &s) const
 Default implementation of ex::diff(). More...
 
virtual int compare_same_type (const basic &other) const
 Returns order relation between two objects of same type. More...
 
virtual bool is_equal_same_type (const basic &other) const
 Returns true if two objects of same type are equal. More...
 
virtual unsigned calchash () const
 Compute the hash value of an object and if it makes sense to store it in the objects status_flags, do so. More...
 
void ensure_if_modifiable () const
 Ensure the object may be modified without hurting others, throws if this is not the case. More...
 
void do_print (const print_context &c, unsigned level) const
 Default output to stream. More...
 
void do_print_tree (const print_tree &c, unsigned level) const
 Tree output to stream. More...
 
void do_print_python_repr (const print_python_repr &c, unsigned level) const
 Python parsable output to stream. More...
 
- Protected Member Functions inherited from GiNaC::container_storage< C >
 container_storage ()
 
 container_storage (size_t n, const ex &e)
 
 container_storage (std::initializer_list< ex > il)
 
template<class In >
 container_storage (In b, In e)
 
void reserve (size_t)
 
 ~container_storage ()
 
void reserve (size_t n)
 
void reserve (std::vector< ex > &v, size_t n)
 

Static Protected Member Functions

static unsigned get_default_flags ()
 Specialization of container::get_default_flags() for lst. More...
 
static char get_open_delim ()
 Specialization of container::get_open_delim() for lst. More...
 
static char get_close_delim ()
 Specialization of container::get_close_delim() for lst. More...
 
- Static Protected Member Functions inherited from GiNaC::container_storage< C >
static void reserve (STLT &, size_t)
 

Private Member Functions

void sort_ (std::random_access_iterator_tag)
 
void sort_ (std::input_iterator_tag)
 
void unique_ ()
 
void unique_ ()
 Specialization of container::unique_() for std::list. More...
 

Additional Inherited Members

- Protected Attributes inherited from GiNaC::basic
unsigned flags
 of type status_flags More...
 
unsigned hashvalue
 hash value More...
 
- Protected Attributes inherited from GiNaC::container_storage< C >
STLT seq
 

Detailed Description

template<template< class T, class=std::allocator< T > > class C>
class GiNaC::container< C >

Wrapper template for making GiNaC classes out of STL containers.

Definition at line 73 of file container.h.

Member Typedef Documentation

◆ STLT

template<template< class T, class=std::allocator< T > > class C>
typedef container_storage<C>::STLT GiNaC::container< C >::STLT
protected

Definition at line 76 of file container.h.

◆ const_iterator

template<template< class T, class=std::allocator< T > > class C>
typedef STLT::const_iterator GiNaC::container< C >::const_iterator

Definition at line 79 of file container.h.

◆ const_reverse_iterator

template<template< class T, class=std::allocator< T > > class C>
typedef STLT::const_reverse_iterator GiNaC::container< C >::const_reverse_iterator

Definition at line 80 of file container.h.

Constructor & Destructor Documentation

◆ container() [1/4]

template<template< class T, class=std::allocator< T > > class C>
GiNaC::container< C >::container ( STLT const &  s)
inline

◆ container() [2/4]

template<template< class T, class=std::allocator< T > > class C>
GiNaC::container< C >::container ( STLT &&  v)
inlineexplicit

◆ container() [3/4]

template<template< class T, class=std::allocator< T > > class C>
GiNaC::container< C >::container ( exvector::const_iterator  b,
exvector::const_iterator  e 
)
inline

◆ container() [4/4]

template<template< class T, class=std::allocator< T > > class C>
GiNaC::container< C >::container ( std::initializer_list< ex il)
inline

Member Function Documentation

◆ get_default_flags()

unsigned GiNaC::lst::get_default_flags
inlinestaticprotected

Specialization of container::get_default_flags() for lst.

Definition at line 84 of file container.h.

Referenced by GiNaC::container< C >::container(), and GiNaC::container< C >::read_archive().

◆ get_open_delim()

char GiNaC::lst::get_open_delim
inlinestaticprotected

Specialization of container::get_open_delim() for lst.

Definition at line 85 of file container.h.

◆ get_close_delim()

char GiNaC::lst::get_close_delim
inlinestaticprotected

Specialization of container::get_close_delim() for lst.

Definition at line 86 of file container.h.

◆ info()

template bool GiNaC::container< C >::info ( unsigned  inf) const
inlineoverridevirtual

Information about the object.

See also
class info_flags

Reimplemented from GiNaC::basic.

Reimplemented in GiNaC::function, GiNaC::indexed, and GiNaC::ncmul.

Definition at line 116 of file container.h.

◆ precedence()

template<template< class T, class=std::allocator< T > > class C>
unsigned GiNaC::container< C >::precedence ( ) const
inlineoverridevirtual

Return relative operator precedence (for parenthezing output).

Reimplemented from GiNaC::basic.

Reimplemented in GiNaC::function, GiNaC::indexed, and GiNaC::ncmul.

Definition at line 117 of file container.h.

Referenced by GiNaC::fderivative::do_print(), GiNaC::fderivative::do_print_csrc(), GiNaC::fderivative::do_print_latex(), and GiNaC::function::print().

◆ nops()

template<template< class T, class=std::allocator< T > > class C>
size_t GiNaC::container< C >::nops ( ) const
inlineoverridevirtual

◆ op()

template<template< class T, class=std::allocator< T > > class C>
ex GiNaC::container< C >::op ( size_t  i) const
overridevirtual

◆ let_op()

template<template< class T, class=std::allocator< T > > class C>
ex & GiNaC::container< C >::let_op ( size_t  i)
overridevirtual

Return modifiable operand/member at position i.

Reimplemented from GiNaC::basic.

Definition at line 305 of file container.h.

References GINAC_ASSERT, and GiNaC::nops().

◆ subs()

template<template< class T, class=std::allocator< T > > class C>
ex GiNaC::container< C >::subs ( const exmap m,
unsigned  options = 0 
) const
overridevirtual

Substitute a set of objects by arbitrary expressions.

The ex returned will already be evaluated.

Reimplemented from GiNaC::basic.

Definition at line 316 of file container.h.

References GiNaC::is_a(), m, and options.

◆ read_archive()

template<template< class T, class=std::allocator< T > > class C>
void GiNaC::container< C >::read_archive ( const archive_node n,
lst syms 
)
inlineoverridevirtual

Load (deserialize) the object from an archive node.

Construct object from archive_node.

Note
This method is essentially a constructor. However, constructors can't be virtual. So, if unarchiving routines are implemented as constructors one would need to define such a constructor in every class, even if all it does is simply calling constructor of a superclass.

Reimplemented from GiNaC::basic.

Reimplemented in GiNaC::fderivative, GiNaC::function, and GiNaC::indexed.

Definition at line 123 of file container.h.

References GiNaC::container< C >::get_default_flags(), n, GiNaC::container_storage< C >::reserve(), GiNaC::container_storage< C >::seq, and GiNaC::basic::setflag().

◆ archive()

template<template< class T, class=std::allocator< T > > class C>
void GiNaC::container< C >::archive ( archive_node n) const
inlineoverridevirtual

Archive the object.

Reimplemented from GiNaC::basic.

Reimplemented in GiNaC::fderivative, GiNaC::function, and GiNaC::indexed.

Definition at line 138 of file container.h.

References GiNaC::archive_node::add_ex(), n, and GiNaC::container_storage< C >::seq.

◆ conjugate()

template<template< class T, class=std::allocator< T > > class C>
ex GiNaC::container< C >::conjugate ( ) const
inlineoverrideprotectedvirtual

◆ real_part()

template<template< class T, class=std::allocator< T > > class C>
ex GiNaC::container< C >::real_part ( ) const
inlineoverrideprotectedvirtual

◆ imag_part()

template<template< class T, class=std::allocator< T > > class C>
ex GiNaC::container< C >::imag_part ( ) const
inlineoverrideprotectedvirtual

◆ is_equal_same_type()

template<template< class T, class=std::allocator< T > > class C>
bool GiNaC::container< C >::is_equal_same_type ( const basic other) const
overrideprotectedvirtual

Returns true if two objects of same type are equal.

Normally needs not be reimplemented as long as it wasn't overwritten by some parent class, since it just calls compare_same_type(). The reason why this function exists is that sometimes it is easier to determine equality than an order relation and then it can be overridden.

Reimplemented from GiNaC::basic.

Reimplemented in GiNaC::fderivative, and GiNaC::function.

Definition at line 362 of file container.h.

References GINAC_ASSERT, and GiNaC::container_storage< C >::seq.

Referenced by GiNaC::function::is_equal_same_type().

◆ thiscontainer() [1/2]

template<template< class T, class=std::allocator< T > > class C>
virtual ex GiNaC::container< C >::thiscontainer ( const STLT v) const
inlineprotectedvirtual

Similar to duplicate(), but with a preset sequence.

Must be overridden by derived classes.

Definition at line 202 of file container.h.

References GiNaC::container< C >::container().

Referenced by GiNaC::container< C >::conjugate(), GiNaC::container< C >::imag_part(), and GiNaC::container< C >::real_part().

◆ thiscontainer() [2/2]

template<template< class T, class=std::allocator< T > > class C>
virtual ex GiNaC::container< C >::thiscontainer ( STLT &&  v) const
inlineprotectedvirtual

Similar to duplicate(), but with a preset sequence (which gets pilfered).

Must be overridden by derived classes.

Definition at line 206 of file container.h.

References GiNaC::container< C >::container().

◆ printseq()

template<template< class T, class=std::allocator< T > > class C>
void GiNaC::container< C >::printseq ( const print_context c,
char  openbracket,
char  delim,
char  closebracket,
unsigned  this_precedence,
unsigned  upper_precedence = 0 
) const
protectedvirtual

◆ sort_() [1/2]

template<template< class T, class=std::allocator< T > > class C>
void GiNaC::container< C >::sort_ ( std::random_access_iterator_tag  )
inlineprivate

Definition at line 214 of file container.h.

References GiNaC::container_storage< C >::seq.

◆ sort_() [2/2]

template<template< class T, class=std::allocator< T > > class C>
void GiNaC::container< C >::sort_ ( std::input_iterator_tag  )
inlineprivate

Definition at line 219 of file container.h.

References GiNaC::container_storage< C >::seq.

◆ unique_() [1/2]

template<template< class T, class=std::allocator< T > > class C>
void GiNaC::container< C >::unique_ ( )
inlineprivate

Definition at line 224 of file container.h.

References GiNaC::container_storage< C >::seq.

◆ prepend()

template<template< class T, class=std::allocator< T > > class C>
container< C > & GiNaC::container< C >::prepend ( const ex b)

Add element at front.

Definition at line 382 of file container.h.

◆ append()

template<template< class T, class=std::allocator< T > > class C>
container< C > & GiNaC::container< C >::append ( const ex b)

◆ remove_first()

template<template< class T, class=std::allocator< T > > class C>
container< C > & GiNaC::container< C >::remove_first

Remove first element.

Definition at line 400 of file container.h.

Referenced by GiNaC::sqrfree(), and GiNaC::symmetrize_cyclic().

◆ remove_last()

template<template< class T, class=std::allocator< T > > class C>
container< C > & GiNaC::container< C >::remove_last

Remove last element.

Definition at line 409 of file container.h.

◆ remove_all()

template<template< class T, class=std::allocator< T > > class C>
container< C > & GiNaC::container< C >::remove_all

Remove all elements.

Definition at line 418 of file container.h.

◆ sort()

template<template< class T, class=std::allocator< T > > class C>
container< C > & GiNaC::container< C >::sort

Sort elements.

Definition at line 427 of file container.h.

◆ unique()

template<template< class T, class=std::allocator< T > > class C>
container< C > & GiNaC::container< C >::unique

Remove adjacent duplicate elements.

Definition at line 442 of file container.h.

◆ begin()

template<template< class T, class=std::allocator< T > > class C>
const_iterator GiNaC::container< C >::begin ( ) const
inline

◆ end()

template<template< class T, class=std::allocator< T > > class C>
const_iterator GiNaC::container< C >::end ( ) const
inline

◆ rbegin()

template<template< class T, class=std::allocator< T > > class C>
const_reverse_iterator GiNaC::container< C >::rbegin ( ) const
inline

Definition at line 241 of file container.h.

References GiNaC::container_storage< C >::seq.

◆ rend()

template<template< class T, class=std::allocator< T > > class C>
const_reverse_iterator GiNaC::container< C >::rend ( ) const
inline

Definition at line 242 of file container.h.

References GiNaC::container_storage< C >::seq.

◆ do_print()

template<template< class T, class=std::allocator< T > > class C>
void GiNaC::container< C >::do_print ( const print_context c,
unsigned  level 
) const
protected

Definition at line 260 of file container.h.

References c.

◆ do_print_tree()

template<template< class T, class=std::allocator< T > > class C>
void GiNaC::container< C >::do_print_tree ( const print_tree c,
unsigned  level 
) const
protected

Definition at line 267 of file container.h.

References c, and GiNaC::nops().

◆ do_print_python()

template<template< class T, class=std::allocator< T > > class C>
void GiNaC::container< C >::do_print_python ( const print_python c,
unsigned  level 
) const
protected

Definition at line 282 of file container.h.

References c.

◆ do_print_python_repr()

template<template< class T, class=std::allocator< T > > class C>
void GiNaC::container< C >::do_print_python_repr ( const print_python_repr c,
unsigned  level 
) const
protected

Definition at line 288 of file container.h.

References c.

◆ subschildren()

template<template< class T, class=std::allocator< T > > class C>
container< C >::STLT GiNaC::container< C >::subschildren ( const exmap m,
unsigned  options = 0 
) const
protected

Definition at line 474 of file container.h.

References GiNaC::are_ex_trivially_equal(), m, options, and GiNaC::ex::subs().

◆ unique_() [2/2]

void GiNaC::container< std::list >::unique_ ( )
inlineprivate

Specialization of container::unique_() for std::list.

Definition at line 435 of file container.h.


The documentation for this class was generated from the following files:

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.