Skip to content

Commit e51b40d

Browse files
committed
Merge Eig_ trait into Lapack trait
1 parent e407602 commit e51b40d

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

lax/src/lib.rs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub use self::svddc::*;
115115
pub use self::triangular::*;
116116
pub use self::tridiagonal::*;
117117

118-
use self::alloc::*;
118+
use self::{alloc::*, error::*, layout::*};
119119
use cauchy::*;
120120
use std::mem::MaybeUninit;
121121

@@ -130,16 +130,37 @@ pub trait Lapack:
130130
+ Solve_
131131
+ Solveh_
132132
+ Cholesky_
133-
+ Eig_
134133
+ Eigh_
135134
+ Triangular_
136135
+ Tridiagonal_
137136
+ Rcond_
138137
+ LeastSquaresSvdDivideConquer_
139138
{
139+
/// Compute right eigenvalue and eigenvectors
140+
fn eig(
141+
calc_v: bool,
142+
l: MatrixLayout,
143+
a: &mut [Self],
144+
) -> Result<(Vec<Self::Complex>, Vec<Self::Complex>)>;
140145
}
141146

142-
impl Lapack for f32 {}
143-
impl Lapack for f64 {}
144-
impl Lapack for c32 {}
145-
impl Lapack for c64 {}
147+
macro_rules! impl_lapack {
148+
($s:ty) => {
149+
impl Lapack for $s {
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

Comments
 (0)