{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture21

# lecture21 - 1.00 Lecture 21 Matrices Matrices Matrix is 2-D...

This preview shows pages 1–5. Sign up to view the full content.

1.00 Lecture 21 October 28, 2005 Matrices Matrices Matrix is 2-D array of m rows by n columns a a a 00 a 01 a 02 a 03 … a 0n 10 a 11 a 12 a 13 … a 1n 20 a 21 a 22 a 23 … a 02n a …… m0 a m1 a m2 a m3 … a mn In math notation, we use index 1, … m and 1, … n. In Java, we usually use index 0, … m-1 and 0, …n-1 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Matrices and Linear Systems Matrices often used to represent a set of linear equations: a 00 x 0 + a 01 x 1 + a 02 x 2 + … + a 0,n-1 x n-1 = b 0 a 10 x 0 + a 11 x 1 + a 12 x 2 + … + a 1,n-1 x n-1 = b 1 a m-1,0 x 0 + a m-1,1 x 1 + a m-1,2 x 2 + … + a m-1,n-1 x n-1 = b m-1 n unknowns x are related by m equations Coefficients a are known, as are right hand side b Matrix representation a 00 a 01 a 02 a 03 … a 0,n-1 x 0 a 10 a 11 a 12 a 13 … a 1,n-1 x 1 a 20 a 21 a 22 a 23 … a 2,n-1 x 2 …… a m-1,0 a m-1,1 a m-1,2 a m-1,3. .. a m-1,n-1 x n-1 = b b 0 1 b b 2 m-1 (m rows x n cols) (n x 1) = (m x 1) Ax=b 2
Matrices, p.2 If n=m, we will try to solve for unique set of x. Obstacles: If any row (equation) or column (variables) is linear combination of others, matrix is degenerate or not of full rank. No solution. If rows or columns are nearly linear combinations, roundoff errors can make them linearly dependent during computations. We’ll fail to find a solution, even though one may exist. Roundoff errors can accumulate rapidly. While you may get a solution, when you substitute it into your equation system, you’ll find it’s not a solution. Linear systems tend to be close to singular (degenerate). Beware! We’ll do solutions for linear systems next lecture Matrices, p.3 In this lecture we cover basic matrix representation and manipulation Used most often to prepare matrices for use in solving linear systems Java has 2-D arrays, declared as, for example double[ ][ ] squareMatrix= new double[5][5]; But there are no built-in methods for them 3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Matrices, p.4 So, it’s helpful to create a Matrix class: Create methods to add, subtract, multiply, form identity matrix, etc. Sparse matrices are handled differently: Almost all large matrices are extremely sparse (99%+ of entries are zeros) Store (i, j, value) in a list or 1-D array 2-D Arrays data[0][0] data data[0] 8.0 14.0 2.0 3.0 No of columns= data[0].length data[1] 5.1 4.2 6.6 0.8 data[2] 2.4 6.4 0.4 4.3 data[2] 3.3 3.2 5.5 6.6 data[3] 12.3 3.7 9.3 3.0 No. of rows= data.length A 2-D array is: a reference to a 1-D array of references to 1-D arrays of data.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 15

lecture21 - 1.00 Lecture 21 Matrices Matrices Matrix is 2-D...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online