Sparse Matrices ( Due 09 Apr 2017 )

There are lots of situations where you will have to use a sparse matrix. We have developed a LinkedList representation of sparse matrices in class. You will complete the implementation and run the test cases.

The first program that you will complete is TestDenseMatrix.py. The program is almost complete. You will re-work the __str__() function such that it will return a 2-D representation of the matrix with the numbers in neat columns right justified. Assume that the numbers given will not be greater than 2 digits and the products will not be greater than 4 digits. Assume also that only positive integers will be given to you.

In the TestSparseMatrix.py you will do similar implementations.

The tests for both the programs are similar. You may always write other auxiliary or helper functions if you need them. The str() function will return a string representation of the matrix that is similar to the Dense Matrix representation, i.e. in the string representation both the zero and non-zero elements will be displayed.

For both the programs you will the use the same test cases from the file matrix.txt. But your programs should be general enough to handle matrices of any size.

For this assignment you may work with a partner. Both of you must read the paper on Pair Programming. .

The files that you will be turning in will be called TestDenseMatrix.py and TestSparseMatrix.py. The headers for both files are as shown in the linked template.

If you are working with a partner both of you will be submitting a single program (from either account) but make sure that you have your partner's name and eid in your program. If you are working alone, then remove the two lines that has the partner's name and eid in the header.

Use the Canvas system to submit your TestDenseMatrix.py and TestSparseMatrix.py files. We should receive your work by 11 PM on Sunday, 09 Apr 2017. There will be substantial penalties if you do not adhere to the guidelines. Remember Python is case sensitive. The name of your file must match exactly what we have specified.

References