From 74bc81e528e96cd062a47a94c7b82a20e51c1238 Mon Sep 17 00:00:00 2001 From: Sophon96 <71684640+Sophon96@users.noreply.github.com> Date: Sun, 8 Oct 2023 10:20:28 -0700 Subject: [PATCH 1/2] feat(matrix): add row and col getters --- core/include/jml/math/matrix.hpp | 2 ++ core/src/math/matrix.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/core/include/jml/math/matrix.hpp b/core/include/jml/math/matrix.hpp index 18a5119..c7a0542 100644 --- a/core/include/jml/math/matrix.hpp +++ b/core/include/jml/math/matrix.hpp @@ -26,6 +26,8 @@ int get_position(int i, int j); public: Matrix(int m, int n); ~Matrix(); + int get_rows(); + int get_cols(); void set_entry(int i, int j, double value); std::unique_ptr multiply(std::unique_ptr); diff --git a/core/src/math/matrix.cpp b/core/src/math/matrix.cpp index ff05bfa..dc957ee 100644 --- a/core/src/math/matrix.cpp +++ b/core/src/math/matrix.cpp @@ -12,6 +12,14 @@ Matrix::~Matrix() { delete this->entries; } +int Matrix::get_rows() { + return m; +} + +int Matrix::get_cols() { + return n; +} + int Matrix::get_position(int i, int j) { return i * this->n + j; } From a23403e4c512a55eedc7836ac6eb1a4d1a6688cf Mon Sep 17 00:00:00 2001 From: Sophon96 <71684640+Sophon96@users.noreply.github.com> Date: Sun, 8 Oct 2023 11:30:51 -0700 Subject: [PATCH 2/2] refactor: rename getters to be more clear --- core/include/jml/math/matrix.hpp | 4 ++-- core/src/math/matrix.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/include/jml/math/matrix.hpp b/core/include/jml/math/matrix.hpp index c7a0542..b2faa85 100644 --- a/core/include/jml/math/matrix.hpp +++ b/core/include/jml/math/matrix.hpp @@ -26,8 +26,8 @@ int get_position(int i, int j); public: Matrix(int m, int n); ~Matrix(); - int get_rows(); - int get_cols(); + int get_n_rows(); + int get_n_cols(); void set_entry(int i, int j, double value); std::unique_ptr multiply(std::unique_ptr); diff --git a/core/src/math/matrix.cpp b/core/src/math/matrix.cpp index dc957ee..c0a901d 100644 --- a/core/src/math/matrix.cpp +++ b/core/src/math/matrix.cpp @@ -12,11 +12,11 @@ Matrix::~Matrix() { delete this->entries; } -int Matrix::get_rows() { +int Matrix::get_n_rows() { return m; } -int Matrix::get_cols() { +int Matrix::get_n_cols() { return n; }