Lecture 12: Matrices Dr. Chengjiang Long Computer Vision Researcher - - PowerPoint PPT Presentation

lecture 12 matrices
SMART_READER_LITE
LIVE PREVIEW

Lecture 12: Matrices Dr. Chengjiang Long Computer Vision Researcher - - PowerPoint PPT Presentation

Lecture 12: Matrices Dr. Chengjiang Long Computer Vision Researcher at Kitware Inc. Adjunct Professor at SUNY at Albany. Email: clong2@albany.edu Important timeline Midterm exam 1 Final exam Midterm exam 2 Midterm exam 1: Oct 8th, 2018


slide-1
SLIDE 1

Lecture 12: Matrices

  • Dr. Chengjiang Long

Computer Vision Researcher at Kitware Inc. Adjunct Professor at SUNY at Albany. Email: clong2@albany.edu

slide-2
SLIDE 2
  • C. Long

Lecture 12 September 28, 2018 2 ICEN/ICSI210 Discrete Structures

Important timeline

Midterm exam 1 Midterm exam 2 Final exam Midterm exam 1: Oct 8th, 2018 (Monday) at LC-25, 9:20am – 11:20am. Coverage: Chap 1.1 -1.8, 2.1-2.6, Lecture slides 2-12. Format: 5 Problems and the 1st one is True/False Problem. The rest problems are in the similar format of homework sets. Exam policy: close book, close note. Important Propositional Equivalences will be given if necessary.

Extra points are available now!

slide-3
SLIDE 3
  • C. Long

Lecture 12 September 28, 2018 3 ICEN/ICSI210 Discrete Structures

Outline

  • Introduction to Matrix
  • Matrix Arithmetic
  • Zero-One Matrices
slide-4
SLIDE 4
  • C. Long

Lecture 12 September 28, 2018 4 ICEN/ICSI210 Discrete Structures

Outline

  • Introduction to Matrix
  • Matrix Arithmetic
  • Zero-One Matrices
slide-5
SLIDE 5
  • C. Long

Lecture 12 September 28, 2018 5 ICEN/ICSI210 Discrete Structures

Introduction

  • Scalars: A single number
  • Vector: A 1D array of numbers, where each element is

identified by an single index

  • Matrix: A 2D array of numbers
slide-6
SLIDE 6
  • C. Long

Lecture 12 September 28, 2018 6 ICEN/ICSI210 Discrete Structures

Matrix

  • Matrices are useful discrete structures that can be

used in many ways. For example, they are used to:

– describe certain types of functions known as linear

transformations.

– Express which vertices of a graph are connected by edges.

slide-7
SLIDE 7
  • C. Long

Lecture 12 September 28, 2018 7 ICEN/ICSI210 Discrete Structures

Linear transformation

slide-8
SLIDE 8
  • C. Long

Lecture 12 September 28, 2018 8 ICEN/ICSI210 Discrete Structures

Matrix: a graph are connected by edges

slide-9
SLIDE 9
  • C. Long

Lecture 12 September 28, 2018 9 ICEN/ICSI210 Discrete Structures

Matrix

Definition: A matrix is a rectangular array of numbers. A matrix with m rows and n columns is called an m×n matrix.

  • The plural of matrix is matrices.
  • A matrix with the same number of rows as columns is called

square.

  • Two matrices are equal if they have the same number of rows

and the same number of columns and the corresponding entries in every position are equal.

3 2 matrix

3 by 2 matrix

slide-10
SLIDE 10
  • C. Long

Lecture 12 September 28, 2018 10 ICEN/ICSI210 Discrete Structures

Notation

  • Let m and n be positive integers and let
  • The i-th row of A is the 1×n matrix [ai1, ai2,…,ain].

The j-th column of A is the m×1 matrix:

  • The (i,j)-th element or entry of A is the

element aij. We can use A = [aij ] to denote the matrix with its (i,j)-th element equal to aij.

slide-11
SLIDE 11
  • C. Long

Lecture 12 September 28, 2018 11 ICEN/ICSI210 Discrete Structures

Types of Matrices

  • Rectangular matrix
  • Contains more than one element and number of rows

is not equal to the number of columns

ú ú ú ú û ù ê ê ê ê ë é

  • 6

7 7 7 7 3 1 1

ú û ù ê ë é 3 3 2 1 1 1

n m ¹

slide-12
SLIDE 12
  • C. Long

Lecture 12 September 28, 2018 12 ICEN/ICSI210 Discrete Structures

Types of Matrices

  • Square matrix
  • The number of rows is equal to the number of columns

(a square matrix A has an order of m)

ú û ù ê ë é 3 1 1

ú ú ú û ù ê ê ê ë é 1 6 6 9 9 1 1 1

m x m The principal or main diagonal of a square matrix is composed of all elements aij for which i=j

