Assignment 6

An Abstract Matrix Class w/ More Derivatives

Due Date: April 15, 2011

Required for submitting:

    • Grade Sheet Print this sheet and bring it to class the day the program is due.

    • Bring your UML diagram to class.

Purpose:

  • The purpose of this exercise has many faces. Most importantly, you need the points. After that, it is important to have experience writing an abstract interface base class from which you will derive even more "specialized" classes. To this end, you will add to your generalized matrix class from the last assignment commonly encountered specialized matrices. This will be a good exercise in applying polymorphism to the matrix operations problem. Furthermore, you will experience the use of (pure) virtual functions. And from the point of view of mathematics, you will become familiar with these various categories of matrices and hopefully discover how to take advantage of their characteristics in solving problems, like Ax = b or even Ax = c. We'll leave problems such as Ax = d for later considerations. Combining the above noted ideas, you will see how polymorphism can improve the efficiency of your code for solving these problems and others.

Resources:

The Concept:

  • The concept of this assignment is the same as for the last assignment, but you will simply be adding more derived classes. You will include child classes for:

      • diagonal matices [aij = 0 for i != j]

      • symmetric matrices [aij = aji]

      • tridiagonal matices [aij = 0 for i > j + 1 or j > i + 1]

  • You will want to pay particular close attention to the access and storage implementations of these types.

Program Specifications:

    • As before, use your own design to implement this work. Make it good!

    • Considerations to think about:

      1. make as many of your matrix operations pure virtual functions as possible

      2. use data storage techniques that are as efficient as possible. Of course, you should realize that a diangonal matrix should use far less storage than a "regular" (dense) matrix.

      3. derived classes should function correctly in all manners: e.g. if A is upper triangular, then a query of A[6,5] had better return 0.

      4. arithmetic operations should be efficient; e.g. multiplying a vector times a diagonal matrix should have only n multiplies and not a bunch of 0-multiplies.

    • Of course, creating the working tools isn't any fun unless you use them to solve some profound problem. Therefore, as part of this assignment, you are going to solve Ax = b for x. I know it's mighty tempting to scream, "Enough with the Ax = b problem!", but that won't help you any. So, to make it a bit more interesting, you will code up methods to solve this problem given that the coefficient matrix, A, has special properties: (1) symmetric A; and (2) tridiagonal A. The Thomas algorithm for tridiagonal matrices and the Cholesky decomposition for symmetric matrices are presented in the text that you used for CS 228, "Numerical Methods for Engineers" by Chapra and Canale, on page 285. If you have the book still, great. If not, I can provide you with a copy. Read the material and understand the algorithms presented and code them. They're cool and you'll like them. Then, of course, I'll give you a system to solve.

    • Submit the usual: all code including a driver. Make the driver able to take command line arguments for the name of a file containing data: an int giving the size of the problem (N), an N x N matrix A, a vector B. In the future I will post a sample file HERE . Some one be sure to remind me. With this data, you will solve the system.

Deliverables:

    1. Code: I will test that the code you submit does indeed compile and run. You are to copy all your source code along with a makefile into your cs328 directory. How to do this is explained in Submission procedure.

    2. makefile: Supply the makefile which compiles and builds your program as detailed above. I really suggest that you play around with and use the third of the makefiles I posted.

    3. Your gradesheet and UML (in class, of course).