From 471c27e126f6934cdba0d0ce5dcbf8f72386b0fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sun, 14 Apr 2024 15:46:44 +0200 Subject: [PATCH] feat: add SdpMatrix2::inverse_and_get_determinant_unchecked --- src/utils/sdp_matrix.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/sdp_matrix.rs b/src/utils/sdp_matrix.rs index 0de2cfe8..50b4130b 100644 --- a/src/utils/sdp_matrix.rs +++ b/src/utils/sdp_matrix.rs @@ -70,12 +70,17 @@ impl SdpMatrix2 { /// Compute the inverse of this SDP matrix without performing any inversibility check. pub fn inverse_unchecked(&self) -> Self { + self.inverse_and_get_determinant_unchecked().0 + } + + /// Compute the inverse of this SDP matrix without performing any inversibility check. + pub fn inverse_and_get_determinant_unchecked(&self) -> (Self, N) { let determinant = self.m11 * self.m22 - self.m12 * self.m12; let m11 = self.m22 / determinant; let m12 = -self.m12 / determinant; let m22 = self.m11 / determinant; - Self { m11, m12, m22 } + (Self { m11, m12, m22 }, determinant) } /// Convert this SDP matrix to a regular matrix representation.