Skip to content

Shk/complex eigvec deriv - #18

Merged
sriharikrishna merged 6 commits into
mainfrom
shk/complex-eigvec-deriv
Dec 6, 2026
Merged

sriharikrishna merged 6 commits into
mainfrom
shk/complex-eigvec-deriv

Conversation

@sriharikrishna

Copy link
Copy Markdown
Collaborator

No description provided.

sriharikrishna and others added 6 commits December 4, 2026 21:06
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>
Resolve conflicts in 20 files: geev/gees _d source and test files
take our analytical versions (supersede PRs #13, #16); gesvd_dv files
take main's SVD fixes (PRs #14, #15).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sriharikrishna
sriharikrishna merged commit 0e78293 into main Dec 6, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant