Return INFO = 1 from xLASQ1 instead of stopping in XERBLA when SIGMX is a NaN - #1387
Return INFO = 1 from xLASQ1 instead of stopping in XERBLA when SIGMX is a NaN#1387rmlarsen wants to merge 1 commit into
Conversation
❌ 10 Tests Failed:
View the top 3 failed test(s) by shortest run time
View the full list of 74 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
…is a NaN xLASQ1 scales the bidiagonal matrix by its largest entry SIGMX before running dqds. When D or E contains a NaN that survives the MAX reductions computing SIGMX (with gfortran, a NaN in D(N)), SIGMX is a NaN and xLASCL rejects it by stopping the process in XERBLA. xBDSQR without singular vectors and xGESVD with JOBU = JOBVT = 'N' take this path; a NaN elsewhere in D returns INFO = 0 with NaN output. Test SIGMX with xISNAN and return INFO = 1, the mechanism Reference-LAPACK#1382 uses for xLALSD and xBDSDC. xBDSQR treats every nonzero INFO from xLASQ1 as a request to finish with the QR algorithm, so it then reports the non-convergence on the NaN data through its own INFO like it does for other non-finite input. Finite input never takes the new branch. xERRBD gets the case as a regression test: a 4 by 4 bidiagonal with a NaN in D(N), passed to xBDSQR without singular vectors, which must return without calling XERBLA. The error-exit tests are where it belongs, since the routine returns no meaningful output for such a matrix and the point of the test is that it returns at all. All four xERRBD files carry it, because the complex xBDSQR takes the same path through the real xLASQ1. Over 120 NaN/Inf cases of DBDSQR without vectors and DGESVD the parent stops in XERBLA 3 times and this branch never; every other case returns the same INFO on both. The full LAPACK test suite passes: 5441901 LAPACK tests, 0 numerical errors, 0 other errors, the same totals as the parent. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
887c16e to
deebd05
Compare
|
Verified on an Apple M4 (macOS, Homebrew gfortran 16.2, Release build with the CI flags). With this branch merged onto current master, the full test suite passes. Difference from x86: the defect does not occur on this machine. gfortran compiles MAX to |
Disclaimer: This PR was prepared using Claude Code.
Summary
xLASQ1scales the bidiagonal matrix by its largest entrySIGMXbefore calling the dqds algorithm. WhenDorEcontains a NaN that survives theMAXreductions that computeSIGMX(with gfortran: a NaN inD(N)),SIGMXis a NaN andxLASCLrejects it by stopping the process inXERBLA(On entry to DLASCL parameter number 4 had an illegal value).xBDSQRwithout singular vectors takes this path, and so doesxGESVDwithJOBU = JOBVT = 'N'. This PR returnsINFO = 1fromxLASQ1instead, which is the same mechanism #1382 uses forxLALSDandxBDSDC.xBDSQRtreats every nonzeroINFOfromxLASQ1as "try the QR algorithm", so it then finishes the QR iteration on the NaN data and reports the non-convergence through its ownINFO, as it does for other non-finite input. Two files:{s,d}lasq1.f.Description
Which NaN positions reach
DLASCLdepends on the compiler'sMAX(gfortran returns the second argument when the first is a NaN, so only a NaN inD(N)propagates; a NaN inD(1)orD(3)is dropped and the routine returnsINFO = 0with NaN output). The guard tests exactly the quantityDLASCLwill reject, so it removes the abort on every compiler without changing the outcome for a NaN that does not reachSIGMX.INFO = 1is documented ("a split was marked by a positive value in E, or the input contains a NaN").Minimal reproducer
Regression test.
xERRBDgets the case: a 4 by 4 bidiagonal with a NaN inD(N), passed toxBDSQRwithout singular vectors, which must return without callingXERBLA. All four files carry it, since the complexxBDSQRreaches the same realxLASQ1. It belongs with the error-exit tests rather than inxCHKBD, because the routine returns no meaningful output for such a matrix and the point of the test is that it returns at all; as a matrix type it would also be misleading, sincexCHKBDcounts the fixed behaviour (IINFO > 0) as a failure while master'sINFO = 0with NaN output passes everyRESULT( J ) .GE. THRESHcomparison. On the parent commit the four sections report the twoxLASCLillegal-argument lines and*** xBDSQR called XERBLA for a matrix with a NaN ***; with the fix they pass.Validation
ctest: 100% of 215 tests passed).DBDSQRwithout vectors andDGESVD; NaN,+Inf,-Infin five positions;N = 2, 3, 5, 8), one process per case: master stops inXERBLAin 3 of them (NaN inD(N),N >= 3, throughDBDSQR), this branch in none; every other case returns the sameINFOas on master.DLASQ1itself: NaN inD(1)andD(3)returnINFO = 0on both; NaN inD(5)stops the process on master and returnsINFO = 1here.DISNAN( SIGMX )is false), so results are unchanged.DGESDDis not affected: it checks its input norm for a NaN up front and returnsINFO = -4.The
INFO = 0returns for a NaN inD(1)orD(3)above are a separate defect, reported as #1392:xLASQ3's deflation tests are written as "keep iterating whileZ(...) .GT. TOL2*(...)", so a NaN operand makes every comparison false and the NaN is deflated as a converged singular value. Widening the check here fromSIGMXto the whole bidiagonal would cover that too; this PR keeps to the position that stops the process.This PR touches
TESTING/EIG/{s,d,c,z}errbd.f, as #1390 does; the two blocks are independent and the textual conflict between them is a trivial one.