Add another case for when eigenvalues should be mapped to zero. Make method private

This commit is contained in:
metric-space 2022-02-15 01:45:33 -05:00
parent e52f11700f
commit 5e10ca46cb
1 changed files with 9 additions and 5 deletions

View File

@ -253,17 +253,21 @@ where
(l, r) (l, r)
} }
/// computes the generalized eigenvalues i.e values of lambda that satisfy the following equation // only used for internal calculation for assembling eigenvectors based on realness of
/// determinant(A - lambda* B) = 0 // eigenvalues and complex-conjugate checks of subsequent non-real eigenvalues
#[must_use] fn eigenvalues(&self) -> OVector<Complex<T>, D>
pub fn eigenvalues(&self) -> OVector<Complex<T>, D>
where where
DefaultAllocator: Allocator<Complex<T>, D>, DefaultAllocator: Allocator<Complex<T>, D>,
{ {
let mut out = Matrix::zeros_generic(self.vsl.shape_generic().0, Const::<1>); let mut out = Matrix::zeros_generic(self.vsl.shape_generic().0, Const::<1>);
let epsilon = T::RealField::default_epsilon();
for i in 0..out.len() { for i in 0..out.len() {
out[i] = if self.beta[i].clone().abs() < T::RealField::default_epsilon() { out[i] = if self.beta[i].clone().abs() < epsilon
|| (self.alphai[i].clone().abs() < epsilon
&& self.alphar[i].clone().abs() < epsilon)
{
Complex::zero() Complex::zero()
} else { } else {
Complex::new(self.alphar[i].clone(), self.alphai[i].clone()) Complex::new(self.alphar[i].clone(), self.alphai[i].clone())