Skip to content

Commit

Permalink
Resolved Issue PEC-CSS#81
Browse files Browse the repository at this point in the history
  • Loading branch information
Modernbeast02 committed Feb 7, 2023
1 parent 3fb7402 commit 019f9f2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/slowmokit/ducks/matrix/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,28 @@ Matrix<T> operator*(Matrix<T> matrix, const G &num)
matrix *= num;
return matrix;
}


template <class T>
Matrix<T> Matrix<T>::matmul(const Matrix<T> rhs)
{
Matrix<T> res = *this;
res *= rhs;
return res;
}

template <class T>
Matrix<T> Matrix<T>::add(const Matrix<T> rhs)
{
Matrix<T> res = *this;
res += rhs;
return res;
}

template <class T>
Matrix<T> Matrix<T>::subtract(const Matrix<T> rhs)
{
Matrix<T> res = *this;
res -= rhs;
return res;
}
24 changes: 24 additions & 0 deletions src/slowmokit/ducks/matrix/matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,30 @@ class Matrix
*/
const std::vector<T> &operator[] (int) const;


/**
* @brief This function will multiply two matrix
* @param rhs: This is the matrix which will be multiplied with the main matrix
* @throw: whatever operator *= throws
*/
Matrix matmul(const Matrix);


/**
* @brief This function will add 2 matrix
* @param rhs: This is the matrix which will be added with the main matrix
* @throw: whatever operator *= throws
*/
Matrix add(const Matrix);


/**
* @brief This function will subtract 2 matrix
* @param rhs: This is the matrix which will be subtracted from the main matrix
* @throw: whatever operator *= throws
*/
Matrix subtract(const Matrix);

};


Expand Down

0 comments on commit 019f9f2

Please sign in to comment.