Cadabra
Computer algebra system for field theory problems
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | Static Private Attributes | List of all members
cadabra::substitute Class Reference

Description

Generic substitution algorithm.

#include <substitute.hh>

Inheritance diagram for cadabra::substitute:
cadabra::Algorithm cadabra::ExManip

Classes

class  Rules
 

Public Member Functions

 substitute (const Kernel &, Ex &tr, Ex &args, bool partial=true)
 
virtual bool can_apply (iterator st)
 Match the lhs of the replacement rule to the subtree 'st' under consideration.
 
virtual result_t apply (iterator &)
 
- Public Member Functions inherited from cadabra::Algorithm
 Algorithm (const Kernel &, Ex &)
 Initialise the algorithm with a reference to the expression tree, but do not yet do anything with this tree.
 
virtual ~Algorithm ()
 
void set_progress_monitor (ProgressMonitor *)
 Provide the algorithm with a ProgressMonitor object on which to register (nested) progress information, to be reported out-of-band to a client.
 
result_t apply_generic (bool deep=true, bool repeat=false, unsigned int depth=0)
 The main entry points for running algorithms, which traverse the tree post-order ('child before parent').
 
result_t apply_generic (iterator &, bool deep, bool repeat, unsigned int depth)
 
result_t apply_pre_order (bool repeat=false)
 Apply algorithm with alternative traversal: starting from the top node, traverse the tree pre-order ('parent before child') and once the algorithm acts at a given node, do not traverse the subtree below anymore.
 
bool check_consistency (iterator) const
 Given an expression top node, check index consistency.
 
bool check_index_consistency (iterator) const
 
bool check_degree_consistency (iterator) const
 Given an expression top node, check differential form degree consistency.
 
void report_progress (const std::string &, int todo, int done, int count=2)
 
index_iterator begin_index (iterator it) const
 
index_iterator end_index (iterator it) const
 
unsigned int number_of_indices (iterator it)
 
std::string get_index_set_name (iterator it) const
 
bool rename_replacement_dummies (iterator, bool still_inside_algo=false)
 Rename the dummies in the sub-tree starting with head at the given iterator.
 
Ex_set_t dependencies (iterator it, bool include_derivatives_of=true) const
 Determine all the Coordinate dependencies of the object at 'it'.
 
bool derivative_acts_on (iterator it) const
 Is this a symbol on which a derivative acts?
 
- Public Member Functions inherited from cadabra::ExManip
 ExManip (const Kernel &, Ex &)
 
bool prod_wrap_single_term (iterator &)
 Take a single non-product node in a sum and wrap it in a product node, so it can be handled on the same footing as a proper product.
 
bool prod_unwrap_single_term (iterator &)
 
bool sum_wrap_single_term (iterator &)
 
bool sum_unwrap_single_term (iterator &)
 
bool is_single_term (iterator)
 Is the indicated node a single term in an expression?
 
bool is_nonprod_factor_in_prod (iterator)
 
void force_node_wrap (iterator &, std::string)
 Wrap a term in a product or sum in a node with indicated name, irrespective of its parent (it usually makes more sense to call the safer prod_wrap_single_term or sum_wrap_single_term above).
 

Static Public Member Functions

static size_t cache_size ()
 Return the number of substitution rules which have been pre-processed and sit in the cache.
 
- Static Public Member Functions inherited from cadabra::Algorithm
static unsigned int number_of_indices (const Properties &, iterator it)
 
static unsigned int number_of_direct_indices (iterator it)
 
static bool is_termlike (iterator)
 Determines whether the indicated node is 'like a term in a sum'.
 
static bool is_factorlike (iterator)
 Determines whether the indicated node is 'like a factor in a product'.
 
static bool is_noncommuting (const Properties &, iterator)
 Generic function to determine if there is any kind of non-commutativity associated to the given object.
 

Public Attributes

Ex_comparator comparator
 
- Public Attributes inherited from cadabra::Algorithm
bool interrupted
 
unsigned int number_of_calls
 
unsigned int number_of_modifications
 
bool suppress_normal_output
 
bool discard_command_node
 
Stopwatch index_sw
 
Stopwatch get_dummy_sw
 
Stopwatch report_progress_stopwatch
 

Private Attributes

Exargs
 
iterator use_rule
 
iterator conditions
 
std::map< iterator, boollhs_contains_dummies
 
std::map< iterator, boolrhs_contains_dummies
 
sort_product sort_product_
 
bool partial
 

Static Private Attributes

