1
1
//! Solve linear problem using LU decomposition
2
2
3
+ use super :: * ;
4
+ use crate :: { error:: * , layout:: MatrixLayout , types:: * } ;
3
5
use num_traits:: Zero ;
4
6
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
-
12
7
/// Wraps `*getrf`, `*getri`, and `*getrs`
13
8
pub trait Solve_ : Scalar + Sized {
14
9
/// Computes the LU factorization of a general `m x n` matrix `a` using
@@ -41,29 +36,30 @@ macro_rules! impl_solve {
41
36
let ( row, col) = l. size( ) ;
42
37
let k = :: std:: cmp:: min( row, col) ;
43
38
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)
46
41
}
47
42
48
43
unsafe fn inv( l: MatrixLayout , a: & mut [ Self ] , ipiv: & Pivot ) -> Result <( ) > {
49
44
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 ( ( ) )
52
47
}
53
48
54
49
unsafe fn rcond( l: MatrixLayout , a: & [ Self ] , anorm: Self :: Real ) -> Result <Self :: Real > {
55
50
let ( n, _) = l. size( ) ;
56
51
let mut rcond = Self :: Real :: zero( ) ;
57
- let info = $gecon(
52
+ $gecon(
58
53
l. lapacke_layout( ) ,
59
54
NormType :: One as u8 ,
60
55
n,
61
56
a,
62
57
l. lda( ) ,
63
58
anorm,
64
59
& mut rcond,
65
- ) ;
66
- into_result( info, rcond)
60
+ )
61
+ . as_lapack_result( ) ?;
62
+ Ok ( rcond)
67
63
}
68
64
69
65
unsafe fn solve(
@@ -76,7 +72,7 @@ macro_rules! impl_solve {
76
72
let ( n, _) = l. size( ) ;
77
73
let nrhs = 1 ;
78
74
let ldb = 1 ;
79
- let info = $getrs(
75
+ $getrs(
80
76
l. lapacke_layout( ) ,
81
77
t as u8 ,
82
78
n,
@@ -86,8 +82,9 @@ macro_rules! impl_solve {
86
82
ipiv,
87
83
b,
88
84
ldb,
89
- ) ;
90
- into_result( info, ( ) )
85
+ )
86
+ . as_lapack_result( ) ?;
87
+ Ok ( ( ) )
91
88
}
92
89
}
93
90
} ;
0 commit comments