SquareMatrix SquareMatrix::operator+(const SquareMatrix & rhs)const { if (getSize() != rhs.getSize()) throw "Matrix must be equal size!!!"; SquareMatrix result(*this); for (unsigned int i = 0; i < result.getSize(); i++) for (unsigned int j = 0; j < result.getSize(); j++) result[i][j] += rhs.get(i, j); return result; }
SquareMatrix SquareMatrix::operator*(const SquareMatrix & matrix) const { if (getSize() != matrix.getSize()) throw "Matrix must be equal size!!!"; SquareMatrix result(getSize()); for (unsigned int i = 0; i < result.getSize(); i++) for (unsigned int j = 0; j < result.getSize(); j++) { double temp = 0; for (unsigned int k = 0; k < getSize(); k++) temp += this->get(i, k) * matrix.get(k, j); result[i][j] = temp; } return result; }