Description
Eigen::new() returns Option<Self> but internally calls .unwrap() on Schur::new(), which can panic before Eigen::new() has a chance to return None:
// src/linalg/eigen.rs, line 72
let (mut eigenvectors, mut eigenvalues) = Schur::new(m, 0).unwrap().unpack();
Schur::new returns Option<Schur<T, D>> and can fail for matrices where the Schur decomposition does not converge. When it does, the .unwrap() panics instead of propagating the failure as None.
Impact
This is inconsistent with every other decomposition in nalgebra (Cholesky::new, LU::new, SVD::try_new, etc.), which return Option/Result on failure without panicking. Users relying on Eigen::new() returning None gracefully may get unexpected panics instead.
Expected behaviour
let (mut eigenvectors, mut eigenvalues) = Schur::new(m, 0)?.unpack();
// or
let (mut eigenvectors, mut eigenvalues) = Schur::new(m, 0)
.map(|s| s.unpack())
.unwrap_or_else(|| return None);
Fix
Replace .unwrap() with ? (using early-return None) or an explicit match/? to propagate the failure as None from Eigen::new().
Description
Eigen::new()returnsOption<Self>but internally calls.unwrap()onSchur::new(), which can panic beforeEigen::new()has a chance to returnNone:Schur::newreturnsOption<Schur<T, D>>and can fail for matrices where the Schur decomposition does not converge. When it does, the.unwrap()panics instead of propagating the failure asNone.Impact
This is inconsistent with every other decomposition in nalgebra (
Cholesky::new,LU::new,SVD::try_new, etc.), which returnOption/Resulton failure without panicking. Users relying onEigen::new()returningNonegracefully may get unexpected panics instead.Expected behaviour
Fix
Replace
.unwrap()with?(using early-returnNone) or an explicitmatch/?to propagate the failure asNonefromEigen::new().