Presentation is loading. Please wait.

Presentation is loading. Please wait.

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 1/21 Module.

Similar presentations


Presentation on theme: "Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 1/21 Module."— Presentation transcript:

1

2 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 1/21 Module #10 - Matrices Bogazici University Department of Computer Engineering CmpE 220 Discrete Mathematics 10. Matrices Haluk Bingöl

3 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 2/21 Module #10 - Matrices Module #10: Matrices Rosen 5 th ed., §2.7 ~18 slides, ~1 lecture

4 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 3/21 Module #10 - Matrices §2.7 Matrices A matrix is a rectangular array of objects (usually numbers). An m  n (“m by n”) matrix has exactly m horizontal rows, and n vertical columns. Plural of matrix = matrices (say MAY-trih-sees) An n  n matrix is called a square matrix, whose order or rank is n. a 3  2 matrix Note: The singular form of “matrices” is “matrix,” not “MAY-trih-see”! Not our meaning!

5 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 4/21 Module #10 - Matrices Applications of Matrices Tons of applications, including: Solving systems of linear equations Computer Graphics, Image Processing Models within many areas of Computational Science & Engineering Quantum Mechanics, Quantum Computing Many, many more…

6 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 5/21 Module #10 - Matrices Matrix Equality Two matrices A and B are considered equal iff they have the same number of rows, the same number of columns, and all their corresponding elements are equal.

7 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 6/21 Module #10 - Matrices Row and Column Order The rows in a matrix are usually indexed 1 to m from top to bottom. The columns are usually indexed 1 to n from left to right. Elements are indexed by row, then column.

8 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 7/21 Module #10 - Matrices Matrices as Functions An m  n matrix A = [a i,j ] of members of a set S can be encoded as a partial function f A : N  N → S, such that for i<m, j<n, f A (i, j) = a i,j. By extending the domain over which f A is defined, various types of infinite and/or multidimensional matrices can be obtained.

9 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 8/21 Module #10 - Matrices Matrix Sums 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 i,j +b i,j ] A+B = [a i,j +b i,j ]

10 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 9/21 Module #10 - Matrices Matrix Products For an m  k matrix A and a k  n matrix B, the product AB is the m  n matrix: I.e., the element of AB indexed (i,j) is given by the vector dot product of the ith row of A and the jth column of B (considered as vectors). Note: Matrix multiplication is not commutative!

11 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 10/21 Module #10 - Matrices Matrix Product Example An example matrix multiplication to practice in class:

12 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 11/21 Module #10 - Matrices n n Identity Matrices 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. Kronecker Delta 1≤i,j≤n1≤i,j≤n

13 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 12/21 Module #10 - Matrices Review: §2.6 Matrices, so far Matrix sums and products: A+B = [a i,j +b i,j ] A+B = [a i,j +b i,j ] Identity matrix of order n: I n = [  ij ], where  ij =1 if i=j and  ij =0 if i  j.

14 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 13/21 Module #10 - Matrices Matrix Inverses For some (but not all) square matrices A, there exists a unique multiplicative inverse A −1 of A, a matrix such that A −1 A = I n. If the inverse exists, it is unique, and A −1 A = AA −1. We won’t go into the algorithms for matrix inversion...

15 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 14/21 Module #10 - Matrices 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 := 0 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)

16 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 15/21 Module #10 - Matrices Powers of Matrices If A is an n  n square matrix and p  0, then: A p :  AAA···A (and A 0 :  I n ) Example: p times

17 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 16/21 Module #10 - Matrices 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  i  n,1  j  m) Matrix Transposition Flip across diagonal

18 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 17/21 Module #10 - Matrices Symmetric Matrices A square matrix A is symmetric iff A=A t. I.e.,  i,j  n: a ij = a ji. Which of the below matrices is symmetric?

19 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 18/21 Module #10 - Matrices Zero-One Matrices Useful for representing other structures. E.g., relations, directed graphs (later in this course) All elements of a zero-one matrix are either 0 or 1 Representing False & True respectively. The join of A, B (both m  n zero-one matrices): A  B :  [a ij  b ij ] The meet of A, B: A  B :  [a ij  b ij ] = [a ij b ij ] The 1’s in A join the 1’s in B to make up the 1’s in C. Where the 1’s in A meet the 1’s in B, we find 1’s in C.

20 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 19/21 Module #10 - Matrices Boolean Products Let A=[a ij ] be an m  k zero-one matrix, & let B=[b ij ] be a k  n zero-one matrix, The boolean product of A and B is like normal matrix , but using  instead of + in the row-column “vector dot product”: A⊙BA⊙B

21 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 20/21 Module #10 - Matrices Boolean Powers For a square zero-one matrix A, and any k  0, the kth Boolean power of A is simply the Boolean product of k copies of A. A [k] :  A ⊙ A ⊙ … ⊙ A A [0] :  I n k times

22 Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 21/21 Module #10 - Matrices References Rosen Discrete Mathematics and its Applications, 5e Mc GrawHill, 2003Rosen Discrete Mathematics and its Applications, 5e Mc GrawHill, 2003


Download ppt "Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl 1/21 Module."

Similar presentations


Ads by Google