Commit c60cc4c
committed
fix(linalg/eig_sym): codex #159 P1×2 — route N=4 and N>64 to Jacobi (safe fallback)
Codex reviewer flagged two real correctness bugs in eig_sym.rs:
1. P1 at eig_sym.rs:584 — Ferrari 4×4 path returns INVALID eigenvalues for
non-diagonal symmetric inputs with nonzero quartic q term. Reviewer's
reproducer: [[4,1,.5,.2],[1,3,.4,.1],[.5,.4,2,.3],[.2,.1,.3,1]] returns
duplicate ~1.7338 with eigenvector residuals ~1.1. Would corrupt all
downstream inverse/polar/SVD that consume the N=4 fast path.
2. P1 at eig_sym.rs:985 — QR bulge chase for N>64 drops similarity-transform
terms in the off-diagonal update. On 65×65 symmetric tridiagonal with
diag 1..65, off-diag 0.1, leaves top eigenpair residuals ~0.1 after
300 iterations.
Fix per reviewer's own suggested fallback: redirect both broken paths to
Jacobi (eig_sym_jacobi) which is correct on all symmetric N×N. Jacobi
sweep limit raised from 50 → 200 to cover the N>64 case at adequate
convergence margin.
Cost: Jacobi is O(N⁴) so N>64 path is slower than implicit-shift QR.
Acceptable until eig_sym_qr is rewritten with full bulge chase, AND
the Ferrari path gets a residual-checked quartic solver. Both tracked
via TODO(fix-pillar-4-ferrari) and TODO(fix-eig-qr-bulge-chase).
N ∈ {2, 3} closed-form paths unchanged — Smith-1961 and the 2×2 case
are correct and remain the hot path for splat3d / cognitive cascade.1 parent 2b42c91 commit c60cc4c
1 file changed
Lines changed: 11 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1132 | 1132 | | |
1133 | 1133 | | |
1134 | 1134 | | |
1135 | | - | |
1136 | | - | |
1137 | | - | |
1138 | | - | |
1139 | | - | |
1140 | | - | |
1141 | | - | |
1142 | | - | |
1143 | | - | |
1144 | | - | |
1145 | | - | |
1146 | | - | |
1147 | | - | |
1148 | | - | |
1149 | | - | |
1150 | | - | |
1151 | | - | |
1152 | | - | |
1153 | | - | |
1154 | | - | |
1155 | | - | |
1156 | | - | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
1157 | 1146 | | |
1158 | 1147 | | |
1159 | 1148 | | |
| |||
0 commit comments