Repository navigation
Do not scale an infinite matrix to zero in xSTEMR; report it from xLARRE - #1404
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1404 +/- ##
========================================
Coverage 70.20% 70.21%
========================================
Files 6237 6237
Lines 500437 500547 +110
Branches 23536 23536
========================================
+ Hits 351336 351450 +114
+ Misses 148639 148635 -4
Partials 462 462
Continue to review full report in Codecov by Harness.
|
e0151a1 to
a612cc9
Compare
a612cc9 to
856d664
Compare
#1389, #1403, #1404 and #1405 add checks to xCHKST that build a NaN as SQRT( -RONE ) or an infinity as ONE / RZERO, the construction that b5dbdf5 exempted in the xERRBD and xERRST error-exit tests: nagfor folds it at compile time and rejects the result. Add chkst to the pattern, which matches ?chkst.f and its generated _64 copies but not ?chkst2stg.f. Other compilers are unaffected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4862656 to
c6f1614
Compare
|
The one failing job, windows-2025-gfortran (static), lost its runner partway through the Build step ("The hosted runner lost communication with the server"; no log was uploaded). The same commit passes the other 49 jobs, including |
xSTEMR scales the matrix into the range xLARRE can represent:
ELSE IF( TNRM.GT.RMAX ) THEN
SCALE = RMAX / TNRM
For a matrix with an infinite entry TNRM is infinite, SCALE underflows
to zero, the scaling turns the infinite entry into a NaN and every
other entry into zero, and the solver ran on that matrix: RANGE = 'A'
and 'I' returned INFO = 0 with every eigenvalue a NaN, RANGE = 'V'
scaled the interval to (0, 0] and returned no eigenvalues, and with
the infinite entry off the diagonal the representation tree search
never returned (the NaN hang of Reference-LAPACK#1389).
Leave a matrix whose scale factor would be zero unscaled, and let
xLARRE, which computes the base representations, reject a matrix with
an infinite entry as one for which no representation exists, INFO = 2,
the code it already uses when the search for a representation gives up.
xSTEMR returns INFO = 12 and the drivers that call it, xSTEVR, xSYEVR
and xHEEVR, fall back to xSTEBZ and xSTEIN as for any other xSTEMR
failure. A NaN matrix is not touched by this change: its norm
compares false against every threshold and it takes the same path as
before.
xCHKST gets the case as a regression test: after the size and type
loops it calls xSTEMR with RANGE = 'A' on an N = NMAX tridiagonal
matrix whose first diagonal entry is +Inf, once with JOBZ = 'V' and
once with JOBZ = 'N', and reports INFO = 0 as a failure. On the
parent commit all four calls return INFO = 0 with NaN eigenvalues;
here they return INFO = 12. Over 420 placements of +Inf and -Inf
(n = 3 to 64, RANGE = 'A', 'V', 'I', real and complex) the parent
returned INFO = 0 with NaN eigenvalues in 52 cases, hung in 24 and
returned INFO = 11 in the rest; this branch returns INFO = 12 in all
of them. The 1 by 1 and 2 by 2 matrices, which xSTEMR solves in closed
form before scaling, are unchanged, and every finite case is
bit-identical.
The full LAPACK test suite passes: 0 numerical errors, 0 other errors,
40 tests more than the parent from the new calls.
The regression test fails on the parent and passes with the fix, and the
reproducer prints the same before and after output, with gfortran 13
(x86-64 Release and Debug with -fcheck=all, and under QEMU on aarch64,
ppc64le, s390x and riscv64), flang-19 and Intel ifx 2025.3.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Review asked for the check to be driven by the test input rather than by a block after the size and type loops. The block is now matrix type 23, selected in sep.in like the other types and run at every N listed there instead of once at N = NMAX. Type 23 is the tridiagonal matrix with diagonal +Inf, 2, ..., N and off-diagonal 1/2, ..., 1/N. Only xSTEMR is run on it, as tests 35 and 37 (JOBZ = 'V' and 'N', RANGE = 'A'), which are 1/ULP when xSTEMR returns INFO = 0. N < 3, which xSTEMR solves in closed form, is skipped. The matrix is built without the random generators, so the seeds, and with them the matrices, of all the other types are unchanged. The type lists in the header comment and in the failure banner also get the missing entry for type 22. With the library changes of the previous commit reverted, every type-23 case fails in all four precisions (N = 3, 5 and 20, both JOBZ, 5 parameter sets). With them, the full suite passes: 307 ctest tests, 0 numerical errors, 0 other errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c6f1614 to
5cb0d20
Compare
AI disclosure: This PR was prepared with Claude Code.
Summary
xSTEMRscales the matrix into the range its representations can handle,SCALE = RMAX / TNRMwhen the max-normTNRMexceedsRMAX. For a matrix with an infinite entryTNRMis infinite,SCALEunderflows to zero, the scaling turns the infinite entry into a NaN and every other entry into zero, and the solver ran on that matrix:RANGE = 'A'and'I'returnedINFO = 0with every eigenvalue a NaN,RANGE = 'V'scaled the interval to(0, 0]and returned no eigenvalues, and with the infinite entry off the diagonal the representation search never returned (the NaN hang of #1389). This PR leaves such a matrix unscaled and letsxLARREreject a matrix with an infinite entry as one for which no base representation exists, soxSTEMRreturnsINFO = 12and its drivers fall back toxSTEBZandxSTEIN. Six files:{s,d,c,z}stemr.f,{s,d}larre.f.Description
RMAXis about1e77in double precision, soRMAX / TNRMis at least5e-232for every finiteTNRMand is zero exactly whenTNRMis infinite. The scaled matrix hasInf * 0 = NaNat the infinite entry and zeros elsewhere;xLARREthen computes Gershgorin bounds and representations from that, andxLARRVorxLARRJrefine them. At the end the eigenvalues are divided bySCALE,0 * Inf = NaN.Fix.
xSTEMRkeepsSCALE = ONEwhen the quotient is zero, which happens for no finite matrix.xLARREtests the max-norm of the matrix it is given against the overflow threshold right after its Gershgorin bounds and returnsINFO = 2, the code it already uses when the search for a base representation gives up (documented as "No base representation could be found in MAXTRY iterations", now "..., or the matrix has an infinite entry").xSTEMRreports that asINFO = 12under its existing1Xconvention.xSTEVR,xSYEVRandxHEEVRtreat any nonzeroINFOfromxSTEMRas a reason to fall back toxSTEBZandxSTEIN, which #1384 makes pass an infinite matrix through unscaled. A NaN matrix is not touched by this change: its norm compares false against every threshold, on both sides, and it takes the same path as before, which #1389 bounds.Minimal reproducer
With
E(1) = +Infinstead, master never returns from the same call.Regression test.
xCHKSTgets matrix type 23, selected insep.inlike the other types and run at everyNlisted there: the tridiagonal matrix with diagonal+Inf, 2, ..., Nand off-diagonal1/2, ..., 1/N. OnlyxSTEMRis run on it, as tests 35 and 37 (JOBZ = 'V'and'N',RANGE = 'A'), which fail when it returnsINFO = 0;N < 3, whichxSTEMRsolves in closed form, is skipped. The matrix is built without the random generators, so the matrices of the other types are unchanged. On the parent commit every type-23 case returnsINFO = 0in every precision (N= 3, 5 and 20, bothJOBZ, 5 parameter sets); with the fix they returnINFO = 12. The position was chosen so that the test fails rather than hangs on the parent.Validation
ctest: 100% of 307 tests passed).xSTEMRwithJOBZ = 'V'andRANGE = 'A','V','I'; +Inf and -Inf inD(1),D(2),D(N),E(1),E(N/2),E(N-1);N = 1, 2, 3, 5, 8, 26, 40, 64;DSTEMRandZSTEMR; one process per case with a 3 s timeout): forN >= 3the parent returnedINFO = 0with NaN eigenvalues in 52 cases, hung in 24 (RANGE = 'I'with the Inf off the diagonal), and returnedINFO = 11, anxLARREfailure on the zero-scaled matrix, in the remaining 344; this branch returnsINFO = 12in all 420. The 1 by 1 and 2 by 2 cases, whichxSTEMRsolves in closed form before scaling, are unchanged.-fcheck=all, and under QEMU on aarch64, ppc64le, s390x and riscv64), flang-19 and Intel ifx 2025.3 (-fp-model=strict).Found while auditing the symmetric tridiagonal eigensolvers for the NaN and overflow handling of #1377-#1391; this is the
xSTEMRinstance of the scale-to-zero defect fixed for the bisection drivers in #1384.