Commit ef9c35bc authored by Sebastian Wolf's avatar Sebastian Wolf

Minor fix for random TT creation

parent 60938073
Pipeline #671 failed with stages
in 3 minutes and 41 seconds
......@@ -140,12 +140,14 @@ namespace xerus {
for(size_t i = 0; i < numComponents; ++i) {
const size_t leftRank = i==0 ? 1 : targetRank[i-1];
const size_t rightRank = i==numComponents-1 ? 1 : targetRank[i];
const size_t rightRank = (i==numComponents-1) ? 1 : targetRank[i];
if(isOperator) {
result.set_component(i, Tensor::random({leftRank, _dimensions[i], _dimensions[numComponents+i], rightRank}, _dist, _rnd));
const auto rndComp = Tensor::random({leftRank, _dimensions[i], _dimensions[numComponents+i], rightRank}, _dist, _rnd);
result.set_component(i, rndComp/rndComp.frob_norm());
} else {
result.set_component(i, Tensor::random({leftRank, _dimensions[i], rightRank}, _dist, _rnd));
const auto rndComp = Tensor::random({leftRank, _dimensions[i], rightRank}, _dist, _rnd);
result.set_component(i, rndComp/rndComp.frob_norm());
}
}
result.move_core(0);
......@@ -178,11 +180,13 @@ namespace xerus {
const std::function<void(Tensor&)> &_modifySingularValues,
distribution& _dist=xerus::misc::defaultNormalDistribution, generator& _rnd=xerus::misc::randomEngine)
{
const size_t numComponents = _dimensions.size()/N;
TTNetwork result = random(_dimensions, _ranks, _dist, _rnd);
const Index i,j,k,l,m;
for (size_t pos = 0; pos+1 < result.degree(); ++pos) {
for (size_t pos = 0; pos+1 < numComponents; ++pos) {
Tensor A;
A(i,j^N,k^N,l) = result.component(pos)(i,j^N,m) * result.component(pos+1)(m,k^N,l);
Tensor U,S,Vt;
......
......@@ -208,12 +208,12 @@ namespace xerus {
CHECK(lapackAnswer == 0, warning, "Call was: LAPACKE_dgesdd(LAPACK_ROW_MAJOR, 'S', " << static_cast<int>(_m) << ", " << static_cast<int>(_n) << ", " << _A << ", " << static_cast<int>(_n) <<", "
<< _S <<", " << _U << ", " << static_cast<int>(std::min(_m, _n)) << ", " << _Vt << ", " << static_cast<int>(_n) << ");");
if(lapackAnswer != 0) {
LOG(warning, "A was: ");
for(size_t i=0; i < _m; ++i) {
for(size_t j=0; j < _n; ++j) {
LOG(warning, tmpA[i*_n+j]);
}
}
LOG(warning, "SVD failed ");
// for(size_t i=0; i < _m; ++i) {
// for(size_t j=0; j < _n; ++j) {
// LOG(warning, tmpA[i*_n+j]);
// }
// }
}
XERUS_PA_END("Dense LAPACK", "Singular Value Decomposition", misc::to_string(_m)+"x"+misc::to_string(_n));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment