-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug in vertcat.m #45
Comments
Hello, |
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 GitHub<#45?email_source=notifications&email_token=AG5NZRQWZGY7M5OWX4E7AMTRAR4THA5CNFSM4KOGFRXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKPYGVI#issuecomment-580879189>, or unsubscribe<https://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. |
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;
The text was updated successfully, but these errors were encountered: