Closed nicolacavallini closed 9 months ago
Dear Nicola,
just compute expected = kron(b,a);
This is an old embarrassing inconsistency between the linear algebra definition of the Kronecker product and the order of array elements in Fortran and derived languages like Matlab. In mathematics, the Kronecker $c = a \otimes b := [a_{i} b]$ and matrix $C = a b^T$ products of vectors contain the same elements $a_i bj$. However, the elements of $c$ are indexed as $c{(i-1)n+j}$ whereas the elements of $C$ are indexed as $c{i+(j-1)n}$. The TT-Toolbox implements the latter, since its original purpose was to compress and restore high-dimensional arrays which Matlab stores always in the $i+(j-1)n+...$ order of elements. It is recommended to use tkron
to compute a Kronecker-like product $a \bar\otimes b := [a b{i}]$ between tttensors and $A \bar\otimes B := [A B{i,j}]$ between tt_matrices, which match the ordering of the full array.
Best, Sergey.
Dear Sergey,
thanks a lot for you reply.
I still need a clarification though:
It is quite important to me to get the ordering of the cores right, because I need to respect a lexicographical ordering of the degrees of freedom.
Am I correct? thanks a lot for your help, Nicola
Looks good. For small matrices like these you can always check with full() that the TT cores you assembled give the full matrix you expect, and vice versa, that the TT-SVD constructor tt_matrix(reshape(A, 2,3,2,3)) gives TT cores (up to rotation and normalisation) you expect.
Thanks a lot Sergey, this helped a lot, best, Nicola
Dears,
I found an issue in going from TT to full format using TT toolbox.
The resulting and expected matrices do not match.
Here a minimal example code to reconstruct the issue.
Am I getting something wrong?
thanks a lot, best, Nicola