Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment Description Create a class Matrix that has features similar to those of the parameterized one-dimensional Array class that was presented in Labs. Matrix should

Assignment Description

Create a class Matrix that has features similar to those of the parameterized one-dimensional Array class that was presented in Labs. Matrix should be able to create a matrix object (two-dimensional array) of any number of rows (with a default value of 2 rows) and any number of columns (with a default value of 3 columns). Matrix should make use of a standard C++, dynamically allocated two-dimensional array to store the elements of the Matrix.

Problem 1: Design, implement and test the Matrix class. The elements of Matrix should be of the integer type. Your Matrix class should contain at least the following features, namely:

A default constructor that sets the matrix elements to zero.

A copy constructor

A destructor

The get and set functions

Overloaded functions for as many relevant C++ built-in operators as you can (the number of overloaded operators will be one of the factors to be used in determining your grade in this mini-project). This should include the overloading of operators such as matrix negation - (a unary operator that multiplies each element of a matrix with -1), matrix pre-increment ++, matrix pre-decrement --, matrix assignment =, matrix addition + (adds two matrices to generate a sum matrix, matrix subtraction -, matrix multiplication * (vector multiplication), matrix +=, matrix equality = = and matrix inequality !=

Overload the operator( ) to perform the double scripting operations. For example, in a 3-by-5 Matrix called A, the programmer could write A (1, 3) to access the element at row 1 and column 3. There should be two versions of operator ( ), one that returns int & and one that returns const int &.

Overload the insertion Matrix in a row-major format) and the extraction >> (to input an entire matrix in a row-major format).

Make sure that the implemented operators should be able to cascade

Problem 2:

Implement the SumMatrixElements ( ) that takes a reference to a matrix as a parameter and returns the sum of the elements within such a Matrix. Implement the function as a regular (non-member) function. Use as many overloaded operators as you can.

double SumMatrixElements (const Matrix & );

Write and test the following regular (non-member) function, namely:

double stdev (const Matrix & );

The function is called from the main/driver program and returns the standard deviation of the data elements stored within a matrix object, where x^_ is the average of the data elements within that object and xi,j is the value of the element at the ith row and the jth column. A formula for the standard deviation is presented below. Note that the 2 in the formula is the square function

image text in transcribed

n m- i=0 / = 0 12172- 2 S n m- i=0 / = 0 12172- 2 S

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions