diff --git a/matrix.hpp b/matrix.hpp index a4aedab..3887d4b 100644 --- a/matrix.hpp +++ b/matrix.hpp @@ -29,14 +29,16 @@ template struct Matrix { for (std::uint32_t i = 0; i < rows; i++) { for (std::uint32_t j = 0; j < cols; j++) { - matfs >> (*this)(j, i); + matfs >> (*this)(i, j); } } matfs.close(); } - T &operator()(std::uint32_t x, std::uint32_t y) { return data[y * cols + x]; } + T &operator()(std::uint32_t row_i, std::uint32_t col_j) { + return data[row_i * cols + col_j]; + } Matrix &operator=(const Matrix &mat) { this->rows = mat.rows; @@ -50,7 +52,7 @@ template struct Matrix { Matrix transposed = *this; for (std::uint32_t i = 0; i < this->rows; i++) { for (std::uint32_t j = 0; j < this->cols; j++) { - transposed(i, j) = (*this)(j, i); + transposed(j, i) = (*this)(i, j); } } return transposed; @@ -62,7 +64,7 @@ template struct Matrix { template std::ostream &operator<<(std::ostream &os, Matrix &mat) { for (std::uint32_t i = 0; i < mat.rows; i++) { for (std::uint32_t j = 0; j < mat.cols; j++) { - os << mat(j, i) << "\t"; + os << mat(i, j) << "\t"; } os << "\n"; }