Professional Documents
Culture Documents
19 Matrices
19 Matrices
ICS141:
Discrete Mathematics for
Computer Science I
Dept. Information & Computer Sci., University of Hawaii
Jan Stelovsky
based on slides by Dr. Baek and Dr. Still
Originals by Dr. M. P. Frank and Dr. J.L. Gross
Provided by McGraw-Hill
Lecture 19
Chapter 3. The Fundamentals
3.8 Matrices
⎡ 3 2⎤ ⎡ 3 2 0⎤
⎢− 1 6⎥ ≠ ⎢− 1 6 0⎥
⎣ ⎦ ⎣ ⎦
AB = C = [cij ]
k
cij = ai1b1 j + ai 2b2 j + + aik bkj = ∑ aibj
=1
n I.e., the element of AB indexed (i, j) is given by
the vector dot product of the i-th row of A and
the j-th column of B (considered as vectors).
n Note: Matrix multiplication is not commutative!
ICS 141: Discrete Mathematics I – Fall 2011 13-8
Matrix Product Example
University of Hawaii
⎡0 − 1⎤
⎡0 1 − 1⎤ ⎢ ⎥
⎢2 0 ⎥ ⋅ ⎢2 0⎥
⎣ 3⎦
⎢⎣ 1 0⎥⎦
⎡0 ⋅ 0 + 1⋅ 2 + (−1) ⋅1 0 ⋅ (−1) + 1 ⋅ 0 + (−1) ⋅ 0⎤
= ⎢ ⎥
⎣ 2 ⋅ 0 + 0 ⋅ 2 + 3 ⋅1 2 ⋅ (−1) + 0 ⋅ 0 + 3 ⋅ 0⎦
⎡ 1 0⎤
= ⎢ ⎥
⎣3 − 2⎦
Non-Commutative
n Matrix multiplication is not commutative!
n A: m × n matrix and B: r × s matrix
n AB is defined when n = r
n BA is defined when s = m
n When both AB and BA are defined, generally they
are not the same size unless m = n = r = s
n If both AB and BA are defined and are the same size,
then A and B must be square and of the same size
n Even when A and B are both n × n matrices,
AB and BA are not necessarily equal
procedure matmul(matrices A: m × k, B: k × n)
for i := 1 to m Θ(m)·{ What’s the Θ of its
time complexity?
for j := 1 to n begin Θ(n)·(
⎡1 0 0⎤
∀1 ≤ i, j ≤ n
⎡⎧1 if i = j ⎤ 0 ⎢ ⎥
1 0⎥
I n = [δ ij ] = ⎢⎨ ⎥ = ⎢ n
⎣⎩0 if i ≠ j ⎦ ⎢ ⎥
⎢ ⎥
Kronecker Delta ⎣0 0 1⎦
⎡ 2 1⎤ ⎡ 3 2⎤
= ⎢ ⎥ ⋅ ⎢ ⎥
⎣ − 1 0 ⎦ ⎣ − 2 − 1⎦
⎡ 4 3⎤
= ⎢ ⎥
⎣ − 3 − 2 ⎦
ICS 141: Discrete Mathematics I – Fall 2011 13-16
Matrix Transposition
University of Hawaii
t ⎡2 0⎤
⎡2 1 3⎤ ⎢ ⎥
⎢0 − 1 − 2⎥ = ⎢ 1 − 1⎥
⎣ ⎦ ⎢⎣ 3 − 2⎥⎦
n The meet of A, B:
n A ∧ B = [aij ∧ bij] = [aij bij]
⎡ k ⎤
∨
A⊙B = C = [cij ] = ⎢ ai ∧ bj ⎥
⎣ =1 ⎦
A[k] = A ⊙ A ⊙ ··· ⊙ A
k times
A[0] = In