xerus
a general purpose tensor library
indexedTensor_tensor_factorisations.h
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 #pragma once
26 
27 #include <vector>
28 #include <limits>
29 
30 #include "basic.h"
31 
32 namespace xerus {
33  class Tensor;
34 
35  namespace internal {
36  template<class tensor_type> class IndexedTensorReadOnly;
37  template<class tensor_type> class IndexedTensor;
38  }
39 
44  public:
45  virtual void operator()(const std::vector<internal::IndexedTensor<Tensor>*>& _output) const = 0;
46 
47  virtual ~TensorFactorisation() = default;
48  };
49 
55  class SVD : public TensorFactorisation{
56  public:
58  const double epsilon;
59  const double softThreshold;
60  const size_t maxRank;
61  const bool preventZero;
62 
64  input(&_input), epsilon(EPSILON), softThreshold(0.0), maxRank(std::numeric_limits<size_t>::max()), preventZero(false) { }
65 
66  SVD(internal::IndexedTensorReadOnly<Tensor>&& _input, const double _softTreshold, const bool _preventZero = false) :
67  input(&_input), epsilon(0.0), softThreshold(_softTreshold), maxRank(std::numeric_limits<size_t>::max()), preventZero(_preventZero) { }
68 
69  SVD(internal::IndexedTensorReadOnly<Tensor>&& _input, const size_t _maxRank, const double _epsilon = EPSILON) :
70  input(&_input), epsilon(_epsilon), softThreshold(0.0), maxRank(_maxRank), preventZero(false) { }
71 
72  SVD(internal::IndexedTensorReadOnly<Tensor>&& _input, const size_t _maxRank, const double _epsilon, const double _softTreshold, const bool _preventZero) :
73  input(&_input), epsilon(_epsilon), softThreshold(_softTreshold), maxRank(_maxRank), preventZero(_preventZero) { }
74 
75  virtual void operator()(const std::vector<internal::IndexedTensor<Tensor>*>& _output) const override;
76  };
77 
83  class QR : public TensorFactorisation {
84  public:
86  QR(internal::IndexedTensorReadOnly<Tensor>&& _input) : input(&_input) { }
87 
88  virtual void operator()(const std::vector<internal::IndexedTensor<Tensor>*>& _output) const override;
89  };
90 
96  class RQ : public TensorFactorisation {
97  public:
99  RQ(internal::IndexedTensorReadOnly<Tensor>&& _input) : input(&_input) { }
100 
101  virtual void operator()(const std::vector<internal::IndexedTensor<Tensor>*>& _output) const override;
102  };
103 
110  class QC : public TensorFactorisation {
111  public:
113  QC(internal::IndexedTensorReadOnly<Tensor>&& _input) : input(&_input) { }
114 
115  virtual void operator()(const std::vector<internal::IndexedTensor<Tensor>*>& _output) const override;
116  };
117 
124  class CQ : public TensorFactorisation {
125  public:
127  CQ(internal::IndexedTensorReadOnly<Tensor>&& _input) : input(&_input) { }
128 
129  virtual void operator()(const std::vector<internal::IndexedTensor<Tensor>*>& _output) const override;
130  };
131 }
SVD(internal::IndexedTensorReadOnly< Tensor > &&_input, const double _softTreshold, const bool _preventZero=false)
Helper class to allow an intuitive syntax for SVD factorisations.
internal::IndexedTensorReadOnly< Tensor > * input
RQ(internal::IndexedTensorReadOnly< Tensor > &&_input)
Internal representation of an readable indexed Tensor or TensorNetwork.
internal::IndexedTensorReadOnly< Tensor > * input
internal::IndexedTensorReadOnly< Tensor > * input
The main namespace of xerus.
Definition: basic.h:37
STL namespace.
CQ(internal::IndexedTensorReadOnly< Tensor > &&_input)
SVD(internal::IndexedTensorReadOnly< Tensor > &&_input, const size_t _maxRank, const double _epsilon, const double _softTreshold, const bool _preventZero)
Internal representation of an readable and writeable indexed Tensor or TensorNetwork.
Definition: indexedTensor.h:37
internal::IndexedTensorReadOnly< Tensor > * input
SVD(internal::IndexedTensorReadOnly< Tensor > &&_input, const size_t _maxRank, const double _epsilon=EPSILON)
SVD(internal::IndexedTensorReadOnly< Tensor > &&_input)
Helper class to allow an intuitive syntax for an rank revealing orthogonal factorisation.
QR(internal::IndexedTensorReadOnly< Tensor > &&_input)
constexpr const value_t EPSILON
The default epsilon value in xerus.
Definition: basic.h:50
QC(internal::IndexedTensorReadOnly< Tensor > &&_input)
Header file for shorthand notations that are xerus specific but used throughout the library...
internal::IndexedTensorReadOnly< Tensor > * input
Helper class to allow an intuitive syntax for RQ factorisations.
Abstract super class for all tensor factorisations.
Helper class to allow an intuitive syntax for an rank revealing orthogonal factorisation.
Helper class to allow an intuitive syntax for QR factorisations.