Matrix Multiplication

Introduction

Matrices are multiplied non-commutatively.

The m rows of matrix A are multiplied by the p rows of matrix B. Therefore, note that A must be as tall as B is wide.

┌    ┐┌      ┐   ┌      ┐
│ 0 0││ 0 0 0│   │ 0 0 0│
│ 0 0││ 0 0 0│ = │ 0 0 0│
│ 0 0│└      ┘   │ 0 0 0│
└    ┘           └      ┘

  A   x   B    =     C

 mxn  x  nxp   =    mxp

A cell in a matrix is expressed as Cij where i is a row index and j is a column index.

Multiplication

In a multiplication of matrices A and B, cell Cij is solved as (row i of A)(column j of B).

Consider the following:

┌    ┐┌    ┐   ┌    ┐
│ 1 2││ 1 0│   │ 1 2│
│ 3 4││ 0 1│ = │ 3 4│
└    ┘└    ┘   └    ┘

cell (1,1) = (row 1 of A)(column 1 of B)
           = [1 2][1 0]
           = (1 * 1) + (2 * 0)
           = 1

cell (1,2) = (row 1 of A)(column 2 of B)
           = [1 2][0 1]
           = (1 * 0) + (2 * 1)
           = 2

cell (2,1) = [3 4][1 0]
           = 3

cell (2,2) = [3 4][0 1]
           = 4


CategoryRicottone