Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Matrix of matrix of mat, Summaries of Computer Science

Yo bc shi hsjsnb. Jsnd hjd. Shjsb

Typology: Summaries

2022/2023

Uploaded on 08/21/2023

cr-dr
cr-dr 🇮🇳

1 document

1 / 24

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
13-1
ICS 141: Discrete Mathematics I – Fall 2011
University of Hawaii University of Hawaii
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
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download Matrix of matrix of mat and more Summaries Computer Science in PDF only on Docsity!

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

Applications of Matrices n Tons of applications, including: n Solving systems of linear equations n Computer Graphics, Image Processing n Games n Models within many areas of Computational Science & Engineering n Quantum Mechanics, Quantum Computing n Many, many more…

Row and Column Order n The rows in a matrix are usually indexed 1 to m from top to bottom. n The columns are usually indexed 1 to n from left to right. n Elements are indexed by row, then by column.

m m mn n n ij

a a a

a a a

a a a

a

1 2 21 22 2 11 12 1

A [ ]

Matrix Sums n The sum A + B of two matrices A , B (which must have the same number of rows, and the same number of columns) is the matrix (also with the same shape) given by adding corresponding elements of A and B. A + B = [ a ij

  • b ij
]

⎥ ⎦ ⎤ ⎢ ⎣ ⎡ − − = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ −

⎥ ⎦ ⎤ ⎢ ⎣ ⎡ − 11 5 11 9 11 3 9 3 0 8 2 6

Matrix Products

n For an m × k matrix A and a k × n matrix B , the product AB is the m × n matrix: 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!

=

k ij i j i j ik kj i j ij

c a b a b a b a b

c

1 1 1 2 2

[ ]

  

AB C

Matrix Product Example ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ = 1 1 2 1 3 1 1 1 0 2 A and B n Because A is a 2× 3 matrix and B is a 2 × 2 matrix, the product AB is not defined.

University of HawaiiUniversity of Hawaii Matrix Multiplication: 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

Matrix Multiplication Algorithm procedure matmul (matrices A : m × k , B : k × n ) for i := 1 to m for j := 1 to n begin c ij

for q := 1 to k c ij := _c ij

  • a iq b qj_ end { C = [ c ij ] is the product of A and B } What’s the Θ of its time complexity? Θ( m )·{ Θ( n )·( Θ(1)+ Θ( k ) · Θ(1))} Answer: Θ ( mnk )

n n Identity Matrices n The identity matrix of order n, I n , is the rank- n square matrix with 1’s along the upper-left to lower-right diagonal, and 0’s everywhere else. ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ ⎩ ⎨ ⎧ ≠ = = = 0 0 1 0 1 0 1 0 0 0 if 1 if [ ]        i j i j n ij I δ Kronecker Delta ∀ 1 ≤ i , jn

Powers of Matrices If A is an n × n square matrix and p ≥ 0, then: n A p = AAA···A (and A 0 = I n

n Example: p times ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ − − = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ − − ⋅ ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ − = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ − ⋅ ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ − ⋅ ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ − = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ − 3 2 4 3 2 1 3 2 1 0 2 1 1 0 2 1 1 0 2 1 1 0 2 1 1 0 2 1 3

Matrix Transposition n If A = [ a ij ] is an m × n matrix, the transpose of A (often written A t or A T ) is the n × m matrix given by A t = B = [ b ij ] = [ a ji ] (1 ≤ in ,1 ≤ jm ) ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎣ ⎡ − = − ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ − − 3 2 1 1 2 0 0 1 2 2 1 3 t

Zero-One Matrices n Useful for representing other structures. n E.g. , relations, directed graphs (later on) n All elements of a zero-one matrix are either 0 or 1. n E.g., representing False & True respectively. n The join of A , B (both m × n zero-one matrices): n AB = [ a ijb ij

]

n The meet of A , B : n AB = [ a ijb ij ] = [ a ij b ij

]

Join and Meet Example ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ ∨ ∨ ∨ ∨ ∨ ∨ ∨ = 1 1 0 1 1 1 0 1 1 1 0 0 1 0 0 1 1 0 A B ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ ∧ ∧ ∧ ∧ ∧ ∧ ∧ = 0 1 0 0 0 0 0 1 1 1 0 0 1 0 0 1 1 0 A B and ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ = 1 1 0 0 1 0 0 1 0 1 0 1 A B