11//! Solve linear problem using LU decomposition
22
3+ use super :: * ;
4+ use crate :: { error:: * , layout:: MatrixLayout , types:: * } ;
35use num_traits:: Zero ;
46
5- use crate :: error:: * ;
6- use crate :: layout:: MatrixLayout ;
7- use crate :: types:: * ;
8-
9- use super :: NormType ;
10- use super :: { into_result, Pivot , Transpose } ;
11-
127/// Wraps `*getrf`, `*getri`, and `*getrs`
138pub trait Solve_ : Scalar + Sized {
149 /// Computes the LU factorization of a general `m x n` matrix `a` using
@@ -41,29 +36,30 @@ macro_rules! impl_solve {
4136 let ( row, col) = l. size( ) ;
4237 let k = :: std:: cmp:: min( row, col) ;
4338 let mut ipiv = vec![ 0 ; k as usize ] ;
44- let info = $getrf( l. lapacke_layout( ) , row, col, a, l. lda( ) , & mut ipiv) ;
45- into_result ( info , ipiv)
39+ $getrf( l. lapacke_layout( ) , row, col, a, l. lda( ) , & mut ipiv) . as_lapack_result ( ) ? ;
40+ Ok ( ipiv)
4641 }
4742
4843 unsafe fn inv( l: MatrixLayout , a: & mut [ Self ] , ipiv: & Pivot ) -> Result <( ) > {
4944 let ( n, _) = l. size( ) ;
50- let info = $getri( l. lapacke_layout( ) , n, a, l. lda( ) , ipiv) ;
51- into_result ( info , ( ) )
45+ $getri( l. lapacke_layout( ) , n, a, l. lda( ) , ipiv) . as_lapack_result ( ) ? ;
46+ Ok ( ( ) )
5247 }
5348
5449 unsafe fn rcond( l: MatrixLayout , a: & [ Self ] , anorm: Self :: Real ) -> Result <Self :: Real > {
5550 let ( n, _) = l. size( ) ;
5651 let mut rcond = Self :: Real :: zero( ) ;
57- let info = $gecon(
52+ $gecon(
5853 l. lapacke_layout( ) ,
5954 NormType :: One as u8 ,
6055 n,
6156 a,
6257 l. lda( ) ,
6358 anorm,
6459 & mut rcond,
65- ) ;
66- into_result( info, rcond)
60+ )
61+ . as_lapack_result( ) ?;
62+ Ok ( rcond)
6763 }
6864
6965 unsafe fn solve(
@@ -76,7 +72,7 @@ macro_rules! impl_solve {
7672 let ( n, _) = l. size( ) ;
7773 let nrhs = 1 ;
7874 let ldb = 1 ;
79- let info = $getrs(
75+ $getrs(
8076 l. lapacke_layout( ) ,
8177 t as u8 ,
8278 n,
@@ -86,8 +82,9 @@ macro_rules! impl_solve {
8682 ipiv,
8783 b,
8884 ldb,
89- ) ;
90- into_result( info, ( ) )
85+ )
86+ . as_lapack_result( ) ?;
87+ Ok ( ( ) )
9188 }
9289 }
9390 } ;
0 commit comments