From 650e7dd20d65b68ce36ebc341dc086b75e210462 Mon Sep 17 00:00:00 2001 From: Arkadiusz Kondas Date: Sat, 30 Apr 2016 23:54:05 +0200 Subject: [PATCH] simply getDeterminant method --- src/Phpml/Math/Matrix.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Phpml/Math/Matrix.php b/src/Phpml/Math/Matrix.php index ee8fd3c..7c04119 100644 --- a/src/Phpml/Math/Matrix.php +++ b/src/Phpml/Math/Matrix.php @@ -126,6 +126,16 @@ class Matrix throw MatrixException::notSquareMatrix(); } + return $this->determinant = $this->calculateDeterminant(); + } + + /** + * @return float|int + * + * @throws MatrixException + */ + private function calculateDeterminant() + { $determinant = 0; if ($this->rows == 1 && $this->columns == 1) { $determinant = $this->matrix[0][0]; @@ -141,7 +151,7 @@ class Matrix } } - return $this->determinant = $determinant; + return $determinant; } /**