addition: solve by inverse

This commit is contained in:
2026-04-29 15:28:49 -06:00
parent 8db0ebb977
commit 410d963f39

View File

@@ -425,6 +425,23 @@ impl Matrix {
Ok(result) Ok(result)
} }
pub fn solve_matrix_with_inverse(
&self,
solution_matrix: Matrix,
) -> Result<Matrix, MatrixError> {
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 { impl Add for Matrix {