Program for handling matrix operations -
- Assign matrix (change values of the matrix, also its size).
- Add two matrices.
- Subtract two matrices.
- Multiply two matrices.
- Multiply by a scalar from left and from the right.
- Compare two matrices.
- Get an index from a matrix.
- Cast to double (get the sum of the values in the matrix).
The program supports taking matrix as input with std::cin
and printing matrix with std::cout
.
The program uses the ideas of OOP, operator overloading, and friend functions to enable the use of the operators from the right.'
The class MyMatrix is handling all the matrix operators.
- the matrix (double**)
- number of rows (int)
- number of columns (int)
- setters.
- delete matrix.
- Constarctors (regular, copy and defualt).
- Destructor.
- getters.
- operators (+, -, *, =, ==, [], double())
- operator * - multiply by scalar from the right.
- operator << - cout.
- operator >> - cin.
The deleration of the class - MyMatrix and each methods in the class, and the friend functions.
The code of the methods and friend functions of MyMatrix class.
The UI - handles the user -
- Take input of the user's matrix, and create an object of Myatrix for the user.
- Present instructions.
- Take input for desired action.
- Call the method for each action (from the user's object).
Do 2, 3 and 4 in a loop until the user press q - means they want to leave.