← Back to Pull requests

xLAEIN: apply the growth test to the growth, not to |x| alone #1400

Closed
unknown closed this pull request without merging on Sep 12, 2026 21:35 UTC
View on GitHub
unknown unknown commented on Sep 10, 2026 15:45 UTC
Author

Summary

xLAEIN decides when one step of inverse iteration has produced an acceptable eigenvector. The residual of that step is governed by how much the solution grew relative to the starting vector, but the test compared the solution norm against GROWTO on its own. That silently assumes every starting vector has the same constant norm, which is not the case.

The criterion

One step of inverse iteration with shift sigma is

        ( A - sigma I ) v^(i+1)  =  tau^(i) v^(i)

The residual of the vector it produces is an identity, not a bound:

        || ( A - sigma I ) v^(i+1) ||        || tau^(i) v^(i) ||
        ------------------------------  =  ---------------------      (1)
              || v^(i+1) ||                    || v^(i+1) ||

The reciprocal of the right-hand side is the norm growth, and the vector is accepted once that growth is large enough that (1) delivers a residual at the level of the accuracy of the eigenvalue:

             || v^(i+1) ||                       1
        --------------------------  >=  C  ---------------            (2)
          || tau^(i) v^(i) ||               n eps || A ||

Then || r || <= (1/C) n eps ||A|| || v^(i+1) ||, the standard requirement on an approximate eigenpair. The essential point is that the criterion is a statement about the ratio: the norm of the starting vector belongs in it.

This is Dhillon's section 3, issue IV (PDF), which attributes the criterion to Wilkinson's The Algebraic Eigenvalue Problem, p. 324.

What the old code did

      GROWTO = TENTH / ROOTN
      ...
            VNORM = SASUM( N, VR, 1 )
            IF( VNORM.GE.GROWTO*SCALE )
     $         GO TO 120

Here VNORM is the 1-norm of the solution and SCALE is xLATRS's scale factor, so dividing the test through by SCALE times the starting vector's 1-norm puts it in the same form as (2):

             ||   solution   ||                 TENTH
        ----------------------------  >=  ----------------------
         SCALE || start vector ||          ROOTN || start vector ||

The right-hand side is what (2) asks for only if

        ROOTN * || start vector ||  ==  N * EPS3       i.e.
        || start vector ||          ==  ROOTN * EPS3

So the starting vector's norm was not so much ignored as assumed constant, and assumed equal to ROOTNEPS3 in particular. That is close to the norm of the restarting vectors the routine builds after a failed attempt, so the assumption holds to within a factor of two for those. It does not hold for the vector the iteration actually starts from:

| starting vector | how it is built | its 1-norm | assumption off by |
|---|---|---|---|
| initial (NOINIT) | every entry EPS3 | N
EPS3 | ROOTN |
| restart | EPS3, then EPS3/(ROOTN+1), one entry - EPS3ROOTN | ~2ROOTNEPS3 | ~2 |
| supplied (INITV='U') | rescaled to 2-norm ROOTN
EPS3 | ROOTNEPS3 .. NEPS3 | 1 .. ROOTN |

The consequence follows from (1). Accepting a growth ROOTN times smaller than required admits a residual ROOTN times larger, so the bound degrades from O( n eps ||H|| ) to O( n*1.5 eps ||H|| ). NEP test 11 measures exactly that quantity divided by n against a threshold of 20, so the old bound permits a ratio of order 10ROOTN and exceeds the threshold as soon as N > 4. The initial vector is where 28,451 of the 28,452 eigenvectors in the NEP test suite are accepted, so it is the case that usually decides the outcome, and one matrix crossed the threshold on aarch64 gfortran:

Matrix order=   10, type=12, seed= 686, 215, 995,3397, result  11 is   27.24
SHS:    1 out of  2016 tests failed to pass the threshold

Instrumenting the routine to print the residual of every accepted vector shows that case as n=10, try 1, residual 27.9 in units of NEPS3|x|, while the very next starting vector gives 0.0209 - a residual 1300 times smaller for the same eigenvalue. So this was never an ill-conditioned eigenvector that no starting vector could resolve. A far better one was one restart away, and the test stopped short because it wasn't strict enough.

