Cadabra
Computer algebra system for field theory problems
Loading...
Searching...
No Matches
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 std::string input_form() const;
44
45 std::string get_name() const;
46 void set_name(std::string);
47
49 cadabra::Ex get_ex() const;
50
53
54 pybind11::object get_multiplier() const;
55 void set_multiplier(pybind11::object);
56
59 // ExNode unwrap(ExNode child);
60
64 void replace(std::shared_ptr<cadabra::Ex> rep);
65
67 ExNode insert(std::shared_ptr<cadabra::Ex> ins);
69
71 ExNode append_child(std::shared_ptr<cadabra::Ex>);
73
75 ExNode add_ex(std::shared_ptr<cadabra::Ex>);
76
78 void erase();
79
82 ExNode getitem_string(std::string tag);
84
86 void setitem_string(std::string tag, std::shared_ptr<cadabra::Ex> val);
87 void setitem_iterator(ExNode, std::shared_ptr<cadabra::Ex> val);
88
92 ExNode terms();
93
98
102
106 ExNode indices();
107
112
115 ExNode args();
116
120
121 std::string tag;
123
127 void update(bool first);
128
129 cadabra::Ex::iterator nxtit;
130 cadabra::Ex::sibling_iterator sibnxtit;
132
135 cadabra::Ex::iterator topit, stopit;
136
139
140 private:
141 };
142
143
144ExNode Ex_iter(std::shared_ptr<cadabra::Ex> ex);
145ExNode Ex_top(std::shared_ptr<cadabra::Ex> ex);
146bool Ex_matches(std::shared_ptr<cadabra::Ex> ex, ExNode& other);
147bool Ex_matches_Ex(std::shared_ptr<cadabra::Ex> ex, std::shared_ptr<cadabra::Ex> other);
148bool ExNode_less(ExNode& one, ExNode& two);
149bool ExNode_greater(ExNode& one, ExNode& two);
150ExNode Ex_getitem_string(std::shared_ptr<cadabra::Ex> ex, std::string tag);
151ExNode Ex_getitem_iterator(std::shared_ptr<cadabra::Ex> ex, ExNode);
152
153
154
bool ExNode_greater(ExNode &one, ExNode &two)
Definition ExNode.cc:525
bool ExNode_less(ExNode &one, ExNode &two)
Definition ExNode.cc:517
ExNode Ex_top(std::shared_ptr< cadabra::Ex > ex)
Definition ExNode.cc:488
ExNode Ex_getitem_iterator(std::shared_ptr< cadabra::Ex > ex, ExNode)
Definition ExNode.cc:544
ExNode Ex_iter(std::shared_ptr< cadabra::Ex > ex)
Definition ExNode.cc:478
bool Ex_matches(std::shared_ptr< cadabra::Ex > ex, ExNode &other)
Definition ExNode.cc:498
bool Ex_matches_Ex(std::shared_ptr< cadabra::Ex > ex, std::shared_ptr< cadabra::Ex > other)
Definition ExNode.cc:506
ExNode Ex_getitem_string(std::shared_ptr< cadabra::Ex > ex, std::string tag)
Definition ExNode.cc:533
ExNode is a combination of an Ex::iterator and an interface which we can use to manipulate the data p...
Definition ExNode.hh:29
cadabra::Ex::iterator stopit
Definition ExNode.hh:135
std::string tag
Definition ExNode.hh:121
std::string __str__() const
Definition ExNode.cc:449
ExNode insert(std::shared_ptr< cadabra::Ex > ins)
Insert a subtree as previous sibling of the current node.
Definition ExNode.cc:228
ExNode args()
Get a new iterator which only iterates over all first-level arguments (non-indices).
Definition ExNode.cc:191
std::shared_ptr< cadabra::Ex > ex
Definition ExNode.hh:33
ExNode getitem_iterator(ExNode)
Definition ExNode.cc:79
std::string _latex_() const
Definition ExNode.cc:466
void set_name(std::string)
Definition ExNode.cc:286
index_position_map_t ind_pos_dummy
Definition ExNode.hh:138
ExNode & next()
Definition ExNode.cc:427
ExNode & iter()
Definition ExNode.cc:333
void set_multiplier(pybind11::object)
Definition ExNode.cc:323
cadabra::Ex get_ex() const
Create a copy of the Ex pointed to by this iterator.
Definition ExNode.cc:293
ExNode children()
Get a new iterator which iterates over all first-level children (a sibling iterator,...
Definition ExNode.cc:201
ExNode terms()
Get a new iterator which only iterates over all first-level terms.
Definition ExNode.cc:133
ExNode append_child_it(ExNode ins)
Definition ExNode.cc:249
bool terms_only
Definition ExNode.hh:122
pybind11::object get_multiplier() const
Definition ExNode.cc:312
ExNode indices()
Get a new iterator which only iterates over all indices (whether direct or inherited).
Definition ExNode.cc:165
ExNode copy() const
Definition ExNode.cc:27
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:90
cadabra::Ex::iterator nxtit
Definition ExNode.hh:129
void setitem_iterator(ExNode, std::shared_ptr< cadabra::Ex > val)
Definition ExNode.cc:113
cadabra::Ex::iterator it
Definition ExNode.hh:34
bool use_sibling_iterator
Definition ExNode.hh:133
std::string input_form() const
Definition ExNode.cc:55
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:210
ExNode insert_it(ExNode ins)
Definition ExNode.cc:235
bool factors_only
Definition ExNode.hh:122
ExNode factors()
Get a new iterator which only iterates over all first-level factors.
Definition ExNode.cc:144
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:155
cadabra::index_iterator indnxtit
Definition ExNode.hh:131
bool indices_only
Definition ExNode.hh:122
cadabra::str_node::parent_rel_t get_parent_rel() const
Definition ExNode.cc:298
void erase()
Erase the current node, iterator becomes invalid!
Definition ExNode.cc:274
index_map_t ind_dummy
Definition ExNode.hh:137
bool use_index_iterator
Definition ExNode.hh:134
cadabra::Ex::iterator topit
Definition ExNode.hh:135
std::string get_name() const
Definition ExNode.cc:279
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:242
void set_parent_rel(cadabra::str_node::parent_rel_t)
Definition ExNode.cc:305
index_map_t ind_free
Definition ExNode.hh:137
ExNode add_ex(std::shared_ptr< cadabra::Ex >)
Add an expression to the given node, adding a sum parent if necessary.
Definition ExNode.cc:256
ExNode free_indices()
Get a new iterator which only iterates over all free indices (whether direct or inherited).
Definition ExNode.cc:177
ExNode getitem_string(std::string tag)
Get a new iterator which always stays below the current one.
Definition ExNode.cc:66
bool args_only
Definition ExNode.hh:122
cadabra::Ex::sibling_iterator sibnxtit
Definition ExNode.hh:130
void update(bool first)
Internal function to update the iterator to the next value.
Definition ExNode.cc:338
Basic storage class for symbolic mathemematical expressions.
Definition Storage.hh:142
Definition IndexClassifier.hh:13
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
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
An iterator which iterates over indices even if they are at lower levels, i.e.
Definition IndexIterator.hh:16
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:62