Sample Assignment: The Matrix Class
|
|
matrix.h:
The header file for the new matrix
class.
matrix.cxx:
The implementation file for the new
matrix class. You will write all of this file, which will
have the implementations of all the matrix's member functions.
matrixtest.cxx
A simple interactive test program. You may write this
program on your own, or you may work together with one or two
other students (sharing your test code).
As indicated above, you will implement a new class called matrix, using a header file and an implementation file. Each matrix object is a rectangular grid of double numbers. The maximum number of rows and columns for the matrix is defined by a static member constant of the matrix class called MAX, which should be set to ten for this assignment. Keep in mind that your implementation should continue to work correctly when we change the size of MAX (something that you can be sure the TA will do when grading your work).
The rows and columns of any matrix can be indexed by
size_t
numbers starting at zero. So, if a matrix has
seven rows, then the indexes of those rows are 0 through 6. All
functions that have indexes as arguments must use an assert statement
to check that the sizes of the indexes are valid for the matrix.
Your matrix class must have these functions:
many_rows
and
many_columns
which return the number of rows or columns
in a matrix.
s = 4.2*t;
r = s*t;
(where r is another matrix).