Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MatrixVs& MatrixVs::multiply(const MatrixVs& rhs) noexcept(false) {
- if(n_col_ != rhs.n_row_) throw std::invalid_argument("Cannot multiply matrices with these parameters");
- MatrixVs res(this->rowCount(), rhs.colCount());
- for (std::ptrdiff_t i = 0; i < this->rowCount(); ++i){
- for (std::ptrdiff_t j = 0; j < rhs.colCount(); ++j){
- res.at(i, j) = 0;
- for (std::ptrdiff_t k = 0; k < rhs.rowCount(); ++k){
- res.at(i, j) += this->at(i, k) * rhs.at(k, j);
- }
- }
- }
- (*this) = res;
- return (*this);
- }
Advertisement
Add Comment
Please, Sign In to add comment