Since f4b5da4 (Reference-LAPACK#1400) the acceptance test of the inverse iteration
in xLAEIN compares V1NORM with GROWTO*SCALE*V0NORM, where GROWTO is
formed once as TENTH / ( N*EPS3 ). xHSEIN passes EPS3 = HNORM*ULP,
so for a Hessenberg matrix of norm below about 0.1/(HUGE*N*ULP)
(about 6e-295 for N = 4 in double precision) N*EPS3 falls below
about 0.1/HUGE and GROWTO overflows to +Inf. The test can then never
hold: every vector is reported as not converged and xHSEIN returns
INFO equal to the number of failures, although the matrix is well
conditioned and all its entries are normal. Before that commit
GROWTO was TENTH/ROOTN and the routines worked down to norms of
about 1e-303.
For example, a well-conditioned 4-by-4 matrix scaled by 2**-1020
(double precision, entries of order 1e-307, accurate eigenvalues
supplied) gives INFO = 4 from DHSEIN, and the same happens in ZHSEIN
from a scale of 2**-990. In single precision it fails from a scale
of 2**-120 of an O(1) matrix.
CLAEIN and ZLAEIN, and SLAEIN and DLAEIN for a real eigenvalue, now
compare V1NORM with ( TENTH*SCALE )*( V0NORM / ( N*EPS3 ) ) and
also require V0NORM > 0. V0NORM is the 1-norm of a vector scaled to
2-norm EPS3*SQRT(N), so the ratio is of order one and nothing
overflows. The test is still applied to the growth
V1NORM/(SCALE*V0NORM), as f4b5da4 intended. SCALE > 0 is not
required: in these paths zero pivots are replaced by EPS3, so
SCALE = 0 with a nonzero starting vector can only come from the
rescaling in xLATRS underflowing after very large growth, which is
exactly a vector to accept.
One behavior changes at ordinary norms, through V0NORM > 0: with
INITV = 'U' and a zero column supplied as starting vector (a real
eigenvalue, or any eigenvalue in CLAEIN/ZLAEIN), the parent accepts
the zero vector (0 >= 0) and returns an all-NaN vector with INFO = 0.
Now the routine restarts from its own vector and returns a proper
eigenvector. For DHSEIN('R','Q','U') on H = [4 1 0; 1 3 1; 0 1 1]
with VR = 0 the parent returns NaN with INFO = 0, and this change
returns a finite vector of unit max-norm. The complex-pair path of
SLAEIN and DLAEIN still returns NaN there, as before.
The complex-pair path of SLAEIN and DLAEIN keeps the test as it was,
with GROWTO now formed only there. Its pivot test treats pivots up
to SMLNUM = UNFL*(N/ULP) as zero, an absolute floor, so for norms of
about SMLNUM and below it cannot give a meaningful vector whatever
the growth test does. Changing only the test would turn the INFO > 0
that the overflow gives there into INFO = 0 with a meaningless
vector, and requiring SCALE > 0 there rejects vectors that are
valid: in my samples the 717 (D) and 387 (S) valid vectors that a
SCALE > 0 requirement rejected were all in this path. That path
needs its own fix and keeps its behavior.
On 6000 random Hessenberg matrices per precision (random, Jordan-like,
clustered, split, perturbed eigenvalues, with and without initial
vectors, scales 2**-200 to 2**200) the vectors, INFO and IFAIL
values from xHSEIN are bit-for-bit identical to those of the parent
commit. On 6000 matrices per precision at scales 2**-900 to 2**-1015
(single precision: 2**-90 to 2**-124), no result that was valid on
the parent got worse, and 845 (D), 925 (S), 2701 (C) and 2619 (Z)
that failed with INFO > 0 on the parent give valid vectors.
Test: in xCHKHS, for matrix types 9 to 11, whose entries are not
much smaller than the norm (and, in the real routines, only when all
eigenvalues came out real, because of the complex-pair path above),
tests 12 and 13 are repeated with H and its eigenvalues scaled down
to a norm of 0.01*UNFL/(N*ULP). There N*ULP*norm(H) is far below
0.1*UNFL, but the entries are still normal. The scaled matrix and
eigenvalues are kept in Z and in WORK, not in documented outputs, and
the check is skipped where subnormal numbers are flushed to zero
(there EPS3 = HNORM*ULP would be zero). On the parent commit
xHSEIN returns INFO > 0 there and tests 12 and 13 fail: 114 results
in each of S and D, 180 in each of C and Z, over the five parameter
sets of nep.in. All pass now, with a largest ratio of about 3
against the threshold of 20. The existing near-underflow types do
not get there: they only go down to about SQRT(UNFL), far above the
failing range.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Summary
xLAEINdecides 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 againstGROWTOon 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
sigmaisThe residual of the vector it produces is an identity, not a bound:
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:
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
Here
VNORMis the 1-norm of the solution andSCALEisxLATRS's scale factor, so dividing the test through bySCALEtimes the starting vector's 1-norm puts it in the same form as (2):The right-hand side is what (2) asks for only if
So the starting vector's norm was not so much ignored as assumed constant, and assumed equal to
ROOTN*EPS3in 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:NOINIT)EPS3N*EPS3ROOTNEPS3, thenEPS3/(ROOTN+1), one entry- EPS3*ROOTN~2*ROOTN*EPS3~2INITV='U')ROOTN*EPS3ROOTN*EPS3 .. N*EPS31 .. ROOTNThe consequence follows from (1). Accepting a growth
ROOTNtimes smaller than required admits a residualROOTNtimes larger, so the bound degrades fromO( n eps ||H|| )toO( n**1.5 eps ||H|| ). NEP test 11 measures exactly that quantity divided bynagainst a threshold of 20, so the old bound permits a ratio of order10*ROOTNand exceeds the threshold as soon asN > 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:Instrumenting the routine to print the residual of every accepted vector shows that case as
n=10, try 1, residual 27.9in units ofN*EPS3*|x|, while the very next starting vector gives0.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
xLAEINtakes exactly one solve from each starting vector - on insufficient growth it chooses a new starting vector rather than iterating on the result - soiis always 0 here. Mapping the notation of (2) onto this routine:A - sigma IBEPS3tau^(0)SCALExLATRSto avoid overflowv^(0)VRon entry, the starting vectorV0NORMv^(1)VRafter the solveV1NORMepstimes the norm of AEPS3xHSEINtoULPtimes the block normnNCTENTHso (2) reads
GROWTObecomes the right-hand side of (3), and the test is then (3) verbatim:GROWTOchanges value, from0.1/SQRT(N)to0.1/(N*EPS3), 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:
TENTH*SCALE/ROOTNROOTNtimes stricterTENTH*SCALE/ROOTN~2times stricterTENTH*SCALE/ROOTN1toROOTNtimes stricterEffect
Worst
xneptest-11 ratio,|HX - XW| / (|H| |X| ulp)on aarch64 now: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'sinvit, which hasgrowto = 0.1d0 / ukroot,ukroot = dsqrt(uk)under the commentgrowto is the criterion for the growth, and which implements [3]. The same missing normalisation is therefore present there. Every commit toSRC/[scdz]laein.fon master is cosmetic, so the criterion is untouched since that import.xSTEINavoids the problem from the other direction:SRC/dstein.frescales the right-hand side before every solve so its norm is a known constant, which is what makes its absolute test onNRMsound.References