xerus
a general purpose tensor library
retractions.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 "../tensor.h"
29 
30 namespace xerus {
31 
34  public:
36 
38  void set_base(const TTTensor &_newBase);
39 
40  std::vector<Tensor> components;
43  TTTangentVector(const TTTensor &_base, const TTTensor &_direction);
47  TTTangentVector operator*(value_t _alpha) const;
48  value_t scalar_product(const TTTangentVector &_other) const;
49  value_t frob_norm() const;
50  private:
51  TTTensor change_direction_incomplete() const;
52  public:
53  explicit operator TTTensor() const;
54  TTTensor added_to_base() const;
55  };
56 
57  TTTangentVector operator*(value_t _alpha, const TTTangentVector &_rhs);
58 
60  struct HOSVDRetraction {
62  size_t rank;
63  std::vector<size_t> rankVector;
64  void operator()(TTTensor &_U, const TTTensor &_change) const;
65  void operator()(TTTensor &_U, const TTTangentVector &_change) const;
66  HOSVDRetraction(size_t _rank) : roundByVector(false), rank(_rank) {}
67  HOSVDRetraction(const std::vector<size_t> &_rank) : roundByVector(true), rank(~0ul), rankVector(_rank) {}
68  };
69 
70  using TTRetractionI = std::function<void(TTTensor &, const TTTangentVector &)>;
71  using TTRetractionII = std::function<void(TTTensor &, const TTTensor &)>;
72  using TTVectorTransport = std::function<void(const TTTensor &, TTTangentVector &)>;
73 
75  void HOSVDRetractionI(TTTensor &_U, const TTTangentVector &_change);
76  void HOSVDRetractionII(TTTensor &_U, const TTTensor &_change);
77 
79  void ALSRetractionII(TTTensor &_U, const TTTensor &_change);
80 
82  void ALSRetractionI(TTTensor &_U, const TTTangentVector &_change);
83 
85  void SubmanifoldRetractionII(TTTensor &_U, const TTTensor &_change);
86 
88  void SubmanifoldRetractionI(TTTensor &_U, const TTTangentVector &_change);
89 
90 
92  void ProjectiveVectorTransport(const TTTensor &_newBase, TTTangentVector &_tangentVector);
93 
94 }
95 
retraction that performs a HOSVD to project back onto the Manifold
Definition: retractions.h:60
TTTangentVector operator*(value_t _alpha) const
TTTensor added_to_base() const
std::function< void(TTTensor &, const TTTangentVector &)> TTRetractionI
Definition: retractions.h:70
class to compactly represent tangent vectors of the manifold of constant TT-rank
Definition: retractions.h:33
void set_base(const TTTensor &_newBase)
Definition: retractions.cpp:76
The main namespace of xerus.
Definition: basic.h:37
void ProjectiveVectorTransport(const TTTensor &_newBase, TTTangentVector &_tangentVector)
simple vector transport by projecting onto the new tangent plane
value_t frob_norm() const
TTNetwork< false > TTTensor
void SubmanifoldRetractionI(TTTensor &_U, const TTTangentVector &_change)
retraction that performs componentwise addition of and where is the i-th component of the riemanni...
TTTangentVector & operator+=(const TTTangentVector &_rhs)
void ALSRetractionII(TTTensor &_U, const TTTensor &_change)
retraction that performs an ALS half-sweep to project back onto the Manifold. Automatically retains t...
Definition: retractions.cpp:62
void HOSVDRetractionII(TTTensor &_U, const TTTensor &_change)
Definition: retractions.cpp:50
std::vector< size_t > rankVector
Definition: retractions.h:63
double value_t
The type of values to be used by xerus.
Definition: basic.h:43
void HOSVDRetractionI(TTTensor &_U, const TTTangentVector &_change)
retraction that performs a HOSVD to project back onto the Manifold
Definition: retractions.cpp:56
value_t scalar_product(const TTTangentVector &_other) const
std::function< void(TTTensor &, const TTTensor &)> TTRetractionII
Definition: retractions.h:71
HOSVDRetraction(const std::vector< size_t > &_rank)
Definition: retractions.h:67
std::vector< Tensor > components
Definition: retractions.h:40
void ALSRetractionI(TTTensor &_U, const TTTangentVector &_change)
retraction that performs an ALS half-sweep to project back onto the Manifold. Automatically retains t...
Definition: retractions.cpp:69
TTTangentVector & operator*=(value_t _alpha)
void SubmanifoldRetractionII(TTTensor &_U, const TTTensor &_change)
retraction that performs componentwise addition of and where is the i-th component of the riemanni...
HOSVDRetraction(size_t _rank)
Definition: retractions.h:66
TTTangentVector & operator-=(const TTTangentVector &_rhs)
std::function< void(const TTTensor &, TTTangentVector &)> TTVectorTransport
Definition: retractions.h:72