16#ifndef __TENSOR_NODE_H_
17#define __TENSOR_NODE_H_ 1
20#include "../Utils/Tensor.h"
32 void SetGate(
const QC::Gates::QuantumGateWithOp<MatrixClass> &gate,
33 Types::qubit_t q1, Types::qubit_t q2 = 0) {
34 const size_t qubitsNumber = gate.getQubitsNumber();
39 throw std::invalid_argument(
40 "The gate has more than 2 qubits. Decompose gates on a higher number "
41 "of qubits in gates on 1 and 2 qubits only.");
45 if (qubitsNumber > 1)
qubits.push_back(q2);
48 if (qubitsNumber > 1)
qubits.push_back(q2);
56 void SetQubit(Types::qubit_t q,
bool zero =
true) {
110 auto cloned = std::make_shared<TensorNode>();
126 auto cloned = std::make_shared<TensorNode>();
131 cloned->tensor = std::make_shared<Utils::Tensor<>>(
tensor->GetDims(),
true);
138 std::shared_ptr<TensorNode>
Clone()
const {
139 auto cloned = std::make_shared<TensorNode>();
144 cloned->tensor = std::make_shared<Utils::Tensor<>>(*tensor);
155 std::vector<Types::qubit_t>
static std::shared_ptr< Utils::Tensor<> > CreateQubit0Tensor()
static std::shared_ptr< Utils::Tensor<> > CreateProjectionTensor(bool onZero=true)
static std::shared_ptr< Utils::Tensor<> > CreateQubit1Tensor()
static std::shared_ptr< Utils::Tensor<> > CreateTensorFromGate(const QC::Gates::QuantumGateWithOp< MatrixClass > &gate)
std::vector< Index > connectionsIndices
std::vector< Types::qubit_t > qubits
std::vector< Index > connections
std::shared_ptr< TensorNode > CloneWithoutTensorCopy() const
Eigen::MatrixXcd MatrixClass
std::shared_ptr< TensorNode > CloneWithADummyTensor() const
void SetQubit(Types::qubit_t q, bool zero=true)
size_t GetQubitsNumber() const
std::shared_ptr< Utils::Tensor<> > tensor
void SetProjector(Types::qubit_t q, bool zero=true)
static constexpr Index NotConnected
std::shared_ptr< TensorNode > Clone() const
bool contractsTheNeededQubit
void SetGate(const QC::Gates::QuantumGateWithOp< MatrixClass > &gate, Types::qubit_t q1, Types::qubit_t q2=0)