Skip to content

Commit

Permalink
return error rather than panic on non-symmetric covariance
Browse files Browse the repository at this point in the history
  • Loading branch information
astraw committed Feb 1, 2024
1 parent 517b673 commit 8e1ab7e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@

#![cfg_attr(not(feature = "std"), no_std)]
#![allow(non_snake_case)]

#[cfg(debug_assertions)]
use approx::assert_relative_eq;
#[cfg(feature = "std")]
use log::trace;
use na::{OMatrix, OVector};
Expand All @@ -50,7 +47,9 @@ macro_rules! debug_assert_symmetric {
($mat:expr) => {
#[cfg(debug_assertions)]
{
assert_relative_eq!($mat, &$mat.transpose(), max_relative = na::convert(1e-5));
if approx::relative_ne!($mat, &$mat.transpose(), max_relative = na::convert(1e-5)) {
return Err(ErrorKind::CovarianceNotPositiveSemiDefinite.into());
}
}
};
}
Expand Down

0 comments on commit 8e1ab7e

Please sign in to comment.