Skip to content

Commit

Permalink
Merge Eig_ trait into Lapack trait
Browse files Browse the repository at this point in the history
  • Loading branch information
termoshtt committed Sep 24, 2022
1 parent e407602 commit e51b40d
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions lax/src/lib.rs
Expand Up @@ -115,7 +115,7 @@ pub use self::svddc::*;
pub use self::triangular::*;
pub use self::tridiagonal::*;

use self::alloc::*;
use self::{alloc::*, error::*, layout::*};
use cauchy::*;
use std::mem::MaybeUninit;

Expand All @@ -130,16 +130,37 @@ pub trait Lapack:
+ Solve_
+ Solveh_
+ Cholesky_
+ Eig_
+ Eigh_
+ Triangular_
+ Tridiagonal_
+ Rcond_
+ LeastSquaresSvdDivideConquer_
{
/// Compute right eigenvalue and eigenvectors
fn eig(
calc_v: bool,
l: MatrixLayout,
a: &mut [Self],
) -> Result<(Vec<Self::Complex>, Vec<Self::Complex>)>;
}

impl Lapack for f32 {}
impl Lapack for f64 {}
impl Lapack for c32 {}
impl Lapack for c64 {}
macro_rules! impl_lapack {
($s:ty) => {
impl Lapack for $s {
fn eig(
calc_v: bool,
l: MatrixLayout,
a: &mut [Self],
) -> Result<(Vec<Self::Complex>, Vec<Self::Complex>)> {
use eig::*;
let work = EigWork::<$s>::new(calc_v, l)?;
let EigOwned { eigs, vr, vl } = work.eval(a)?;
Ok((eigs, vr.or(vl).unwrap_or_default()))
}
}
};
}
impl_lapack!(c64);
impl_lapack!(c32);
impl_lapack!(f64);
impl_lapack!(f32);

0 comments on commit e51b40d

Please sign in to comment.