Replace Brandts sorting with LAPACK DTRSEN, stabilize Gram-Schmidt#64
Open
Marius1311 wants to merge 1 commit intomainfrom
Open
Replace Brandts sorting with LAPACK DTRSEN, stabilize Gram-Schmidt#64Marius1311 wants to merge 1 commit intomainfrom
Marius1311 wants to merge 1 commit intomainfrom
Conversation
- Replace 624-line Python Brandts sorting (_sort_real_schur.py) with a single LAPACK DTRSEN call in sorted_brandts_schur(). Same Bai-Demmel algorithm, compiled Fortran instead of Python loops. Fixes subspace angle failures for n >= 100. - Replace single-pass Modified Gram-Schmidt in _gram_schmidt_mod() with Householder QR (np.linalg.qr, LAPACK DGEQRF). Single-pass MGS lost orthogonality for ill-conditioned inputs (kappa up to 1e16). QR is backward stable regardless of conditioning. Same O(nm^2) complexity, faster in practice (compiled LAPACK vs Python loops). - Replace fragile constant-vector detection (element-wise constancy check with tight tolerance) with cosine similarity against sqrt(eta). The old check failed when Schur vectors were only approximately constant due to numerical noise from different eigenvalue orderings. - Recompute R in _do_schur() after re-orthogonalization to maintain the Schur relation in the new basis. - Update tests accordingly.
21ace14 to
bd49915
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace 624-line Python Brandts sorting (_sort_real_schur.py) with a single LAPACK DTRSEN call in sorted_brandts_schur(). Same Bai-Demmel algorithm, compiled Fortran instead of Python loops. Fixes subspace angle failures for n >= 100.
Replace single-pass Modified Gram-Schmidt in _gram_schmidt_mod() with Householder QR (np.linalg.qr, LAPACK DGEQRF). Single-pass MGS lost orthogonality for ill-conditioned inputs (kappa up to 1e16). QR is backward stable regardless of conditioning. Same O(nm^2) complexity, faster in practice (compiled LAPACK vs Python loops).
Replace fragile constant-vector detection (element-wise constancy check with tight tolerance) with cosine similarity against sqrt(eta). The old check failed when Schur vectors were only approximately constant due to numerical noise from different eigenvalue orderings.
Recompute R in _do_schur() after re-orthogonalization to maintain the Schur relation in the new basis.
Update tests accordingly.