이산수학(Discrete Mathematics)
행렬(Matrices)
2016년 봄학기
강원대학교 컴퓨터과학전공 문양세
Introduction
Matrices
A matrix (say MAY-trix) is a rectangular array of objects
(usually numbers). (행렬은 수의 사각형 배열이다.)
An mn (“m by n”) matrix has exactly m horizontal rows,
and n vertical columns. (m개의 행과 n개의 열을 갖는 행렬)
Plural of matrix = matrices
An nn matrix is called a square matrix, whose order is n.
(행과 열의 개수가 같은 행렬을 정방행렬이라 한다.)
Tons of applications:
• Models within Computational Science & Engineering
• Computer Graphics, Image Processing, Network Modeling
• Many, many more …
Page 2
Discrete Mathematics
by Yang-Sae Moon
Matrix Equality
Matrices
Two matrices A and B are equal iff they have the same
number of rows, the same number of columns, and all
corresponding elements are equal.
(두 행렬이 같은 수의 행과 열을 가지며 각 위치의 해당 원소의 값이 같으
면 “두 행렬은 같다”고 정의한다.)
Example
3 2 3 2 3 2 0
1 6 1 6 1 6 0
Page 3
Discrete Mathematics
by Yang-Sae Moon
Row and Column Order (1/2)
Matrices
The rows in a matrix are usually indexed 1 to m from top
to bottom. (행은 위에서 아래로 1~m의 색인 값을 갖는다.)
The columns are usually indexed 1 to n from left to right.
(열은 왼쪽에서 오른쪽으로 1~n의 색인 값을 갖는다.)
Elements are indexed by row, then column.
(각 원소는 행 색인, 열 색인의 순으로 표현한다.)
a1,1 a1,2
a
a 2 ,2
2
,
1
A ai, j
am,1 am,2
Page 4
a1,n
a2,n
am,n
Discrete Mathematics
by Yang-Sae Moon
Row and Column Order (2/2)
Matrices
Let A be mn matrix [ai,j],
ith row = 1n matrix [ai,1 ai,2 … ai,n],
a1, j
a
2,j
jth column = m1 matrix .
.
.
am , j
Page 5
Discrete Mathematics
by Yang-Sae Moon
Matrix Sums
Matrices
The sum A+B of two mn matrices A, B is the mn matrix
given by adding corresponding elements.
(A+B는 (i,j)번째 원소로서 ai,j+bi,j를 갖는 행렬이다.)
A+B = C = [ci,j] = [ai,j+bi,j] where A = [ai,j] and B = [bi,j]
Example
4 1 4 4 2
1 0 1 3
2 2 3 1 3 0 3 1 3
3 4 0 1 1
2 2 5
2
Page 6
Discrete Mathematics
by Yang-Sae Moon
Matrix Products (1/2)
Matrices
For an mk matrix A and a kn matrix B, the product AB is
the mn matrix:
k
AB C ci, j ai, b, j
1
I.e., element (i,j) of AB is given by the vector dot product
of the ith row of A and the jth column of B (considered as
vectors). (AB의 원소 (i,j)는 A의 i번째 열과 B의 j번째 행의 곱이다.)
a1,1
a
2 ,1
ai ,1
am ,1
a1,2
a2 ,2
ai ,2
am ,2
...
a1,k
... a2 ,k b1,1
b2 ,1
... ai ,k
bk ,1
... am ,k
b1,2
... b1, j
b2 ,2
... b2 , j
bk ,2
... bk , j
Page 7
... b1,n c1,1
... b2 ,n c 2 ,1
... bk ,n cm ,1
c1,2
...
c 2 ,2
...
ci , j
cm ,2
...
c1,n
c 2 ,n
cm ,n
Discrete Mathematics
by Yang-Sae Moon
Matrix Products (2/2)
Matrices
Example
0 1 1 0
0 1 1
1 0 5 1
2 0 3 2 0 2 0 3 2 11 3
1 0
3
1
Matrix multiplication is not commutative!
(교환법칙 성립 안 함)
1 1
2
A
,B 1
2
1
3 2 4
AB
3
5
3
•
A = mn matrix, B = rs matrix
•
AB can be defined when n = r
•
BA can be defined when s = m
•
Both AB and BA can be defined when m = n = r = s
Page 8
1
1
3
BA
2
Discrete Mathematics
by Yang-Sae Moon
Matrix Multiplication Algorithm
Matrices
procedure matmul(matrices A: mk, B: kn)
for i := 1 to m
for j := 1 to n
begin
ci,j := 0
(m)·
(n)·
(
What’s the of its
time complexity?
(1)+
(k) ·
(1)
ci,j := ci,j + ai,qbq,j
)
for q := 1 to k
end
{C=[ci,j] is the product of A and B}
Page 9
Answer: (mnk)
k
AB C ci, j ai, b, j
1
Discrete Mathematics
by Yang-Sae Moon
Identity Matrices (항등 행렬)
Matrices
The identity matrix of order n, In, is the order-n matrix
with 1’s along the upper-left to lower-right diagonal and
0’s everywhere else. ((i,i)번째 원소가 1이고, 나머지는 모두 0인 행렬)
1 0 0
1
if
i
j
0
1
0
In
0
if
i
j
0 0 1
AIn = InA = A
Page 10
Discrete Mathematics
by Yang-Sae Moon
Matrix Inverses (역행렬)
Matrices
For some (but not all) square matrices A, there exists a
unique multiplicative inverse A-1 of A, a matrix such that
A-1A = In. (정방 행렬 A에 대해서 하나의 유일한 역행렬 A-1이 존재한다.)
If the inverse exists, it is unique, and A-1A = AA-1.
2 3 1 7 8 5 1 0 0
1 2
4 5 3 0 1 0
1
1 1 3 1 1 1 0 0 1
A
-1
A
Page 11
I3
Discrete Mathematics
by Yang-Sae Moon
Matrix Transposition (전치 행렬)
Matrices
If A=[ai,j] is an mn matrix, the transpose of A (often
written At or AT) is the nm matrix given by
At = B = [bi,j] = [aj,i] (1in,1jm)
3
2 1
0 1 2
t
Flip
across
diagonal
Page 12
2 0
1 1
3 2
Discrete Mathematics
by Yang-Sae Moon
Symmetric Matrices (대칭 행렬)
Matrices
A square matrix A is symmetric iff A=At.
I.e., i,jn: aij = aji .
Which is symmetric?
1 1
1 1
1 1
2 1 3
1
0
1
3 1 2
Page 13
3 0 1
0 2 1
1 1 2
Discrete Mathematics
by Yang-Sae Moon
Powers of Matrices (멱행렬)
Matrices
If A is an nn square matrix and p0, then:
Ap AAA···A
(A0 In)
p times
3
1
2
1 0 1
2
1
4
3
2
Example:
1 2 1 2 1
0 1 0 1 0
2
1 3
0 2 1
3
2
Page 14
Discrete Mathematics
by Yang-Sae Moon
Zero-One Matrices (0-1 행렬)
Matrices
Useful for representing other structures.
• E.g., relations, directed graphs (later in course)
All elements of a zero-one matrix are 0 or 1
• Representing False & True respectively.
The meet of A, B (both mn zero-one matrices):
AB : [aijbij] (= [aij bij])
The join of A, B: AB : [aijbij]
1 0 1
0 1
A
, B
0 1 0
1 1
1 1 1
AB
, A B
1 1 0
0
0
0 0 0
0 1 0
Page 15
Discrete Mathematics
by Yang-Sae Moon
Boolean Products (부울 곱) (1/2)
Matrices
Let A=[aij] be an mk zero-one matrix,
& let B=[bij] be a kn zero-one matrix,
The Boolean product of A and B is like normal matrix
multiplication, but
• using “” instead “+”
• using “” instead of “∙”
k
A⊙B C cij ai bj
1
Page 16
Discrete Mathematics
by Yang-Sae Moon
Boolean Products (부울 곱) (2/2)
Matrices
Example:
1 0
1 1
A 0 1 , B
0 1
1 0
(1 1) (0 0)
A⊙B (0 1) (1 0)
(1 1) (0 0)
0
1
(1 1) (0 1) (1 0) (0 1) 1 1 0
(0 1) (1 1) (0 0) (1 1) 0 1 1
(1 1) (0 1) (1 0) (0 1) 1 1 0
Algorithm of Boolean Product
procedure Boolean product(A,B: zero-one matrices)
for i := 1 to m
for j := 1 to n
begin
cij := 0
for q := 1 to k
cij := cij (aiq bqj)
end
{C = [cij] is the Boolean product of A and B.}
Page 17
Discrete Mathematics
by Yang-Sae Moon
Boolean Powers (부울 거듭제곱)
Matrices
For a square zero-one matrix A, and any k0, the kth
Boolean power of A is simply the Boolean product of k
copies of A.
(A의 k 부울린 거듭제곱)
A[k] A⊙A⊙…⊙A, A[0] In
k times
Example:
1 1 0
1 1 1
1 1 1
A 0 0 1 , A[2] A⊙A 1 0 0 , A[3] A[2]⊙A 1 1 0
1 0 0
1 1 0
1 1 1
1 1 1
A[4] A[3]⊙A 1 1 1 , A[n] A[5] A[4]
1 1 1
Page 18
Discrete Mathematics
by Yang-Sae Moon
Homework #4
Matrices
Page 19
Discrete Mathematics
by Yang-Sae Moon
© Copyright 2026 Paperzz