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.
Matrix and Vector classes
that do not make use of specialization. However, such an implementation
would have several shortcomings:
Vector objects would be identical to the code for
adding and subtracting two \(n \times 1\) or
\(1 \times n\) Matrix objects).
Matrix class would contain "unnecessary" methods
(e.g., to pre-multiply and post-multiply a Matrix
by a Vector).
Matrix and an
\(n \times n\) Matrix a
Vector or a \(1 \times n\) Matrix?).
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.
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.
Matrix and Vector templates are
available on-line:
Note that, in keeping with the course style guide, templates should
have a suffix of .hpp (if possible in your development
environment).
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.
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*").
Copyright 2014