Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a class to perform various matrix operations. A matrix is a set of number

ID: 3653473 • Letter: D

Question

Design a class to perform various matrix operations. A matrix is a set of numbers arranged in rows and columns. Therefore, every element of a matrix has a row position and a column position. If A is a matrix of 5 rows and 6 columns, we say that matrix A is of the size 5 X 6 and sometimes denote it as A5X6. Clearly, a convenient place to store a matrix is in a two-dimensional array. Two matrices can be added and subtracted if they have the same size. Suppose that A = [aij] and B =[bij] are two matrices of the size m n, where aij denotes the element of A in the ith row and the jth column, and so on. The sum and difference of A and B is given by A + B = [aij + bij] and A - B = [aij -bij] The multiplication of A and B (A * B) is defined only if the number of columns of A are the same as the number of rows of B. If A is of the size m n and B is of the size n t, then A * B = [cik] is of the size m x t and the element cik is given by the formula cik = (a)i1( b)1k +( a)i2(b)2k + . . . + (a)in(b)nk Design and implement a class matrixType that can store a matrix of any size. Overload the operators +, -, and * to perform the addition, subtraction, and multiplication operations, respectively, and overload the operator << to output a matrix. Also, write a test program to test various operations on matrices.

Explanation / Answer

#include using namespace std; //member function of matrix class class matrix{ public: matrix(); matrix(int m,int n); int getRow(); int getCol(); double& operator()(int, int); //the operator used in the matrix class which are (addition operator, multiplication operator,substraction operator, and divide operator). friend ostream& operator
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote