Skip to content

Commit a782e10

Browse files
authored
Merge pull request #5858 from martin-frbg/lapack1286
Increase tolerance in ?LASD2 to improve ?BDSDC stability (Reference-LAPACK PR 1286)
2 parents 66d041d + 6265056 commit a782e10

3 files changed

Lines changed: 23 additions & 17 deletions

File tree

benchmark/pybench/benchmarks/bench_blas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def test_gesdd(benchmark, mn, variant):
236236

237237
assert info == 0
238238

239-
atol = {'s': 1e-5, 'd': 1e-13}
239+
atol = {'s': 5e-5, 'd': 1e-13}
240240
np.testing.assert_allclose(u @ np.diag(s) @ vt, a, atol=atol[variant])
241241

242242

lapack-netlib/SRC/dlasd2.f

Lines changed: 11 additions & 8 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 DLASD2 + dependencies
109
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlasd2.f">
1110
*> [TGZ]</a>
1211
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlasd2.f">
1312
*> [ZIP]</a>
1413
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlasd2.f">
1514
*> [TXT]</a>
16-
*> \endhtmlonly
1715
*
1816
* Definition:
1917
* ===========
@@ -254,7 +252,7 @@
254252
*> \author Univ. of Colorado Denver
255253
*> \author NAG Ltd.
256254
*
257-
*> \ingroup OTHERauxiliary
255+
*> \ingroup lasd2
258256
*
259257
*> \par Contributors:
260258
* ==================
@@ -263,9 +261,11 @@
263261
*> California at Berkeley, USA
264262
*>
265263
* =====================================================================
266-
SUBROUTINE DLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, VT,
264+
SUBROUTINE DLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU,
265+
$ VT,
267266
$ LDVT, DSIGMA, U2, LDU2, VT2, LDVT2, IDXP, IDX,
268267
$ IDXC, IDXQ, COLTYP, INFO )
268+
IMPLICIT NONE
269269
*
270270
* -- LAPACK auxiliary routine --
271271
* -- LAPACK is a software package provided by Univ. of Tennessee, --
@@ -303,7 +303,8 @@ SUBROUTINE DLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, VT,
303303
EXTERNAL DLAMCH, DLAPY2
304304
* ..
305305
* .. External Subroutines ..
306-
EXTERNAL DCOPY, DLACPY, DLAMRG, DLASET, DROT, XERBLA
306+
EXTERNAL DCOPY, DLACPY, DLAMRG, DLASET, DROT,
307+
$ XERBLA
307308
* ..
308309
* .. Intrinsic Functions ..
309310
INTRINSIC ABS, MAX
@@ -396,7 +397,7 @@ SUBROUTINE DLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, VT,
396397
*
397398
EPS = DLAMCH( 'Epsilon' )
398399
TOL = MAX( ABS( ALPHA ), ABS( BETA ) )
399-
TOL = EIGHT*EPS*MAX( ABS( D( N ) ), TOL )
400+
TOL = EIGHT*EIGHT*EPS*MAX( ABS( D( N ) ), TOL )
400401
*
401402
* There are 2 kinds of deflation -- first a value in the z-vector
402403
* is small, second two (or more) singular values are very close
@@ -479,7 +480,8 @@ SUBROUTINE DLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, VT,
479480
IDXJ = IDXJ - 1
480481
END IF
481482
CALL DROT( N, U( 1, IDXJP ), 1, U( 1, IDXJ ), 1, C, S )
482-
CALL DROT( M, VT( IDXJP, 1 ), LDVT, VT( IDXJ, 1 ), LDVT, C,
483+
CALL DROT( M, VT( IDXJP, 1 ), LDVT, VT( IDXJ, 1 ), LDVT,
484+
$ C,
483485
$ S )
484486
IF( COLTYP( J ).NE.COLTYP( JPREV ) ) THEN
485487
COLTYP( J ) = 3
@@ -621,7 +623,8 @@ SUBROUTINE DLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, VT,
621623
CALL DCOPY( N-K, DSIGMA( K+1 ), 1, D( K+1 ), 1 )
622624
CALL DLACPY( 'A', N, N-K, U2( 1, K+1 ), LDU2, U( 1, K+1 ),
623625
$ LDU )
624-
CALL DLACPY( 'A', N-K, M, VT2( K+1, 1 ), LDVT2, VT( K+1, 1 ),
626+
CALL DLACPY( 'A', N-K, M, VT2( K+1, 1 ), LDVT2, VT( K+1,
627+
$ 1 ),
625628
$ LDVT )
626629
END IF
627630
*

lapack-netlib/SRC/slasd2.f

Lines changed: 11 additions & 8 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 SLASD2 + dependencies
109
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slasd2.f">
1110
*> [TGZ]</a>
1211
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slasd2.f">
1312
*> [ZIP]</a>
1413
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slasd2.f">
1514
*> [TXT]</a>
16-
*> \endhtmlonly
1715
*
1816
* Definition:
1917
* ===========
@@ -254,7 +252,7 @@
254252
*> \author Univ. of Colorado Denver
255253
*> \author NAG Ltd.
256254
*
257-
*> \ingroup OTHERauxiliary
255+
*> \ingroup lasd2
258256
*
259257
*> \par Contributors:
260258
* ==================
@@ -263,9 +261,11 @@
263261
*> California at Berkeley, USA
264262
*>
265263
* =====================================================================
266-
SUBROUTINE SLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, VT,
264+
SUBROUTINE SLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU,
265+
$ VT,
267266
$ LDVT, DSIGMA, U2, LDU2, VT2, LDVT2, IDXP, IDX,
268267
$ IDXC, IDXQ, COLTYP, INFO )
268+
IMPLICIT NONE
269269
*
270270
* -- LAPACK auxiliary routine --
271271
* -- LAPACK is a software package provided by Univ. of Tennessee, --
@@ -303,7 +303,8 @@ SUBROUTINE SLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, VT,
303303
EXTERNAL SLAMCH, SLAPY2
304304
* ..
305305
* .. External Subroutines ..
306-
EXTERNAL SCOPY, SLACPY, SLAMRG, SLASET, SROT, XERBLA
306+
EXTERNAL SCOPY, SLACPY, SLAMRG, SLASET, SROT,
307+
$ XERBLA
307308
* ..
308309
* .. Intrinsic Functions ..
309310
INTRINSIC ABS, MAX
@@ -396,7 +397,7 @@ SUBROUTINE SLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, VT,
396397
*
397398
EPS = SLAMCH( 'Epsilon' )
398399
TOL = MAX( ABS( ALPHA ), ABS( BETA ) )
399-
TOL = EIGHT*EPS*MAX( ABS( D( N ) ), TOL )
400+
TOL = EIGHT*EIGHT*EPS*MAX( ABS( D( N ) ), TOL )
400401
*
401402
* There are 2 kinds of deflation -- first a value in the z-vector
402403
* is small, second two (or more) singular values are very close
@@ -479,7 +480,8 @@ SUBROUTINE SLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, VT,
479480
IDXJ = IDXJ - 1
480481
END IF
481482
CALL SROT( N, U( 1, IDXJP ), 1, U( 1, IDXJ ), 1, C, S )
482-
CALL SROT( M, VT( IDXJP, 1 ), LDVT, VT( IDXJ, 1 ), LDVT, C,
483+
CALL SROT( M, VT( IDXJP, 1 ), LDVT, VT( IDXJ, 1 ), LDVT,
484+
$ C,
483485
$ S )
484486
IF( COLTYP( J ).NE.COLTYP( JPREV ) ) THEN
485487
COLTYP( J ) = 3
@@ -621,7 +623,8 @@ SUBROUTINE SLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, VT,
621623
CALL SCOPY( N-K, DSIGMA( K+1 ), 1, D( K+1 ), 1 )
622624
CALL SLACPY( 'A', N, N-K, U2( 1, K+1 ), LDU2, U( 1, K+1 ),
623625
$ LDU )
624-
CALL SLACPY( 'A', N-K, M, VT2( K+1, 1 ), LDVT2, VT( K+1, 1 ),
626+
CALL SLACPY( 'A', N-K, M, VT2( K+1, 1 ), LDVT2, VT( K+1,
627+
$ 1 ),
625628
$ LDVT )
626629
END IF
627630
*

0 commit comments

Comments
 (0)