Let \(\mathbf{A}\) be a matrix of size \(n\times p\) and \(B\) be a matrix of size \(p\times q\).
The
matrix product \(\mathbf{A} \times B\) is a matrix \(C\) of size \(n\times q\) where the entry \(c_{ij}\) is the dot product of the \(i\)-th row of \(\mathbf{A}\) and the \(j\)-th column of \(B\):$$c_{ij}=\sum_{k=1}^p a_{ik}b_{kj}, \qquad 1 \leqslant i \leqslant n,\; 1 \leqslant j \leqslant q.$$

The product is only defined if the number of columns in \(\mathbf{A}\) is equal to the number of rows in \(B\). We often write \(\mathbf{A}B\) for \(\mathbf{A} \times B\).