@@ -20,7 +20,7 @@ macro_rules! impl_eig_complex {
20
20
fn eig(
21
21
calc_v: bool ,
22
22
l: MatrixLayout ,
23
- mut a: & mut [ Self ] ,
23
+ a: & mut [ Self ] ,
24
24
) -> Result <( Vec <Self :: Complex >, Vec <Self :: Complex >) > {
25
25
let ( n, _) = l. size( ) ;
26
26
// LAPACK assumes a column-major input. A row-major input can
@@ -42,52 +42,55 @@ macro_rules! impl_eig_complex {
42
42
( EigenVectorFlag :: Not , EigenVectorFlag :: Not )
43
43
} ;
44
44
let mut eigs = unsafe { vec_uninit( n as usize ) } ;
45
- let mut rwork = unsafe { vec_uninit( 2 * n as usize ) } ;
45
+ let mut rwork: Vec < Self :: Real > = unsafe { vec_uninit( 2 * n as usize ) } ;
46
46
47
- let mut vl = jobvl. then( || unsafe { vec_uninit( ( n * n) as usize ) } ) ;
48
- let mut vr = jobvr. then( || unsafe { vec_uninit( ( n * n) as usize ) } ) ;
47
+ let mut vl: Option <Vec <Self >> =
48
+ jobvl. then( || unsafe { vec_uninit( ( n * n) as usize ) } ) ;
49
+ let mut vr: Option <Vec <Self >> =
50
+ jobvr. then( || unsafe { vec_uninit( ( n * n) as usize ) } ) ;
49
51
50
52
// calc work size
51
53
let mut info = 0 ;
52
54
let mut work_size = [ Self :: zero( ) ] ;
53
55
unsafe {
54
56
$ev(
55
- jobvl as u8 ,
56
- jobvr as u8 ,
57
- n,
58
- & mut a ,
59
- n,
60
- & mut eigs,
61
- & mut vl. as_mut( ) . map( |v| v. as_mut_slice( ) ) . unwrap_or( & mut [ ] ) ,
62
- n,
63
- & mut vr. as_mut( ) . map( |v| v. as_mut_slice( ) ) . unwrap_or( & mut [ ] ) ,
64
- n,
65
- & mut work_size,
66
- - 1 ,
67
- & mut rwork,
57
+ jobvl. as_ptr ( ) ,
58
+ jobvr. as_ptr ( ) ,
59
+ & n,
60
+ AsPtr :: as_mut_ptr ( a ) ,
61
+ & n,
62
+ AsPtr :: as_mut_ptr ( & mut eigs) ,
63
+ AsPtr :: as_mut_ptr ( vl. as_mut( ) . map( |v| v. as_mut_slice( ) ) . unwrap_or( & mut [ ] ) ) ,
64
+ & n,
65
+ AsPtr :: as_mut_ptr ( vr. as_mut( ) . map( |v| v. as_mut_slice( ) ) . unwrap_or( & mut [ ] ) ) ,
66
+ & n,
67
+ AsPtr :: as_mut_ptr ( & mut work_size) ,
68
+ & ( - 1 ) ,
69
+ AsPtr :: as_mut_ptr ( & mut rwork) ,
68
70
& mut info,
69
71
)
70
72
} ;
71
73
info. as_lapack_result( ) ?;
72
74
73
75
// actal ev
74
76
let lwork = work_size[ 0 ] . to_usize( ) . unwrap( ) ;
75
- let mut work = unsafe { vec_uninit( lwork) } ;
77
+ let mut work: Vec <Self > = unsafe { vec_uninit( lwork) } ;
78
+ let lwork = lwork as i32 ;
76
79
unsafe {
77
80
$ev(
78
- jobvl as u8 ,
79
- jobvr as u8 ,
80
- n,
81
- & mut a ,
82
- n,
83
- & mut eigs,
84
- & mut vl. as_mut( ) . map( |v| v. as_mut_slice( ) ) . unwrap_or( & mut [ ] ) ,
85
- n,
86
- & mut vr. as_mut( ) . map( |v| v. as_mut_slice( ) ) . unwrap_or( & mut [ ] ) ,
87
- n,
88
- & mut work,
89
- lwork as i32 ,
90
- & mut rwork,
81
+ jobvl. as_ptr ( ) ,
82
+ jobvr. as_ptr ( ) ,
83
+ & n,
84
+ AsPtr :: as_mut_ptr ( a ) ,
85
+ & n,
86
+ AsPtr :: as_mut_ptr ( & mut eigs) ,
87
+ AsPtr :: as_mut_ptr ( vl. as_mut( ) . map( |v| v. as_mut_slice( ) ) . unwrap_or( & mut [ ] ) ) ,
88
+ & n,
89
+ AsPtr :: as_mut_ptr ( vr. as_mut( ) . map( |v| v. as_mut_slice( ) ) . unwrap_or( & mut [ ] ) ) ,
90
+ & n,
91
+ AsPtr :: as_mut_ptr ( & mut work) ,
92
+ & lwork,
93
+ AsPtr :: as_mut_ptr ( & mut rwork) ,
91
94
& mut info,
92
95
)
93
96
} ;
@@ -106,8 +109,8 @@ macro_rules! impl_eig_complex {
106
109
} ;
107
110
}
108
111
109
- impl_eig_complex ! ( c64, lapack :: zgeev ) ;
110
- impl_eig_complex ! ( c32, lapack :: cgeev ) ;
112
+ impl_eig_complex ! ( c64, lapack_sys :: zgeev_ ) ;
113
+ impl_eig_complex ! ( c32, lapack_sys :: cgeev_ ) ;
111
114
112
115
macro_rules! impl_eig_real {
113
116
( $scalar: ty, $ev: path) => {
0 commit comments