diff --git a/ndarray-linalg/src/error.rs b/ndarray-linalg/src/error.rs index 93d7ee3c..35042b51 100644 --- a/ndarray-linalg/src/error.rs +++ b/ndarray-linalg/src/error.rs @@ -12,9 +12,17 @@ pub enum LinalgError { #[error("Not square: rows({}) != cols({})", rows, cols)] NotSquare { rows: i32, cols: i32 }, - /// LAPACK subroutine returns non-zero code - #[error("LAPACK: return_code = {}", return_code)] - Lapack { return_code: i32 }, + #[error( + "Invalid value for LAPACK subroutine {}-th argument", + -return_code + )] + LapackInvalidValue { return_code: i32 }, + + #[error( + "Comutational failure in LAPACK subroutine: return_code = {}", + return_code + )] + LapackComputationalFailure { return_code: i32 }, /// Strides of the array is not supported #[error("invalid stride: s0={}, s1={}", s0, s1)] diff --git a/ndarray-linalg/src/lapack/cholesky.rs b/ndarray-linalg/src/lapack/cholesky.rs index 9d085044..80a6ab29 100644 --- a/ndarray-linalg/src/lapack/cholesky.rs +++ b/ndarray-linalg/src/lapack/cholesky.rs @@ -1,10 +1,7 @@ //! Cholesky decomposition -use crate::error::*; -use crate::layout::MatrixLayout; -use crate::types::*; - -use super::{into_result, UPLO}; +use super::*; +use crate::{error::*, layout::MatrixLayout, types::*}; pub trait Cholesky_: Sized { /// Cholesky: wrapper of `*potrf` @@ -25,14 +22,14 @@ macro_rules! impl_cholesky { impl Cholesky_ for $scalar { unsafe fn cholesky(l: MatrixLayout, uplo: UPLO, a: &mut [Self]) -> Result<()> { let (n, _) = l.size(); - let info = $trf(l.lapacke_layout(), uplo as u8, n, a, n); - into_result(info, ()) + $trf(l.lapacke_layout(), uplo as u8, n, a, n).as_lapack_result()?; + Ok(()) } unsafe fn inv_cholesky(l: MatrixLayout, uplo: UPLO, a: &mut [Self]) -> Result<()> { let (n, _) = l.size(); - let info = $tri(l.lapacke_layout(), uplo as u8, n, a, l.lda()); - into_result(info, ()) + $tri(l.lapacke_layout(), uplo as u8, n, a, l.lda()).as_lapack_result()?; + Ok(()) } unsafe fn solve_cholesky( @@ -44,8 +41,9 @@ macro_rules! impl_cholesky { let (n, _) = l.size(); let nrhs = 1; let ldb = 1; - let info = $trs(l.lapacke_layout(), uplo as u8, n, nrhs, a, l.lda(), b, ldb); - into_result(info, ()) + $trs(l.lapacke_layout(), uplo as u8, n, nrhs, a, l.lda(), b, ldb) + .as_lapack_result()?; + Ok(()) } } }; diff --git a/ndarray-linalg/src/lapack/eig.rs b/ndarray-linalg/src/lapack/eig.rs index 3fb20012..4e80cb9e 100644 --- a/ndarray-linalg/src/lapack/eig.rs +++ b/ndarray-linalg/src/lapack/eig.rs @@ -1,13 +1,9 @@ //! Eigenvalue decomposition for general matrices +use super::*; +use crate::{error::*, layout::MatrixLayout, types::*}; use num_traits::Zero; -use crate::error::*; -use crate::layout::MatrixLayout; -use crate::types::*; - -use super::into_result; - /// Wraps `*geev` for real/complex pub trait Eig_: Scalar { unsafe fn eig( @@ -30,7 +26,7 @@ macro_rules! impl_eig_complex { let mut w = vec![Self::Complex::zero(); n as usize]; let mut vl = Vec::new(); let mut vr = vec![Self::Complex::zero(); (n * n) as usize]; - let info = $ev( + $ev( l.lapacke_layout(), b'N', jobvr, @@ -42,8 +38,9 @@ macro_rules! impl_eig_complex { n, &mut vr, n, - ); - into_result(info, (w, vr)) + ) + .as_lapack_result()?; + Ok((w, vr)) } } }; @@ -82,6 +79,7 @@ macro_rules! impl_eig_real { .zip(wi.iter()) .map(|(&r, &i)| Self::Complex::new(r, i)) .collect(); + // If the j-th eigenvalue is real, then // eigenvector = [ vr[j], vr[j+n], vr[j+2*n], ... ]. // @@ -121,7 +119,8 @@ macro_rules! impl_eig_real { }) .collect(); - into_result(info, (w, v)) + info.as_lapack_result()?; + Ok((w, v)) } } }; diff --git a/ndarray-linalg/src/lapack/eigh.rs b/ndarray-linalg/src/lapack/eigh.rs index 5c1b0824..509c08a4 100644 --- a/ndarray-linalg/src/lapack/eigh.rs +++ b/ndarray-linalg/src/lapack/eigh.rs @@ -1,13 +1,9 @@ //! Eigenvalue decomposition for Hermite matrices +use super::*; +use crate::{error::*, layout::MatrixLayout, types::*}; use num_traits::Zero; -use crate::error::*; -use crate::layout::MatrixLayout; -use crate::types::*; - -use super::{into_result, UPLO}; - /// Wraps `*syev` for real and `*heev` for complex pub trait Eigh_: Scalar { unsafe fn eigh( @@ -37,8 +33,9 @@ macro_rules! impl_eigh { let (n, _) = l.size(); let jobz = if calc_v { b'V' } else { b'N' }; let mut w = vec![Self::Real::zero(); n as usize]; - let info = $ev(l.lapacke_layout(), jobz, uplo as u8, n, &mut a, n, &mut w); - into_result(info, w) + $ev(l.lapacke_layout(), jobz, uplo as u8, n, &mut a, n, &mut w) + .as_lapack_result()?; + Ok(w) } unsafe fn eigh_generalized( @@ -51,7 +48,7 @@ macro_rules! impl_eigh { let (n, _) = l.size(); let jobz = if calc_v { b'V' } else { b'N' }; let mut w = vec![Self::Real::zero(); n as usize]; - let info = $evg( + $evg( l.lapacke_layout(), 1, jobz, @@ -62,8 +59,9 @@ macro_rules! impl_eigh { &mut b, n, &mut w, - ); - into_result(info, w) + ) + .as_lapack_result()?; + Ok(w) } } }; diff --git a/ndarray-linalg/src/lapack/least_squares.rs b/ndarray-linalg/src/lapack/least_squares.rs index 83638f35..28e7980e 100644 --- a/ndarray-linalg/src/lapack/least_squares.rs +++ b/ndarray-linalg/src/lapack/least_squares.rs @@ -1,14 +1,10 @@ //! Least squares +use super::*; +use crate::{error::*, layout::MatrixLayout, types::*}; use ndarray::{ErrorKind, ShapeError}; use num_traits::Zero; -use crate::error::*; -use crate::layout::MatrixLayout; -use crate::types::*; - -use super::into_result; - /// Result of LeastSquares pub struct LeastSquaresOutput { /// singular values @@ -53,7 +49,7 @@ macro_rules! impl_least_squares { let mut singular_values: Vec = vec![Self::Real::zero(); k as usize]; let mut rank: i32 = 0; - let status = $gelsd( + $gelsd( a_layout.lapacke_layout(), m, n, @@ -67,15 +63,13 @@ macro_rules! impl_least_squares { &mut singular_values, rcond, &mut rank, - ); - - into_result( - status, - LeastSquaresOutput { - singular_values, - rank, - }, ) + .as_lapack_result()?; + + Ok(LeastSquaresOutput { + singular_values, + rank, + }) } unsafe fn least_squares_nrhs( @@ -99,7 +93,7 @@ macro_rules! impl_least_squares { let mut singular_values: Vec = vec![Self::Real::zero(); k as usize]; let mut rank: i32 = 0; - let status = $gelsd( + $gelsd( a_layout.lapacke_layout(), m, n, @@ -111,15 +105,12 @@ macro_rules! impl_least_squares { &mut singular_values, rcond, &mut rank, - ); - - into_result( - status, - LeastSquaresOutput { - singular_values, - rank, - }, ) + .as_lapack_result()?; + Ok(LeastSquaresOutput { + singular_values, + rank, + }) } } }; diff --git a/ndarray-linalg/src/lapack/mod.rs b/ndarray-linalg/src/lapack/mod.rs index a5fce2a8..5c5728d0 100644 --- a/ndarray-linalg/src/lapack/mod.rs +++ b/ndarray-linalg/src/lapack/mod.rs @@ -54,11 +54,19 @@ impl Lapack for f64 {} impl Lapack for c32 {} impl Lapack for c64 {} -pub fn into_result(return_code: i32, val: T) -> Result { - if return_code == 0 { - Ok(val) - } else { - Err(LinalgError::Lapack { return_code }) +trait AsLapackResult { + fn as_lapack_result(self) -> Result<()>; +} + +impl AsLapackResult for i32 { + fn as_lapack_result(self) -> Result<()> { + if self > 0 { + return Err(LinalgError::LapackComputationalFailure { return_code: self }); + } + if self < 0 { + return Err(LinalgError::LapackInvalidValue { return_code: self }); + } + Ok(()) } } diff --git a/ndarray-linalg/src/lapack/qr.rs b/ndarray-linalg/src/lapack/qr.rs index 823e112e..4afb8f43 100644 --- a/ndarray-linalg/src/lapack/qr.rs +++ b/ndarray-linalg/src/lapack/qr.rs @@ -1,14 +1,10 @@ //! QR decomposition +use super::*; +use crate::{error::*, layout::MatrixLayout, types::*}; use num_traits::Zero; use std::cmp::min; -use crate::error::*; -use crate::layout::MatrixLayout; -use crate::types::*; - -use super::into_result; - /// Wraps `*geqrf` and `*orgqr` (`*ungqr` for complex numbers) pub trait QR_: Sized { unsafe fn householder(l: MatrixLayout, a: &mut [Self]) -> Result>; @@ -23,15 +19,15 @@ macro_rules! impl_qr { let (row, col) = l.size(); let k = min(row, col); let mut tau = vec![Self::zero(); k as usize]; - let info = $qrf(l.lapacke_layout(), row, col, &mut a, l.lda(), &mut tau); - into_result(info, tau) + $qrf(l.lapacke_layout(), row, col, &mut a, l.lda(), &mut tau).as_lapack_result()?; + Ok(tau) } unsafe fn q(l: MatrixLayout, mut a: &mut [Self], tau: &[Self]) -> Result<()> { let (row, col) = l.size(); let k = min(row, col); - let info = $gqr(l.lapacke_layout(), row, k, k, &mut a, l.lda(), &tau); - into_result(info, ()) + $gqr(l.lapacke_layout(), row, k, k, &mut a, l.lda(), &tau).as_lapack_result()?; + Ok(()) } unsafe fn qr(l: MatrixLayout, a: &mut [Self]) -> Result> { diff --git a/ndarray-linalg/src/lapack/solve.rs b/ndarray-linalg/src/lapack/solve.rs index 581a2eb1..89762cf1 100644 --- a/ndarray-linalg/src/lapack/solve.rs +++ b/ndarray-linalg/src/lapack/solve.rs @@ -1,14 +1,9 @@ //! Solve linear problem using LU decomposition +use super::*; +use crate::{error::*, layout::MatrixLayout, types::*}; use num_traits::Zero; -use crate::error::*; -use crate::layout::MatrixLayout; -use crate::types::*; - -use super::NormType; -use super::{into_result, Pivot, Transpose}; - /// Wraps `*getrf`, `*getri`, and `*getrs` pub trait Solve_: Scalar + Sized { /// Computes the LU factorization of a general `m x n` matrix `a` using @@ -41,20 +36,20 @@ macro_rules! impl_solve { let (row, col) = l.size(); let k = ::std::cmp::min(row, col); let mut ipiv = vec![0; k as usize]; - let info = $getrf(l.lapacke_layout(), row, col, a, l.lda(), &mut ipiv); - into_result(info, ipiv) + $getrf(l.lapacke_layout(), row, col, a, l.lda(), &mut ipiv).as_lapack_result()?; + Ok(ipiv) } unsafe fn inv(l: MatrixLayout, a: &mut [Self], ipiv: &Pivot) -> Result<()> { let (n, _) = l.size(); - let info = $getri(l.lapacke_layout(), n, a, l.lda(), ipiv); - into_result(info, ()) + $getri(l.lapacke_layout(), n, a, l.lda(), ipiv).as_lapack_result()?; + Ok(()) } unsafe fn rcond(l: MatrixLayout, a: &[Self], anorm: Self::Real) -> Result { let (n, _) = l.size(); let mut rcond = Self::Real::zero(); - let info = $gecon( + $gecon( l.lapacke_layout(), NormType::One as u8, n, @@ -62,8 +57,9 @@ macro_rules! impl_solve { l.lda(), anorm, &mut rcond, - ); - into_result(info, rcond) + ) + .as_lapack_result()?; + Ok(rcond) } unsafe fn solve( @@ -76,7 +72,7 @@ macro_rules! impl_solve { let (n, _) = l.size(); let nrhs = 1; let ldb = 1; - let info = $getrs( + $getrs( l.lapacke_layout(), t as u8, n, @@ -86,8 +82,9 @@ macro_rules! impl_solve { ipiv, b, ldb, - ); - into_result(info, ()) + ) + .as_lapack_result()?; + Ok(()) } } }; diff --git a/ndarray-linalg/src/lapack/solveh.rs b/ndarray-linalg/src/lapack/solveh.rs index 9a5b3b6e..b7466455 100644 --- a/ndarray-linalg/src/lapack/solveh.rs +++ b/ndarray-linalg/src/lapack/solveh.rs @@ -2,11 +2,8 @@ //! //! See also [the manual of dsytrf](http://www.netlib.org/lapack/lapack-3.1.1/html/dsytrf.f.html) -use crate::error::*; -use crate::layout::MatrixLayout; -use crate::types::*; - -use super::{into_result, Pivot, UPLO}; +use super::*; +use crate::{error::*, layout::MatrixLayout, types::*}; pub trait Solveh_: Sized { /// Bunch-Kaufman: wrapper of `*sytrf` and `*hetrf` @@ -33,8 +30,9 @@ macro_rules! impl_solveh { // Work around bug in LAPACKE functions. Ok(ipiv) } else { - let info = $trf(l.lapacke_layout(), uplo as u8, n, a, l.lda(), &mut ipiv); - into_result(info, ipiv) + $trf(l.lapacke_layout(), uplo as u8, n, a, l.lda(), &mut ipiv) + .as_lapack_result()?; + Ok(ipiv) } } @@ -45,8 +43,8 @@ macro_rules! impl_solveh { ipiv: &Pivot, ) -> Result<()> { let (n, _) = l.size(); - let info = $tri(l.lapacke_layout(), uplo as u8, n, a, l.lda(), ipiv); - into_result(info, ()) + $tri(l.lapacke_layout(), uplo as u8, n, a, l.lda(), ipiv).as_lapack_result()?; + Ok(()) } unsafe fn solveh( @@ -62,7 +60,7 @@ macro_rules! impl_solveh { MatrixLayout::C(_) => 1, MatrixLayout::F(_) => n, }; - let info = $trs( + $trs( l.lapacke_layout(), uplo as u8, n, @@ -72,8 +70,9 @@ macro_rules! impl_solveh { ipiv, b, ldb, - ); - into_result(info, ()) + ) + .as_lapack_result()?; + Ok(()) } } }; diff --git a/ndarray-linalg/src/lapack/svd.rs b/ndarray-linalg/src/lapack/svd.rs index d62ed8cc..2bdd145a 100644 --- a/ndarray-linalg/src/lapack/svd.rs +++ b/ndarray-linalg/src/lapack/svd.rs @@ -1,13 +1,9 @@ //! Singular-value decomposition +use super::*; +use crate::{error::*, layout::MatrixLayout, types::*}; use num_traits::Zero; -use crate::error::*; -use crate::layout::MatrixLayout; -use crate::types::*; - -use super::into_result; - #[repr(u8)] enum FlagSVD { All = b'A', @@ -60,7 +56,7 @@ macro_rules! impl_svd { }; let mut s = vec![Self::Real::zero(); k as usize]; let mut superb = vec![Self::Real::zero(); (k - 1) as usize]; - let info = $gesvd( + $gesvd( l.lapacke_layout(), ju as u8, jvt as u8, @@ -74,15 +70,13 @@ macro_rules! impl_svd { &mut vt, ldvt, &mut superb, - ); - into_result( - info, - SVDOutput { - s, - u: if calc_u { Some(u) } else { None }, - vt: if calc_vt { Some(vt) } else { None }, - }, ) + .as_lapack_result()?; + Ok(SVDOutput { + s, + u: if calc_u { Some(u) } else { None }, + vt: if calc_vt { Some(vt) } else { None }, + }) } } }; diff --git a/ndarray-linalg/src/lapack/svddc.rs b/ndarray-linalg/src/lapack/svddc.rs index 915ea4e4..850d5a15 100644 --- a/ndarray-linalg/src/lapack/svddc.rs +++ b/ndarray-linalg/src/lapack/svddc.rs @@ -1,12 +1,7 @@ +use super::*; +use crate::{error::*, layout::MatrixLayout, svddc::UVTFlag, types::*}; use num_traits::Zero; -use crate::error::*; -use crate::layout::MatrixLayout; -use crate::svddc::UVTFlag; -use crate::types::*; - -use super::{into_result, SVDOutput}; - pub trait SVDDC_: Scalar { unsafe fn svddc(l: MatrixLayout, jobz: UVTFlag, a: &mut [Self]) -> Result>; } @@ -32,7 +27,7 @@ macro_rules! impl_svdd { let ldu = l.resized(m, ucol).lda(); let mut vt = vec![Self::zero(); (vtrow * n).max(1) as usize]; let ldvt = l.resized(vtrow, n).lda(); - let info = $gesdd( + $gesdd( l.lapacke_layout(), jobz as u8, m, @@ -44,19 +39,17 @@ macro_rules! impl_svdd { ldu, &mut vt, ldvt, - ); - into_result( - info, - SVDOutput { - s, - u: if jobz == UVTFlag::None { None } else { Some(u) }, - vt: if jobz == UVTFlag::None { - None - } else { - Some(vt) - }, - }, ) + .as_lapack_result()?; + Ok(SVDOutput { + s, + u: if jobz == UVTFlag::None { None } else { Some(u) }, + vt: if jobz == UVTFlag::None { + None + } else { + Some(vt) + }, + }) } } }; diff --git a/ndarray-linalg/src/lapack/triangular.rs b/ndarray-linalg/src/lapack/triangular.rs index a38ed405..98967bf1 100644 --- a/ndarray-linalg/src/lapack/triangular.rs +++ b/ndarray-linalg/src/lapack/triangular.rs @@ -1,10 +1,7 @@ //! Implement linear solver and inverse matrix -use super::{into_result, Transpose, UPLO}; - -use crate::error::*; -use crate::layout::MatrixLayout; -use crate::types::*; +use super::*; +use crate::{error::*, layout::MatrixLayout, types::*}; #[derive(Debug, Clone, Copy)] #[repr(u8)] @@ -37,8 +34,8 @@ macro_rules! impl_triangular { ) -> Result<()> { let (n, _) = l.size(); let lda = l.lda(); - let info = $trtri(l.lapacke_layout(), uplo as u8, diag as u8, n, a, lda); - into_result(info, ()) + $trtri(l.lapacke_layout(), uplo as u8, diag as u8, n, a, lda).as_lapack_result()?; + Ok(()) } unsafe fn solve_triangular( @@ -53,7 +50,7 @@ macro_rules! impl_triangular { let lda = al.lda(); let (_, nrhs) = bl.size(); let ldb = bl.lda(); - let info = $trtrs( + $trtrs( al.lapacke_layout(), uplo as u8, Transpose::No as u8, @@ -64,8 +61,9 @@ macro_rules! impl_triangular { lda, &mut b, ldb, - ); - into_result(info, ()) + ) + .as_lapack_result()?; + Ok(()) } } }; diff --git a/ndarray-linalg/src/lapack/tridiagonal.rs b/ndarray-linalg/src/lapack/tridiagonal.rs index 1a42a9db..417ac0f8 100644 --- a/ndarray-linalg/src/lapack/tridiagonal.rs +++ b/ndarray-linalg/src/lapack/tridiagonal.rs @@ -1,17 +1,10 @@ //! Implement linear solver using LU decomposition //! for tridiagonal matrix +use super::*; +use crate::{error::*, layout::MatrixLayout, opnorm::*, tridiagonal::*, types::*}; use num_traits::Zero; -use super::NormType; -use super::{into_result, Pivot, Transpose}; - -use crate::error::*; -use crate::layout::MatrixLayout; -use crate::opnorm::*; -use crate::tridiagonal::{LUFactorizedTridiagonal, Tridiagonal}; -use crate::types::*; - /// Wraps `*gttrf`, `*gtcon` and `*gttrs` pub trait Tridiagonal_: Scalar + Sized { /// Computes the LU factorization of a tridiagonal `m x n` matrix `a` using @@ -37,8 +30,9 @@ macro_rules! impl_tridiagonal { let anom = a.opnorm_one()?; let mut du2 = vec![Zero::zero(); (n - 2) as usize]; let mut ipiv = vec![0; n as usize]; - let info = $gttrf(n, &mut a.dl, &mut a.d, &mut a.du, &mut du2, &mut ipiv); - into_result(info, (du2, anom, ipiv)) + $gttrf(n, &mut a.dl, &mut a.d, &mut a.du, &mut du2, &mut ipiv) + .as_lapack_result()?; + Ok((du2, anom, ipiv)) } unsafe fn rcond_tridiagonal(lu: &LUFactorizedTridiagonal) -> Result { @@ -46,7 +40,7 @@ macro_rules! impl_tridiagonal { let ipiv = &lu.ipiv; let anorm = lu.anom; let mut rcond = Self::Real::zero(); - let info = $gtcon( + $gtcon( NormType::One as u8, n, &lu.a.dl, @@ -56,8 +50,9 @@ macro_rules! impl_tridiagonal { ipiv, anorm, &mut rcond, - ); - into_result(info, rcond) + ) + .as_lapack_result()?; + Ok(rcond) } unsafe fn solve_tridiagonal( @@ -70,7 +65,7 @@ macro_rules! impl_tridiagonal { let (_, nrhs) = bl.size(); let ipiv = &lu.ipiv; let ldb = bl.lda(); - let info = $gttrs( + $gttrs( lu.a.l.lapacke_layout(), t as u8, n, @@ -82,8 +77,9 @@ macro_rules! impl_tridiagonal { ipiv, b, ldb, - ); - into_result(info, ()) + ) + .as_lapack_result()?; + Ok(()) } } }; diff --git a/ndarray-linalg/src/lobpcg/lobpcg.rs b/ndarray-linalg/src/lobpcg/lobpcg.rs index e11a24ab..a86f868e 100644 --- a/ndarray-linalg/src/lobpcg/lobpcg.rs +++ b/ndarray-linalg/src/lobpcg/lobpcg.rs @@ -337,7 +337,7 @@ pub fn lobpcg< // if this fails (or the algorithm was restarted), then just use span{R, X} let result = p_ap .as_ref() - .ok_or(LinalgError::Lapack { return_code: 1 }) + .ok_or(LinalgError::LapackComputationalFailure { return_code: 1 }) .and_then(|(active_p, active_ap)| { let xap = x.t().dot(active_ap); let rap = r.t().dot(active_ap); diff --git a/ndarray-linalg/src/solve.rs b/ndarray-linalg/src/solve.rs index 007500c4..60eb070b 100644 --- a/ndarray-linalg/src/solve.rs +++ b/ndarray-linalg/src/solve.rs @@ -476,7 +476,7 @@ where self.ensure_square()?; match self.factorize() { Ok(fac) => fac.sln_det(), - Err(LinalgError::Lapack { return_code }) if return_code > 0 => { + Err(LinalgError::LapackComputationalFailure { .. }) => { // The determinant is zero. Ok((A::zero(), A::Real::neg_infinity())) } @@ -494,7 +494,7 @@ where self.ensure_square()?; match self.factorize_into() { Ok(fac) => fac.sln_det_into(), - Err(LinalgError::Lapack { return_code }) if return_code > 0 => { + Err(LinalgError::LapackComputationalFailure { .. }) => { // The determinant is zero. Ok((A::zero(), A::Real::neg_infinity())) } diff --git a/ndarray-linalg/src/solveh.rs b/ndarray-linalg/src/solveh.rs index dc929d8c..481757e6 100644 --- a/ndarray-linalg/src/solveh.rs +++ b/ndarray-linalg/src/solveh.rs @@ -423,7 +423,7 @@ where fn sln_deth(&self) -> Result<(A::Real, A::Real)> { match self.factorizeh() { Ok(fac) => Ok(fac.sln_deth()), - Err(LinalgError::Lapack { return_code }) if return_code > 0 => { + Err(LinalgError::LapackComputationalFailure { .. }) => { // Determinant is zero. Ok((A::Real::zero(), A::Real::neg_infinity())) } @@ -447,7 +447,7 @@ where fn sln_deth_into(self) -> Result<(A::Real, A::Real)> { match self.factorizeh_into() { Ok(fac) => Ok(fac.sln_deth_into()), - Err(LinalgError::Lapack { return_code }) if return_code > 0 => { + Err(LinalgError::LapackComputationalFailure { .. }) => { // Determinant is zero. Ok((A::Real::zero(), A::Real::neg_infinity())) }