Repository navigation
Conversation
…infinity in A This extends the change to xGEEV in Reference-LAPACK#1382 to its three sibling drivers. xGEEV returns INFO = -4 without calling XERBLA when xLANGE of A is a NaN or exceeds xLAMCH( 'Overflow' ). xGEES, xGEESX and xGEEVX test neither, with two consequences. An infinity in A makes ANRM infinite, which exceeds BIGNUM, so the driver scales A by CSCALE / ANRM = 0. The infinity becomes 0 * Inf, a NaN, and every other entry becomes zero. DGEES, DGEESX and DGEEVX with every BALANC return INFO = 0 and all-NaN eigenvalues for a 6-by-6 matrix with one infinity at A(2,3). A NaN in A is not caught either. xGEEVX with BALANC = 'S' or 'B' calls xGEBAL, which detects the NaN, calls XERBLA ("On entry to DGEBAL parameter number 3 had an illegal value"), and the reference XERBLA stops the program. With BALANC = 'N' or 'P', and in xGEES and xGEESX, which balance with 'P', the NaN comes back as INFO > 0 from xHSEQR. Test ANRM right after xLANGE, before the scaling branches, in the same form as xGEEV, and return INFO = -5 for xGEES, -6 for xGEESX and -6 for xGEEVX, the position of A in each argument list, without calling XERBLA. A NaN is reported like an infinity, as in xGEEV. The INFO descriptions say so. For the complex routines xLANGE takes the absolute value of each entry, so an entry with finite real and imaginary parts whose absolute value overflows is reported the same way, as in CGEEV and ZGEEV; the descriptions say that too. Callers that today get INFO > 0 from xGEES, xGEESX or xGEEVX with BALANC = 'N' or 'P' for a NaN, or INFO = 0 and NaN eigenvalues for an infinity, now get a negative INFO. Nothing changes for finite input. Test: xERRED calls each of the three drivers in all four precisions with a NaN and with an infinity at A(2,1) of a 2-by-2 matrix, and xGEEVX with each of BALANC = 'N', 'P', 'S' and 'B', and fails if INFO is not the expected negative value or if XERBLA is called. On the parent every case fails. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1499 +/- ##
==========================================
+ Coverage 70.63% 70.64% +0.01%
==========================================
Files 6243 6243
Lines 501290 501570 +280
Branches 23516 23516
==========================================
+ Hits 354100 354353 +253
- Misses 146327 146353 +26
- Partials 863 864 +1
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Harness.
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI disclosure: This PR was prepared with Claude Code.
Summary
This extends #1382, which made
xGEEVreturnINFO = -4without callingXERBLAfor a NaN or an infinity inA, to the three sibling driversxGEES,xGEESXandxGEEVX. They have no such test, and misbehave on non-finite input in two ways. Found by reading the sibling of #1382.With one infinity at
A(2,3)of a 6-by-6 matrix,DGEES,DGEESXandDGEEVX(everyBALANC) returnINFO = 0and NaN eigenvalues. With a NaN at the same place,DGEEVXwithBALANC = 'S'or'B'stops the program:** On entry to DGEBAL parameter number 3 had an illegal value. WithBALANC = 'N'or'P', and inDGEESandDGEESX, which balance with'P', a NaN comes back asINFO = 6(the QR algorithm "did not converge").Description
An infinity in
AmakesANRM = xLANGE( 'M', ... )infinite. That exceedsBIGNUM, so the driver scalesAbyCSCALE / ANRM = 0: the infinity becomes0 * Inf, a NaN, and every other entry becomes zero. A NaN inAis not tested either.xGEBALwith'S'or'B'detects it and callsXERBLA, and the referenceXERBLAstops the process. The other balancing options hand the NaN toxHSEQR, which reports a non-convergence.Fix
In
{s,d,c,z}gees.f,{s,d,c,z}geesx.fand{s,d,c,z}geevx.f, right afterANRM = xLANGE( 'M', ... )and before the scaling branches, return without callingXERBLAifANRMis a NaN or exceedsxLAMCH( 'Overflow' ), in the same form asxGEEV.INFOis minus the position ofAin the argument list:INFOxGEES-5xGEESX-6xGEEVX-6As in
xGEEV, a NaN is reported the same way as an infinity. TheINFOdescriptions document this, and for the complex routines, wherexLANGEtakes the absolute value of each entry, they add that an entry whose absolute value overflows is reported too, asCGEEVandZGEEVdo. Twelve source files. Nothing changes for finite input.Behavior change: a caller that today gets
INFO > 0from one of these drivers for a NaN, orINFO = 0with NaN eigenvalues for an infinity, now gets a negativeINFO.Reproducer
Master:
With this change:
(
WRis not set on the new path, so its printed value is whatever the array held.) With a NaN in place of the infinity, master returnsINFO = 6fromDGEESandDGEESX.Regression test
xERREDfollows thexGEEVcase of #1382. For each ofxGEES,xGEESXandxGEEVX, in all four precisions, it puts a NaN and then an infinity atA(2,1)of a 2-by-2 matrix, and forxGEEVXrepeats that withBALANC = 'N','P','S'and'B'. A case fails ifINFOis not the value above or ifXERBLAis called (the testXERBLArecords the call instead of stopping). Twelve cases per precision.With only the test changes on top of master, in every precision every
xGEES(2 of 2),xGEESX(2 of 2) andxGEEVX(8 of 8) case fails (*** DGEEVX did not return INFO = -6 without calling XERBLA for a matrix with a NaN or an infinity (INFO = 0) ***, andINFO = 2for some complex cases), and thexGEEVXNaN cases withBALANC = 'S'and'B'also log thexGEBALXERBLAcall. With the fix all pass:xGEES8 tests done,xGEESX9,xGEEVX19 (18 in the complex precisions).Test suite
The full test suite passes, configured as in CI (
CBLAS=ON,LAPACKE=ON,LAPACKE_WITH_TMG=ON) with the_64API. All 333 CTest entries pass, with 5755188 LAPACK tests (5755190 for the_64API), 11973112 LAPACKE tests, 319677 BLAS tests and 645492 CBLAS tests for each API, and 0 numerical errors and 0 other errors. These are the counts of master; the error-exit tests are not counted. A second build with CI's gfortran flags (-O2 -Wall -Wno-unused-dummy-argument -Wno-unused-variable -Wno-unused-label -Werror=conversion -fimplicit-none -frecursive -fcheck=all) passes the suite as well, and the changed files compile with the same warnings as on master. The builds used GNU Fortran and GCC 15.2.0 withCMAKE_BUILD_TYPE=Releaseon x86-64 Linux.Not changed here
xGGES,xGGEVand their variants scale by the norms ofAandBin the same way and have no such test either. They are not changed here.Checklist
INFOdescriptions ofxGEES,xGEESXandxGEEVX.)