slide-13
SLIDE 13
  • C. Long

Lecture 12 September 28, 2018 13 ICEN/ICSI210 Discrete Structures

Types of Matrices

  • Diagonal matrix
  • A square matrix where all the elements are zero except

those on the main diagonal

ú ú ú û ù ê ê ê ë é 1 2 1

ú ú ú ú û ù ê ê ê ê ë é 9 5 3 3

aij =0 for all i ≠ j aij = 0 for some or all i = j

slide-14
SLIDE 14
  • C. Long

Lecture 12 September 28, 2018 14 ICEN/ICSI210 Discrete Structures

Types of Matrices

  • Unit or Identity matrix - I
  • A diagonal matrix with ones on the main diagonal

aij =0 for all i ≠ j aij = 1 for some or all i = j

ú ú ú ú û ù ê ê ê ê ë é 1 1 1 1

ú û ù ê ë é 1 1 ú û ù ê ë é

ij ij

a a

slide-15
SLIDE 15
  • C. Long

Lecture 12 September 28, 2018 15 ICEN/ICSI210 Discrete Structures

Types of Matrices

  • Null (zero) matrix - 0
  • All elements in the matrix are zero

aij =0 for all i, j

ú ú ú û ù ê ê ê ë é

ú ú ú û ù ê ê ê ë é

slide-16
SLIDE 16
  • C. Long

Lecture 12 September 28, 2018 16 ICEN/ICSI210 Discrete Structures

Types of Matrices

  • Triangular matrix
  • A square matrix whose elements above or below the

main diagonal are all zero

ú ú ú û ù ê ê ê ë é 3 2 5 1 2 1 ú ú ú û ù ê ê ê ë é 3 2 5 1 2 1 ú ú ú û ù ê ê ê ë é 3 6 1 9 8 1

slide-17
SLIDE 17
  • C. Long

Lecture 12 September 28, 2018 17 ICEN/ICSI210 Discrete Structures

Types of Matrices

  • Upper Triangular matrix
  • A square matrix whose elements below the main

diagonal are all zero

aij = 0 for all i > j

ú ú ú û ù ê ê ê ë é 3 8 1 7 8 1 ú ú ú ú û ù ê ê ê ê ë é 3 8 7 4 7 1 4 4 7 1 ú ú ú û ù ê ê ê ë é

ij ij ij ij ij ij

a a a a a a

slide-18
SLIDE 18
  • C. Long

Lecture 12 September 28, 2018 18 ICEN/ICSI210 Discrete Structures

Types of Matrices

  • Lower Triangular matrix
  • A square matrix whose elements above the main

diagonal are all zero

aij = 0 for all i < j

ú ú ú û ù ê ê ê ë é 3 2 5 1 2 1 ú ú ú û ù ê ê ê ë é

ij ij ij ij ij ij

a a a a a a

slide-19
SLIDE 19
  • C. Long

Lecture 12 September 28, 2018 19 ICEN/ICSI210 Discrete Structures

Types of Matrices

  • Scalar matrix
  • A diagonal matrix whose main diagonal elements are equal

to the same scalar

  • A scalar is defined as a single number or constant

ú ú ú û ù ê ê ê ë é 1 1 1

ú ú ú ú û ù ê ê ê ê ë é 6 6 6 6

ú ú ú û ù ê ê ê ë é

ij ij ij

a a a

aij =0 for all i ≠ j aij = a for some or all i = j

slide-20
SLIDE 20
  • C. Long

Lecture 12 September 28, 2018 20 ICEN/ICSI210 Discrete Structures

Outline

  • Introduction to Matrix
  • Matrix Arithmetic
  • Zero-One Matrices
slide-21
SLIDE 21
  • C. Long

Lecture 12 September 28, 2018 21 ICEN/ICSI210 Discrete Structures

Matrix addition

Defintion: Let A = [aij] and B = [bij] be m×n matrices. The sum of A and B, denoted by A + B, is the m×n matrix that has aij + bij as its (i,j)-th element. In other words, A + B = [aij + bij]. Example: Note that matrices of different sizes can not be added.

slide-22
SLIDE 22
  • C. Long

Lecture 12 September 28, 2018 22 ICEN/ICSI210 Discrete Structures

Matrix multiplication

Definition: Let A be an n×k matrix and B be a k × n

  • matrix. The product of A and B, denoted by AB, is the

m×n matrix that has its (i,j)-th element equal to the sum of the products of the corresponding elments from the i-th row of A and the j-th column of B. In other words, if AB = [cij] then cij = ai1b1j + ai2b2j + … + akjb2j. Example: The product of two matrices is undefined when the number of columns in the first matrix is not the same as the number of rows in the second.

slide-23
SLIDE 23
  • C. Long

Lecture 12 September 28, 2018 23 ICEN/ICSI210 Discrete Structures

