Skip to content

Commit 6ed0c09

Browse files
authored
Merge pull request #6193 from martin-frbg/lapack1387
Return INFO=1 in S/DLASQ1 instead of returning via XERBLA when SIGMX is NaN (Reference-LAPACK PR 1387)
2 parents 06608a6 + 16dadb9 commit 6ed0c09

8 files changed

Lines changed: 220 additions & 304 deletions

File tree

‎lapack-netlib/SRC/dlasq1.c‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,6 @@ typedef struct Namelist Namelist;
226226
*/
227227

228228

229-
230-
231229
/* Table of constant values */
232230

233231
static integer c__1 = 1;
@@ -241,7 +239,6 @@ static integer c__0 = 0;
241239
/* Online html documentation available at */
242240
/* http://www.netlib.org/lapack/explore-html/ */
243241

244-
/* > \htmlonly */
245242
/* > Download DLASQ1 + dependencies */
246243
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlasq1.
247244
f"> */
@@ -252,7 +249,6 @@ f"> */
252249
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlasq1.
253250
f"> */
254251
/* > [TXT]</a> */
255-
/* > \endhtmlonly */
256252

257253
/* Definition: */
258254
/* =========== */
@@ -318,7 +314,8 @@ f"> */
318314
/* > = 0: successful exit */
319315
/* > < 0: if INFO = -i, the i-th argument had an illegal value */
320316
/* > > 0: the algorithm failed */
321-
/* > = 1, a split was marked by a positive value in E */
317+
/* > = 1, a split was marked by a positive value in E, or */
318+
/* > the input contains a NaN */
322319
/* > = 2, current block of Z not diagonalized after 100*N */
323320
/* > iterations (in inner while loop) On exit D and E */
324321
/* > represent a matrix with the same singular values */
@@ -336,9 +333,7 @@ f"> */
336333
/* > \author Univ. of Colorado Denver */
337334
/* > \author NAG Ltd. */
338335

339-
/* > \date December 2016 */
340-
341-
/* > \ingroup auxOTHERcomputational */
336+
/* > \ingroup lasq1 */
342337

343338
/* ===================================================================== */
344339
/* Subroutine */ void dlasq1_(integer *n, doublereal *d__, doublereal *e,
@@ -349,9 +344,10 @@ f"> */
349344
doublereal d__1, d__2, d__3;
350345

351346
/* Local variables */
347+
integer i__;
348+
doublereal eps;
352349
extern /* Subroutine */ void dlas2_(doublereal *, doublereal *, doublereal
353350
*, doublereal *, doublereal *);
354-
integer i__;
355351
doublereal scale;
356352
integer iinfo;
357353
doublereal sigmn;
@@ -363,17 +359,15 @@ f"> */
363359
extern /* Subroutine */ void dlascl_(char *, integer *, integer *,
364360
doublereal *, doublereal *, integer *, integer *, doublereal *,
365361
integer *, integer *);
362+
extern logical disnan_(doublereal *);
366363
doublereal safmin;
367-
extern /* Subroutine */ void xerbla_(char *, integer *, ftnlen);
368-
extern void dlasrt_(
364+
extern /* Subroutine */ void xerbla_(char *, integer *, ftnlen), dlasrt_(
369365
char *, integer *, doublereal *, integer *);
370-
doublereal eps;
371366

372367

373-
/* -- LAPACK computational routine (version 3.7.0) -- */
368+
/* -- LAPACK computational routine -- */
374369
/* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
375370
/* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
376-
/* December 2016 */
377371

378372

379373
/* ===================================================================== */
@@ -431,6 +425,14 @@ f"> */
431425
/* L20: */
432426
}
433427

428+
/* A NaN in D or E can make SIGMX a NaN, which DLASCL would reject */
429+
/* by stopping in XERBLA; report it through INFO instead. */
430+
431+
if (disnan_(&sigmx)) {
432+
*info = 1;
433+
return;
434+
}
435+
434436
/* Copy D and E into WORK (in the Z format) and scale (squaring the */
435437
/* input data makes scaling by a power of the radix pointless). */
436438

‎lapack-netlib/SRC/dlasq1.f‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
* Online html documentation available at
66
* http://www.netlib.org/lapack/explore-html/
77
*
8-
*> \htmlonly
98
*> Download DLASQ1 + dependencies
109
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlasq1.f">
1110
*> [TGZ]</a>
1211
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlasq1.f">
1312
*> [ZIP]</a>
1413
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlasq1.f">
1514
*> [TXT]</a>
16-
*> \endhtmlonly
1715
*
1816
* Definition:
1917
* ===========
@@ -83,7 +81,8 @@
8381
*> = 0: successful exit
8482
*> < 0: if INFO = -i, the i-th argument had an illegal value
8583
*> > 0: the algorithm failed
86-
*> = 1, a split was marked by a positive value in E
84+
*> = 1, a split was marked by a positive value in E, or
85+
*> the input contains a NaN
8786
*> = 2, current block of Z not diagonalized after 100*N
8887
*> iterations (in inner while loop) On exit D and E
8988
*> represent a matrix with the same singular values
@@ -101,10 +100,11 @@
101100
*> \author Univ. of Colorado Denver
102101
*> \author NAG Ltd.
103102
*
104-
*> \ingroup auxOTHERcomputational
103+
*> \ingroup lasq1
105104
*
106105
* =====================================================================
107106
SUBROUTINE DLASQ1( N, D, E, WORK, INFO )
107+
IMPLICIT NONE
108108
*
109109
* -- LAPACK computational routine --
110110
* -- LAPACK is a software package provided by Univ. of Tennessee, --
@@ -128,11 +128,13 @@ SUBROUTINE DLASQ1( N, D, E, WORK, INFO )
128128
DOUBLE PRECISION EPS, SCALE, SAFMIN, SIGMN, SIGMX
129129
* ..
130130
* .. External Subroutines ..
131-
EXTERNAL DCOPY, DLAS2, DLASCL, DLASQ2, DLASRT, XERBLA
131+
EXTERNAL DCOPY, DLAS2, DLASCL, DLASQ2, DLASRT,
132+
$ XERBLA
132133
* ..
133134
* .. External Functions ..
134135
DOUBLE PRECISION DLAMCH
135-
EXTERNAL DLAMCH
136+
LOGICAL DISNAN
137+
EXTERNAL DISNAN, DLAMCH
136138
* ..
137139
* .. Intrinsic Functions ..
138140
INTRINSIC ABS, MAX, SQRT
@@ -176,6 +178,14 @@ SUBROUTINE DLASQ1( N, D, E, WORK, INFO )
176178
SIGMX = MAX( SIGMX, D( I ) )
177179
20 CONTINUE
178180
*
181+
* A NaN in D or E can make SIGMX a NaN, which DLASCL would reject
182+
* by stopping in XERBLA; report it through INFO instead.
183+
*
184+
IF( DISNAN( SIGMX ) ) THEN
185+
INFO = 1
186+
RETURN
187+
END IF
188+
*
179189
* Copy D and E into WORK (in the Z format) and scale (squaring the
180190
* input data makes scaling by a power of the radix pointless).
181191
*

0 commit comments

Comments
 (0)