1#ifndef _H_contraction_tree_
2#define _H_contraction_tree_
23 Node() : is_assigned(false), left(nullptr), right(nullptr), root(nullptr){};
24 Node(
const Node &rhs) {
25 this->left = rhs.left;
26 this->right = rhs.right;
27 this->root = rhs.root;
28 this->utensor = rhs.utensor;
29 this->is_assigned = rhs.is_assigned;
32 this->left = rhs.left;
33 this->right = rhs.right;
34 this->root = rhs.root;
35 this->utensor = rhs.utensor;
36 this->is_assigned = rhs.is_assigned;
39 Node(Node *in_left, Node *in_right,
const UniTensor &in_uten = UniTensor())
40 : is_assigned(false), left(nullptr), right(nullptr), root(nullptr) {
42 this->right = in_right;
44 in_right->root =
this;
45 if (in_uten.uten_type() !=
UTenType.Void) this->utensor = in_uten;
47 void assign_utensor(
const UniTensor &in_uten) {
48 this->utensor = in_uten;
49 this->is_assigned =
true;
51 void clear_utensor() {
52 this->is_assigned =
false;
53 this->utensor = UniTensor();
57 class ContractionTree {
59 std::vector<Node> nodes_container;
60 std::vector<Node> base_nodes;
63 ContractionTree(
const ContractionTree &rhs) {
64 this->nodes_container = rhs.nodes_container;
65 this->base_nodes = rhs.base_nodes;
67 ContractionTree &
operator==(
const ContractionTree &rhs) {
68 this->nodes_container = rhs.nodes_container;
69 this->base_nodes = rhs.base_nodes;
75 nodes_container.clear();
81 void reset_contraction_order() {
82 nodes_container.clear();
83 for (cytnx_uint64 i = 0; i < base_nodes.size(); i++) {
84 base_nodes[i].root =
nullptr;
90 for (cytnx_uint64 i = 0; i < this->nodes_container.size(); i++) {
91 this->nodes_container[i].clear_utensor();
93 for (cytnx_uint64 i = 0; i < this->base_nodes.size(); i++) {
94 this->base_nodes[i].clear_utensor();
97 void build_default_contraction_tree();
98 void build_contraction_tree_by_tokens(
const std::map<std::string, cytnx_uint64> &name2pos,
99 const std::vector<std::string> &tokens);
Definition Accessor.hpp:12
UniTensorType_class UTenType
UniTensor type.
Definition UniTensor_base.cpp:24
Tensor operator==(const Tensor &Lt, const Tensor &Rt)
The comparison operator for Tensor.