Repository navigation
Report a NaN or an infinity in the input of xGELSD, xGESDD, xGEEV, xLALSD and xBDSDC through INFO instead of stopping in XERBLA - #1382
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1382 +/- ##
==========================================
+ Coverage 70.10% 70.12% +0.02%
==========================================
Files 6213 6213
Lines 498005 498531 +526
Branches 23446 23446
==========================================
+ Hits 349106 349615 +509
- Misses 148462 148480 +18
+ Partials 437 436 -1
... and 5 files with indirect coverage changes Continue to review full report in Codecov by Harness.
|
9e8fed1 to
24e080d
Compare
…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>
|
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, the new tests fail without the fix, and the reproducer behaves as described above. |
…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>
24e080d to
7fe8be8
Compare
|
@rmlarsen It's failing on one thing on the "Special Build Configurations / openmp-ubuntu-26.04-arm-gfortran (shared)" job: |
46dcd88 to
8fe6889
Compare
|
@mohawk2 Thanks for flagging it. That failure doesn't come from this PR: I've also just rebased onto master to resolve a conflict with #1458 in |
|
@mohawk2 @langou it isn't completely clear to me whether all my recently submitted MRs agree with https://arxiv.org/abs/2207.09281 in their choice of INFO values returned. What is the status of following that set of guidelines in LAPACK currently and is it the plan to eventually follow it strictly for all public APIs? |
…when the bidiagonal contains a NaN xLALSD and xBDSDC scale the bidiagonal by its largest entry before the divide and conquer phase, guarded only by ORGNRM.EQ.ZERO. xLANST propagates a NaN, and xLASCL rejects CFROM = NaN as an illegal argument, so the call ends in XERBLA and the reference XERBLA stops the program. A NaN anywhere in A reaches xGELSD's bidiagonal, and so does an infinity, because the driver's scaling multiplies by zero and leaves NaN where the infinity was. xGESDD guards its own input against a NaN (Reference-LAPACK#469) but an infinity still reaches xBDSDC the same way. Every other least-squares driver returns from such input (xGELSS with INFO > 0 from xBDSQR, the rest with INFO = 0); xGELSD is the only one that kills the process. Test the norm with xISNAN at the scaling sites of xLALSD (including the N = 1 branch) and xBDSDC and return INFO = 1, the value xLASDA already uses when a singular value fails to converge, in all precisions. Document the new return in xLALSD, xBDSDC and xGELSD. xERRLS gets the case as a regression test: a 2 by 2 matrix with a NaN, passed to xGELSD, which must return INFO = 1 without calling XERBLA. The error-exit tests are where it belongs, since the driver returns no solution for such a matrix and the point of the test is that it returns at all; on the parent it reports the illegal xLASCL argument and returns INFO = -4 with a NaN solution. The added test changes nothing for finite input: over the finite cases of the sweep the solutions are bit-identical to the parent commit. Over 2296 (precision, m, n, NaN or infinity, position) xGELSD cases and 810 xBDSDC cases with a NaN, this branch returns from every call; xGELSD returns INFO = 1 in every case, xBDSDC in every divide and conquer case, and no call reaches XERBLA. The full LAPACK test suite passes: 5441901 LAPACK and 315872 BLAS tests, 0 numerical errors, 0 other errors, the same totals as the parent. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
8fe6889 to
4d9667f
Compare
|
My preference would be after the call to CLANGE at Line 407 in c9967aa check whether ANRM is NaN or not. If ANRM is NaN, then return INFO = -4. A precedent is #1136. See: Lines 344 to 359 in c9967aa I think we should also bail out for INFs. The idea was to generalize this for more LAPACK routines with the rationale: "we often compute a norm of matrices in input for scaling, while doing so we might as well check whether the norm is NaN, if the norm of the matrix is NaN, we bail out with INFO = - ( position of the array A in the argument list ) so as to indicate an error in the data. |
…ugh a negative INFO Following review, and the rule of Reference-LAPACK#1136 for xGEEV: when the norm that a routine computes for scaling is a NaN, or here also an infinity, return INFO = -(position of the array) instead of a positive INFO. xGELSD tests ANRM right after xLANGE and returns INFO = -4. xGESDD's existing NaN guard on ANRM also catches an infinity; without that, an infinity in A reaches xBDSDC as a NaN and would come back as INFO = -5, which in xGESDD's argument list names LDA. xLALSD and xBDSDC, which returned INFO = 1 at their scaling sites in the previous revision, now test D and then E with xLANGE right after the N = 0 quick return and return -5/-6 and -4/-5. The test comes before the lower-to-upper rotation, which mixes E into D, and covers every path, including the xLASDQ paths of xBDSDC. As in xGESDD, none of these returns calls XERBLA: the caller gets control back. The error-exit tests check every new return and that XERBLA is not called: xGELSD with a NaN and an infinity and xLALSD with a bad D and E in xERRLS, xBDSDC with a bad D and E in xERRBD, and xGESDD with a NaN and an infinity in xERRED, which joins the NAG -Onopropagate list. On master every new case fails except xGESDD with a NaN (Reference-LAPACK#469). A sweep of 22380 cases (NaN, +Inf and -Inf at every position of A, or of D and E; all precisions, UPLO, JOBZ and COMPQ values, sizes on both sides of the divide and conquer threshold) returns the expected INFO everywhere without reaching XERBLA, and the outputs for finite input are bit-identical to master. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@langou Thanks, done in 3d90a78. One difference from the Following the same rule further down:
I've updated the description. |
|
Lots of good questions from @rmlarsen. (*) I note that the previous LAPACK convention was very consistent in the sense that if (*) There is some work #1411, #1407 to make (*) The one question I am not sure is how much do we want to do Numerical Linear Algebra with Inf and NaN. Should we try to solve system of linear equation with an Inf? Should we try to solve system of linear equation with an NaN? In some cases, this is meaningful work. The distinction between Inf and NaN is significant. Sometimes Inf makes sense, and NaN does not. I can see more people wanted us to push through Inf through LAPACK than NaNs. (*) The current LAPACK routines have mostly not been designed with Inf and NaN in mind as input parameters. We might handle some of this internally when we expect them to occur in our computation and then do the right thing, but I think we can say that we have not been designing routines with Inf and NaN as input data in mind. This is true for drivers, but also for our internal routines. We test our subroutines to make sure any Inf or NaN in input will not create an infinite loop but that's about it. Therefore I think that checking for Inf and NaN and bailing out makes sense. In particular when the first thing we do in the subroutine is compute the norm of an array. We would have a negative INFO parameter pointing to the first "invalid" array. We would not call XERBLA. Then, in the future, if we want and handle NaN and/or Inf in some particular subroutines, that's great, we can work on it, but, as of now, I do not think we understand enough the behavior of our subroutines with NaN and Inf in input and so, in my opinion, the sensible thing to do in my opinion is to bail out. If we want to guarantee a certain behavior with NaN and Inf, we should probably then create new routines. Some handle NaN and Inf, some bail out. (This is somewhat the essence of https://arxiv.org/abs/2207.09281.) |
Well actually, let us switch xGEEV so that xGEEV returns a negative INFO (it already does) but does not call XERBLA and does a quick return. Can you PR this? Maybe by adding to this PR? |
This sounds great. I am just worried that people (including us and LAPACK itself!) using |
I am pausing. ⏸️ We do compute the norm of B early on: Lines 430 to 433 in c9967aa So there would be no cost in detecting Inf or NaN in B. Great. The thing is that, as much as, if there is Inf or NaN in A, the SVD solve will likely propagate these everywhere. The NaN and Inf in B seem more innocuous if we think about the sequence UNMBR, LALSD, UNMBR. I am on the fence. If someone has an opinion, let it known. I am more leaning towards leaving B as is and solve with NaN and Inf in B and see what happens. |
That sounds like a good approach. I'd suggest adding tests for this behaviour with current code and seeing what the results are - they might make sense, in which case the test just permanently captures that, or they might not, in which case the code can be fixed. |
…finity in A Following review: xGEEV has returned INFO = -4 for a NaN in A since Reference-LAPACK#1136, but it called XERBLA first, and the reference XERBLA stops the program. Return without calling XERBLA, as xGESDD and xGELSD do, so that the caller gets control back. Test an infinity as well. An infinity in A passed the NaN test, was scaled by zero in xGEEV's own scaling, which leaves a NaN in its place and zeros elsewhere, and came back as INFO = 0 with every eigenvalue a NaN. Since an infinite ANRM also exceeds BIGNUM, the test now comes right after xLANGE, before the scaling branches, in the same form as in xGELSD and xGESDD. xERRED checks both cases, and that XERBLA is not called. With the parent's xGEEV the NaN case calls XERBLA and the infinity case returns INFO = 0, in all precisions. Also following review, xERRLS records what the least-squares drivers do with a NaN in B, which none of them checks: for each of xGELS, xGELST, xGETSLS, xGELSS, xGELSY and xGELSD, a NaN in one column of B gives INFO = 0, the solution for the other column, and a NaN in the solution for its own, without calling XERBLA. These cases pass on the parent as well; they pin down the current behavior. An infinity in B is not tested: every driver scales B by zero when its norm is infinite and by infinity when it undoes the scaling, so the whole solution comes back NaN, and whether to change that is left open. The full LAPACK test suite passes, with and without the _64 API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@langou @mohawk2 Thanks. Updated in eee8174:
Callers of
I have not changed or tested the infinity case. Skipping the scaling of The full test suite passes with and without the |
I'm getting outside of my area of knowledge here. But it's quite surprising for me, to have a parameter error (negative |
…tive INFO xBDSVDMR3 rejects a NaN or an infinity in D or E before any work and returns INFO = N+1 without calling XERBLA. xGESVDMR3 passes that on as INFO = MIN(M,N)+1 when A contains one, since a NaN reaches the bidiagonal unscaled and an infinity is scaled by zero into a NaN; when singular vectors are requested, the xORMBR calls that follow overwrite it on three of the four paths (Reference-LAPACK#1482), and the call returns INFO = 0 with NS = 0. Follow instead the rule that Reference-LAPACK#1382 applies to xGEEV, xGESDD, xGELSD and xBDSDC, extending the NaN check that Reference-LAPACK#1136 added to xGEEV: when the input contains a NaN or an infinity, return INFO = -(position of the array), without calling XERBLA, so that the caller gets control back. xBDSVDMR3 now tests D and then E, in separate loops so that the two can be told apart, and returns -5 or -6. xGESVDMR3 tests ANRM right after xLANGE, before the scaling, and returns -6, with the test that Reference-LAPACK#1382 uses. A finite A, scaled into [SMLNUM, BIGNUM], gives a finite bidiagonal, so xBDSVDMR3's test no longer fires from xGESVDMR3. For a complex A, xLANGE takes the absolute value of each entry, so an entry whose real and imaginary parts are finite but whose absolute value overflows also returns -6: the largest singular value of A would overflow too, and the parent returned INFO = 0 with NaN singular values. INFO = N+2 and the fallback's INFO stay positive: they report a failed computation, not bad input. The INFO descriptions of both routines document the change, and the one of xGESVDMR3 drops a line, inherited from xGESVDX, about an INFO = N*2+1 that xGESVDMR3 never returns. LAPACKE_?bdsvdmr3 already returns -6 / -7 for a NaN in D / E from its own NaN check, which is the new Fortran -5 / -6 after LAPACKE's shift for MATRIX_LAYOUT. The NaN check of LAPACKE_?gesvdmr3 returned -6 for A, which is its seventh argument, so a NaN would have come back as -6 and an infinity as -7; it now returns -7. LAPACKE_?gesvdx, from which it was copied, has the same -6, but it is released and is left alone. Neither routine is in a release yet, so no released interface changes. xERRBD checks xBDSVDMR3 with an infinity in D (-5) and a NaN in E (-6), and xERRED checks xGESVDMR3 with a NaN and with an infinity in A (-6), each also failing if XERBLA is called. On the parent, the xBDSVDMR3 cases return 3 (N+1) and the xGESVDMR3 cases 2 (MIN(M,N)+1). Both routines check their workspace before the input, so the work arrays of xERRBD and xERRED grow to the minimum sizes for these small problems, and xERRED joins the NAG -Onopropagate list that keeps the compiler from folding SQRT( -ONE ) and ONE / ZERO. The full test suite passes, with and without the _64 API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CGEEV, ZGEEV, CGESDD, ZGESDD, CGELSD and ZGELSD test the xLANGE 'M' norm of A for a NaN or a value above the overflow threshold. For a complex A, xLANGE takes the absolute value of each entry, so an entry whose real and imaginary parts are finite but whose absolute value overflows also returns INFO = -4. Master returns INFO = 0 for such a matrix, with NaN eigenvalues or singular values, because the scaling by BIGNUM / ANRM is a scaling by zero. The INFO descriptions now say so, as Reference-LAPACK#1483 does for CGESVDMR3 and ZGESVDMR3. Comments only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed 451264e, a comments-only follow-up. For a complex |
|
@mohawk2 wrote:
Hi @mohawk2, See first bullet at: #1382 (comment). I had written
So I agree that we need to be careful about this. To answer your question, I think that, as of now, LAPACK always calls GESDD's behavior was changed with #471. This pull request fell through the scrutiny cracks at the time. Maybe for the better. Serendipitous. Returning negative That being said, I think this change is for the better. @rmlarsen already gave good arguments for the change. Let me repeat what @rmlarsen wrote:
I agree with all this. Another compelling argument is that this would follow https://arxiv.org/pdf/2207.09281. (Disclaimer: Arguably I am biased as a co-author.) Here are some quotes. Section 2.4.3 page 11,
Section 2.5.2 page 15,
Section 2.5.2 page 16,
Section 2.5.2 page 17,
Julien. |
…tive INFO xBDSVDMR3 rejects a NaN or an infinity in D or E before any work and returns INFO = N+1 without calling XERBLA. xGESVDMR3 passes that on as INFO = MIN(M,N)+1 when A contains one, since a NaN reaches the bidiagonal unscaled and an infinity is scaled by zero into a NaN; when singular vectors are requested, the xORMBR calls that follow overwrite it on three of the four paths (Reference-LAPACK#1482), and the call returns INFO = 0 with NS = 0. Follow instead the rule that Reference-LAPACK#1382 applies to xGEEV, xGESDD, xGELSD and xBDSDC, extending the NaN check that Reference-LAPACK#1136 added to xGEEV: when the input contains a NaN or an infinity, return INFO = -(position of the array), without calling XERBLA, so that the caller gets control back. xBDSVDMR3 now tests D and then E, in separate loops so that the two can be told apart, and returns -5 or -6. xGESVDMR3 tests ANRM right after xLANGE, before the scaling, and returns -6, with the test that bidiagonal, so xBDSVDMR3's test no longer fires from xGESVDMR3. For a complex A, xLANGE takes the absolute value of each entry, so an entry whose real and imaginary parts are finite but whose absolute value overflows also returns -6: the largest singular value of A would overflow too, and the parent returned INFO = 0 with NaN singular values. INFO = N+2 and the fallback's INFO stay positive: they report a failed computation, not bad input. The INFO descriptions of both routines document the change, and the one of xGESVDMR3 drops a line, inherited from xGESVDX, about an INFO = N*2+1 that xGESVDMR3 never returns. LAPACKE_?bdsvdmr3 already returns -6 / -7 for a NaN in D / E from its own NaN check, which is the new Fortran -5 / -6 after LAPACKE's shift for MATRIX_LAYOUT. The NaN check of LAPACKE_?gesvdmr3 returned -6 for A, which is its seventh argument, so a NaN would have come back as -6 and an infinity as -7; it now returns -7. LAPACKE_?gesvdx, from which it was copied, has the same -6, but it is released and is left alone. Neither routine is in a release yet, so no released interface changes. xERRBD checks xBDSVDMR3 with an infinity in D (-5) and a NaN in E (-6), and xERRED checks xGESVDMR3 with a NaN and with an infinity in A (-6), each also failing if XERBLA is called. On the parent, the xBDSVDMR3 cases return 3 (N+1) and the xGESVDMR3 cases 2 (MIN(M,N)+1). Both routines check their workspace before the input, so the work arrays of xERRBD and xERRED grow to the minimum sizes for these small problems, and xERRED joins the NAG -Onopropagate list that keeps the compiler from folding SQRT( -ONE ) and ONE / ZERO. The full test suite passes, with and without the _64 API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AI disclosure: This PR was prepared with Claude Code.
Summary
xGELSDstops the program whenAcontains a NaN or an infinity, and so doxLALSDandxBDSDCwhen the bidiagonal does. In each case the routine scales by a norm that it never tests:xLANSTpropagates a NaN,xLASCLrejectsCFROM = NaNas an illegal argument, and the referenceXERBLAstops. An infinity gets the same treatment, becausexGELSD's own scaling multiplies by zero and leaves a NaN where the infinity was.xGEEVreturnsINFO = -4for a NaN inA(#1136), but it callsXERBLAfirst, and an infinity inAcomes back asINFO = 0with every eigenvalue a NaN.Following the rule of #1136 (a NaN in the norm that a routine computes for scaling is reported as an error in that argument, here extended to an infinity), this PR tests those norms and returns
INFO = -(position of the array):INFOxGELSDA-4xGESDDA-4xGEEVXERBLA) or, now, infinity inA-4xLALSDD/E-5/-6xBDSDCD/E-4/-5As in
xGESDD, none of these returns callsXERBLA: the input is bad data, not a programming error, and the caller gets control back. Nothing changes for finite input.Description
With a NaN at
A(2,2)of a 6-by-4 least-squares problem, one process per call:DGELS,DGELST,DGETSLS,DGELSYINFO = 0, NaN solutionDGELSSINFO = 3(DBDSQRdid not converge)DGELSD,ZGELSD** On entry to DLASCL parameter number 4 had an illegal valueThe backtrace is
DGELSD->DLALSD->DLASCL->XERBLA, from the unconditionalDLASCL( 'G', 0, 0, ORGNRM, ONE, ... )afterORGNRM = DLANST( 'M', N, D, E ).xGESDDalready returnsINFO = -4for a NaN inA, but an infinity passes that guard, becomes a NaN in the same way, and stops the process insidexBDSDC.Fix
{s,d,c,z}gelsd.f: right afterANRM = xLANGE( 'M', ... ), returnINFO = -4ifANRMis a NaN or exceedsxLAMCH( 'Overflow' ).{s,d,c,z}gesdd.f: the existingxISNAN( ANRM )guard also testsANRM > xLAMCH( 'Overflow' ). Without it, an infinity inAwould reachxBDSDCas a NaN and come back asINFO = -5, which inxGESDD's argument list would nameLDA.{s,d,c,z}lalsd.fand{s,d}bdsdc.f: after theN = 0quick return,xLANGE( 'M', ... )ofDand then ofE, and a return with the position of the first one that is not finite. The test comes before any work: the lower-to-upper rotation forUPLO = 'L'mixesEintoD, after which the two can no longer be told apart. It also covers every path, including the small-problem and singular-values-only paths ofxBDSDC, which go throughxLASDQand previously returnedINFO = 0with a NaN result or a non-convergence count.{s,d,c,z}geev.f: the NaN test onANRMreturns without callingXERBLA, also testsANRM > xLAMCH( 'Overflow' ), and moves before the scaling branches, since an infiniteANRMalso exceedsBIGNUM.The
INFOdescriptions of all five routines document the new values. Eighteen source files.For a complex
A,xLANGEtakes the absolute value of each entry, so inCGEEV,ZGEEV,CGESDD,ZGESDD,CGELSDandZGELSDan entry with finite real and imaginary parts whose absolute value overflows also returns-4; master returnsINFO = 0for such a matrix, with NaN eigenvalues or singular values, because the scaling byBIGNUM / ANRMis a scaling by zero. TheirINFOdescriptions say so, as #1483 does forCGESVDMR3andZGESVDMR3.Minimal reproducer
Validation
NaN, +Inf and -Inf at every position, all precisions, every path
A sweep program puts a NaN,
+Infor-Inf(in a complexA, the-Infgoes in the imaginary part) at each position of the input and checks the returnedINFO.XERBLAis replaced by a routine that stops the process with status 99, so a completed run proves that no case reached it.xGELSDA: shapes (1,1), (2,2), (5,3), (3,5), (25,25), (26,26), (40,25), (25,40), (80,60), every position up to 40 per shape-4xGESDDJOBZ = 'N'and'S'-4xLALSDDandEforN= 1, 2, 5, 25, 26, 60,UPLO = 'U'and'L', every position-5/-6xBDSDCCOMPQ = 'N','P'and'I'-4/-522380 cases in total. On master the sweep stops on its first case, in
SLASCLcalled fromSGELSD.Finite input: the same program writes every output (
INFO,RANK,S,B,U,VT,D) of the four routines over the same shapes, sizes and options to a file; the file from this branch is bit-identical to the one from master.Regression tests
The error-exit tests get the cases, since the point is that the routine returns at all and returns the right
INFO:xERRLS:xGELSDwith a NaN and with an infinity inA(-4), andxLALSDwith an infinity inD(-5) and a NaN inE(-6).xERRBD:xBDSDCwith an infinity inD(-4) and a NaN inE(-5).xERRED:xGESDDandxGEEVwith a NaN and with an infinity inA(-4).Each case also fails if
XERBLAis called. Built with only the test changes on top of master, every case fails in all precisions exceptxGESDDwith a NaN, which master already handles (#469) (*** DGELSD did not return INFO = -4 without calling XERBLA for input with a NaN or an infinity (INFO = -4) ***, where-4is the valueDLASCLhands back after itsXERBLAcall, and so on). With thexGEEVof the previous revision, its NaN case callsXERBLAand its infinity case returnsINFO = 0.xERRLSalso records what the least-squares drivers do with a NaN inB, which none of them checks: for each ofxGELS,xGELST,xGETSLS,xGELSS,xGELSYandxGELSD, a NaN in one column ofBgivesINFO = 0, the solution for the other column, and a NaN in the solution for its own, without callingXERBLA. These cases pass on master as well; they pin down the current behavior (see "Not changed here" for an infinity).xGELSDneeds a real workspace of about 800 for a 2 by 2 problem, so the arrays inxERRLSgrow accordingly. ThexERRLSandxERREDfiles join the-Onopropagatelist that already keeps the NAG compiler from folding theSQRT( -ONE )andONE / ZEROthat build the NaN and the infinity.Test suite
The full LAPACK test suite passes on this branch, for the default API and for the
_64API: 119 of 119 CTest entries without the_64API and all 118_64entries with it, each with 5739011 LAPACK tests and 319677 BLAS tests, 0 numerical errors and 0 other errors (13th Gen Intel(R) Core(TM) i7-13700HX, Linux under WSL2, GNU Fortran 15.2.0,CMAKE_BUILD_TYPE=Release). The previous revision passed on an Apple M4 (macOS 26.7, Homebrew GCC 16.2) with 5738981 LAPACK tests.Performance
The new tests are one
xLANGE( 'M', ... )ofDand one ofE, which isO(N), in front ofO(N^2)work or more inxLALSDandxBDSDC, and one comparison inxGELSDandxGESDD. I have not re-timed this revision; the timings in the earlier description were for the previous version of the patch and are no longer shown.Not changed here
The least-squares drivers do not test
B, and they solve with whatever it contains. With a NaN in one column ofBthat gives a NaN solution for that column and leaves the others exact (bit-identical to a run with a finite value in its place);xERRLSnow checks this.An infinity in
Bdoes not stay in its column. Every driver scalesBbyBIGNUM / BNRM = 0whenBNRMis infinite, which turns the infinity into a NaN and every other entry into zero, and undoing the scaling at the end multiplies by an infinity, which turns those zeros into NaNs. The solution for every right-hand side comes back NaN, withINFO = 0: in double precision, all six drivers, for shapes 6x4, 4x6, 60x40, 40x60 and 30x30,+Infand-Inf. Skipping that scaling whenBNRMis infinite would make an infinity behave like a NaN; that is not part of this PR.Checklist
INFOdescriptions ofxGELSD,xGESDD,xGEEV,xLALSDandxBDSDC.)