The fix

xLAEIN takes exactly one solve from each starting vector - on insufficient growth it chooses a new starting vector rather than iterating on the result - so i is always 0 here. Mapping the notation of (2) onto this routine:

| theory | xLAEIN | note |
|---|---|---|
| A - sigma I | B | the U factor, zero pivots replaced by EPS3 |
| tau^(0) | SCALE | chosen by xLATRS to avoid overflow |
| v^(0) | VR on entry, the starting vector | 1-norm V0NORM |
| v^(1) | VR after the solve | 1-norm V1NORM |
| eps times the norm of A | EPS3 | set by xHSEIN to ULP times the block norm |
| n | N | |
| C | TENTH | the existing constant, unchanged |

so (2) reads

                 V1NORM                    TENTH
        -------------------------   >=   -----------                  (3)
             SCALE * V0NORM              N * EPS3

GROWTO becomes the right-hand side of (3), and the test is then (3) verbatim:

      GROWTO = TENTH / ( REAL( N )*EPS3 )
      ...
            V0NORM = SASUM( N, VR, 1 )
*
            CALL SLATRS( 'Upper', TRANS, 'Nonunit', NORMIN, N, B, LDB,
     $                   VR, SCALE, WORK, IERR )
*
            V1NORM = SASUM( N, VR, 1 )
            IF( V1NORM.GE.GROWTO*SCALE*V0NORM )
     $         GO TO 120

GROWTO changes value, from 0.1/SQRT(N) to 0.1/(NEPS3), because it changes meaning: it is no longer a bound on ||x|| but the growth ratio that (3) requires. Nothing else in the routine uses it.

The effective threshold each starting vector now faces, relative to before:

| starting vector | before | now |
|---|---|---|
| initial | TENTH
SCALE/ROOTN | ROOTN times stricter |
| restart | TENTHSCALE/ROOTN | ~2 times stricter |
| supplied | TENTH
SCALE/ROOTN | 1 to ROOTN times stricter |

Effect

Worst xnep test-11 ratio, |HX - XW| / (|H| |X| ulp) on aarch64 now:

| precision | before (gfortran 15.2) | after (gfortran 15.2) | after (flang 21.1.8) |
|---|---|---|---|
| S | 27.24 | 4.17 | 2.74 |
| D | 3.05 | 3.05 | 3.05 |
| C | 3.95 | 3.95 | 6.20 |
| Z | 4.52 | 4.52 | 3.41 |

Because only the accept/reject decision changes and no iterate is touched, vectors that already passed come back bit-identical - visible above in the D and Z columns.

Notes

The 0.1/SQRT(N) threshold is inherited verbatim from EISPACK's invit, which has growto = 0.1d0 / ukroot, ukroot = dsqrt(uk) under the comment growto is the criterion for the growth, and which implements [3]. The same missing normalisation is therefore present there. Every commit to SRC/[scdz]laein.f on master is cosmetic, so the criterion is untouched since that import.

xSTEIN avoids the problem from the other direction: SRC/dstein.f rescales the right-hand side before every solve so its norm is a known constant, which is what makes its absolute test on NRM sound.

References

1. I. S. Dhillon, Current inverse iteration software can fail, BIT Numerical Mathematics 38 (1998). PDF
2. J. H. Wilkinson, The Algebraic Eigenvalue Problem, Oxford University Press, 1965.
3. G. Peters and J. H. Wilkinson, The calculation of specified eigenvectors by inverse iteration, in Wilkinson & Reinsch, Handbook for Automatic Computation II: Linear Algebra, Springer, 1971.

Diff: 650 lines (+487 / -163) across 8 files Reviewer: martin-frbg Review duration: 3230m
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
0.52
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.388
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1400"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 52% (MEDIUM) · Higher = larger blast radius
52%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 20.5% · Safe to merge
20.5%