addition: solve by inverse
This commit is contained in:
17
src/lib.rs
17
src/lib.rs
@@ -425,6 +425,23 @@ impl Matrix {
|
||||
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user