Skip to content

Commit

Permalink
feat: add SdpMatrix2::inverse_and_get_determinant_unchecked
Browse files Browse the repository at this point in the history
  • Loading branch information
sebcrozet committed Apr 28, 2024
1 parent f3b4918 commit 471c27e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils/sdp_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,17 @@ impl<N: SimdRealField + Copy> SdpMatrix2<N> {

/// 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.
Expand Down

0 comments on commit 471c27e

Please sign in to comment.