Loading include/xerus/algorithms/uqAdf.h +2 −0 Original line number Diff line number Diff line Loading @@ -56,5 +56,7 @@ namespace xerus { TTTensor uq_adf(const UQMeasurementSet& _measurments, const TTTensor& _guess); Tensor uq_avg(const TTTensor& _x, const size_t _N); void uq_mc(std::vector<std::vector<double>>& _randomVariables, std::vector<Tensor>& _solutions, const size_t _N); } src/unitTests/ttOther.cxx +4 −2 Original line number Diff line number Diff line Loading @@ -61,11 +61,13 @@ static misc::UnitTest tt_pseudo_inv("TT", "Non-operator Pseudo Inverse", [](){ const size_t d = 2; const TTTensor op = TTTensor::random(std::vector<size_t>(2*d, 10), std::vector<size_t>(2*d-1, 4)); TTTensor tmp = op; tmp.move_core(d); auto parts = tmp.chop(d); std::pair<TensorNetwork, TensorNetwork> parts = tmp.chop(d); Tensor core = tmp.get_component(d); Tensor U,S,V; (U(i,r1), S(r1,r2), V(r2,j^2)) = SVD(tmp.get_component(d)(i,j^2)); (U(i,r1), S(r1,r2), V(r2,j^2)) = SVD(core(i,j^2)); S.modify_diagonal_entries([](double &_v){ if (_v>1e-10) { _v = 1/_v; Loading tutorials/ttTensor.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ int main() { // ensure that A is symmetric by calculating @f$ A\cdot A^T @f$ // here i^d signifies, that i should represent a multi-index of dimension d // the TTOperator of order 2d is thus fully indexed by two indices of the form i^d, j^d A(i^d, k^d) = A(i^d, j^d) * A(k^d, j^d); A(i/2, k/2) = A(i/2, j/2) * A(k/2, j/2); // the rank of A increased in the last operation: using xerus::misc::operator<<; Loading @@ -49,7 +49,7 @@ int main() { // as the ALS will not modify the rank of X, the residual will most likely not be zero in the end // here i&n denotes that i should be a multiindex spanning all but n indices of the given tensor // in this case j&0 simply denotes that j should span all indices of X and B std::cout << "Residual ||A*X-B|| = " << frob_norm(A(i^d, j^d)*X(j&0) - B(i&0)) << " this is likely not equal to 0..." << std::endl; std::cout << "Residual ||A*X-B|| = " << frob_norm(A(i^d, j^d)*X(j&0) - B(i&0))/frob_norm(B) << " this is likely not equal to 0..." << std::endl; } /** Loading Loading
include/xerus/algorithms/uqAdf.h +2 −0 Original line number Diff line number Diff line Loading @@ -56,5 +56,7 @@ namespace xerus { TTTensor uq_adf(const UQMeasurementSet& _measurments, const TTTensor& _guess); Tensor uq_avg(const TTTensor& _x, const size_t _N); void uq_mc(std::vector<std::vector<double>>& _randomVariables, std::vector<Tensor>& _solutions, const size_t _N); }
src/unitTests/ttOther.cxx +4 −2 Original line number Diff line number Diff line Loading @@ -61,11 +61,13 @@ static misc::UnitTest tt_pseudo_inv("TT", "Non-operator Pseudo Inverse", [](){ const size_t d = 2; const TTTensor op = TTTensor::random(std::vector<size_t>(2*d, 10), std::vector<size_t>(2*d-1, 4)); TTTensor tmp = op; tmp.move_core(d); auto parts = tmp.chop(d); std::pair<TensorNetwork, TensorNetwork> parts = tmp.chop(d); Tensor core = tmp.get_component(d); Tensor U,S,V; (U(i,r1), S(r1,r2), V(r2,j^2)) = SVD(tmp.get_component(d)(i,j^2)); (U(i,r1), S(r1,r2), V(r2,j^2)) = SVD(core(i,j^2)); S.modify_diagonal_entries([](double &_v){ if (_v>1e-10) { _v = 1/_v; Loading
tutorials/ttTensor.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ int main() { // ensure that A is symmetric by calculating @f$ A\cdot A^T @f$ // here i^d signifies, that i should represent a multi-index of dimension d // the TTOperator of order 2d is thus fully indexed by two indices of the form i^d, j^d A(i^d, k^d) = A(i^d, j^d) * A(k^d, j^d); A(i/2, k/2) = A(i/2, j/2) * A(k/2, j/2); // the rank of A increased in the last operation: using xerus::misc::operator<<; Loading @@ -49,7 +49,7 @@ int main() { // as the ALS will not modify the rank of X, the residual will most likely not be zero in the end // here i&n denotes that i should be a multiindex spanning all but n indices of the given tensor // in this case j&0 simply denotes that j should span all indices of X and B std::cout << "Residual ||A*X-B|| = " << frob_norm(A(i^d, j^d)*X(j&0) - B(i&0)) << " this is likely not equal to 0..." << std::endl; std::cout << "Residual ||A*X-B|| = " << frob_norm(A(i^d, j^d)*X(j&0) - B(i&0))/frob_norm(B) << " this is likely not equal to 0..." << std::endl; } /** Loading