32 _U(i&0) = _U(i&0) + _change(i&0);
51 std::vector<size_t> oldRank = _U.
ranks();
57 std::vector<size_t> oldRank = _U.
ranks();
65 roundingALS(_U, target);
72 roundingALS(_U, target);
89 Index i1,i2,j1,j2,r,s, s2;
90 std::vector<Tensor> leftStackUV;
91 std::vector<Tensor> leftStackUU;
92 Tensor tmp({1,1}, [](){
return 1.0;});
93 leftStackUV.push_back(tmp);
94 leftStackUU.push_back(tmp);
95 for (
size_t i=0; i<baseL.degree()-1; ++i) {
97 newLeft(j1,j2) = leftStackUV.back()(i1,i2) * baseL.get_component(i)(i1,r,j1) * _direction.
get_component(i)(i2,r,j2);
98 leftStackUV.emplace_back(std::move(newLeft));
99 newLeft(j1,j2) = leftStackUU.back()(i1,i2) * baseL.get_component(i)(i1,r,j1) * baseL.get_component(i)(i2,r,j2);
100 leftStackUU.emplace_back(std::move(newLeft));
104 std::vector<Tensor> tmpComponents;
105 for (
size_t i=baseL.degree(); i>0; --i) {
106 const size_t currIdx = i-1;
107 std::unique_ptr<Tensor> newComponent(
new Tensor);
108 const Tensor &UComp = baseL.get_component(currIdx);
111 V(i1,r,j1) = uuInv(i1,s)* leftStackUV.back()(s,i2) * _direction.
get_component(currIdx)(i2,r,j2) * right(j1,j2);
116 UTV(i1,i2) = V(i1,r,j1) * UComp(i2,r,j1);
117 V(i1,r,j1) = V(i1,r,j1) - UTV(i1,s) * UComp(s,r,j1);
119 tmpComponents.emplace_back(std::move(V));
121 right(j1,j2) = UComp(j1,r,i1) * _direction.
get_component(currIdx)(j2,r,i2) * right(i1,i2);
123 leftStackUV.pop_back();
124 leftStackUU.pop_back();
126 while (!tmpComponents.empty()) {
127 components.emplace_back(std::move(tmpComponents.back()));
128 tmpComponents.pop_back();
134 for (
size_t i=0; i<components.size(); ++i) {
142 for (
size_t i=0; i<components.size(); ++i) {
149 for (
auto &c : components) {
171 Tensor left({1,1}, [](){
return 1.0;});
172 for (
size_t i=0; i<components.size(); ++i) {
173 result +=
value_t(left(i1,i2)*components[i](i1,r,j1)*_other.
components[i](i2,r,j1));
174 if (i < components.size()-1) {
175 left(j1,j2) = left(i1,i2) * baseL.get_component(i)(i1,r,j1) * baseL.get_component(i)(i2,r,j2);
182 return std::sqrt(scalar_product(*
this));
186 TTTensor TTTangentVector::change_direction_incomplete()
const {
189 for (
size_t i=1; i<components.size(); ++i) {
190 const Tensor &baseComponent = baseL.get_component(i);
191 REQUIRE(baseComponent.
dimensions == components[i].dimensions,
"illegal base tensor for this tangent vector (ranks or external dimension do not coincide)");
192 if (i < components.size()-1) {
194 newComponent(i1,r1,n,i2,r2) =
Tensor::dirac({2,2},{0,0})(i1,i2) * baseComponent(r1,n,r2)
197 newComponent.
reinterpret_dimensions({components[i].dimensions[0]*2, components[i].dimensions[1], components[i].dimensions[2]*2});
198 result.set_component(i, newComponent);
201 newComponent(i1,r1,n,r2) =
Tensor::dirac({2},0)(i1) * components[i](r1,n,r2)
204 result.set_component(i, newComponent);
211 if (components.size() == 1) {
216 TTTensor result = change_direction_incomplete();
219 newComponent(r1,n,i2,r2) =
Tensor::dirac({2},0)(i2) * baseL.get_component(0)(r1,n,r2)
237 if (components.size() == 1) {
240 result = result + baseL;
243 TTTensor result = change_direction_incomplete();
246 newComponent(r1,n,i2,r2) =
Tensor::dirac({2},0)(i2) * baseL.get_component(0)(r1,n,r2)
247 +
Tensor::dirac({2},1)(i2) * (baseL.get_component(0)(r1,n,r2) + components[0](r1,n,r2));
270 static const Index i1,j1,r;
272 std::unique_ptr<Tensor> newComponent(
new Tensor);
static void lapack_solver(const TensorNetwork &_A, std::vector< Tensor > &_x, const TensorNetwork &_b, const ALSAlgorithmicData &_data)
local solver that calls the corresponding lapack routines (LU solver)
TTTangentVector operator*(value_t _alpha) const
void pseudo_inverse(Tensor &_inverse, const Tensor &_input, const size_t _splitPos)
Low-Level calculation of the pseudo inverse of a given Tensor.
TTTensor added_to_base() const
#define XERUS_REQUIRE_TEST
DimensionTuple dimensions
Vector containing the individual dimensions of the tensor.
class to compactly represent tangent vectors of the manifold of constant TT-rank
void set_base(const TTTensor &_newBase)
The main namespace of xerus.
Class that handles simple (non-decomposed) tensors in a dense or sparse representation.
void ProjectiveVectorTransport(const TTTensor &_newBase, TTTangentVector &_tangentVector)
simple vector transport by projecting onto the new tangent plane
bool canonicalized
Flag indicating whether the TTNetwork is canonicalized.
Tensor operator*(const value_t _factor, Tensor _tensor)
Calculates the entrywise multiplication of the Tensor _tensor with the constant _factor.
void reinterpret_dimensions(DimensionTuple _newDimensions)
Reinterprets the dimensions of the tensor.
Wrapper class for all ALS variants (dmrg etc.)
size_t degree() const
Gets the degree of the TensorNetwork.
void operator()(TTTensor &_U, const TTTensor &_change) const
value_t frob_norm() const
static Tensor XERUS_warn_unused dirac(DimensionTuple _dimensions, const MultiIndex &_position)
: Returns a Tensor with a single entry equals one and all other zero.
void move_core(const size_t _position, const bool _keepRank=false)
Move the core to a new position.
TTNetwork< false > TTTensor
std::vector< size_t > ranks() const
Gets the ranks of the TTNetwork.
void SubmanifoldRetractionI(TTTensor &_U, const TTTangentVector &_change)
retraction that performs componentwise addition of and where is the i-th component of the riemanni...
void set_component(const size_t _idx, Tensor _T)
Sets a specific component of the TT decomposition.
Default include file for the xerus library.
TTTangentVector & operator+=(const TTTangentVector &_rhs)
Header file for comfort functions and macros that should not be exported in the library.
void ALSRetractionII(TTTensor &_U, const TTTensor &_change)
retraction that performs an ALS half-sweep to project back onto the Manifold. Automatically retains t...
void HOSVDRetractionII(TTTensor &_U, const TTTensor &_change)
std::vector< size_t > rankVector
double value_t
The type of values to be used by xerus.
Class used to represent indices that can be used to write tensor calculations in index notation...
void HOSVDRetractionI(TTTensor &_U, const TTTangentVector &_change)
retraction that performs a HOSVD to project back onto the Manifold
value_t scalar_product(const TTTangentVector &_other) const
std::vector< Tensor > components
void ALSRetractionI(TTTensor &_U, const TTTangentVector &_change)
retraction that performs an ALS half-sweep to project back onto the Manifold. Automatically retains t...
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...
TTTangentVector & operator-=(const TTTangentVector &_rhs)
void round(const std::vector< size_t > &_maxRanks, const double _eps=EPSILON)
Reduce all ranks up to a given accuracy and maximal number.
const Tensor & get_component(const size_t _idx) const
Read access to a specific component of the TT decomposition.
size_t corePosition
The position of the core.
std::vector< size_t > dimensions
Dimensions of the external indices, i.e. the dimensions of the tensor represented by the network...