@@ -4,12 +4,14 @@ use lapack::c;
4
4
5
5
use error:: * ;
6
6
use layout:: MatrixLayout ;
7
+ use num_traits:: Zero ;
7
8
use types:: * ;
8
9
9
10
use super :: { Pivot , Transpose , into_result} ;
11
+ use super :: opnorm:: NormType ;
10
12
11
13
/// Wraps `*getrf`, `*getri`, and `*getrs`
12
- pub trait Solve_ : Sized {
14
+ pub trait Solve_ : AssociatedReal + Sized {
13
15
/// Computes the LU factorization of a general `m x n` matrix `a` using
14
16
/// partial pivoting with row interchanges.
15
17
///
@@ -20,11 +22,12 @@ pub trait Solve_: Sized {
20
22
/// if it is used to solve a system of equations.
21
23
unsafe fn lu ( MatrixLayout , a : & mut [ Self ] ) -> Result < Pivot > ;
22
24
unsafe fn inv ( MatrixLayout , a : & mut [ Self ] , & Pivot ) -> Result < ( ) > ;
25
+ unsafe fn rcond ( MatrixLayout , a : & [ Self ] , anorm : Self :: Real ) -> Result < Self :: Real > ;
23
26
unsafe fn solve ( MatrixLayout , Transpose , a : & [ Self ] , & Pivot , b : & mut [ Self ] ) -> Result < ( ) > ;
24
27
}
25
28
26
29
macro_rules! impl_solve {
27
- ( $scalar: ty, $getrf: path, $getri: path, $getrs: path) => {
30
+ ( $scalar: ty, $getrf: path, $getri: path, $gecon : path , $ getrs: path) => {
28
31
29
32
impl Solve_ for $scalar {
30
33
unsafe fn lu( l: MatrixLayout , a: & mut [ Self ] ) -> Result <Pivot > {
@@ -41,6 +44,13 @@ impl Solve_ for $scalar {
41
44
into_result( info, ( ) )
42
45
}
43
46
47
+ unsafe fn rcond( l: MatrixLayout , a: & [ Self ] , anorm: Self :: Real ) -> Result <Self :: Real > {
48
+ let ( n, _) = l. size( ) ;
49
+ let mut rcond = Self :: Real :: zero( ) ;
50
+ let info = $gecon( l. lapacke_layout( ) , NormType :: One as u8 , n, a, l. lda( ) , anorm, & mut rcond) ;
51
+ into_result( info, rcond)
52
+ }
53
+
44
54
unsafe fn solve( l: MatrixLayout , t: Transpose , a: & [ Self ] , ipiv: & Pivot , b: & mut [ Self ] ) -> Result <( ) > {
45
55
let ( n, _) = l. size( ) ;
46
56
let nrhs = 1 ;
@@ -52,7 +62,7 @@ impl Solve_ for $scalar {
52
62
53
63
} } // impl_solve!
54
64
55
- impl_solve ! ( f64 , c:: dgetrf, c:: dgetri, c:: dgetrs) ;
56
- impl_solve ! ( f32 , c:: sgetrf, c:: sgetri, c:: sgetrs) ;
57
- impl_solve ! ( c64, c:: zgetrf, c:: zgetri, c:: zgetrs) ;
58
- impl_solve ! ( c32, c:: cgetrf, c:: cgetri, c:: cgetrs) ;
65
+ impl_solve ! ( f64 , c:: dgetrf, c:: dgetri, c:: dgecon , c :: dgetrs) ;
66
+ impl_solve ! ( f32 , c:: sgetrf, c:: sgetri, c:: sgecon , c :: sgetrs) ;
67
+ impl_solve ! ( c64, c:: zgetrf, c:: zgetri, c:: zgecon , c :: zgetrs) ;
68
+ impl_solve ! ( c32, c:: cgetrf, c:: cgetri, c:: cgecon , c :: cgetrs) ;
0 commit comments