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

Added printing functions for TensorConn and TensorOperation.

parent edc81eed
/** ExaTN: Tensor basic types and parameters
REVISION: 2019/05/31
REVISION: 2019/06/05
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......
/** ExaTN::Numerics: Tensor connected to other tensors inside a tensor network
REVISION: 2019/05/31
REVISION: 2019/06/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
#include "tensor_connected.hpp"
#include <iostream>
namespace exatn{
namespace numerics{
......@@ -15,6 +17,16 @@ TensorConn::TensorConn(std::shared_ptr<Tensor> tensor, unsigned int id, const st
{
}
void TensorConn::printIt() const
{
std::cout << id_ << ": ";
tensor_->printIt();
std::cout << ": { ";
for(const auto & leg: legs_) leg.printIt();
std::cout << " }" << std::endl;
return;
}
std::shared_ptr<Tensor> TensorConn::getTensor()
{
return tensor_;
......
/** ExaTN::Numerics: Tensor connected to other tensors in a tensor network
REVISION: 2019/05/31
REVISION: 2019/06/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -44,6 +44,9 @@ public:
TensorConn & operator=(TensorConn &&) noexcept = default;
virtual ~TensorConn() = default;
/** Prints. **/
void printIt() const;
/** Returns a co-owned pointer to the tensor. **/
std::shared_ptr<Tensor> getTensor();
......
/** ExaTN::Numerics: Tensor operation
REVISION: 2019/05/31
REVISION: 2019/06/05
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
#include "tensor_operation.hpp"
#include <iostream>
namespace exatn{
namespace numerics{
......@@ -17,6 +19,23 @@ TensorOperation::TensorOperation(TensorOpCode opcode, unsigned int num_operands,
operands_.reserve(num_operands);
}
void TensorOperation::printIt() const
{
std::cout << "TensorOperation(" << static_cast<int>(opcode_) << "){" << std::endl;
if(pattern_.length() > 0) std::cout << " " << pattern_ << std::endl;
for(const auto & tensor: operands_){
std::cout << " ";
tensor->printIt();
std::cout << std::endl;
}
for(const auto & scalar: scalars_){
std::cout << " " << scalar;
}
if(scalars_.size() > 0) std::cout << std::endl;
std::cout << "}" << std::endl;
return;
}
unsigned int TensorOperation::getNumOperands() const
{
return num_operands_;
......
......@@ -41,6 +41,9 @@ public:
/** Returns TRUE iff the tensor operation is fully set. **/
virtual bool isSet() const = 0;
/** Prints. **/
virtual void printIt() const;
/** Returns the number of tensor operands required for the tensor operation. **/
unsigned int getNumOperands() const;
......
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