Repository navigation
Handle conjugate pairs in either order (Accelerate, #68) - #75
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Nov 13, 2026
_check_conj_split only flagged a cut when the eigenvalue at the boundary had a positive imaginary part. With Apple Accelerate, the Brandts sort can leave a 2x2 block whose pair comes out negative-first, so a cut went unnoticed and GPCCA used a non-invariant subspace. Check abs(imag), and read eigenvalues off the Schur blocks with the positive imaginary part first instead of rsf2csf. Test macOS on PyPI wheels (Accelerate). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Marius1311
force-pushed
the
fix/conj-pair-order
branch
from
November 13, 2026 13:55
fcacc48 to
03f1317
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.
Fixes #68. Replaces #62. Part of #70.
Cause
On macOS with numpy/scipy from PyPI, LAPACK comes from Apple Accelerate. There, the Brandts sort can leave a 2x2 block whose conjugate pair comes out with the negative imaginary part first. For
P_2(LM, all 12 sorted) the pairs come out[+, +, −]; with OpenBLAS they are always[+, +, +]. Atm = 9the last eigenvalue is then−0.432 − 0.390i._check_conj_splitonly looked atimag > EPS, so it missed the cut, and GPCCA went on with a basis that cuts a 2x2 block: subspace angle 0.70 rad.The diagnostic run in #73 showed this: on Accelerate,
schur()and every Brandts swap have residuals around 1e-15; only the pair order differs.Change
_check_conj_splitchecksabs(imag). On Accelerate this alone fixes the four split tests: run.sorted_brandts_schurreads eigenvalues off the Schur blocks, positive imaginary part first (as LAPACK orders them), instead ofrsf2csf. This fixes the remaining two (test_P_2_LM/LR[brandts], which comparetop_eigenvalues), with no test-side normalisation.hatch-test.py3.12-stable (macOS, Accelerate)), so the Accelerate path stays covered.Linux: no change in results (85 passed, 44 skipped locally). On Linux, sorted eigenvalues already came positive-first: 1044 Brandts and 530 SLEPc pairs checked.
🤖 Generated with Claude Code