JMU
Programming Assignment 2


1 Overview: For this assignment you must implement a Matrix class and modify your Vector class from programming assignment 1 appropriately.

This assignment is both about matrix arithmetic and C++. With regard to the former, you must implement various operations. With regard to the latter, you must use specialization and templates.

2 Thinking About Specialization: One could implement Matrix and Vector classes that do not make use of specialization. However, such an implementation would have several shortcomings:

To overcome these shortcomings, in this assignment if you need a row Vector you will use a \(1 \times n\) Matrix and if you need a column Vector you will use a \(m \times 1\) Matrix instead. However, you will still have a Vector "class" because it will contain the friend functions that are specific to Vecor objects.

3 Thinking About Templates: Your Vector class from programming assignment 1 is adequate but will be somewhat difficult to work with for the rest of the semester. In particular, until you become familiar with computer graphics, you are likely to make mistakes involving the dimensionality of various vectors (and matrices) and your current implementation of these classes will not "catch" those mistakes at compile-time. Hence, in this assignment you will use templates to create Vector and Matrix objects that can be checked for dimensional mismtaches at compile-time.
4 Detailed Specification: The detailed specification/design for (and partial implementations of) the Matrix and Vector templates are available on-line:

Matrix ( Design )

Vector ( Design )

Note that, in keeping with the course style guide, templates should have a suffix of .hpp (if possible in your development environment).

5 Unit Testing: You must write a driver to test your implementation of the Matrix class and your modified implementation of the Vector class. As before, your driver must include at least three test cases for each method/operator.
6 Compile-Time Testing: In addition to the run-time tests, you must ensure that dimensional mismatches are caught at compile-time. For example, given the the declarations and initializations:
      Matrix<2,2> A;      
      Matrix<2,3> B;

      A = {5,1,
           8,9};

      B = {2,7,0,
           3,4,6};
  

The operationr B*A should generate a compile-time error (something like "No match for operator*").

7 Submission: In addition to the normal materials, your submission must include: your new driver for this programming assignment, and the hardcopy output from your driver for this assignment.
8 A Special Note About Collaboration on this Assignment: You may share code from your driver (only) with other students. However, if you include code in your driver that you did not write you must include a comment (for each test case) that credits the source. In either words, you may form a team to create test cases (to reduce the burden on any individual but still ensure that your code is adequately tested).
9 Grading: Your implementation must work correctly for you to receive credit for this assignment.

Copyright 2014