Commit 1ce2f25a authored by Philipp  Trunschke's avatar Philipp Trunschke

retab

parent aff3546b
This diff is collapsed.
This diff is collapsed.
// Xerus - A General Purpose Tensor Library
// Copyright (C) 2014-2018 Benjamin Huber and Sebastian Wolf.
//
// Copyright (C) 2014-2018 Benjamin Huber and Sebastian Wolf.
//
// Xerus is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
//
// Xerus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
//
// You should have received a copy of the GNU Affero General Public License
// along with Xerus. If not, see <http://www.gnu.org/licenses/>.
//
// For further information on Xerus visit https://libXerus.org
// For further information on Xerus visit https://libXerus.org
// or contact us at contact@libXerus.org.
/**
......@@ -25,21 +25,21 @@
#include <xerus/tensorNetwork.h>
namespace xerus {
TensorNetwork::Link::Link(const size_t _other, const size_t _indexPos, const size_t _dim, const bool _external) noexcept
: other(_other), indexPosition(_indexPos), dimension(_dim), external(_external) {}
bool TensorNetwork::Link::links(const size_t _other) const noexcept { return !external && other == _other; }
TensorNetwork::Link::Link(const size_t _other, const size_t _indexPos, const size_t _dim, const bool _external) noexcept
: other(_other), indexPosition(_indexPos), dimension(_dim), external(_external) {}
bool TensorNetwork::Link::links(const size_t _other) const noexcept { return !external && other == _other; }
/*- - - - - - - - - - - - - - - - - - - - - - - - - - External functions - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
std::ostream &operator<<(std::ostream &_out, const xerus::TensorNetwork::Link &_rhs) {
_out << "L{";
if (_rhs.external) {
_out << "ext";
} else {
_out << _rhs.other;
}
_out << " (" << _rhs.indexPosition << "), dim " << _rhs.dimension << "}";
if (_rhs.external) {
_out << "ext";
} else {
_out << _rhs.other;
}
_out << " (" << _rhs.indexPosition << "), dim " << _rhs.dimension << "}";
return _out;
}
} // namespace xerus
This diff is collapsed.
// Xerus - A General Purpose Tensor Library
// Copyright (C) 2014-2018 Benjamin Huber and Sebastian Wolf.
//
// Copyright (C) 2014-2018 Benjamin Huber and Sebastian Wolf.
//
// Xerus is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
//
// Xerus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
//
// You should have received a copy of the GNU Affero General Public License
// along with Xerus. If not, see <http://www.gnu.org/licenses/>.
//
// For further information on Xerus visit https://libXerus.org
// For further information on Xerus visit https://libXerus.org
// or contact us at contact@libXerus.org.
/**
......@@ -26,43 +26,43 @@
#include <xerus/tensor.h>
namespace xerus {
TensorNetwork::TensorNode::TensorNode() : erased(true) { }
TensorNetwork::TensorNode::TensorNode(const TensorNetwork::TensorNode& _other) : tensorObject(_other.tensorObject ? new Tensor(*_other.tensorObject) : nullptr), neighbors(_other.neighbors), erased(_other.erased) { }
TensorNetwork::TensorNode::TensorNode( std::unique_ptr<Tensor>&& _tensorObject) : tensorObject(std::move(_tensorObject)), neighbors(), erased(false) {}
TensorNetwork::TensorNode::TensorNode(std::unique_ptr<Tensor>&& _tensorObject, std::vector<Link> _neighbors) : tensorObject(std::move(_tensorObject)), neighbors(std::move(_neighbors)), erased(false) {}
TensorNetwork::TensorNode::~TensorNode() = default;
TensorNetwork::TensorNode& TensorNetwork::TensorNode::operator=(const TensorNetwork::TensorNode& _other) {
if(_other.tensorObject) {
if(tensorObject) {
*tensorObject = *_other.tensorObject;
} else {
tensorObject.reset( new Tensor(*_other.tensorObject));
}
if(tensorObject) {
*tensorObject = *_other.tensorObject;
} else {
tensorObject.reset( new Tensor(*_other.tensorObject));
}
} else {
tensorObject.reset();
}
tensorObject.reset();
}
neighbors = _other.neighbors;
erased = _other.erased;
return *this;
}
TensorNetwork::TensorNode& TensorNetwork::TensorNode::operator=( TensorNetwork::TensorNode&& _other) noexcept {
tensorObject = std::move(_other.tensorObject);
neighbors = std::move(_other.neighbors);
erased = _other.erased;
return *this;
}
TensorNetwork::TensorNode TensorNetwork::TensorNode::strippped_copy() const {
return TensorNetwork::TensorNode(std::unique_ptr<Tensor>(), neighbors);
}
size_t TensorNetwork::TensorNode::size() const noexcept {
size_t s = 1;
for (const Link &l : neighbors) {
......@@ -70,11 +70,11 @@ namespace xerus {
}
return s;
}
size_t TensorNetwork::TensorNode::degree() const noexcept {
return neighbors.size();
}
void TensorNetwork::TensorNode::erase() noexcept {
erased = true;
neighbors.clear();
......
This diff is collapsed.
Markdown is supported
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