Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program needs to use pointers in the solution, instead of vectors. Use C++ for language. Exercise 4.2 Create a Matrix class and implement the

This program needs to use pointers in the solution, instead of vectors. Use C++ for language.

image text in transcribedimage text in transcribed

Exercise 4.2 Create a Matrix class and implement the following member functions: The constructors and the destructor getSize() which returns the size of the matrix; setValue( int position, int value) which sets the value in the matrix at given position; getValue (int position) which returns the current value at given position; an add method which adds two matrices together; a subtract method which subtract two matrices together; a multiply methods which multiplies two matrices together, if possible; an overlap function which overlaps two matrices together. The augment function takes two matrices A and B of size mlxnl and m2xn2, respectively, and produce a new matrix C of size mLxnL, where mL (resp. nl) is the largest between ml and m2 (resp. nl and n2). The values of C will either come from the original matrices by overlapping matrix B over matrix A. Wherever a value is not available it initialized to default value 0. For example: If you overlap two matrices A of size 4x2 and B of size 3x5, the resulting matrix C is of size 4x5. A= B= C = A overlap B = 23 13 63 79 8 2 6 51 391 2 3 57314 8 2651 39123 57314 79000 Here is another example. Consider matrix A of size 2x3 and matrix B of size 3x1, the overlapped matrix C is of size 2x3. A= B 235 134 C = A overlap B = 8 3 5 835 334 500 While the numerical values of the example are integers, the class definition should be general enough to consider different possible types. Test your class by writing a driver function that performs the following actions on the matrices A, B, and C given in the example above: 1. initialize two matrices A and B 2. add A and B together and then subtracts them 3. print both input matrices and the resulting matrix after addition and subtraction 4. print both input matrices and the resulting matrix after multiplication, if possible. If not possible explain the reason of the error 5. overlap the two matrices by using the overlap function. 6. display both input matrices and the output matrix produced by the overlap function

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

Principles Of Multimedia Database Systems

Authors: V.S. Subrahmanian

1st Edition

1558604669, 978-1558604667

More Books

Students also viewed these Databases questions

Question

=+you think is being taxed when more money is printed? Why?

Answered: 1 week ago