Saint Louis University |
Computer Science 146
|
Dept. of Math & Computer Science |
Topic: Matrix proxy class (first draft)
Due:
11:59pm Tuesday, 8 November 2011
Please make sure you adhere to the policies on academic integrity.
In class, we have begun discussions of what it might take to provide support for using ranges to describe submatrices in expressions that mutate the original matrix. For example, we would like support for behaviors such as
A(range(3,5), range(4,8)) = B; // assuming B is matrix with proper sizeThe solution that we have described is to use what is known as a Proxy design pattern, in which we make a second class that serves as an intermediary for providing a public view of a submatrix while internally refering to the original values of the matrix.
Unfortunately, our initial solution is incomplete. Here are some examples of syntaxes that are still illegal with our current codebase:
cout << A(2, range(3,2,9)) + A(4, range(0,3)) << endl; // add two submatrices with equal size cout << A(2, range(3,2,9)) + matrix(1,3,1) << endl; // add a submatrix to some other matrix matrix B(A(range(0,2), range(0,4))); // create a new (independent) matrix based on a submatrixYour task is to modify the code base so that the above syntaxes are supported with natural semantics.
If working on turing, change directories into a desired subdirectory of your home folder if desired, and to execute the following command verbatim
cp -R /Public/goldwasser/146/asgn07 .This will cause a new folder named asgn07 to appear in your working directory including all files that you need for this assignment. Alternatively, these files can be downloaded individual from this website. The matrix definition is essentially the same one we have been using for past assignments. However, we have written a new driver for this assignment to make it easier for you to test your code. That driver is named test and can be built with the make command.
We have changed our codebase a bit from past assignments. In particular, we have divide the code across several additional files.
makeit will attempt to compile your matrix code and the test driver. Assuming it compiles cleanly, you can execute the driver by subsequently typing
./test
Attach an updated version of any files that you modify, together with a readme.txt file that gives an overview of your changes, should be submitted electronically (details on the submission process).