Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
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.
  • Loading branch information
angsch committed Feb 23, 2024
commit 230b8c4862a3f45ee645e26e8f609ac3dbe9574d
6 changes: 6 additions & 0 deletions SRC/cbdsqr.f
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,12 @@ SUBROUTINE CBDSQR( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,
*
160 CONTINUE
DO 170 I = 1, N
IF( D( I ).EQ.ZERO ) THEN
*
* Avoid -ZERO
*
D( I ) = ZERO
END IF
IF( D( I ).LT.ZERO ) THEN
D( I ) = -D( I )
*
Expand Down
6 changes: 6 additions & 0 deletions SRC/dbdsqr.f
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,12 @@ SUBROUTINE DBDSQR( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,
*
160 CONTINUE
DO 170 I = 1, N
IF( D( I ).EQ.ZERO ) THEN
*
* Avoid -ZERO
*
D( I ) = ZERO
END IF
IF( D( I ).LT.ZERO ) THEN
D( I ) = -D( I )
*
Expand Down
7 changes: 7 additions & 0 deletions SRC/sbdsqr.f
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,14 @@ SUBROUTINE SBDSQR( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,
*
160 CONTINUE
DO 170 I = 1, N
IF( D( I ).EQ.ZERO ) THEN
*
* Avoid -ZERO
*
D( I ) = ZERO
END IF
IF( D( I ).LT.ZERO ) THEN

D( I ) = -D( I )
*
* Change sign of singular vectors, if desired
Expand Down
6 changes: 6 additions & 0 deletions SRC/zbdsqr.f
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,12 @@ SUBROUTINE ZBDSQR( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,
*
160 CONTINUE
DO 170 I = 1, N
IF( D( I ).EQ.ZERO ) THEN
*
* Avoid -ZERO
*
D( I ) = ZERO
END IF
IF( D( I ).LT.ZERO ) THEN
D( I ) = -D( I )
*
Expand Down