Homework two consists of implementing a series of methods for manipulating matrices. We shall assume that we have attached our computer to a holotransducer attached to the warp drive, and this device has provided us with a series of files each representing an array of numbers. The numbers in the file are whitespace delimited. Unfortunately, not all of the data is "good" in the sense that every so often an illegal character will present itself. You must massage the file to remove erroneous characters. You are to keep all numerical values, spaces, tabs, newlines and decimal points. All other characters are to be eliminated from the files.
At this point, what remains is supposed to be a rectangular array of (floating point) numbers. If any of the rows is longer than another, the data must be eliminated, since it does not represent a matrix. If, however, the result after bad character elimination is a rectangular array, then it may be used in the following study.
For any two matrices, you are to find the sum, the scalar multiple, the matrix product (if the matrices are compatible).
For any square matrix, you are to determine whether the matrix is invertible (determinant nonzero), and if it is you are to find its inverse. This means you must implement code to calculate the determinant of a square matrix, and must implement the elimination method to find the matrix inverse. The inverse must be written to a file. You must then provide the opportunity to multiply the original matrix times its inverse to check whether you do in fact have the correct matrix inverse.
Matrices may also present themselves that represent the coefficients of a system of n linear equations in n unknowns. You must also have code which will find the solution of any such system of equations. You may find the solution directly by using a modified elimination method, or simply find the inverse of the coefficient matrix and multiply it appropriately.
This does not all have to be in one program, but if you choose, it can be driven by a menu system which allows interaction with the user.
Due Date: 3 Feb 2012
If you have any questions, please contact Dr. Eggen.