280 likes | 402 Views
Lecture 08a: MATRICES Sec 2.7. CS1050: Understanding and Constructing Proofs. Spring 2006. Jarek Rossignac. Lecture Objectives. Understand vectors, matrices, their products and properties. Illustrate these on linear transformations. What do coordinates mean?.
E N D
Lecture 08a: MATRICESSec 2.7 CS1050: Understanding and Constructing Proofs Spring 2006 Jarek Rossignac
Lecture Objectives • Understand vectors, matrices, their products and properties. • Illustrate these on linear transformations
What do coordinates mean? • Let C be a coordinate system with origin o and basis (i, j) • i and j are unit length vectors orthogonal to each other • Let point p have coordinates (x,y) in C • Define p in terms of x, y, o, i, j: p = o + xi + yj start at o make x steps in the i direction make y steps in the j direction p y x j i o
p xp y yp x i j yi xi o yo xo How do we represent points and vectors? Using an ordered set of coordinates in an agreed-upon, yet not specified, global coordinate system o = (xo, yo ) i = ( xi, yi ) j = ( xj, yj ) p = ( xp, yp )
Operations on points and vectors • Subtracting two points yields a vector (displacement) ( xp , yp ) – ( xo , yo ) =( xp– xo , po– yo ) • Adding a vector to a point moves the point ( xo , yo ) + ( xj , yj ) =( xo+xj , yo+yj ) • Adding two vectors adds the corresponding coordinates ( xi , yi ) + ( xj , yj ) =( xi+xj , yi+yj ) • Multiplying a vector by a scalar multiplies its length s( xi, yi ) =( sxi, syi ) • The dot product of two vectors is the sum of the products of corresponding terms ( xi , yi ) ( xj , yj ) = ( xi xj + yiyj )
What is a matrix? • A scalar or ordered set of matrices • scalars, vectors, mxn tables are matrices For example (i , j , o ) is a 2x3 matrix often presented as a table (i , j , o ) =
What is a matrix-vector product? Generalization of the dot product: Sum of products of corresponding terms (a , b , c )( x , y, z) = ax+by+cz
What is the matrix form of (xp,yp)? p =xi +yj + o = ( i , j , o ) ( x , y, 1) ( xp , yp ) = x( xi , yi ) + y( xj , yj ) + ( xo , yo ) = ( xxi , xyi ) + ( yxj , yyj ) + ( xo , yo ) = ( xxi+yxj+xo , xyi+yyj+ yo ) =
What is the homogeneous representation? • Add a third coordinate: 1 for points, 0 for vectors o = (xo, yo, 1) i = ( xi, yi, 0) j = ( xj, yj, 0) p = ( xp, yp, 1)
Homogeneous matrix form of (xp,yp)? p =xi +yj + o = ( i , j , o ) ( x , y, 1) ( xp , yp , 1) = x( xi , yi , 0) + y( xj , yj , 0) + 1( xo , yo , 1) = ( xxi+yxj+xo , xyi+yyj+ yo , 1) =
Performing the multiplication • Multiply columns and add =
p xp y yp x i j yi xi o yo xo How to compute (x,y) ? o = (xo, yo ), i = ( xi, yi ), j = ( xj, yj ), p = ( xp, yp ) Let op = p – o x = opi y = opj vi is the normal projection of vector v on the unit vector i
How to extend this to 3D ? o = (xo, yo, zo, 1) i = ( xi, yi, zi, 0) j = ( xj, yj, zj, 0) p = ( xp, yp, zp, 1) p zp (0,0,1) (0,1,0) yp (1,0,0) xp
More general notation for matrices A = [ aij ]rc i is the row number j is the column number We say that A is an rc matrix if it has r rows and c columns We say that an nn matrix is square. In a square matrix, aii are the diagonalelements. Their sum aij is the trace of A A34 =
Operations for matrices Equality: [ aij ]mn = [ bij ]mn when ij aij = bij Addition: [ aij ]mn + [ bij ]mn = [ aij + bij ]mn Multiplication: [ aij ]mk [ bij ]kn = [ ai* b*j ]mn ai*is a vector made from the row elements: (ai1 , ai2 ,… aic) b*j is a vector made from the column elements: (b1j , b2j ,… brj) In general, matrix multiplication is not commutative AB≠BA
What is the cost of matrix multiplication? How many multiplications, additions are performed when multiplying two nn matrices? We need to compute n2 dot products Each one requires n multiplications and n–1 additions Total: n3 multiplications and (n–1)n2 additions
Best order for chain multiplication? Matrix multiplication is associative: ((Akm Bmn)Cno)Dop = Akm((BmnCno)Dop) Which order requires fewest multiplications? (Akm Bmn) requires kmn multiplications (kn of m) ((Akm Bmn)Cno)Dop requires kmn+kno+kod Akm((BmnCno)Dop) requires mno+mop+kmp
What is the identity matrix? In = [ ij ]nn where ii = 1 and ij = 0 when i≠j diagonal terms are 1, the others 0 Property of identity: AmnIn = ImAmn= Amn
What is the power of a square matrix? Ann0= In Annk= AnnAnn … Ann (product of k matrices)
What is the transpose of a matrix? [ aij ]mnt= [ aji ]nm
When is a square matrix symmetric? A is symmetric if A=At, i.e., ij aij= aji A mirror reflection about the diagonal will not change the matrix.
What are joins and meets of binary matrices? Entries represent truth values (denoted 0 and 1 for simplicity) The join of two Boolean matrices is [ aij ]mn [ bij ]mn = [ aij bij ]mn The meet of two Boolean matrices is [ aij ]mn[ bij ]mn = [ aij bij ]mn
What is the Boolean product? The dot product of two Boolean vectors is the disjunctive form [ ai ]k [ bi ]k = a1b1 a2b2 … akbk The Boolean product of two binary matrices is [ aij ]mk[ bij ]kn = [ ai* b*j ]mn
What is the Boolean product? The dot product of two Boolean vectors is the disjunctive form [ ai ]k [ bi ]k = a1b1 a2b2 … akbk The Boolean product of two binary matrices is [ aij ]mk[ bij ]kn = [ ai* b*j ]mn
What is the Boolean power? The rthBoolean power , denoted A[r], of a square binary matrix A is A[r] = AA … A (Boolean product of r terms) with A[0] = I
Assigned Reading • 2.7
Assigned Exercises for Quiz • Page 204-205: 4.a, 13, 19 • Changes of coordinate system • Assume that you have a series of m transformations each represented in homogeneous form by a 4x4 matrix and v vertices, which you want to transform by each matrix in the series. Is it cheaper to first compute the result of multiplying the series into a single matrix and then use it to transform all the vertices, or is it cheaper to multiply each vertex by the each matrix? Does the answer depend on the values of m and v? If so, how?