Matrix
Here we have a m ˆ n (m by n) matrix. (image source: wikipedia)
⃝c -Trenn, King’s College London 2
Matrix Multiplication
̈ ̨ ̈ ̨ ̈ ̨
c1,1 c1,2 c1,3 a1,1 a1,2 a1,3 b1,1 b1,2 b1,3 ̊‹ ̊‹ ̊‹
̊c c c ‹“ ̊a a a ‹ ̈ ̊b b b ‹ (1) 2,1 2,2 2,3 2,1 2,2 2,3 2,1 2,2 2,3
̋‚ ̋‚ ̋‚
c3,1 c3,2 c3,3 a3,1 a3,2 a3,3
From left matrix: select matching row From right matrix: select matching column Multiply them component-wise
b3,1 b3,2
b3,3
⃝c -Trenn, King’s College London
3
Matrix Multiplication
̈ ̨ ̈ ̨ ̈ ̨
c1,1 c1,2 c1,3 a1,1 a1,2 a1,3 b1,1 b1,2 b1,3 ̊‹ ̊‹ ̊‹
̊c c c ‹“ ̊a a a ‹ ̈ ̊b b b ‹ (1) 2,1 2,2 2,3 2,1 2,2 2,3 2,1 2,2 2,3
̋‚ ̋‚ ̋‚
c3,1 c3,2 c3,3 a3,1 a3,2 a3,3
From left matrix: select matching row
From right matrix: select matching column
Multiply them component-wise
ř
b3,1 b3,2
b3,3
Formula ci,j “
k ai,k ̈ bk,j
⃝c -Trenn, King’s College London
4
Matrix Multiplication
̈ ̨ ̈ ̨ ̈ ̨
c1,1 c1,2 c1,3 a1,1 a1,2 a1,3 b1,1 b1,2 b1,3 ̊‹ ̊‹ ̊‹
̊c c c ‹“ ̊a a a ‹ ̈ ̊b b b ‹ (1) 2,1 2,2 2,3 2,1 2,2 2,3 2,1 2,2 2,3
̋‚ ̋‚ ̋‚
c3,1 c3,2 c3,3 a3,1 a3,2 a3,3
From left matrix: select matching row
From right matrix: select matching column
Multiply them component-wise
ř
Formula ci,j “
c1,1 “a1,1 ̈b1,1 `a1,2 ̈b2,1 `a1,3 ̈b3,1
b3,1 b3,2
b3,3
⃝c -Trenn, King’s College London
5
k ai,k ̈ bk,j
Matrix Multiplication
̈ ̨ ̈ ̨ ̈ ̨
c1,1 c1,2 c1,3 a1,1 a1,2 a1,3 b1,1 b1,2 b1,3 ̊‹ ̊‹ ̊‹
̊c c c ‹“ ̊a a a ‹ ̈ ̊b b b ‹ (2) 2,1 2,2 2,3 2,1 2,2 2,3 2,1 2,2 2,3
̋‚ ̋‚ ̋‚
c3,1 c3,2 c3,3 a3,1 a3,2 a3,3
From left matrix: select matching row From right matrix: select matching column Multiply them component-wise
b3,1 b3,2
b3,3
⃝c -Trenn, King’s College London
6
Matrix Multiplication
̈ ̨ ̈ ̨ ̈ ̨
c1,1 c1,2 c1,3 a1,1 a1,2 a1,3 b1,1 b1,2 b1,3 ̊‹ ̊‹ ̊‹
̊c c c ‹“ ̊a a a ‹ ̈ ̊b b b ‹ (2) 2,1 2,2 2,3 2,1 2,2 2,3 2,1 2,2 2,3
̋‚ ̋‚ ̋‚
c3,1 c3,2 c3,3 a3,1 a3,2 a3,3
From left matrix: select matching row
From right matrix: select matching column
Multiply them component-wise
ř
b3,1 b3,2
b3,3
Formula ci,j “
k ai,k ̈ bk,j
⃝c -Trenn, King’s College London
7
Matrix Multiplication
̈ ̨ ̈ ̨ ̈ ̨
c1,1 c1,2 c1,3 a1,1 a1,2 a1,3 b1,1 b1,2 b1,3 ̊‹ ̊‹ ̊‹
̊c c c ‹“ ̊a a a ‹ ̈ ̊b b b ‹ (2) 2,1 2,2 2,3 2,1 2,2 2,3 2,1 2,2 2,3
̋‚ ̋‚ ̋‚
c3,1 c3,2 c3,3 a3,1 a3,2 a3,3
From left matrix: select matching row
From right matrix: select matching column
Multiply them component-wise
ř
Formula ci,j “
c2,3 “a2,1 ̈b1,3 `a2,2 ̈b2,3 `a2,3 ̈b3,3
b3,1 b3,2
b3,3
⃝c -Trenn, King’s College London
8
k ai,k ̈ bk,j
Matrix Multiplication: example
What happens if you multiply
̈ ̨
1
̊‹ ̊ 1 ‹
̊‹ ́ ̄
̊1‹ ̈ 1 2 3 4 (3) ̊‹
̊ 1 ‹
̋‚
1
⃝c -Trenn, King’s College London
9
Matrix Multiplication: example
What happens if you multiply
̈ ̨
1
̊‹ ̊ 1 ‹
̊‹ ́ ̄
̊1‹ ̈ 1 2 3 4 (3) ̊‹
̊ 1 ‹
̋‚
1
First note that if you multiply a m ˆ k matrix with k ˆ n matrix, then the out outcome is m ˆ n.
⃝c -Trenn, King’s College London 10
Matrix Multiplication: example
What happens if you multiply
̈ ̨
1
̊‹ ̊ 1 ‹
̊‹ ́ ̄
̊1‹ ̈ 1 2 3 4 (3) ̊‹
̊ 1 ‹
̋‚
1
First note that if you multiply a m ˆ k matrix with k ˆ n matrix, then the out outcome is m ˆ n.
In this case, 5 ˆ 4 since m “ 5, k “ 1, n “ 4.
⃝c -Trenn, King’s College London 11
Matrix Multiplication: example
What happens if you multiply
̈ ̨
1
̊‹ ̊ 1 ‹
̊‹ ́ ̄
̊1‹ ̈ 1 2 3 4 (3) ̊‹
̊ 1 ‹
̋‚
1
First note that if you multiply a m ˆ k matrix with k ˆ n matrix, then the out outcome is m ˆ n.
In this case, 5 ˆ 4 since m “ 5, k “ 1, n “ 4.
The outcome is
̈ ̨
1234
̊‹
̊ 1 2 3 4 ‹ ̊‹
̊1234‹ (4) ̊‹
̊ 1 2 3 4 ‹ ̋‚
⃝c -Trenn, King’s College London
12
1234
Transpose
The transpose of a matrix A is an operation which flips the matrix along its diagonal (switches the row and column indices of the matrix)
becomes
̈ ̨
abcd
A“ ̋ ‚ (5) efgh
̈ ̨
ae
̊‹
̊ b f ‹
AT “ ̊ ‹ (6)
Notethat`AT ̆T “A ⃝c -Trenn, King’s College London
13
̊ c g ‹ ̋‚
dh