Question: 5 pts ] Write a MyMatrix class to represent a 2 x 2 matrix that has 4 private float members. There are many ways you
pts Write a MyMatrix class to represent a x matrix that has private float members. There are many ways you
can define these variables such as using an array or a vector. However, it is recommended that you define a single
variable for each of the four numbers such as:
a a
a a
pts Add getters and setters for each private data member.
pts Implement a constructor to set the data members to valid values when an object is created. You should
implement a single overloaded constructor to take zero to four inputs with default values.
pts Implement a print method that prints the values of the matrix to the screen in the form: a a; a a
pts Write a main program that unit tests the getters, setters, constructor and print methods of your MyMatrix
class. Add comments to your program for each test. Your main program should have a comment block above the
main function. Your program should have enough unit tests to prove that your methods work correctly.
pts Implement a method to compute the matrix norm, ie the square root of the sum of squares of the matrix
elements. For example, if the Matrix object is A then Anorm returns the norm of the matrix. Add a comment block
for this function.
pts Implement an add method that takes another MyMatrix object as the input parameter, performs the matrix
addition and stores the result in the matrix object. For example, if the Matrix object is A then AaddB should
change the member variables of A to the result of AB
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
