Repository navigation
Shk/complex eigvec deriv - #18
Merged
Merged
Conversation
Fix sign and index bugs in omega rotation formulas across all 8 SVD derivative files (d/s/c/z × _d/_dv). The off-diagonal omega terms had a missing minus sign and, for omegav, swapped g indices making it identical to omegau. For complex variants, sigma subscripts were also swapped. Add projector terms (I-UU^T) and (I-VV^T) for rectangular matrices in real _d and _dv files. Rewrite test_dgesvd_d to check singular vector derivatives (dU, dVT) via central finite differences with sign alignment, testing both tall and wide matrix shapes. Rewrite test_dgeev_d to cover complex conjugate eigenvalue pairs and eigenvector derivatives. Add static signature audit checks to audit.py: ndir/nvar position (S4), type consistency for precision prefix (S5), companion arg ordering (S6), and derivative vs primal arg count comparison (S7). All 1048 tests pass. Full audit PASS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…files Non-symmetric eigen/Schur reverse (_b/_bv): note brute-force O(n^4) forward-mode transposition should be replaced with analytical adjoint (Kao & Hennequin 2020 for Schur, Giles 2008 Sec. 6 for eigen). Non-symmetric eigen/Schur forward (_d/_dv): note Schur vector derivatives and complex conjugate pair eigenvector derivatives are not yet implemented. SVD projector TODOs removed — implemented on shk/test-coverage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…/geevx Add analytical eigenvector derivatives for all four sub-cases of complex eigenvalue interactions (R-R, R-C, C-R, C-C, conjugate-self) using perturbation theory from Giles (2008). The implementation handles LAPACK's real storage format for complex conjugate pairs. Source files updated (4 _d routines + 4 _dv TODO updates): - dgeev_d, sgeev_d, dgeevx_d, sgeevx_d: full eigenvector derivative computation for real and complex eigenvalues - dgeev_dv, sgeev_dv, dgeevx_dv, sgeevx_dv: TODO narrowed to left eigenvector derivatives only Test rewritten (test_dgeev_d): validates eigenvector derivatives for all eigenvalue types with normalization gauge projection, achieving ~9e-9 relative error for DP. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…hase alignment
Rewrite all 7 test files (d/s geev/geevx _d and _dv) to validate complex
conjugate pair eigenvector derivatives against central finite differences.
Key changes:
- Replace sign-flip alignment with full complex phase rotation for FD
eigenvector comparison: compute conj(v_base)^T * v_pert = alpha + j*beta,
then rotate v_pert by e^{-j*atan2(beta,alpha)} before FD differencing.
This handles arbitrary normalization phase rotations, not just sign flips.
- Add gauge projection (remove v_i component) for complex eigenvector
derivative comparison to handle normalization freedom.
- Fix SP _dv tests (sgeev_dv, sgeevx_dv): remove 1e-3 scaling on ad entries
that pushed FD differences into SP rounding noise.
- All _d tests use two cases: all-real eigenvalues + complex conjugate pairs.
- All _dv tests validate across ndir=2 directions with eigenvalue matching.
All 1048 tests pass, audit.py reports PASS.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…gorithm Implement analytical reverse-mode derivatives for all 32 _b/_bv routines (geev, geevx, gees, geesx across z/d/c/s precisions) using the Giles (2008) eigendecomposition adjoint. For Schur decompositions, combine eigenvector recovery via xTREVC with Sylvester-equation Schur vector contribution. Also complete the remaining forward-mode TODOs: left eigenvector tangents for geev/geevx _d routines and Schur vector tangents via xTRSYL for gees/geesx _d/_dv routines. Key changes across 64 source files + 8 test files: - Eigenvalue reverse (_b/_bv): VL^H * diag(w_bar/d) * VR decomposition - Real routines use complex arithmetic internally for conjugate pairs - Schur reverse: eigenvector recovery + triangular Sylvester correction - Fix ZTREVC/CTREVC calls (add missing RWORK parameter) - Fix DTREVC/STREVC workspace (n → 3*n) - Update audit.py to allow complex types in real reverse-mode routines - Update gees/geesx test FD validation for Schur vector derivatives All 1048 tests pass. Audit clean. Zero regressions vs baseline. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
No description provided.