Not truncating properly in TT-SVD
I notice the tSVD in TT-SVD is implemented as
1468 // Find rank due to the Epsilon (NOTE the scaling factor can be ignored, as it does not change the ratios).
1469 for(size_t j = 1; j < rank; ++j) {
1470 if (tmpS[j] <= _eps*tmpS[0]) {
1471 rank = j;
1472 break;
1473 }
1474 }
which is different from Oseledets's TT paper and will make the desired error tolerance not met. I'm not sure if there will be any side effects if I simply modify the truncation procedure.
The corresponding MATLAB codes in TT-toolbox are as follows.
...
pos=1;
ep=eps/sqrt(d-1);
for i=1:d-1
m=n(i)*r(i); c=reshape(c,[m,numel(c)/m]);
[u,s,v]=svd(c,'econ');
s=diag(s); r1=my_chop2(s,ep*norm(s));
u=u(:,1:r1); s=s(1:r1);
r(i+1)=r1;
core(pos:pos+r(i)*n(i)*r(i+1)-1, 1)=u(:);
v=v(:,1:r1);
v=v*diag(s); c=v';
pos=pos+r(i)*n(i)*r(i+1);
end
...
function [r] = my_chop2(sv,eps)
sv0=cumsum(sv(end:-1:1).^2);
ff=find(sv0<eps.^2);
if (isempty(ff) )
r=numel(sv);
else
r=numel(sv)-ff(end);
end
return
end
Would you pls fix this problem? Thanks for your time!