Open rkuoyemnbeek opened 4 years ago
Hello, thanks for your interest in TT-Toolbox. Could you please post a Minimal Working Example for reproducing the problem? For consistent summation/concatenation, tensors must have equal mode sizes, so strictly speaking if nb~=n, the vertcat is ill-defined anyway...
Hello,
If I want to concatenate 2 tensors (A en B), it thought that the mode sizes are equal except for the first mode. So if A is a tensor of size n_1 x n_2 x … x n_d then B needs to be of size m x n_2 x … n_d, but m and n_1 could be different. But apparently I was wrong about this. In my particular case n_1 > 1 and m = 1 and then the fix I presented on github works but as soon as m > 1 and m not equal to n_1 it does not work anymore. So you can delete my post as it does not work in general.
Is there a way in the TT-toolbox to concatenate two tensors according to the first mode, without make them full again, concatenate and then again calculate a decomposition?
Regards, Koen Van: dolgov notifications@github.com Verzonden: vrijdag 31 januari 2020 20:36 Aan: oseledets/TT-Toolbox TT-Toolbox@noreply.github.com CC: rkuoyemnbeek koen.ruymbeek@hotmail.com; Author author@noreply.github.com Onderwerp: Re: [oseledets/TT-Toolbox] bug in vertcat.m (#45)
Hello, thanks for your interest in TT-Toolbox. Could you please post a Minimal Working Example for reproducing the problem? For consistent summation/concatenation, tensors must have equal mode sizes, so strictly speaking if nb~=n, the vertcat is ill-defined anyway...
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/oseledets/TT-Toolbox/issues/45?email_source=notifications&email_token=AG5NZRQWZGY7M5OWX4E7AMTRAR4THA5CNFSM4KOGFRXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKPYGVI#issuecomment-580879189, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AG5NZRT434TFEWFVN3UFRJ3RAR4THANCNFSM4KOGFRXA.
OK, I see, so you want to concatenate tensors in the first mode, keeping the leftmost rank to be 1 instead. This could be an alternative definition. Existing vertcat, horzcat concatenate tensors in the trailing TT ranks, so the mode sizes must be equal. This proved to be more convenient in the past, since we used this concatenation for only a handful of tensors, e.g. different eigenvectors, and then it was convenient to compute e.g. the Gram matrix via a single dot(a,b) command.
Your operation can be done in existing functionality by reshaping a TT to turn the first mode size into the first trailing rank, e.g. a = tt_reshape(a, n(2:end), [], n(1), 1); where the latter 2 arguments denote first resp last TT ranks. Now the vertcat will apply.
bug in for-loop, starting from line 42. Problem was that the dimension n, was the n from a different tensor, which may for the first mode of the tensor be different. This is the correct for-loop.
for j=2:nargin b = varargin{j}; rb = b.r; ps = b.ps; nb = b.n; for i=1:d-1 cr{i}(curr(i)+1:curr(i)+rb(i), :, curr(i+1)+1:curr(i+1)+rb(i+1)) = reshape(b.core(ps(i):ps(i+1)-1), rb(i), nb(i), rb(i+1)); end; cr{d}(curr(d)+1:curr(d)+rb(d), :, 1:r(d+1)) = reshape(b.core(ps(d):ps(d+1)-1), rb(d), nb(d), rb(d+1));
curr = curr+rb; end;