1#ifndef _H_contraction_tree_
2#define _H_contraction_tree_
25 Node() : is_assigned(false), left(nullptr), right(nullptr), root(nullptr){};
26 Node(
const Node &rhs) {
27 this->left = rhs.left;
28 this->right = rhs.right;
29 this->root = rhs.root;
30 this->utensor = rhs.utensor;
31 this->is_assigned = rhs.is_assigned;
34 this->left = rhs.left;
35 this->right = rhs.right;
36 this->root = rhs.root;
37 this->utensor = rhs.utensor;
38 this->is_assigned = rhs.is_assigned;
41 Node(Node *in_left, Node *in_right,
const UniTensor &in_uten = UniTensor())
42 : is_assigned(false), left(nullptr), right(nullptr), root(nullptr) {
44 this->right = in_right;
46 in_right->root =
this;
47 if (in_uten.uten_type() !=
UTenType.Void) this->utensor = in_uten;
49 void assign_utensor(
const UniTensor &in_uten) {
50 this->utensor = in_uten;
51 this->is_assigned =
true;
53 void clear_utensor() {
54 this->is_assigned =
false;
55 this->utensor = UniTensor();
59 class ContractionTree {
61 std::vector<Node> nodes_container;
62 std::vector<Node> base_nodes;
65 ContractionTree(
const ContractionTree &rhs) {
66 this->nodes_container = rhs.nodes_container;
67 this->base_nodes = rhs.base_nodes;
69 ContractionTree &
operator==(
const ContractionTree &rhs) {
70 this->nodes_container = rhs.nodes_container;
71 this->base_nodes = rhs.base_nodes;
77 nodes_container.clear();
83 void reset_contraction_order() {
84 nodes_container.clear();
85 for (cytnx_uint64 i = 0; i < base_nodes.size(); i++) {
86 base_nodes[i].root =
nullptr;
92 for (cytnx_uint64 i = 0; i < this->nodes_container.size(); i++) {
93 this->nodes_container[i].clear_utensor();
95 for (cytnx_uint64 i = 0; i < this->base_nodes.size(); i++) {
96 this->base_nodes[i].clear_utensor();
99 void build_default_contraction_tree();
100 void build_contraction_tree_by_tokens(
const std::map<std::string, cytnx_uint64> &name2pos,
101 const std::vector<std::string> &tokens);
Helper function to print vector with ODT:
Definition Accessor.hpp:12
UniTensorType_class UTenType
UniTensor type.
Tensor operator==(const Tensor &Lt, const Tensor &Rt)
The comparison operator for Tensor.