xerus
a general purpose tensor library
link.cpp
Go to the documentation of this file.
1 // Xerus - A General Purpose Tensor Library
2 // Copyright (C) 2014-2017 Benjamin Huber and Sebastian Wolf.
3 //
4 // Xerus is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as published
6 // by the Free Software Foundation, either version 3 of the License,
7 // or (at your option) any later version.
8 //
9 // Xerus is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
13 //
14 // You should have received a copy of the GNU Affero General Public License
15 // along with Xerus. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // For further information on Xerus visit https://libXerus.org
18 // or contact us at contact@libXerus.org.
19 
25 #include <xerus/tensorNetwork.h>
26 
27 namespace xerus {
28  TensorNetwork::Link::Link(const size_t _other, const size_t _indexPos, const size_t _dim, const bool _external) noexcept
29  : other(_other), indexPosition(_indexPos), dimension(_dim), external(_external) {}
30 
31  bool TensorNetwork::Link::links(const size_t _other) const noexcept { return !external && other == _other; }
32 
33  /*- - - - - - - - - - - - - - - - - - - - - - - - - - External functions - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
34 
35  std::ostream &operator<<(std::ostream &_out, const xerus::TensorNetwork::Link &_rhs) {
36  _out << "L{";
37  if (_rhs.external) {
38  _out << "ext";
39  } else {
40  _out << _rhs.other;
41  }
42  _out << " (" << _rhs.indexPosition << "), dim " << _rhs.dimension << "}";
43  return _out;
44  }
45 } // namespace xerus
The main namespace of xerus.
Definition: basic.h:37
std::ostream & operator<<(std::ostream &_out, const xerus::Index &_idx)
Allows to pretty print indices, giving the valueId and span.
Definition: index.cpp:175
Header file for the TensorNetwork class.