CS2141 Program Three

Due: Friday, 9 July 2010, at 11:59pm

Matrices are used in a wide variety of applications in mathematics, physics, and a plethora of other fields. Though widely used, matrices provide a number of interesting implementational challenges, including the need to deal with dynamic memory allocation and mis-matched matrix sized. (Operations on large or distributed matrices present efficiency challenges as well, though these are rather beyond the scope of this course.) Matrices also have the rather nice feature of supporting a wide variety of mathematical operations. This makes them ideal as an introduction to operator overloading.

For this assignment, you will be implementing a matrix class capable of dealing with matrices of doubles.

Goals

The goals of this assignment are:
Notice! This is a difficult assignment. Break your work into parts and get started early so that it is easier to handle.

Problem Description

Your task for this program is to build a Matrix class to represent a matrix of doubles. Your class will need to provide overloaded operators to make using the class easier.

Unlike previous projects, main() will be provided for you. You need only provide an implemenation of the Matrix class to power the pre-written code.

Input

There is no need for you to implement input as part of your matrix class.

Ouput

You should overload the << operator to output Matrices:

Matrices should be output as bracketed matrices with bracketed rows. Each row should have have values printed with one space between them. The matrix should start on a new line, and each row should be on a seperate line. All lines but the first should have a single space prior to the first bracket on the line.

This statement

cout << "The first Matrix is: " << matrix1 << endl << "The second Matrix is: " << matrix2 << endl;

should print something formatted like:

The first Matrix is:
[[4.2 5.6 3.2 6.7 1.221 6 1000000]
 [4.6 1.1 0.9999 3.1 1 100000 0]
 [0 0 0 0 0 0 0]
 [4 5 6 7 0 0 0]]
 
The second Matrix is:
[[5.5 1000.1 0 0 0 0]
 [4.6 1.1 0.9999 3.1 1 100000]
 [0 0 0 0 0 0]
 [4.5 5.5 6.5 0 0 0]
 [0 0 0 0 0 0]]

Code Requirements

Matrix Class

This class should create a Matrix which can store doubles.

The Matrix class should have the following functionality: