diff --git a/rtchallenge/src/matrices.rs b/rtchallenge/src/matrices.rs index de29a4e..475ae54 100644 --- a/rtchallenge/src/matrices.rs +++ b/rtchallenge/src/matrices.rs @@ -81,6 +81,20 @@ impl Matrix3x3 { let m = [[rows[0][0], rows[0][1]], [rows[1][0], rows[1][1]]]; Matrix2x2 { m } } + + /// + /// # Examples + /// ``` + /// use rtchallenge::matrices::{Matrix2x2, Matrix3x3}; + /// + /// let a = Matrix3x3::new([3., 5., 0.], [2., -1., -7.], [6., -1., 5.]); + /// let b = a.submatrix(1, 0); + /// assert_eq!(b.determinant(), 25.0); + /// assert_eq!(b.determinant(), a.minor(1, 0)); + /// ``` + pub fn minor(&self, row: usize, col: usize) -> f32 { + self.submatrix(row, col).determinant() + } } impl Index<(usize, usize)> for Matrix3x3 { type Output = f32;