|
GiNaC
1.6.2
|
Wrapper template for making GiNaC classes out of C++ structures. More...
#include <structure.h>
Public Member Functions | |
| structure (const T &t) | |
| Construct structure as a copy of a given C++ structure. | |
| ex | eval (int level=0) const |
| Perform automatic non-interruptive term rewriting rules. | |
| ex | evalf (int level=0) const |
| Evaluate object numerically. | |
| ex | evalm () const |
| Evaluate sums, products and integer powers of matrices. | |
| ex | eval_indexed (const basic &i) const |
| Perform automatic symbolic evaluations on indexed expression that contains this object as the base expression. | |
| void | print (const print_context &c, unsigned level=0) const |
| Output to stream. | |
| unsigned | precedence () const |
| Return relative operator precedence (for parenthezing output). | |
| bool | info (unsigned inf) const |
| Information about the object. | |
| size_t | nops () const |
| Number of operands/members. | |
| ex | op (size_t i) const |
| Return operand/member at position i. | |
| ex | operator[] (const ex &index) const |
| ex | operator[] (size_t i) const |
| ex & | let_op (size_t i) |
| Return modifyable operand/member at position i. | |
| ex & | operator[] (const ex &index) |
| ex & | operator[] (size_t i) |
| bool | has (const ex &other, unsigned options=0) const |
| Test for occurrence of a pattern. | |
| bool | match (const ex &pattern, exmap &repl_lst) const |
| Check whether the expression matches a given pattern. | |
| ex | subs (const exmap &m, unsigned options=0) const |
| Substitute a set of objects by arbitrary expressions. | |
| ex | map (map_function &f) const |
| Construct new expression by applying the specified function to all sub-expressions (one level only, not recursively). | |
| int | degree (const ex &s) const |
| Return degree of highest power in object s. | |
| int | ldegree (const ex &s) const |
| Return degree of lowest power in object s. | |
| ex | coeff (const ex &s, int n=1) const |
| Return coefficient of degree n in object s. | |
| ex | expand (unsigned options=0) const |
| Expand expression, i.e. | |
| ex | collect (const ex &s, bool distributed=false) const |
| Sort expanded expression in terms of powers of some object(s). | |
| ex | series (const relational &r, int order, unsigned options=0) const |
| Default implementation of ex::series(). | |
| ex | normal (exmap &repl, exmap &rev_lookup, int level=0) const |
| Default implementation of ex::normal(). | |
| ex | to_rational (exmap &repl) const |
| Default implementation of ex::to_rational(). | |
| ex | to_polynomial (exmap &repl) const |
| numeric | integer_content () const |
| ex | smod (const numeric &xi) const |
| Apply symmetric modular homomorphism to an expanded multivariate polynomial. | |
| numeric | max_coefficient () const |
| Implementation ex::max_coefficient(). | |
| exvector | get_free_indices () const |
| Return a vector containing the free indices of an expression. | |
| ex | add_indexed (const ex &self, const ex &other) const |
| Add two indexed expressions. | |
| ex | scalar_mul_indexed (const ex &self, const numeric &other) const |
| Multiply an indexed expression with a scalar. | |
| bool | contract_with (exvector::iterator self, exvector::iterator other, exvector &v) const |
| Try to contract two indexed expressions that appear in the same product. | |
| unsigned | return_type () const |
| return_type_t | return_type_tinfo () const |
| const T * | operator-> () const |
| T & | get_struct () |
| const T & | get_struct () const |
Protected Member Functions | |
| ex | eval_ncmul (const exvector &v) const |
| bool | match_same_type (const basic &other) const |
| Returns true if the attributes of two objects are similar enough for a match. | |
| ex | derivative (const symbol &s) const |
| Default implementation of ex::diff(). | |
| bool | is_equal_same_type (const basic &other) const |
| Returns true if two objects of same type are equal. | |
| 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. | |
Static Private Member Functions | |
| static const char * | get_class_name () |
Private Attributes | |
| T | obj |
Wrapper template for making GiNaC classes out of C++ structures.
Definition at line 115 of file structure.h.
| GiNaC::structure< T, CP >::structure | ( | const T & | t | ) | [inline] |
Construct structure as a copy of a given C++ structure.
Default constructor.
Definition at line 123 of file structure.h.
| static const char* GiNaC::structure< T, ComparisonPolicy >::get_class_name | ( | ) | [inline, static, private] |
Definition at line 119 of file structure.h.
| ex GiNaC::structure< T, ComparisonPolicy >::eval | ( | int | level = 0 | ) | const [inline, virtual] |
Perform automatic non-interruptive term rewriting rules.
Reimplemented from GiNaC::basic.
Definition at line 129 of file structure.h.
References GiNaC::basic::hold().
| ex GiNaC::structure< T, ComparisonPolicy >::evalf | ( | int | level = 0 | ) | const [inline, virtual] |
Evaluate object numerically.
Reimplemented from GiNaC::basic.
Definition at line 130 of file structure.h.
| ex GiNaC::structure< T, ComparisonPolicy >::evalm | ( | ) | const [inline, virtual] |
Evaluate sums, products and integer powers of matrices.
Reimplemented from GiNaC::basic.
Definition at line 131 of file structure.h.
| ex GiNaC::structure< T, ComparisonPolicy >::eval_ncmul | ( | const exvector & | v | ) | const [inline, protected, virtual] |
Reimplemented from GiNaC::basic.
Definition at line 133 of file structure.h.
References GiNaC::hold_ncmul().
| ex GiNaC::structure< T, ComparisonPolicy >::eval_indexed | ( | const basic & | i | ) | const [inline, virtual] |
Perform automatic symbolic evaluations on indexed expression that contains this object as the base expression.
Reimplemented from GiNaC::basic.
Definition at line 135 of file structure.h.
References GiNaC::basic::hold().
| void GiNaC::structure< T, ComparisonPolicy >::print | ( | const print_context & | c, |
| unsigned | level = 0 |
||
| ) | const [inline, virtual] |
Output to stream.
This performs double dispatch on the dynamic type of *this and the dynamic type of the supplied print context.
| c | print context object that describes the output formatting |
| level | value that is used to identify the precedence or indentation level for placing parentheses and formatting |
Reimplemented from GiNaC::basic.
Definition at line 138 of file structure.h.
| unsigned GiNaC::structure< T, ComparisonPolicy >::precedence | ( | ) | const [inline, virtual] |
Return relative operator precedence (for parenthezing output).
Reimplemented from GiNaC::basic.
Definition at line 139 of file structure.h.
| bool GiNaC::structure< T, ComparisonPolicy >::info | ( | unsigned | inf | ) | const [inline, virtual] |
Information about the object.
Reimplemented from GiNaC::basic.
Definition at line 142 of file structure.h.
| size_t GiNaC::structure< T, ComparisonPolicy >::nops | ( | ) | const [inline, virtual] |
Number of operands/members.
Reimplemented from GiNaC::basic.
Definition at line 145 of file structure.h.
| ex GiNaC::structure< T, ComparisonPolicy >::op | ( | size_t | i | ) | const [inline, virtual] |
Return operand/member at position i.
Reimplemented from GiNaC::basic.
Definition at line 146 of file structure.h.
| ex GiNaC::structure< T, ComparisonPolicy >::operator[] | ( | const ex & | index | ) | const [inline, virtual] |
Reimplemented from GiNaC::basic.
Definition at line 147 of file structure.h.
Referenced by GiNaC::structure< T, ComparisonPolicy >::operator[]().
| ex GiNaC::structure< T, ComparisonPolicy >::operator[] | ( | size_t | i | ) | const [inline, virtual] |
Reimplemented from GiNaC::basic.
Definition at line 148 of file structure.h.
References GiNaC::structure< T, ComparisonPolicy >::operator[]().
| ex& GiNaC::structure< T, ComparisonPolicy >::let_op | ( | size_t | i | ) | [inline, virtual] |
Return modifyable operand/member at position i.
Reimplemented from GiNaC::basic.
Definition at line 149 of file structure.h.
| ex& GiNaC::structure< T, ComparisonPolicy >::operator[] | ( | const ex & | index | ) | [inline, virtual] |
Reimplemented from GiNaC::basic.
Definition at line 150 of file structure.h.
References GiNaC::structure< T, ComparisonPolicy >::operator[]().
| ex& GiNaC::structure< T, ComparisonPolicy >::operator[] | ( | size_t | i | ) | [inline, virtual] |
Reimplemented from GiNaC::basic.
Definition at line 151 of file structure.h.
References GiNaC::structure< T, ComparisonPolicy >::operator[]().
| bool GiNaC::structure< T, ComparisonPolicy >::has | ( | const ex & | pattern, |
| unsigned | options = 0 |
||
| ) | const [inline, virtual] |
Test for occurrence of a pattern.
An object 'has' a pattern if it matches the pattern itself or one of the children 'has' it. As a consequence (according to the definition of children) given e=x+y+z, e.has(x) is true but e.has(x+y) is false.
Reimplemented from GiNaC::basic.
Definition at line 154 of file structure.h.
References options.
| bool GiNaC::structure< T, ComparisonPolicy >::match | ( | const ex & | pattern, |
| exmap & | repl_lst | ||
| ) | const [inline, virtual] |
Check whether the expression matches a given pattern.
For every wildcard object in the pattern, a pair with the wildcard as a key and matching expression as a value is added to repl_lst.
Reimplemented from GiNaC::basic.
Definition at line 155 of file structure.h.
| bool GiNaC::structure< T, ComparisonPolicy >::match_same_type | ( | const basic & | other | ) | const [inline, protected, virtual] |
Returns true if the attributes of two objects are similar enough for a match.
This function must not match subexpressions (this is already done by basic::match()). Only attributes not accessible by op() should be compared. This is also the reason why this function doesn't take the wildcard replacement list from match() as an argument: only subexpressions are subject to wildcard matches. Also, this function only needs to be implemented for container classes because is_equal_same_type() is automatically used instead of match_same_type() if nops() == 0.
Reimplemented from GiNaC::basic.
Definition at line 157 of file structure.h.
| ex GiNaC::structure< T, ComparisonPolicy >::subs | ( | const exmap & | m, |
| unsigned | options = 0 |
||
| ) | const [inline, virtual] |
Substitute a set of objects by arbitrary expressions.
The ex returned will already be evaluated.
Reimplemented from GiNaC::basic.
Definition at line 161 of file structure.h.
References options.
| ex GiNaC::structure< T, ComparisonPolicy >::map | ( | map_function & | f | ) | const [inline, virtual] |
Construct new expression by applying the specified function to all sub-expressions (one level only, not recursively).
Reimplemented from GiNaC::basic.
Definition at line 164 of file structure.h.
| int GiNaC::structure< T, ComparisonPolicy >::degree | ( | const ex & | s | ) | const [inline, virtual] |
Return degree of highest power in object s.
Reimplemented from GiNaC::basic.
Definition at line 167 of file structure.h.
| int GiNaC::structure< T, ComparisonPolicy >::ldegree | ( | const ex & | s | ) | const [inline, virtual] |
Return degree of lowest power in object s.
Reimplemented from GiNaC::basic.
Definition at line 168 of file structure.h.
| ex GiNaC::structure< T, ComparisonPolicy >::coeff | ( | const ex & | s, |
| int | n = 1 |
||
| ) | const [inline, virtual] |
Return coefficient of degree n in object s.
Reimplemented from GiNaC::basic.
Definition at line 169 of file structure.h.
References n.
| ex GiNaC::structure< T, ComparisonPolicy >::expand | ( | unsigned | options = 0 | ) | const [inline, virtual] |
Expand expression, i.e.
multiply it out and return the result as a new expression.
Reimplemented from GiNaC::basic.
Definition at line 172 of file structure.h.
References options.
| ex GiNaC::structure< T, ComparisonPolicy >::collect | ( | const ex & | s, |
| bool | distributed = false |
||
| ) | const [inline, virtual] |
Sort expanded expression in terms of powers of some object(s).
| s | object(s) to sort in |
| distributed | recursive or distributed form (only used when s is a list) |
Reimplemented from GiNaC::basic.
Definition at line 173 of file structure.h.
| ex GiNaC::structure< T, ComparisonPolicy >::derivative | ( | const symbol & | s | ) | const [inline, protected, virtual] |
Default implementation of ex::diff().
It maps the operation on the operands (or returns 0 when the object has no operands).
Reimplemented from GiNaC::basic.
Definition at line 177 of file structure.h.
| ex GiNaC::structure< T, ComparisonPolicy >::series | ( | const relational & | r, |
| int | order, | ||
| unsigned | options = 0 |
||
| ) | const [inline, virtual] |
Default implementation of ex::series().
This performs Taylor expansion.
Reimplemented from GiNaC::basic.
Definition at line 179 of file structure.h.
References options.
| ex GiNaC::structure< T, ComparisonPolicy >::normal | ( | exmap & | repl, |
| exmap & | rev_lookup, | ||
| int | level = 0 |
||
| ) | const [inline, virtual] |
Default implementation of ex::normal().
It normalizes the children and replaces the object with a temporary symbol.
Reimplemented from GiNaC::basic.
Definition at line 182 of file structure.h.
| ex GiNaC::structure< T, ComparisonPolicy >::to_rational | ( | exmap & | repl | ) | const [inline, virtual] |
Default implementation of ex::to_rational().
This replaces the object with a temporary symbol.
Reimplemented from GiNaC::basic.
Definition at line 183 of file structure.h.
| ex GiNaC::structure< T, ComparisonPolicy >::to_polynomial | ( | exmap & | repl | ) | const [inline, virtual] |
Reimplemented from GiNaC::basic.
Definition at line 184 of file structure.h.
| numeric GiNaC::structure< T, ComparisonPolicy >::integer_content | ( | ) | const [inline, virtual] |
Reimplemented from GiNaC::basic.
Definition at line 187 of file structure.h.
| ex GiNaC::structure< T, ComparisonPolicy >::smod | ( | const numeric & | xi | ) | const [inline, virtual] |
Apply symmetric modular homomorphism to an expanded multivariate polynomial.
This function is usually used internally by heur_gcd().
| xi | modulus |
Reimplemented from GiNaC::basic.
Definition at line 188 of file structure.h.
| numeric GiNaC::structure< T, ComparisonPolicy >::max_coefficient | ( | ) | const [inline, virtual] |
Implementation ex::max_coefficient().
Reimplemented from GiNaC::basic.
Definition at line 189 of file structure.h.
| exvector GiNaC::structure< T, ComparisonPolicy >::get_free_indices | ( | ) | const [inline, virtual] |
Return a vector containing the free indices of an expression.
Reimplemented from GiNaC::basic.
Definition at line 192 of file structure.h.
| ex GiNaC::structure< T, ComparisonPolicy >::add_indexed | ( | const ex & | self, |
| const ex & | other | ||
| ) | const [inline, virtual] |
Add two indexed expressions.
They are guaranteed to be of class indexed (or a subclass) and their indices are compatible. This function is used internally by simplify_indexed().
| self | First indexed expression; its base object is *this |
| other | Second indexed expression |
Reimplemented from GiNaC::basic.
Definition at line 193 of file structure.h.
| ex GiNaC::structure< T, ComparisonPolicy >::scalar_mul_indexed | ( | const ex & | self, |
| const numeric & | other | ||
| ) | const [inline, virtual] |
Multiply an indexed expression with a scalar.
This function is used internally by simplify_indexed().
| self | Indexed expression; its base object is *this |
| other | Numeric value |
Reimplemented from GiNaC::basic.
Definition at line 194 of file structure.h.
References GiNaC::basic::ex.
| bool GiNaC::structure< T, ComparisonPolicy >::contract_with | ( | exvector::iterator | self, |
| exvector::iterator | other, | ||
| exvector & | v | ||
| ) | const [inline, virtual] |
Try to contract two indexed expressions that appear in the same product.
If a contraction exists, the function overwrites one or both of the expressions and returns true. Otherwise it returns false. It is guaranteed that both expressions are of class indexed (or a subclass) and that at least one dummy index has been found. This functions is used internally by simplify_indexed().
| self | Pointer to first indexed expression; its base object is *this |
| other | Pointer to second indexed expression |
| v | The complete vector of factors |
Reimplemented from GiNaC::basic.
Definition at line 195 of file structure.h.
| unsigned GiNaC::structure< T, ComparisonPolicy >::return_type | ( | ) | const [inline, virtual] |
Reimplemented from GiNaC::basic.
Definition at line 198 of file structure.h.
References GiNaC::return_types::commutative.
| return_type_t GiNaC::structure< T, ComparisonPolicy >::return_type_tinfo | ( | ) | const [inline, virtual] |
Reimplemented from GiNaC::basic.
Definition at line 199 of file structure.h.
References r, GiNaC::return_type_t::rl, and GiNaC::return_type_t::tinfo.
| bool GiNaC::structure< T, ComparisonPolicy >::is_equal_same_type | ( | const basic & | other | ) | const [inline, protected, virtual] |
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.
Definition at line 208 of file structure.h.
References GINAC_ASSERT, and GiNaC::structure< T, ComparisonPolicy >::obj.
| unsigned GiNaC::structure< T, ComparisonPolicy >::calchash | ( | ) | const [inline, protected, virtual] |
Compute the hash value of an object and if it makes sense to store it in the objects status_flags, do so.
The method inherited from class basic computes a hash value based on the type and hash values of possible members. For this reason it is well suited for container classes but atomic classes should override this implementation because otherwise they would all end up with the same hashvalue.
Reimplemented from GiNaC::basic.
Definition at line 216 of file structure.h.
| const T* GiNaC::structure< T, ComparisonPolicy >::operator-> | ( | ) | const [inline] |
Definition at line 221 of file structure.h.
References GiNaC::structure< T, ComparisonPolicy >::obj.
| T& GiNaC::structure< T, ComparisonPolicy >::get_struct | ( | ) | [inline] |
Definition at line 222 of file structure.h.
References GiNaC::structure< T, ComparisonPolicy >::obj.
| const T& GiNaC::structure< T, ComparisonPolicy >::get_struct | ( | ) | const [inline] |
Definition at line 223 of file structure.h.
References GiNaC::structure< T, ComparisonPolicy >::obj.
T GiNaC::structure< T, ComparisonPolicy >::obj [private] |
Definition at line 225 of file structure.h.
Referenced by GiNaC::structure< T, ComparisonPolicy >::get_struct(), GiNaC::structure< T, ComparisonPolicy >::is_equal_same_type(), and GiNaC::structure< T, ComparisonPolicy >::operator->().