DarkArtheme

Untitled

Nov 1st, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. MatrixVs& MatrixVs::multiply(const MatrixVs& rhs) noexcept(false) {
  2.     if(n_col_ != rhs.n_row_) throw std::invalid_argument("Cannot multiply matrices with these parameters");
  3.     MatrixVs res(this->rowCount(), rhs.colCount());
  4.     for (std::ptrdiff_t i = 0; i < this->rowCount(); ++i){
  5.         for (std::ptrdiff_t j = 0; j < rhs.colCount(); ++j){
  6.             res.at(i, j) = 0;
  7.             for (std::ptrdiff_t k = 0; k < rhs.rowCount(); ++k){
  8.                 res.at(i, j) += this->at(i, k) * rhs.at(k, j);
  9.             }
  10.         }
  11.     }
  12.     (*this) = res;
  13.     return (*this);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment