diff --git a/src/lib.rs b/src/lib.rs index 9f20d13..3bc13eb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -425,6 +425,23 @@ impl Matrix { Ok(result) } + + pub fn solve_matrix_with_inverse( + &self, + solution_matrix: Matrix, + ) -> Result { + if self.columns != self.rows { + return Err(MatrixError::NotSquared); + } + + if solution_matrix.rows != self.rows || solution_matrix.columns != 1 { + return Err(MatrixError::InvalidDataSize); + } + + let solution_matrix = (self.inverse()? * solution_matrix)?; + + Ok(solution_matrix) + } } impl Add for Matrix {