Question: please help with writing this program in C++ language (1) Continuing writing the CMatrix class in Question 2 from Assignment 2, we will expand it


please help with writing this program in C++ language
(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 **allocateMatrixMemory(int n): to allocate an nx n array of integers. void deallocateMatrixMemory(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 nx n. int getElementAt(int i, int j): to return the element at (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 (D) with the new element. Check whether the indices are OK. Return the old element. void swap Elements At(int in, int j1, int 12, int j2): to swap the element at (i1, j1) with the element at (i2, 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 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 makeldentity0: 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 copyMatrix(const CMatrixExt &M): to take one Matrix Ext parameter and copy it to this current copy Matrix CMatrixExt object. Use assert to ensure that the dimensions of the two matrices are compatible CMatrixExt add Matrix(const CMatrixExt &M): to take one Matrix Ext 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 subtract Matrix(const CMatrixExt&M): to take one Matrix Ext 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. T 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 multiply Matrix(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 is Bigger(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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
