Cadabra
Computer algebra system for field theory problems
Loading...
Searching...
No Matches
evaluate.hh
Go to the documentation of this file.
1
2#pragma once
3
4#include "Compare.hh"
5#include "IndexClassifier.hh"
6#include <map>
7#include <string>
8
13
92#include "Algorithm.hh"
93#include "properties/Indices.hh"
94
95namespace cadabra {
96
97 class evaluate : public Algorithm {
98 public:
106 evaluate(const Kernel&, Ex&, const Ex& component_values, bool rhs=false,
107 bool simplify=true, const std::string& simplifier="");
108
109 virtual bool can_apply(iterator) override;
110 virtual result_t apply(iterator&) override;
111
116
121 void simplify_components(iterator, bool run_sympy=true);
122
123 private:
126 std::string simplifier;
127
134 std::map<std::string, Ex> simplify_cache;
135
136 bool is_component(iterator it) const;
137 bool is_scalar_function(iterator it) const;
138
144
148
150
155 const IndexClassifier::index_map_t& ind_dummy);
156
160
164
167
170
171 };
172
173 }
Base class for all algorithms, containing generic routines and in particular the logic for index clas...
Definition Algorithm.hh:54
Definition Storage.hh:170
result_t
Keeping track of what algorithms have done to this expression.
Definition Storage.hh:200
Ex::sibling_iterator sibling_iterator
Definition ExManip.hh:14
Ex::iterator iterator
Definition ExManip.hh:12
std::multimap< Ex, Ex::iterator, tree_exact_less_for_indexmap_obj > index_map_t
A map from a pattern to the position where it occurs in the tree.
Definition IndexClassifier.hh:23
Definition Kernel.hh:15
Definition evaluate.hh:97
virtual bool can_apply(iterator) override
Definition evaluate.cc:32
iterator handle_components(iterator it)
Definition evaluate.cc:136
bool is_component(iterator it) const
Definition evaluate.cc:116
bool is_scalar_function(iterator it) const
Definition evaluate.cc:37
void merge_component_children(iterator it)
Merge entries in a single 'components' node when they are for the same index value(s).
Definition evaluate.cc:516
void cleanup_components(iterator it1)
Cleanup all components in a 'components' node; that is, call the cleanup_dispatch function on them.
Definition evaluate.cc:641
bool only_rhs
Definition evaluate.hh:125
iterator dense_factor(iterator sib, const IndexClassifier::index_map_t &ind_free, const IndexClassifier::index_map_t &ind_dummy)
Expand a tensor factor into a components node with all components written out explicitly.
Definition evaluate.cc:422
std::string simplifier
Definition evaluate.hh:126
iterator handle_prod(iterator it)
Definition evaluate.cc:1238
virtual result_t apply(iterator &) override
Definition evaluate.cc:43
iterator handle_derivative(iterator it)
Definition evaluate.cc:655
void simplify_components(iterator, bool run_sympy=true)
Simplify all components of a 'components' node by collecting terms and optionally running sympy's sim...
Definition evaluate.cc:1137
iterator handle_epsilon(iterator it)
Definition evaluate.cc:1065
const Ex & components
Definition evaluate.hh:124
void merge_components(iterator it1, iterator it2)
Merge the information in two 'components' nodes at the given iterators, moving all out of the second ...
Definition evaluate.cc:560
iterator wrap_scalar_in_components_node(iterator sib)
Wrap a non-component scalar node in a 'components' node.
Definition evaluate.cc:1214
void unwrap_scalar_in_components_node(iterator sib)
Inverse of the above.
Definition evaluate.cc:1224
std::map< std::string, Ex > simplify_cache
Results of scalar-backend simplification, keyed on the exact expression sent to the backend.
Definition evaluate.hh:134
bool call_sympy
Definition evaluate.hh:125
iterator handle_sum(iterator it)
Definition evaluate.cc:152
iterator handle_factor(sibling_iterator sib, const IndexClassifier::index_map_t &full_ind_free)
Replace a single factor with a 'components' ... The full_ind_free argument can contain a list of indi...
Definition evaluate.cc:245
General purpose brute force scalar simplification algorithm.
Definition simplify.hh:20
Functions to handle the exchange properties of two or more symbols in a product.
Definition Adjform.cc:83
Ex rhs(Ex_ptr ex)
Definition py_ex.cc:423
void set(rset_t::iterator &num, multiplier_t fac)
Definition Storage.cc:1180