5858//! According to the property input metrix,
5959//! there are several types of eigenvalue problem API
6060//!
61- //! - [Eig_] trait provides methods for eigenvalue problem for general matrix.
61+ //! - [eig] module for eigenvalue problem for general matrix.
6262//! - [Eigh_] trait provides methods for eigenvalue problem for symmetric/hermite matrix.
6363//!
6464//! Singular Value Decomposition
@@ -101,7 +101,6 @@ mod triangular;
101101mod tridiagonal;
102102
103103pub use self :: cholesky:: * ;
104- pub use self :: eig:: Eig_ ;
105104pub use self :: eigh:: * ;
106105pub use self :: flags:: * ;
107106pub use self :: least_squares:: * ;
@@ -115,7 +114,7 @@ pub use self::svddc::*;
115114pub use self :: triangular:: * ;
116115pub use self :: tridiagonal:: * ;
117116
118- use self :: alloc:: * ;
117+ use self :: { alloc:: * , error :: * , layout :: * } ;
119118use cauchy:: * ;
120119use std:: mem:: MaybeUninit ;
121120
@@ -130,16 +129,38 @@ pub trait Lapack:
130129 + Solve_
131130 + Solveh_
132131 + Cholesky_
133- + Eig_
134132 + Eigh_
135133 + Triangular_
136134 + Tridiagonal_
137135 + Rcond_
138136 + LeastSquaresSvdDivideConquer_
139137{
138+ /// Compute right eigenvalue and eigenvectors
139+ fn eig (
140+ calc_v : bool ,
141+ l : MatrixLayout ,
142+ a : & mut [ Self ] ,
143+ ) -> Result < ( Vec < Self :: Complex > , Vec < Self :: Complex > ) > ;
140144}
141145
142- impl Lapack for f32 { }
143- impl Lapack for f64 { }
144- impl Lapack for c32 { }
145- impl Lapack for c64 { }
146+ macro_rules! impl_lapack {
147+ ( $s: ty) => {
148+ impl Lapack for $s {
149+ /// Compute right eigenvalue and eigenvectors
150+ fn eig(
151+ calc_v: bool ,
152+ l: MatrixLayout ,
153+ a: & mut [ Self ] ,
154+ ) -> Result <( Vec <Self :: Complex >, Vec <Self :: Complex >) > {
155+ use eig:: * ;
156+ let work = EigWork :: <$s>:: new( calc_v, l) ?;
157+ let EigOwned { eigs, vr, vl } = work. eval( a) ?;
158+ Ok ( ( eigs, vr. or( vl) . unwrap_or_default( ) ) )
159+ }
160+ }
161+ } ;
162+ }
163+ impl_lapack ! ( c64) ;
164+ impl_lapack ! ( c32) ;
165+ impl_lapack ! ( f64 ) ;
166+ impl_lapack ! ( f32 ) ;
0 commit comments