static Rules replacement_rules = substitute::Rules()
 
static size_t cache_hits = 0
 
static size_t cache_misses = 0
 

Additional Inherited Members

- Public Types inherited from cadabra::Algorithm
typedef std::set< Ex, tree_exact_less_objEx_set_t
 
typedef Ex::result_t result_t
 
- Public Types inherited from cadabra::ExManip
typedef Ex::iterator_base iterator_base
 
typedef Ex::iterator iterator
 
typedef Ex::post_order_iterator post_order_iterator
 
typedef Ex::sibling_iterator sibling_iterator
 
- Protected Types inherited from cadabra::Algorithm
typedef std::pair< sibling_iterator, sibling_iteratorrange_t
 Finding objects in sets.
 
typedef std::vector< range_trange_vector_t
 
- Protected Member Functions inherited from cadabra::Algorithm
bool contains (sibling_iterator from, sibling_iterator to, sibling_iterator arg)
 
void find_argument_lists (range_vector_t &, bool only_comma_lists=true) const
 
template<class Iter >
range_vector_t::iterator find_arg_superset (range_vector_t &, Iter st, Iter nd)
 
range_vector_t::iterator find_arg_superset (range_vector_t &, sibling_iterator it)
 
unsigned int locate_single_object (Ex::iterator obj_to_find, Ex::iterator st, Ex::iterator nd, std::vector< unsigned int > &store)
 
bool locate_object_set (const Ex &objs, Ex::iterator st, Ex::iterator nd, std::vector< unsigned int > &store)
 
bool separated_by_derivative (iterator, iterator, iterator check_dependence) const
 Figure out whether two objects (commonly indices) are separated by a derivative operator, as in.
 
void pushup_multiplier (iterator)
 
template<class BinaryPredicate >
unsigned int intersection_number (sibling_iterator, sibling_iterator, sibling_iterator, sibling_iterator, BinaryPredicate) const
 Determine the number of elements in the first range which also occur in the second range.
 
void node_zero (iterator)
 
void node_one (iterator)
 
void node_integer (iterator, int)
 
- Static Protected Member Functions inherited from cadabra::Algorithm
static bool compare_ (const str_node &, const str_node &)
 
- Protected Attributes inherited from cadabra::Algorithm
ProgressMonitorpm
 
bool traverse_ldots
 
- Protected Attributes inherited from cadabra::ExManip
const Kernelkernel
 
Extr
 

Constructor & Destructor Documentation

◆ substitute()

substitute::substitute ( const Kernel k,
Ex tr,
Ex args,
bool  partial = true 
)

Member Function Documentation

◆ apply()

Algorithm::result_t substitute::apply ( iterator st)
virtual

Implements cadabra::Algorithm.

◆ cache_size()

size_t substitute::cache_size ( )
static

Return the number of substitution rules which have been pre-processed and sit in the cache.

◆ can_apply()

bool substitute::can_apply ( iterator  st)
virtual

Match the lhs of the replacement rule to the subtree 'st' under consideration.

This will fill the replacement_map giving a map from objects appearing in the rule to what they matched to.

For F_{m n} -> G_{m n}, position-free indices and the expression F^{m n}, we would get a replacement map

 _m  -> ^m
 _n  -> ^n

(Note how it is important that despite these indices being position-free, the rules in the replacement map do not ignore sub/superscript information). In the apply member, we then replace all of 'st' with the rhs of the rule, and scan through the rule (with a basic replacement_map.find based on simple tree comparison logic, not pattern matching) for replacements to be made.

Implements cadabra::Algorithm.

Member Data Documentation

◆ args

Ex& cadabra::substitute::args
private

◆ cache_hits

size_t substitute::cache_hits = 0
staticprivate

◆ cache_misses

size_t substitute::cache_misses = 0
staticprivate

◆ comparator

Ex_comparator cadabra::substitute::comparator

◆ conditions

iterator cadabra::substitute::conditions
private

◆ lhs_contains_dummies

std::map<iterator, bool> cadabra::substitute::lhs_contains_dummies
private

◆ partial

bool cadabra::substitute::partial
private

◆ replacement_rules

substitute::Rules substitute::replacement_rules = substitute::Rules()
staticprivate

◆ rhs_contains_dummies

std::map<iterator, bool> cadabra::substitute::rhs_contains_dummies
private

◆ sort_product_

sort_product cadabra::substitute::sort_product_
private

◆ use_rule

iterator cadabra::substitute::use_rule
private

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