Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Students are expected to write, run, test, and debug a fully-working C++ program for the following computing problem:In mathematics, a matrix is a rectangular array

  • Students are expected to write, run, test, and debug a fully-working C++ program for the following computing problem:In mathematics, a matrix is a rectangular array of numbers, arranged in rows and columns. For example, the dimension of the below matrix is 2 x 3 (read “two by three”), because there are two rows and 3 columns: A=[ 1 2 -1]

    -1 0 3


    Matrices can be called sparse or dense depending on the number of zero elements. A sparse matrix is a matrix in which most of the elements are zero. By contrast, if most of the elements are nonzero, then the matrix is considered dense.For dense matrices, all values need to be stored in the system. However, for sparse matrices, since the number of non-zero values is less, instead of unnecessarily occupying memory for zero values, we may store the corresponding row and column information of the non-zero values in the system.To be more specific, for a dense matrix, every cell of the matrix needs to occupy memory, however, for a sparse matrix, only row, column, and value information needs to be stored. Both sparse and dense matrices are to be derived from the general matrix class. The general matrix class should contain a couple of pure virtual functions, namely, the get, set,and resize, to be overridden by the sparse/dense matrices to meet their specific needs.Also note that, for a sparse matrix, get function needs to apply a kind of search operation since we are not storing the whole n x m system. Some mathematical operations that need to be defined are matrix addition, subtraction, and multiplication. Matrix transpose, multiplying by a constant, and testing whether two matrices commute (equal) or not, are the other functions that should be defined. Moreover, inputting and outputting of the matrices should be presented in such a way that a user may specify values into the matrices. Remember, when possible, operator functions need to be overloaded. Partial grading will be applied in case there is no full implementation.


Step by Step Solution

3.58 Rating (165 Votes )

There are 3 Steps involved in it

Step: 1

include include using namespace std Defines a class Matrix class Matrix private Data member to store ... 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

Financial Management for Public Health and Not for Profit Organizations

Authors: Steven A. Finkler, Thad Calabrese

4th edition

133060411, 132805669, 9780133060416, 978-0132805667

More Books

Students also viewed these Electrical Engineering questions

Question

What is the difference between periodic and perpetual inventory?

Answered: 1 week ago