Illustration of matrix multiplication

  • The Product of A = [aij] and B = [bij]
slide-24
SLIDE 24
  • C. Long

Lecture 12 September 28, 2018 24 ICEN/ICSI210 Discrete Structures

Matrix multiplication is not commutative

Example: Let Does AB = BA? Solution: AB ≠ BA

slide-25
SLIDE 25
  • C. Long

Lecture 12 September 28, 2018 25 ICEN/ICSI210 Discrete Structures

Identity matrix and powers of matrices

Definition: The identity matrix of order n is the n x n matrix In = [dij], where dij = 1 if i = j and dij = 0 if i≠j. AIn = ImA = = A, when A is an m×n matrix Powers of square matrices can be defined. When A is an n ´ n matrix, we have: A0 = In Ar = AAA∙∙∙A

slide-26
SLIDE 26
  • C. Long

Lecture 12 September 28, 2018 26 ICEN/ICSI210 Discrete Structures

Transposes of matrices

Definition: Let A = [aij] be an m×n matrix. The transpose of A, denoted by AT ,is the n×m matrix

  • btained by interchanging the rows and columns of A.

If AT = [bij], then bij = aji for i =1,2,…,n and j = 1,2, ...,m.

slide-27
SLIDE 27
  • C. Long

Lecture 12 September 28, 2018 27 ICEN/ICSI210 Discrete Structures

Transposes of matrices

Definition: A square matrix A is called symmetric if A = AT. Thus A = [aij] is symmetric if aij = aji for i and j with 1≤ i≤ n and 1≤ j≤ n. Square matrices do not change when their rows and columns are interchanged.

slide-28
SLIDE 28
  • C. Long

Lecture 12 September 28, 2018 28 ICEN/ICSI210 Discrete Structures

Outline

  • Introduction to Matrix
  • Matrix Arithmetic
  • Zero-One Matrices
slide-29
SLIDE 29
  • C. Long

Lecture 12 September 28, 2018 29 ICEN/ICSI210 Discrete Structures

Zero-one matrices

Definition: A matrix all of whose entries are either 0 or 1 is called a zero-one matrix Algorithms operating on discrete structures represented by zero-one matrices are based on Boolean arithmetic defined by the following Boolean operations:

slide-30
SLIDE 30
  • C. Long

Lecture 12 September 28, 2018 30 ICEN/ICSI210 Discrete Structures

Zero-one matrices

Definition: Let A = [aij] and B = [bij] be an m ´ n zero-one matrices.

  • The join of A and B is the zero-one matrix with (i,j)-th entry

aij ∨ bij. The join of A and B is denoted by A ∨ B.

  • The meet of of A and B is the zero-one matrix with (i,j)-th

entry aij ∧ bij. The meet of A and B is denoted by A ∧ B.

slide-31
SLIDE 31
  • C. Long

Lecture 12 September 28, 2018 31 ICEN/ICSI210 Discrete Structures

Joins and meets of zero-one matrices

Example: Find the join and meet of the zero-one matrices Solution: The join of A and B is The meet of A and B is

slide-32
SLIDE 32
  • C. Long

Lecture 12 September 28, 2018 32 ICEN/ICSI210 Discrete Structures

Boolean product of zero-one matrices

Definition: Let A = [aij] be an m × k zero-one

matrix and B = [bij] be a k × n zero-one matrix. The

Boolean product of A and B, denoted by A ⊙ B, is the m×n zero-one matrix with(i,j)-th entry

cij = (ai1 ∧ b1j)∨ (ai2 ∧ b2j) ∨ … ∨ (aik ∧ bkj).

Example: Find the Boolean product of A and B, where

slide-33
SLIDE 33
  • C. Long

Lecture 12 September 28, 2018 33 ICEN/ICSI210 Discrete Structures

Boolean product of zero-one matrices

Solution: The Boolean product A ⊙ B is given by

slide-34
SLIDE 34
  • C. Long

Lecture 12 September 28, 2018 34 ICEN/ICSI210 Discrete Structures

Boolean product of zero-one matrices

Definition: Let A be a square zero-one matrix

and let r be a positive integer. The r-th Boolean power of A is the Boolean product of r factors

  • f A, denoted by A[r] . Hence,

We define A[r] to be In. (The Boolean product is well defined because the

Boolean product of matrices is associative.)

slide-35
SLIDE 35
  • C. Long

Lecture 12 September 28, 2018 35 ICEN/ICSI210 Discrete Structures

Boolean product of zero-one matrices

Example: Let Find An for all positive integers n. Solution:

slide-36
SLIDE 36
  • C. Long

Lecture 12 September 28, 2018 36 ICEN/ICSI210 Discrete Structures

Next class

  • Topic: Algorithm
  • Pre-class reading: Chap 3.1