30
$\begingroup$

How would I go about calculating the outer product of two matrices of 2 dimensions each? From what I can find, outer product seems to be the product of two vectors, $u$ and the transpose of another vector, $v^T$.

As an example, how would I calculate the outer product of $A$ and $B$, where $$A = \begin{pmatrix}1 & 2 \\ 3 & 4\end{pmatrix} \qquad B = \begin{pmatrix}5 & 6 & 7 \\ 8 & 9 & 10\end{pmatrix}$$

$\endgroup$

3 Answers 3

25
$\begingroup$

The outer product usually refers to the tensor product of vectors. If you want something like the outer product between a $m \times n$ matrix $A$ and a $p\times q$ matrix $B$, you can see the generalization of outer product, which is the Kronecker product. It is noted $A \otimes B$ and equals: $$A \otimes B = \begin{pmatrix}a_{11}B & \dots & a_{1n}B \\ \vdots & \ddots & \vdots \\ a_{m1}B & \dots & a_{mn}B\end{pmatrix}$$

$\endgroup$
1
  • 1
    $\begingroup$ I think this answer would benefit by contrasting the outer product of a tensor algebra, and the kronecker product. See comment in tylers answer. $\endgroup$
    – LudvigH
    Apr 23, 2020 at 9:39
18
$\begingroup$

To extend davcha's answer, for your specific example, you would get:

$$A\otimes B= \left( \begin{array}{cc} \left( \begin{array}{ccc} 5 & 6 & 7 \\ 8 & 9 & 10 \\ \end{array} \right) & \left( \begin{array}{ccc} 10 & 12 & 14 \\ 16 & 18 & 20 \\ \end{array} \right) \\ \left( \begin{array}{ccc} 15 & 18 & 21 \\ 24 & 27 & 30 \\ \end{array} \right) & \left( \begin{array}{ccc} 20 & 24 & 28 \\ 32 & 36 & 40 \\ \end{array} \right) \\ \end{array} \right) $$

$\endgroup$
13
$\begingroup$

I think @davcha's answer and @Sandu Ursu's answer are wrong. They have calculated the Kronecker Product.

According to the definition of outer product, the outer product of A and B should be a $2×2×2×3$ tensor. You can follow this answer to compute it using numpy.

$\endgroup$
2
  • 1
    $\begingroup$ This is a valid point. One should be careful with the term "outer product" since it can be understood as different things. Does one expect 2 or 4 indices? $\endgroup$
    – LudvigH
    Apr 23, 2020 at 9:41
  • 2
    $\begingroup$ This is not entirely accurate. Sandu Ursu's answer is actually correct: what he described is indeed a $2 \times 2 \times 2 \times 3$ tensor; davcha's answer is just ambiguous -- it can either be treated as a $m \times n \times p \times q$ tensor or as a matrix with block notation. $\endgroup$ Sep 7, 2021 at 3:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .