# How is the multiplication between a multidimensional tensor with a matrix defined?

I am thinking this calculation in the following way but I am wondering if it is correct. Can anybody explain to me please?

For example, I have a 3-way tensor $T^{u×i×t}$. How do I multiply this tensor with another matrix $M^{j×h}$, and what constraints this matrix must have, say dimensions etc? Is it that the matrix must has one dimension whose length equals to the length of one dimension of the tensor?

For example, the tensor is $T^{u×i×t}=T^{5×4×3}$. And a matrix is $M^{3×7}$.

So I suppose for the tensor $T^{5×4×3}$ I can slice it into 5 matrices along the $u$ mode, each of which is a matrix $M^{3×4}$. Then I can apply matrix multiplication on each slice matrix $M^{4×3}$ and the matrix $M^{3×7}$. Then finally I get a tensor which is $T^{5×4×7}$ . So,

$T^{u×i×t}×M^{t×h}=T^{u×i×h}$

Is this right?

However I suppose I can also slice the original tensor $T^{5×4×3}$ into 4 matrices along the $i$ mode. Then I can also get a tensor $T^{5×4×7}$. Will the two tensors be equal to each other?

Any references I can read more about it?

How about more higher dimensional tensors, e.g. $T^{u×i×t×h×j}$ ?

• Also, can this be done in Matlab without a for loop? Apr 5 '14 at 9:42
• Is my calculation procedure correct? Apr 5 '14 at 10:02

I notice this question has been asked some time ago and my answer is very likely too late but since people might search for it I thought providing an answer would still be a valuable contribution. Here ot goes:

A common way (though maybe not the only way) to define (tensor,matrix) products is the $n$-mode product. It's basically an extension of the idea of bilinear forms (multiply "from the left" and "from the right") to multiple dimensions (also "from behind" and in all other dimensions).

Essentially it maps an $I_1 \times I_2 \times ... \times I_N$ tensor to an $I_1 \times ... \times J_n \times ... \times I_N$ matrix by a multiplication in the $n$-th mode with a matrix that is of size $J_n \times I_n$. Therefore, the size of the tensor in the $n$-th mode must agree to the number of columns of the matrix (this being pure convention, one might have as well used the rows). It does so by multiplying each $n$-mode vector by $M$ from the left, where $n$-mode vectors are the generealization of column and row vectors (i.e., the vectors you get if all indices are fixed and one is running in its range).

A common notation of this is $S = T \times_n M$, where $T \in \mathbb{R}^{I_1 \times I_2 \times ... \times I_N}$ and $M \in \mathbb{R}^{J_n \times I_n}$.

For more information about these products and their properties I recommend consulting [*], it's freely available if you google it.

[*] Kolda, Tamara G., and Brett W. Bader. "Tensor decompositions and applications." SIAM review 51.3 (2009): 455-500.

Since you also asked how to implement it in Matlab without loops, it is quite easy:

order = [n:N,1:n-1];
Tsize = size(T);
S = ipermute(reshape(M*reshape(permute(T,order),Tsize(n),[]),[size(M,1),Tsize(order(2:end))]),order);