Skip to content

Commit

Permalink
Remove special subdim=2 case from SymmetricEigen
Browse files Browse the repository at this point in the history
  • Loading branch information
CattleProdigy committed Feb 21, 2023
1 parent 8b4587c commit 1d64d61
Showing 1 changed file with 2 additions and 42 deletions.
44 changes: 2 additions & 42 deletions src/linalg/symmetric_eigen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use approx::AbsDiffEq;
use num::Zero;

use crate::allocator::Allocator;
use crate::base::{DefaultAllocator, Matrix2, OMatrix, OVector, SquareMatrix, Vector2};
use crate::base::{DefaultAllocator, OMatrix, OVector, SquareMatrix, Vector2};
use crate::dimension::{Dim, DimDiff, DimSub, U1};
use crate::storage::Storage;
use simba::scalar::ComplexField;
Expand Down Expand Up @@ -131,10 +131,7 @@ where
Self::delimit_subproblem(&diag, &mut off_diag, dim - 1, eps.clone());

while end != start {
let subdim = end - start + 1;

#[allow(clippy::comparison_chain)]
if subdim > 2 {
{
let m = end - 1;
let n = end;

Expand Down Expand Up @@ -191,43 +188,6 @@ where
{
end -= 1;
}
} else if subdim == 2 {
let m = Matrix2::new(
diag[start].clone(),
off_diag[start].clone().conjugate(),
off_diag[start].clone(),
diag[start + 1].clone(),
);
let eigvals = m.eigenvalues().unwrap();

// A = [ a c ]
// [ c b ]
// v = [ v1; v2 ]
// (A-lI)v = 0
// (a-l1)v1 + c*v2 = 0
//
// let v1 = c
// (a-l1)c + c*v2 = 0
// (a-l1)c = -c*v2
// v2 = l1 - a
let basis = Vector2::new(
off_diag[start].clone(),
eigvals.x.clone() - diag[start].clone(),
);

diag[start] = eigvals[0].clone();
diag[start + 1] = eigvals[1].clone();

if let Some(ref mut q) = q_mat {
if let Some((rot, _)) =
GivensRotation::try_new(basis.x.clone(), basis.y.clone(), eps.clone())
{
let rot = GivensRotation::new_unchecked(rot.c(), T::from_real(rot.s()));
rot.rotate_rows(&mut q.fixed_columns_mut::<2>(start));
}
}

end -= 1;
}

// Re-delimit the subproblem in case some decoupling occurred.
Expand Down

0 comments on commit 1d64d61

Please sign in to comment.