Cadabra
Computer algebra system for field theory problems
ExNode.hh
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "Kernel.hh"
5 #include "Storage.hh"
6 #include "IndexIterator.hh"
7 #include "IndexClassifier.hh"
8 #include <memory>
9 #include <pybind11/pybind11.h>
10 
24 
26  public:
27  ExNode(const cadabra::Kernel&, std::shared_ptr<cadabra::Ex>);
28 
29  std::shared_ptr<cadabra::Ex> ex;
30  cadabra::Ex::iterator it;
31 
32  ExNode& iter();
33  ExNode& next();
34 
35  ExNode copy() const;
36 
37  std::string __str__() const;
38  std::string _latex_() const;
39 
40  std::string get_name() const;
41  void set_name(std::string);
42 
45 
46  pybind11::object get_multiplier() const;
47  void set_multiplier(pybind11::object);
48 
51  // ExNode unwrap(ExNode child);
52 
56  void replace(std::shared_ptr<cadabra::Ex> rep);
57 
59  ExNode insert(std::shared_ptr<cadabra::Ex> ins);
60  ExNode insert_it(ExNode ins);
61 
63  ExNode append_child(std::shared_ptr<cadabra::Ex>);
65 
67  ExNode add_ex(std::shared_ptr<cadabra::Ex>);
68 
70  void erase();
71 
74  ExNode getitem_string(std::string tag);
76 
78  void setitem_string(std::string tag, std::shared_ptr<cadabra::Ex> val);
79  void setitem_iterator(ExNode, std::shared_ptr<cadabra::Ex> val);
80 
84  ExNode terms();
85 
89  ExNode factors();
90 
94 
98  ExNode indices();
99 
104 
107  ExNode args();
108 
111  ExNode children();
112 
113  std::string tag;
115 
119  void update(bool first);
120 
121  cadabra::Ex::iterator nxtit;
122  cadabra::Ex::sibling_iterator sibnxtit;
124 
127  cadabra::Ex::iterator topit, stopit;
128 
131 
132  private:
133  };
134 
135 
136 ExNode Ex_iter(std::shared_ptr<cadabra::Ex> ex);
137 ExNode Ex_top(std::shared_ptr<cadabra::Ex> ex);
138 bool Ex_matches(std::shared_ptr<cadabra::Ex> ex, ExNode& other);
139 bool ExNode_less(ExNode& one, ExNode& two);
140 bool ExNode_greater(ExNode& one, ExNode& two);
141 ExNode Ex_getitem_string(std::shared_ptr<cadabra::Ex> ex, std::string tag);
142 ExNode Ex_getitem_iterator(std::shared_ptr<cadabra::Ex> ex, ExNode);
143 
144 
145 
ExNode_greater
bool ExNode_greater(ExNode &one, ExNode &two)
Definition: ExNode.cc:461
ExNode::args
ExNode args()
Get a new iterator which only iterates over all first-level arguments (non-indices).
Definition: ExNode.cc:177
Storage.hh
ExNode::_latex_
std::string _latex_() const
Definition: ExNode.cc:416
ExNode::insert_it
ExNode insert_it(ExNode ins)
Definition: ExNode.cc:221
ExNode::indices_only
bool indices_only
Definition: ExNode.hh:114
Ex_matches
bool Ex_matches(std::shared_ptr< cadabra::Ex > ex, ExNode &other)
Definition: ExNode.cc:445
ExNode::getitem_string
ExNode getitem_string(std::string tag)
Get a new iterator which always stays below the current one.
Definition: ExNode.cc:52
Ex_getitem_iterator
ExNode Ex_getitem_iterator(std::shared_ptr< cadabra::Ex > ex, ExNode)
Definition: ExNode.cc:480
Ex_iter
ExNode Ex_iter(std::shared_ptr< cadabra::Ex > ex)
Definition: ExNode.cc:425
cadabra::IndexClassifier::index_map_t
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
ExNode::terms_only
bool terms_only
Definition: ExNode.hh:114
ExNode::indnxtit
cadabra::index_iterator indnxtit
Definition: ExNode.hh:123
ExNode::own_indices
ExNode own_indices()
Get a new iterator which only iterates over all first-level indices (that is, does not iterate over i...
Definition: ExNode.cc:141
ExNode::update
void update(bool first)
Internal function to update the iterator to the next value.
Definition: ExNode.cc:307
ExNode::free_indices
ExNode free_indices()
Get a new iterator which only iterates over all free indices (whether direct or inherited).
Definition: ExNode.cc:163
cadabra::index_iterator
An iterator which iterates over indices even if they are at lower levels, i.e.
Definition: IndexIterator.hh:16
cadabra::Kernel
Definition: Kernel.hh:14
ExNode_less
bool ExNode_less(ExNode &one, ExNode &two)
Definition: ExNode.cc:453
ExNode::indices
ExNode indices()
Get a new iterator which only iterates over all indices (whether direct or inherited).
Definition: ExNode.cc:151
IndexIterator.hh
cadabra::IndexClassifier
Definition: IndexClassifier.hh:13
Ex_getitem_string
ExNode Ex_getitem_string(std::shared_ptr< cadabra::Ex > ex, std::string tag)
Definition: ExNode.cc:469
ExNode::use_index_iterator
bool use_index_iterator
Definition: ExNode.hh:126
ExNode::replace
void replace(std::shared_ptr< cadabra::Ex > rep)
Take a child argument out of the node and add as child of current.
Definition: ExNode.cc:196
ExNode::ind_pos_dummy
index_position_map_t ind_pos_dummy
Definition: ExNode.hh:130
ExNode::use_sibling_iterator
bool use_sibling_iterator
Definition: ExNode.hh:125
ExNode::terms
ExNode terms()
Get a new iterator which only iterates over all first-level terms.
Definition: ExNode.cc:119
ExNode::set_name
void set_name(std::string)
Definition: ExNode.cc:270
ExNode::add_ex
ExNode add_ex(std::shared_ptr< cadabra::Ex >)
Add an expression to the given node, adding a sum parent if necessary.
Definition: ExNode.cc:242
cadabra::IndexClassifier::index_position_map_t
std::map< Ex::iterator, int, Ex::iterator_base_less > index_position_map_t
A map from the position of each index to the sequential index.
Definition: IndexClassifier.hh:26
ExNode::append_child
ExNode append_child(std::shared_ptr< cadabra::Ex >)
Append a subtree as a child. Return an ExNode pointing to the new child.
Definition: ExNode.cc:228
ExNode::set_multiplier
void set_multiplier(pybind11::object)
Definition: ExNode.cc:293
ExNode::ex
std::shared_ptr< cadabra::Ex > ex
Definition: ExNode.hh:29
ExNode::get_name
std::string get_name() const
Definition: ExNode.cc:265
ExNode::tag
std::string tag
Definition: ExNode.hh:113
ExNode::next
ExNode & next()
Definition: ExNode.cc:380
ExNode::iter
ExNode & iter()
Definition: ExNode.cc:302
ExNode::set_parent_rel
void set_parent_rel(cadabra::str_node::parent_rel_t)
Definition: ExNode.cc:280
cadabra::one
void one(rset_t::iterator &num)
Definition: Storage.cc:999
ExNode::append_child_it
ExNode append_child_it(ExNode ins)
Definition: ExNode.cc:235
ExNode::erase
void erase()
Erase the current node, iterator becomes invalid!
Definition: ExNode.cc:260
ExNode::it
cadabra::Ex::iterator it
Definition: ExNode.hh:30
ExNode::sibnxtit
cadabra::Ex::sibling_iterator sibnxtit
Definition: ExNode.hh:122
ExNode::insert
ExNode insert(std::shared_ptr< cadabra::Ex > ins)
Insert a subtree as previous sibling of the current node.
Definition: ExNode.cc:214
ExNode::get_multiplier
pybind11::object get_multiplier() const
Definition: ExNode.cc:285
ExNode::nxtit
cadabra::Ex::iterator nxtit
Definition: ExNode.hh:121
ExNode::setitem_iterator
void setitem_iterator(ExNode, std::shared_ptr< cadabra::Ex > val)
Definition: ExNode.cc:99
ExNode::stopit
cadabra::Ex::iterator stopit
Definition: ExNode.hh:127
ExNode::copy
ExNode copy() const
Definition: ExNode.cc:24
ExNode::topit
cadabra::Ex::iterator topit
Definition: ExNode.hh:127
ExNode::ind_free
index_map_t ind_free
Definition: ExNode.hh:129
ExNode
ExNode is a combination of an Ex::iterator and an interface which we can use to manipulate the data p...
Definition: ExNode.hh:25
ExNode::get_parent_rel
cadabra::str_node::parent_rel_t get_parent_rel() const
Definition: ExNode.cc:275
ExNode::factors_only
bool factors_only
Definition: ExNode.hh:114
Kernel.hh
ExNode::children
ExNode children()
Get a new iterator which iterates over all first-level children (a sibling iterator,...
Definition: ExNode.cc:187
ExNode::ind_dummy
index_map_t ind_dummy
Definition: ExNode.hh:129
IndexClassifier.hh
ExNode::args_only
bool args_only
Definition: ExNode.hh:114
cadabra::str_node::parent_rel_t
parent_rel_t
Child nodes are related to their parent node by a so-called parent relation, which can be one of thes...
Definition: Storage.hh:61
ExNode::__str__
std::string __str__() const
Definition: ExNode.cc:402
ExNode::setitem_string
void setitem_string(std::string tag, std::shared_ptr< cadabra::Ex > val)
Set all elements with the indicated tag to the given value.
Definition: ExNode.cc:76
ExNode::getitem_iterator
ExNode getitem_iterator(ExNode)
Definition: ExNode.cc:65
ExNode::ExNode
ExNode(const cadabra::Kernel &, std::shared_ptr< cadabra::Ex >)
Definition: ExNode.cc:18
ExNode::factors
ExNode factors()
Get a new iterator which only iterates over all first-level factors.
Definition: ExNode.cc:130
Ex_top
ExNode Ex_top(std::shared_ptr< cadabra::Ex > ex)
Definition: ExNode.cc:435