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

This problem consists of writing a C++ class for matrices. For simplicity, we re

ID: 3766857 • Letter: T

Question

This problem consists of writing a C++ class for matrices. For simplicity, we restrict the entries of the matrices to integers modulo 2. The name of the class will be Matrix. The C++ code should be placed in files Matrix.h and Matrix.cpp.

The operations shown below should be supported for matrices.

a.cols() == b.rows()

Matrices may be defined in three ways, illustrated as follows:

Matrix b(3, 5); Matrix b is a 3 × 5 matrix (3 rows, 5 columns), with each entry initialized to 0.

Matrix c(3, 4, "1 0 1 1" Matrix c is a 3× 4matrix with the entries shown.

"0 0 1 0"

"1 1 1 0");

Matrix d = c; Initialization by copy

In the definition of c above, the third argument to the constructor is merely a string, containing integers separated by white space. Recall that the C++ compiler automatically concatenates string literals separated only by white space.

Operation Preconditions Side Effects Value Returned a = b none a becomes a copy of b a by reference a.rows() none none The number of rows in a a.cols none none the number of columns in a a == b a and b have the same size none True if aij = bij for all i and j a + b a and b have the same size none A new matrix equal to the sum of a and b a += b a and b have the same size Matrix a is replaced by the sum of a and b a by reference a * b

a.cols() == b.rows()

None A new matrix equal to the product of a and b a *= b a.cols() == b.rows() Matrix a is replaced by the product of a and b a by reference a.tr() None None A new matrix equal to the transpose of a a.inv() i) a is a square matrix ii) a is invertible None A new matrix equal to the inverse of a a(i, j) Subscripys i and j are in bounds i.e. 0 a.rows() and 0 j a.cols() None A reference or const reference to the i, j th element of a. If a is a non const matrix, a reference will be returned. The reference may be used on the left of an assignment, to assign a new value to a(i, j). a.swapRows(i, k) Subscripts i and k are in bounds, i.e. 0 a.rows() and 0 k a.rows() Exchanges rows i and k of matrix a None a.addToRow(i,k) Subscripts i and k are in bounds, as above Replaces row i of a by the sum of row i and row k None Matrix::ident(n) static method n is a positive integer None Constructs and returns an n by n identity matrix(Is on the diagonal, (Is elsewhere).

Explanation / Answer

Program :

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