Commit dd178e2f authored by Dmitry I. Lyakh's avatar Dmitry I. Lyakh
Browse files

Declared new methods in Tensor and TensorNetwork.

parent 3694cd21
/** ExaTN::Numerics: Tensor
REVISION: 2019/07/02
REVISION: 2019/07/08
Copyright (C) 2018-2018 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2018 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -34,6 +34,15 @@ name_(name)
{
}
Tensor::Tensor(const std::string & name, //tensor name
const Tensor & left_tensor, //left tensor
const Tensor & right_tensor, //right tensor
int index_pattern[]):
name_(name)
{
//`Finish
}
void Tensor::printIt() const
{
std::cout << name_; signature_.printIt(); shape_.printIt();
......
/** ExaTN::Numerics: Abstract Tensor
REVISION: 2019/07/02
REVISION: 2019/07/08
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -77,6 +77,11 @@ public:
const std::vector<T> & extents); //tensor dimension extents
/** Create a rank-0 tensor (scalar). **/
Tensor(const std::string & name); //tensor name
/** Create a tensor by contracting two other tensors. **/
Tensor(const std::string & name, //tensor name
const Tensor & left_tensor, //left tensor
const Tensor & right_tensor, //right tensor
int index_pattern[]); //index contraction pattern
Tensor(const Tensor & tensor) = default;
Tensor & operator=(const Tensor & tensor) = default;
......
/** ExaTN::Numerics: Tensor network
REVISION: 2019/07/07
REVISION: 2019/07/08
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -94,8 +94,22 @@ bool TensorNetwork::appendTensorNetwork(TensorNetwork && network,
return true;
}
bool TensorNetwork::reoderOutputModes(const std::vector<unsigned int> & order)
void TensorNetwork::reoderOutputModes(const std::vector<unsigned int> & order)
{
//`Finish
return;
}
bool TensorNetwork::deleteTensor(unsigned int tensor_id)
{
assert(tensor_id != 0); //output tensor cannot be deleted
//`Finish
return true;
}
bool TensorNetwork::contractTensors(unsigned int left_id, unsigned int right_id, unsigned int result_id)
{
assert(left_id != right_id && left_id != result_id && right_id != result_id);
//`Finish
return true;
}
......
/** ExaTN::Numerics: Tensor network
REVISION: 2019/07/07
REVISION: 2019/07/08
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -102,7 +102,7 @@ public:
with the modes of the input tensors already present in the tensor network.
The unmatched modes of the newly appended tensor will be appended to the
existing modes of the output tensor of the tensor network (at the end). **/
bool appendTensor(unsigned int tensor_id, //in: tensor id (unique within the tensor network)
bool appendTensor(unsigned int tensor_id, //in: appended tensor id (unique within the tensor network)
std::shared_ptr<Tensor> tensor, //in: appended tensor
const std::vector<TensorLeg> & connections); //in: tensor connections
......@@ -110,7 +110,7 @@ public:
with the modes of the output tensor of the tensor network. The unmatched modes
of the newly appended tensor will be appended to the existing modes of the
output tensor of the tensor network (at the end). **/
bool appendTensor(unsigned int tensor_id, //in: tensor id (unique within the tensor network)
bool appendTensor(unsigned int tensor_id, //in: appended tensor id (unique within the tensor network)
std::shared_ptr<Tensor> tensor, //in: appended tensor
const std::vector<std::pair<unsigned int, unsigned int>> & pairing); //in: leg pairing: output tensor mode -> appended tensor mode
......@@ -122,8 +122,20 @@ public:
bool appendTensorNetwork(TensorNetwork && network, //in: appended tensor network
const std::vector<std::pair<unsigned int, unsigned int>> & pairing); //in: leg pairing: output tensor mode (primary) -> output tensor mode (appended)
/** Reoders the modes of the output tensor of the tensor network. **/
bool reoderOutputModes(const std::vector<unsigned int> & order); //in: new order of the output tensor modes (N2O)
/** Reoders the modes of the output tensor of the tensor network:
order[x] = y: yth mode of the output tensor becomes its xth mode. **/
void reoderOutputModes(const std::vector<unsigned int> & order); //in: new order of the output tensor modes (N2O)
/** Deletes a tensor from the tensor network (output tensor cannot be deleted!).
The released tensor legs will be joined at the end of the output tensor. **/
bool deleteTensor(unsigned int tensor_id); //in: id of the tensor to be deleted
/** Contracts two tensors in the tensor network, producing another tensor: result = left * right.
The uncontracted modes of the left tensor will precede the uncontracted modes
of the right tensor in the tensor-result. **/
bool contractTensors(unsigned int left_id, //in: left tensor id (present in the tensor network)
unsigned int right_id, //in: right tensor id (present in the tensor network)
unsigned int result_id); //in: result tensor id (absent in the tensor network, to be appended)
private:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment