18
$\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$
19
$\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$
12
$\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$
1
$\begingroup$

I think @davcha and @Sandu Ursu 's answers 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$

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.