by Qiang Gao, updated at Mar 20, 2017
Matrix multiplication can be defined equivalently in four different ways as following, where vector $$ \mathbf{a} $$ is column vector by default and $$ \mathbf{a}^\intercal $$ means corresponding row vector, the transpose of $$ \mathbf{a} $$.
$$ \begin{align} \mathbf{A}{m \times n} \mathbf{B}{n \times p} & = \begin{bmatrix} — & \boldsymbol{\alpha}_1^\intercal & — \ & \vdots & \ — & \boldsymbol{\alpha}_m^\intercal & — \end{bmatrix} \begin{bmatrix} | & & | \ \mathbf{b}_1 & \cdots & \mathbf{b}_p \ | & & | \end{bmatrix} \ & = \begin{bmatrix} \boldsymbol{\alpha}_1^\intercal \mathbf{b}_1 & \cdots & \boldsymbol{\alpha}_1^\intercal \mathbf{b}_p \ \vdots & \ddots & \vdots \ \boldsymbol{\alpha}_m^\intercal \mathbf{b}_1 & \cdots & \boldsymbol{\alpha}_m^\intercal \mathbf{b}_p \end{bmatrix} \end{align} $$
$$ \begin{align} \mathbf{A}{m \times n} \mathbf{B}{n \times p} & = \begin{bmatrix} | & & | \ \mathbf{a}_1 & \cdots & \mathbf{a}_n \ | & & | \end{bmatrix} \begin{bmatrix} — & \boldsymbol{\beta}_1^\intercal & — \ & \vdots & \ — & \boldsymbol{\beta}n^\intercal & — \end{bmatrix} \ & = \sum{i=1}^n \mathbf{a}_i \boldsymbol{\beta}_i^\intercal \end{align} $$
$$ \begin{align} \mathbf{A}{m \times n} \mathbf{B}{n \times p} & = \begin{bmatrix} | & & | \ \mathbf{a}_1 & \cdots & \mathbf{a}n \ | & & | \end{bmatrix} \begin{bmatrix} | & & | \ \mathbf{b}1 & \cdots & \mathbf{b}p \ | & & | \end{bmatrix} \ & = \begin{bmatrix} | & & | \ \sum{i=1}^n b{i1} \mathbf{a}i & \cdots & \sum{i=1}^n b{ip} \mathbf{a}_i \ | & & | \end{bmatrix} \end{align} $$
$$ \begin{align} \mathbf{A}{m \times n} \mathbf{B}{n \times p} & = \begin{bmatrix} — & \boldsymbol{\alpha}_1^\intercal & — \ & \vdots & \ — & \boldsymbol{\alpha}m^\intercal & — \end{bmatrix} \begin{bmatrix} — & \boldsymbol{\beta}1^\intercal & — \ & \vdots & \ — & \boldsymbol{\beta}n^\intercal & — \end{bmatrix} \ & = \begin{bmatrix} — & \sum{i=1}^n a{1i} \boldsymbol{\beta}i^\intercal & — \ & \vdots & \ — & \sum{i=1}^n a{mi} \boldsymbol{\beta}_i^\intercal & — \end{bmatrix} \end{align} $$
-
If you are concerning each element of the result of $$ \mathbf{A} \mathbf{B} $$, then you should use the inner-way multiplication.
-
If you want the express $$ \mathbf{A} \mathbf{B} $$ as a sum, then you should use the outer-way multiplication.
-
If you are concerning each column of the result of $$ \mathbf{A} \mathbf{B} $$, then you should use the column-way multiplication.
-
If you are concerning each row of the result of $$ \mathbf{A} \mathbf{B} $$, then you should use the row-way multiplication.
Copyright ©2018 by Qiang Gao