1
$\begingroup$

First consider 1D case. Suppose I would like to compute \begin{alignat}{2} m_p = \sum_{x=1}^{N} x^p f(x), \qquad \forall\; p = 1, 2, \dots, P \end{alignat} I know it can be expressed as a matrix product as follows \begin{alignat}{2} \underbrace{ \begin{bmatrix} m_1 \\ m_2 \\ \vdots \\ m_P \end{bmatrix} }_{:=\, \boldsymbol{m}} = \underbrace{ \begin{bmatrix} 1^1 & 2^1 & \dots & N^1 \\ 1^2 & 2^2 & \dots & N^2 \\ \vdots & \vdots & \ddots & \vdots \\ 1^P & 2^P & \dots & N^P \end{bmatrix} }_{ :=\, X} \underbrace{ \begin{bmatrix} f(1) \\ f(2) \\ \vdots \\ f(N) \end{bmatrix} }_{:=\, \boldsymbol{f}} \end{alignat}

Now generalizing this to 2D case, I know that \begin{alignat}{2} m_{pq} = \sum_{x=1}^{N} \sum_{y=1}^{M} x^p y^q f(x, y), \qquad \forall\; p = 1, 2, \dots, P;\; q = 1, 2, \dots, Q \end{alignat} can be expressed as \begin{alignat}{2} &\underbrace{ \begin{bmatrix} m_{11} & m_{12} & \dots & m_{1Q} \\ m_{21} & m_{22} & \dots & m_{2Q} \\ \vdots & \vdots & \ddots & \vdots \\ m_{P1} & m_{P2} & \dots & m_{PQ} \end{bmatrix} }_{ :=\, M} =\\ &=\underbrace{ \begin{bmatrix} 1^1 & 2^1 & \dots & N^1 \\ 1^2 & 2^2 & \dots & N^2 \\ \vdots & \vdots & \ddots & \vdots \\ 1^P & 2^P & \dots & N^P \end{bmatrix} }_{ :=\, X} \underbrace{ \begin{bmatrix} f(1,1) & f(1,2) & \dots & f(1,M) \\ f(2,1) & f(2,2) & \dots & f(2,M) \\ \vdots & \vdots & \ddots & \vdots \\ f(N,1) & f(N,2) & \dots & f(N,M) \end{bmatrix} }_{ :=\, F} \underbrace{ \begin{bmatrix} 1^1 & 2^1 & \dots & M^1 \\ 1^2 & 2^2 & \dots & M^2 \\ \vdots & \vdots & \ddots & \vdots \\ 1^Q & 2^Q & \dots & M^Q \end{bmatrix}^{\top} }_{ :=\, Y^{\top}} \end{alignat} Now my question is how does this generalize to 3D case? That is how can I express in terms of vectors/matrices/tensors the tensor \begin{alignat}{2} \begin{pmatrix} m_{pqr} \end{pmatrix}_{p=1, q=1, r=1}^{p=P, q=Q, r=R} \end{alignat} whose elements are given as \begin{alignat}{2} m_{pqr} = \sum_{x=1}^{N} \sum_{y=1}^{M} \sum_{z=1}^{K} x^p y^q z^r f(x, y, z), \qquad \forall\; p = 1, 2, \dots, P;\; q = 1, 2, \dots, Q;\; r = 1, 2, \dots, R. \end{alignat}

$\endgroup$
1
$\begingroup$

People usually stop writing down matrices when dealing with rank-3 tensors and higher. In your case, using the Einstein summation convention,

1D: $m_p = X_{pi} f_i$ with $X_{pi} = i^p$, $f_i = f(i)$

2D: $m_{pq} = X_{pi} Y_{qj} f_{ij}$ with $X_{pi}$ as above, $Y_{qj} = j^q$, $f_{ij} = f(i,j)$.

3D: $m_{pqr} = X_{pi} Y_{qj} Z_{rk} f_{ijk}$ with $Z_{rk} = k^r$, $f_{ijk} = f(i,j,k)$.

For the 3D case, while the $X$, $Y$, and $Z$ objects could be written as matrices, the $m_{pqr}$ and $f_{ijk}$ are not easily expressed that way.

$\endgroup$
  • $\begingroup$ To clarify, the motivation for this question is not just for notation/expression purposes. I am implementing this in MATLAB programming language, where being able to recast this expression as a multiplication of matrices/tensors promises substantial gains in computational time. $\endgroup$ – aberdysh Jun 9 '17 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.