Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Notes: (*) The assignment must be finished independently. Any plagiarism is forbidden and will be dealt with seriously. (*) Your submission will be marked on

Notes:
(*) The assignment must be finished independently. Any plagiarism is forbidden and will be dealt with seriously.
(*) Your submission will be marked on the correctness and readability (including comments) of your program.
(*) Write a Makefile that is used to compile your programs. For instance, make testMatrixExt will generate an executable called testMatrixExt to test your program for Question (1) while make testMatrixPro will generate an executable called testMatrixPro to test your program for Question (2). If you just issue make, then both will be generated.
(1) Continuing writing the CMatrix class in Question 2 from Assignment 2, we will expand it in this question. Lets call the new class CMatrixExt. All requirements regarding element indices are the same as before. Data members are the same as before. The following is the list of member functions. Note that some of them can be borrowed from your answer in Assignment 2.
-int **allocateMatrixMemory(int n): to allocate an n x n array of integers.
-void deallocateMatrixMemory(int **M, int n): to ----deallocate an n x n array of integers. CMatrixExt(int n = 2): constructor.
-CMatrixExt(const CMatrixExt &M): copy constructor: copy matrix M to this current matrix using deep copying.
~CMatrixExt(): destructor.
-int getDimension(void): to return the dimension: n for the matrix n x n.
-int getElementAt(int i, int j): to return the element at (i, j). Check whether the indices are OK. The indices start from 1 and will be checked.
-int replaceElementAt(int i, int j, int newint): to replace the element at (i, j) with the new element. Check whether the indices are OK. Return the old element.
-void swapElementsAt(int i1, int j1, int i2, int j2): to swap the element at (i1, j1) with the element at (i2, j2). Chech whether the indices are OK.
-void resizeMatrix(int newsize): to resize the matrix with the new size Copy the original elements if necessary.
-void readMatrix(void):
-void printMatrix(void): to read or print out the matrix from cin or to cout. Read elements and print out elements by following the row-major order.
-void makeIdentity(): to make the current matrix an identity, i.e., change all the elements on the diagonal to 1 and change all the other element to 0.
-void copyMatrix(const CMatrixExt &M) : to take one CMatrixExt parameter and copy it to this current copyMatrix CMatrixExt object. Use assert to ensure that the dimensions of the two matrices are compatible.
-CMatrixExt addMatrix(const CMatrixExt &M) : to take one CMatrixExt parameter and return the result that is the sum between the current object and the supplied object. Use assert to ensure that the dimensions of the two matrices are compatible.
-CMatrixExt addMatrix(int i): to add x to each element of the current matrix and return the result.
-CMatrixExt subtractMatrix(const CMatrixExt &M) : to take one CMatrixExt parameter and return the result that is the difference between the current object and the supplied object. Use assert to ensure that the dimensions of the two matrices are compatible.
-CMatrixExt subtractMatrix(int x): to substract x from each element of the current matrix and return the result.
-CMatrixExt multiplyMatrix(const CMatrixExt &M) : to take one additional CMatrix parameter, compute the product of the current matrix with it, and return the result. Use assert to ensure that the dimensions of the two matrices are compatible.
-CMatrixExt multiplyMatrix(int x): to multiply each element of the current matrix by x. Return the result. Dont change the current matrix.
-bool isDiagonal(void): to teturn true if all the elements not on the diagonal are zeros Otherwise return false.
-bool isIdentity(void): to return true if all the elements on the diagonal are ones and all the elements elsewhere are zeros. Otherwise return false.
-bool isBigger(const CMatrixExt &M): For two matrices A and B, we say A > B, if every element of A is bigger than the corresponding element of B. Return true if the current matrix > the input matrix M. Otherwise return false.
-bool isSmaller(const CMatrixExt &M): For two matrices A and B, we say A
-bool isEqual(const CMatrixExt &M): For two matrices A and B, we say A = B, if every element of A is equal to the corresponding element of B. Return true if the current matrix = input matrix M. Otherwise return false
Create a test program called testMatrixExt.cc. Your test should show that the member functions of the matrix class work as expected. One good way to do this: create two 3 x 3 matrices, read elements in them, do additions, subtractions and multiplication between the two matrices or between a matrix and an integer. Each time print the result out to verify (show) that your program works.
image text in transcribed
image text in transcribed
there is a second part to the question.
(2) Let us make some semi-professional class such that you can show it to your teammates and let them use it. Continuing writing the CMatrixExt class in Question 1, we will modify it in this question. Lets call the new class CMatrixPro. All requirements regarding element indices are the same as before. Data members are the same as before. Modify the following member functions into overloaded operators, while keeping the other members functions as before.
Create a test program called testMatrixPro.cc. Your test should show that the member functions/operators of the matrix class work as expected. One good way to do this: create two 3 x 3 matrices, read elements in them, do additions, subtractions and multiplication between the two matrices or between a matrix and an integer using the corresponding operators. Each time print the result out to verify (show) that your program works.
image text in transcribed
has to be C++ language
i added photos of the actual assignment. this is all we were given
image text in transcribed
image text in transcribed
yes i think so.
Spring 2020 CPSC2620 Assignment 3 Due: February 14 (Friday), 2020 11:55pm Notes: ) The assignment must be finished independently. Any plagiarism is forbidden and will be dealt with seriously. (*) Your submission will be marked on the correctness and readability (including comments) of your program. (9) Write a Makefile that is used to compile your programs. For instance, make test MatrixExt will generate an executable called test MatrixExt to test your program for Question (1) while make testMatrix Pro will generate an executable called testMatrixPro to test your program for Question (2). If you just issue make, then both will be generated. (1) Continuing writing the CMatrix class in Question 2 from Assignment 2, we will expand it in this question. Let's call the new class CMatrix Ext. All requirements regarding element indices are the same as before. Data members are the same as before. The following is the list of member functions. Note that some of them can be borrowed from your answer in Assignment 2. int allocateMatrix Memory(int n): to allocate an nxn array of integers. void deallocate Matrix Memory(int **M, int n): to deallocate an nxn array of integers. CMatrixExt(int n = 2): constructor. CMatrixExt(const CMatrixExt &M): copy constructor: copy matrix M to this current matrix using deep copying. -CMatrixExt(): destructor int getDimension(void): to return the dimension: n for the matrix nxn. int getElementAtint i, int j): to return the element at 11). Check whether the indices are OK. The indices start from 1 and will be checked. int replaceElementAt(int i, int j, int newint): to replace the element at with the new element. Check whether the indices are OK. Return the old element. void swap ElementsAt(int in, int j1, int i2, int j2): to swap the element at (11.j1) with the element at (12, 12). Chech whether the indices are OK. void resizeMatrix(int newsize): to resize the matrix with the new size Copy the original elements if necessary. void read Matrix(void): void printMatrix(void): to read or print out the matrix from cin or to cout. Read elements and print out elements by following the row-major order. void makeldentity: to make the current matrix an identity, ie, change all the elements on the diagonal to 1 and change all the other element to 0. void copy Matrix(const CMatrixExt&M): to take one MatrixExt parameter and copy it to this current copyMatrix CMatrixExt object. Use assert to ensure that the dimensions of the two matrices are compatible CMatrixExt addMatrix(const CMatrixExt &M): to take one MatrixExt parameter and return the result that is the sum between the current object and the supplied object. Use assert to ensure that the dimensions of the two matrices are compatible CMatrixExt addMatrix(int i): to add x to each element of the current matrix and return the result. CMatrixExt subtractMatrix(const CMatrixExt&M): to take one MatrixExt parameter and return the result that is the difference between the current object and the supplied object. Use assert to ensure that the dimensions of the two matrices are compatible. CMatrixExt subtract Matrix(int x): to substract x from each element of the current matrix and return the result. CMatrixExt multiply Matrix(const CMatrixExt &M): to take one additional CMatrix parameter, compute the product of the current matrix with it, and return the result. Use assert to ensure that the dimensions of the two matrices are compatible. CMatrixExt multiplyMatrix(int x): to multiply each element of the current matrix by x. Return the result. Don't change the current matrix. bool isDiagonal(void): to teturn true if all the elements not on the diagonal are zeros Otherwise return false. bool isIdentity(void): to return true if all the elements on the diagonal are ones and all the elements elsewhere are zeros. Otherwise return false. bool isBigger(const CMatrixExt &M): For two matrices A and B, we say A > B, if every element of A is bigger than the corresponding element of B. Return true if the current matrix > the input matrix M. Otherwise return false. bool isSmaller(const CMatrix Ext &M): For two matrices A and B, we say A >(implemented as a friend) implemented as a member operator) >(implemented as a friend) implemented as a friend) implemented as a member operator) + implemented as member operators for both versions) - implemented as member operators for both version) implemented as member operators for both versions) implemented as a member operator)

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_2

Step: 3

blur-text-image_3

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 Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions

Question

8. Explain the difference between translation and interpretation.

Answered: 1 week ago

Question

10. Discuss the complexities of language policies.

Answered: 1 week ago

Question

1. Understand how verbal and nonverbal communication differ.

Answered: 1 week ago