Skip to content

Commit 230b8c4

Browse files
committed
Fix -ZERO singular value in bdsqr
[D,Z]BDSQR returns for D = [ -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0] E = [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] as singular value D(10) = -ZERO. By definition, singular values are non-negative. LASQ1 already fixes the sign and returns +ZERO.
1 parent acbac10 commit 230b8c4

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

SRC/cbdsqr.f

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,12 @@ SUBROUTINE CBDSQR( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,
809809
*
810810
160 CONTINUE
811811
DO 170 I = 1, N
812+
IF( D( I ).EQ.ZERO ) THEN
813+
*
814+
* Avoid -ZERO
815+
*
816+
D( I ) = ZERO
817+
END IF
812818
IF( D( I ).LT.ZERO ) THEN
813819
D( I ) = -D( I )
814820
*

SRC/dbdsqr.f

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,12 @@ SUBROUTINE DBDSQR( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,
817817
*
818818
160 CONTINUE
819819
DO 170 I = 1, N
820+
IF( D( I ).EQ.ZERO ) THEN
821+
*
822+
* Avoid -ZERO
823+
*
824+
D( I ) = ZERO
825+
END IF
820826
IF( D( I ).LT.ZERO ) THEN
821827
D( I ) = -D( I )
822828
*

SRC/sbdsqr.f

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,14 @@ SUBROUTINE SBDSQR( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,
817817
*
818818
160 CONTINUE
819819
DO 170 I = 1, N
820+
IF( D( I ).EQ.ZERO ) THEN
821+
*
822+
* Avoid -ZERO
823+
*
824+
D( I ) = ZERO
825+
END IF
820826
IF( D( I ).LT.ZERO ) THEN
827+
821828
D( I ) = -D( I )
822829
*
823830
* Change sign of singular vectors, if desired

SRC/zbdsqr.f

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,12 @@ SUBROUTINE ZBDSQR( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,
807807
*
808808
160 CONTINUE
809809
DO 170 I = 1, N
810+
IF( D( I ).EQ.ZERO ) THEN
811+
*
812+
* Avoid -ZERO
813+
*
814+
D( I ) = ZERO
815+
END IF
810816
IF( D( I ).LT.ZERO ) THEN
811817
D( I ) = -D( I )
812818
*

0 commit comments

Comments
 (0)