Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Matrix class creation
- The matrix takes the number of rows and the number of columns upon creation. Each element of the matrix is input using
- either the Initialize() or Populate() functions. Initialize() might be removed later since it is not as general as
- Populate()
- */
- #pragma once
- template <class T>
- class Matrix {
- private:
- int nRow, nCol;
- T* elem;
- public:
- Matrix(int a, int b) : nRow(a), nCol(b) {
- elem = new T[nRow * nCol];
- }
- Matrix() : nRow(0), nCol(0) {
- elem = new T[0];
- elem[0] = 0;
- }
- int getRow(); //Returns number of rows in matrix
- int getCol(); //Returns number of columns in matrix
- void Initialize(); //Function for matrix class to handle data input, not as general as Populate
- void Populate(int* nRowPos, int* nColPos, T vals); //Function inputs given data into matrix; does not handle the input
- void Deinitialize(); //Delete the array in matrix
- void Show(); //Display matrix
- //T Determinant(T n = 1, T det = 0); //Calculate matrix determinant
- //T Trace(); //Calculate trace of matrix
- T Determinant(T n = 1, T det = 0);
- T Trace();
- Matrix<T> Reduce(int r, int c); //Remove a given row and column from matrix
- Matrix<T> operator+ (const Matrix& rhs); //Define matrix addition
- //Matrix<T> operator- (const Matrix& rhs); //Define matrix subtraction(TODO)
- Matrix<T> operator* (const Matrix& rhs); //Define matrix multiplication
- bool operator== (const Matrix& rhs); //Define matrix equality
- bool operator!= (const Matrix& rhs); //Define matrix inequality
- };
Advertisement
Add Comment
Please, Sign In to add comment