2
2
3
3
use crate :: layout:: MatrixLayout ;
4
4
use cauchy:: * ;
5
- use lapacke :: Layout :: ColumnMajor as cm ;
5
+ use num_traits :: Zero ;
6
6
7
7
pub use super :: NormType ;
8
8
@@ -14,18 +14,24 @@ macro_rules! impl_opnorm {
14
14
( $scalar: ty, $lange: path) => {
15
15
impl OperatorNorm_ for $scalar {
16
16
unsafe fn opnorm( t: NormType , l: MatrixLayout , a: & [ Self ] ) -> Self :: Real {
17
- match l {
18
- MatrixLayout :: F { col, lda } => $lange( cm, t as u8 , lda, col, a, lda) ,
19
- MatrixLayout :: C { row, lda } => {
20
- $lange( cm, t. transpose( ) as u8 , lda, row, a, lda)
21
- }
22
- }
17
+ let m = l. lda( ) ;
18
+ let n = l. len( ) ;
19
+ let t = match l {
20
+ MatrixLayout :: F { .. } => t,
21
+ MatrixLayout :: C { .. } => t. transpose( ) ,
22
+ } ;
23
+ let mut work = if matches!( t, NormType :: Infinity ) {
24
+ vec![ Self :: Real :: zero( ) ; m as usize ]
25
+ } else {
26
+ Vec :: new( )
27
+ } ;
28
+ $lange( t as u8 , m, n, a, m, & mut work)
23
29
}
24
30
}
25
31
} ;
26
32
} // impl_opnorm!
27
33
28
- impl_opnorm ! ( f64 , lapacke :: dlange) ;
29
- impl_opnorm ! ( f32 , lapacke :: slange) ;
30
- impl_opnorm ! ( c64, lapacke :: zlange) ;
31
- impl_opnorm ! ( c32, lapacke :: clange) ;
34
+ impl_opnorm ! ( f64 , lapack :: dlange) ;
35
+ impl_opnorm ! ( f32 , lapack :: slange) ;
36
+ impl_opnorm ! ( c64, lapack :: zlange) ;
37
+ impl_opnorm ! ( c32, lapack :: clange) ;
0 commit comments