oseledets/TT-Toolbox

TT Matrix by vector multiplication doesn't work for rectangular matrices if row and column modes are different

Opened this issue · 1 comments

Consider the following example

M = 192;
N = 64;
tt_x = tt_tensor(reshape(randn(N,1), factor(N)), 1e-3);
tt_P = tt_matrix(rand(M,N), 1e-3, factor(M), factor(N));
tt_P2 = tt_matrix(rand(M,N), 1e-3, [4, 2,2,2,2,3], factor(N)); % mode lengths are the same
res2 = tt_P2 * tt_x; % works ok
res = tt_P * tt_x; % fails

I am not an expert in (Q)TT formats, and don't know if it is an expected behavior. If yes, I suggest you add notes on it to the documentation or matrix multiplication header.

Thanks!

Yes, the products should have the same dimensions and core by core consistent mode sizes.
I added the corresponding remark to tt_matrix/mtimes.
The tt_matrix constructor help is already consistent, since it says " If either of N or M is shorter than another, it is expanded by ones, such that the number of TT blocks is max(length(N), length(M))"
You may use tt_reshape to adjust the mode sizes.