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 
28 
30  public:
31  ExNode(const cadabra::Kernel&, std::shared_ptr<cadabra::Ex>);
32 
33  std::shared_ptr<cadabra::Ex> ex;
34  cadabra::Ex::iterator it;
35 
36  ExNode& iter();
37  ExNode& next();
38 
39  ExNode copy() const;
40 
41  std::string __str__() const;
42  std::string _latex_() const;
43 
44  std::string get_name() const;
45  void set_name(std::string);
46 
48  cadabra::Ex get_ex() const;
49 
52 
53  pybind11::object get_multiplier() const;
54  void set_multiplier(pybind11::object);
55 
58  // ExNode unwrap(ExNode child);
59 
63  void replace(std::shared_ptr<cadabra::Ex> rep);
64 
66  ExNode insert(std::shared_ptr<cadabra::Ex> ins);
67  ExNode insert_it(ExNode ins);
68 
70  ExNode append_child(std::shared_ptr<cadabra::Ex>);
72 
74  ExNode add_ex(std::shared_ptr<cadabra::Ex>);
75 
77  void erase();
78 
81  ExNode getitem_string(std::string tag);
83 
85  void setitem_string(std::string tag, std::shared_ptr<cadabra::Ex> val);
86  void setitem_iterator(ExNode, std::shared_ptr<cadabra::Ex> val);
87 
91  ExNode terms();
92 
96  ExNode factors();
97 
101 
105  ExNode indices();
106 
111 
114  ExNode args();
115 
118  ExNode children();
119 
120  std::string tag;
122 
126  void update(bool first);
127 
128  cadabra::Ex::iterator nxtit;
129  cadabra::Ex::sibling_iterator sibnxtit;
131 
134  cadabra::Ex::iterator topit, stopit;
135 
138 
139  private:
140  };
141 
142 
143 ExNode Ex_iter(std::shared_ptr<cadabra::Ex> ex);
144 ExNode Ex_top(std::shared_ptr<cadabra::Ex> ex);
145 bool Ex_matches(std::shared_ptr<cadabra::Ex> ex, ExNode& other);
146 bool Ex_matches_Ex(std::shared_ptr<cadabra::Ex> ex, std::shared_ptr<cadabra::Ex> other);
147 bool ExNode_less(ExNode& one, ExNode& two);
148 bool ExNode_greater(ExNode& one, ExNode& two);
149 ExNode Ex_getitem_string(std::shared_ptr<cadabra::Ex> ex, std::string tag);
150 ExNode Ex_getitem_iterator(std::shared_ptr<cadabra::Ex> ex, ExNode);
151 
152 
153 
ExNode::it
cadabra::Ex::iterator it
Definition: ExNode.hh:34
ExNode::get_multiplier
pybind11::object get_multiplier() const
Definition: ExNode.cc:300
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::sibnxtit
cadabra::Ex::sibling_iterator sibnxtit
Definition: ExNode.hh:129
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:244
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:230
ExNode::free_indices
ExNode free_indices()
Get a new iterator which only iterates over all free indices (whether direct or inherited).
Definition: ExNode.cc:165
cadabra::index_iterator
Definition: IndexIterator.hh:16
cadabra::Kernel
Definition: Kernel.hh:15
ExNode_less
bool ExNode_less(ExNode &one, ExNode &two)
Definition: ExNode.cc:497
ExNode::getitem_iterator
ExNode getitem_iterator(ExNode)
Definition: ExNode.cc:67
ExNode::setitem_iterator
void setitem_iterator(ExNode, std::shared_ptr< cadabra::Ex > val)
Definition: ExNode.cc:101
ExNode::get_parent_rel
cadabra::str_node::parent_rel_t get_parent_rel() const
Definition: ExNode.cc:286
ExNode::ind_free
index_map_t ind_free
Definition: ExNode.hh:136
ExNode::append_child_it
ExNode append_child_it(ExNode ins)
Definition: ExNode.cc:237
ExNode::stopit
cadabra::Ex::iterator stopit
Definition: ExNode.hh:134
ExNode::set_multiplier
void set_multiplier(pybind11::object)
Definition: ExNode.cc:311
ExNode::__str__
std::string __str__() const
Definition: ExNode.cc:432
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::factors
ExNode factors()
Get a new iterator which only iterates over all first-level factors.
Definition: ExNode.cc:132
ExNode_greater
bool ExNode_greater(ExNode &one, ExNode &two)
Definition: ExNode.cc:505
Ex_matches
bool Ex_matches(std::shared_ptr< cadabra::Ex > ex, ExNode &other)
Definition: ExNode.cc:481
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:78
ExNode::get_ex
cadabra::Ex get_ex() const
Create a copy of the Ex pointed to by this iterator.
Definition: ExNode.cc:281
Ex_top
ExNode Ex_top(std::shared_ptr< cadabra::Ex > ex)
Definition: ExNode.cc:471
ExNode::use_sibling_iterator
bool use_sibling_iterator
Definition: ExNode.hh:132
ExNode::topit
cadabra::Ex::iterator topit
Definition: ExNode.hh:134
ExNode::set_parent_rel
void set_parent_rel(cadabra::str_node::parent_rel_t)
Definition: ExNode.cc:293
Ex_getitem_string
ExNode Ex_getitem_string(std::shared_ptr< cadabra::Ex > ex, std::string tag)
Definition: ExNode.cc:513
ExNode::getitem_string
ExNode getitem_string(std::string tag)
Get a new iterator which always stays below the current one.
Definition: ExNode.cc:54
Ex_matches_Ex
bool Ex_matches_Ex(std::shared_ptr< cadabra::Ex > ex, std::shared_ptr< cadabra::Ex > other)
Definition: ExNode.cc:489
IndexClassifier.hh
Storage.hh
ExNode::tag
std::string tag
Definition: ExNode.hh:120
ExNode::children
ExNode children()
Get a new iterator which iterates over all first-level children (a sibling iterator,...
Definition: ExNode.cc:189
ExNode::erase
void erase()
Erase the current node, iterator becomes invalid!
Definition: ExNode.cc:262
ExNode::iter
ExNode & iter()
Definition: ExNode.cc:321
Ex_getitem_iterator
ExNode Ex_getitem_iterator(std::shared_ptr< cadabra::Ex > ex, ExNode)
Definition: ExNode.cc:524
IndexIterator.hh
cadabra::one
void one(rset_t::iterator &num)
Definition: Storage.cc:1020
ExNode::indices
ExNode indices()
Get a new iterator which only iterates over all indices (whether direct or inherited).
Definition: ExNode.cc:153
ExNode::nxtit
cadabra::Ex::iterator nxtit
Definition: ExNode.hh:128
ExNode::_latex_
std::string _latex_() const
Definition: ExNode.cc:449
ExNode::terms_only
bool terms_only
Definition: ExNode.hh:121
ExNode::terms
ExNode terms()
Get a new iterator which only iterates over all first-level terms.
Definition: ExNode.cc:121
ExNode
ExNode is a combination of an Ex::iterator and an interface which we can use to manipulate the data p...
Definition: ExNode.hh:29
ExNode::insert_it
ExNode insert_it(ExNode ins)
Definition: ExNode.cc:223
Ex_iter
ExNode Ex_iter(std::shared_ptr< cadabra::Ex > ex)
Definition: ExNode.cc:461
cadabra::Ex
Definition: Storage.hh:140
ExNode::update
void update(bool first)
Internal function to update the iterator to the next value.
Definition: ExNode.cc:326
ExNode::set_name
void set_name(std::string)
Definition: ExNode.cc:274
ExNode::ExNode
ExNode(const cadabra::Kernel &, std::shared_ptr< cadabra::Ex >)
Definition: ExNode.cc:20
ExNode::copy
ExNode copy() const
Definition: ExNode.cc:26
ExNode::ind_pos_dummy
index_position_map_t ind_pos_dummy
Definition: ExNode.hh:137
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:198
ExNode::insert
ExNode insert(std::shared_ptr< cadabra::Ex > ins)
Insert a subtree as previous sibling of the current node.
Definition: ExNode.cc:216
ExNode::factors_only
bool factors_only
Definition: ExNode.hh:121
ExNode::next
ExNode & next()
Definition: ExNode.cc:410
cadabra::IndexClassifier
Definition: IndexClassifier.hh:13
ExNode::get_name
std::string get_name() const
Definition: ExNode.cc:267
ExNode::indnxtit
cadabra::index_iterator indnxtit
Definition: ExNode.hh:130
Kernel.hh
ExNode::ind_dummy
index_map_t ind_dummy
Definition: ExNode.hh:136
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:143
ExNode::args
ExNode args()
Get a new iterator which only iterates over all first-level arguments (non-indices).
Definition: ExNode.cc:179
ExNode::indices_only
bool indices_only
Definition: ExNode.hh:121
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::ex
std::shared_ptr< cadabra::Ex > ex
Definition: ExNode.hh:33
ExNode::args_only
bool args_only
Definition: ExNode.hh:121
ExNode::use_index_iterator
bool use_index_iterator
Definition: ExNode.hh:133