DOC PREVIEW
OSU CS 419 - Matrices

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1MatricesMike [email protected] State Universitymjb – September 5, 2014Oregon State UniversityComputer GraphicsMatricesA matrix is a 2D array of numbers, arranged in rows that go across and columns that go down:A column:123456 7 84 columns3 rowsmjb – September 5, 2014Oregon State UniversityComputer Graphics9101112Matrix sizes are termed “#rows x #columns”, so this is a 3x4 matrix2Matrix TransposeA matrix transpose is formed by interchanging the rows and columns:128411731062951121110987654321Tmjb – September 5, 2014Oregon State UniversityComputer Graphics1284This is a 3x4 matrix This is a 4x3 matrixSquare MatricesA square matrix has the same number of rows and columns1234563 columns3 rowsmjb – September 5, 2014Oregon State UniversityComputer Graphics789This is a 3x3 matrix3Row and Column MatricesA matrix can have a single row (a “row matrix”) or just a single column (a “column matrix”)”123456This is a 1x3 matrixmjb – September 5, 2014Oregon State UniversityComputer GraphicsThis is a 3x1 matrix6Sometimes these are called row and column vectors, but that overloads the word “vector” and we won’t do it…Matrix MultiplicationThe basic operation of matrix multiplication is to pair-wise multiply a single row by a single columnAC123456*→32***→4*1 + 5*2 + 6*3mjb – September 5, 2014Oregon State UniversityComputer GraphicsAB61x3 3x1 1x14Matrix MultiplicationTwo matrices, A and B, can be multiplied if the number of columns in A equals the number of rows in B. The result is a matrix that has the same number of rows as A and the same number of columns as B.  *          ABCmjb – September 5, 2014Oregon State UniversityComputer GraphicsI x K K x JI x JMatrix Multiplication in SoftwareHere’s how to remember how to do it:1C=A*B1.C = A B2. [ I x J ] = [ I x K ] * [ K x J ]I x K K x JI x J=mjb – September 5, 2014Oregon State UniversityComputer GraphicsC[ i ][ j ] = A[ i ][ k ] * B[ k ][ j ] ;5Matrix Multiplication in Softwarefor( int i = 0; i < numArows; i++ )(;;){for( int j = 0; j < numBcols; j++ ){C[ i ][ j ] = 0.;for( int k = 0; k < numAcols; k++ ){mjb – September 5, 2014Oregon State UniversityComputer GraphicsC[ i ][ j ] += A[ i ][ k ] * B[ k ][ j ];}}}Note: numAcols must == numBrows !Matrix Multiplication in SoftwareNote that:C[ i ][ j ] = 0.;for( int k = 0; k < numAcols; k++ ){C[ i ][ j ] += A[ i ][ k ] * B[ k ][ j ];}mjb – September 5, 2014Oregon State UniversityComputer Graphics}Is like saying:C[ i ][ j ] = A[i][0] * B[0][j] + A[i][1] * B[1][j] + A[i][2] * B[2][j] + A[i][3] * B[3][j] ;6Matrix Multiplication where B and C are Column Matricesfor( int i = 0; i < numArows; i++ ){C[ i ] 0C[ i ] = 0.;for( int k = 0; k < numAcols; k++ ){C[ i ] += A[ i ][ k ] * B[ k ];}}mjb – September 5, 2014Oregon State UniversityComputer GraphicsTo help you remember this, think of the “C[ i ]“ lines as:C[ i ][ 0 ] = 0.;…C[ i ][ 0 ] += A[ i ][ k ] * B[ k ][ 0 ];A Special MatrixConsider the matrix * column situation below:0xzy xCAAB  00yzxyzyx zCA ABCAA B    ()CABABABABABABThis gives:mjb – September 5, 2014Oregon State UniversityComputer Graphics(,,)yz zy zx xz xy yxCABABABABABAB  Which you hopefully recognize as the Cross Product AxB7DeterminantsThe determinant is important in graphics applications. It represents sort of a “scale factor”, when the matrix is used to represent a transformation.The determinant of a 2x2 matrix is easy:detABADBCCDmjb – September 5, 2014Oregon State UniversityComputer GraphicsDeterminantsdetABCDEFThe determinant of a 3x3 matrix is done in terms of its component 2x2 sub-matrices:detDEFGH Idet det detEF DF DEABCHIGIGH      mjb – September 5, 2014Oregon State UniversityComputer Graphics()()( )AEI FH B DI FG C DH EG     8InversesThe matrix inverse is also important in graphics applications because it represents the undoing of the original transformation matrix. It is also useful in solving systems of simultaneous equations.The inverse of a 2x2 matrix is the transpose of the cofactor matrix dividedThe inverse of a 2x2 matrix is the transpose of the cofactor matrix divided by the determinant:11ABDBCD C AAD BC      mjb – September 5, 2014Oregon State UniversityComputer GraphicsCD C AAD BC  Inverses1ABCDEFThe determinant of a 3x3 matrix is done in terms of its component 2x2 sub-matrices:det det detEF DF DEHI GI GH      DEFGH Idet det detdet det detBC AC ABHI GI GHBC AC ABEF DF DEABC  mjb – September 5, 2014Oregon State UniversityComputer GraphicsThe determinant of 4x4 and larger matrices can be done in a similar way, but usually isn’t. Gauss Elimination is more efficient.det DEFGH


View Full Document

OSU CS 419 - Matrices

Download Matrices
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Matrices and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Matrices 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?