190 likes | 410 Views
Matrices. CSLU 1100.003 Fall 2007 Cameron McInally cameron.mcinally@nyu.edu Fordham University. Matrices. Matrix In English… What is a list of items called? What is a list of lists called?. a list. a table. Matrices. Matrix In Computer Science… What is a row of elements called?
E N D
Matrices CSLU 1100.003 Fall 2007 Cameron McInally cameron.mcinally@nyu.edu Fordham University
Matrices • Matrix • In English… • What is a list of items called? • What is a list of lists called? a list. a table.
Matrices • Matrix • In Computer Science… • What is a row of elements called? • What is an array of arrays called? an array. a matrix.
Matrices • Elements of a Matrix • The items. • How do we reference a particular element in matrix M? M = M(x,y) = item y in array x
Matrices • Elements of a Matrix M = M(1,2) = M(0,0) = M(1,0) = M(3,2) = J A B L
Matrices • Examples
Matrices • Size of a Matrix • We describe the size of a matrix by its width and its height. So…. size(A) = number_of_elements(A) = 3x2 3*2 = 6
Matrices • Adding Matrices • Rule #1: The two matrices we wish to add must be the same size. • Rule #2: Add the corresponding elements in the two matrices to create a new matrix. • Rule #3: Memorize these.
Matrices • Adding Matrices Example • Rule #1: Both matrices are 3x2. • Rule #2:
Matrices • Adding Matrices Example • Rule #1:A is 3x2 and B is 2x3. A and B can not be added together!!!
Matrices • Scalar Multiplication • Rule #0: A scalar is a single number. • Rule #1: Multiply each element in a matrix by a scalar.
Matrices • Scalar Multiplication Example
Matrices • Matrix Multiplication • Rule #1 : You can only multiple two matrices if the number of columns in the first matrix is equal to the number of rows in the second matrix.
Matrices • Matrix Multiplication • Rule #1 Explained: • Can we multiply A x B? • Yes, we have a 2x3 matrix multiplied by a 3x2 matrix. The number of columns in the first one (3) matches the number of rows in the second one (3).
Matrices • Matrix Multiplication • Rule #1 Explained: • Can we multiply D x A? • No it is a 3x3 multiplied by a 2x3. The number of columns in the first one (3) does not match the number of rows in the second one (2). Note: We can multiply A x D.
Matrices • Matrix Multiplication What is A x B? First rewrite the matrices so that the first one is on the left of the result matrix and the second one is above the result matrix. Start with the first row on the left matrix and the first column on the above matrix. Multiply each pair of terms from 1..n and add them together. 30 10 6 -6
Matrices • Matrix Multiplication Example • What is D*B?
Matrices • Matrix Multiplication Practice What is AxC? What is CxA? What is AxD? What is DxA?
Homework(Always Due in One Week) Matrices • Read Appendix B section “Matrix Operations” • Complete Section 6.1 pages 623: 1 (a – e), 2(a – d) [Hint: I is the Identity Matrix] • Why is I called the Identity Matrix?