Skip to content

Commit 7c8604c

Browse files
author
Maarten Baert
committed
Fix documentation error and ordering bug in SLASD2 and DLASD2
1 parent fd0ebf6 commit 7c8604c

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

SRC/dlasd2.f

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
*> On entry D contains the singular values of the two submatrices
8787
*> to be combined. On exit D contains the trailing (N-K) updated
8888
*> singular values (those which were deflated) sorted into
89-
*> increasing order.
89+
*> decreasing order.
9090
*> \endverbatim
9191
*>
9292
*> \param[out] Z
@@ -217,7 +217,7 @@
217217
*> IDXQ is INTEGER array, dimension(N)
218218
*> This contains the permutation which separately sorts the two
219219
*> sub-problems in D into ascending order. Note that entries in
220-
*> the first hlaf of this permutation must first be moved one
220+
*> the first half of this permutation must first be moved one
221221
*> position backward; and entries in the second half
222222
*> must first have NL+1 added to their values.
223223
*> \endverbatim
@@ -451,7 +451,7 @@ SUBROUTINE DLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU,
451451
*
452452
* Check if singular values are close enough to allow deflation.
453453
*
454-
IF( ABS( D( J )-D( JPREV ) ).LE.TOL ) THEN
454+
IF( ( D( J )-D( JPREV ) ).LE.TOL ) THEN
455455
*
456456
* Deflation is possible.
457457
*
@@ -487,7 +487,14 @@ SUBROUTINE DLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU,
487487
END IF
488488
COLTYP( JPREV ) = 4
489489
K2 = K2 - 1
490-
IDXP( K2 ) = JPREV
490+
*
491+
* Insert the deflated index in the correct position in IDXP.
492+
* If J - JPREV is greater than 1, the indices in between
493+
* must be shifted to preserve the correct output order.
494+
*
495+
DO 105 JP = JPREV, J - 1
496+
IDXP( K2 + J - 1 - JP ) = JP
497+
105 CONTINUE
491498
JPREV = J
492499
ELSE
493500
K = K + 1

SRC/slasd2.f

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
*> On entry D contains the singular values of the two submatrices
8787
*> to be combined. On exit D contains the trailing (N-K) updated
8888
*> singular values (those which were deflated) sorted into
89-
*> increasing order.
89+
*> decreasing order.
9090
*> \endverbatim
9191
*>
9292
*> \param[out] Z
@@ -217,7 +217,7 @@
217217
*> IDXQ is INTEGER array, dimension (N)
218218
*> This contains the permutation which separately sorts the two
219219
*> sub-problems in D into ascending order. Note that entries in
220-
*> the first hlaf of this permutation must first be moved one
220+
*> the first half of this permutation must first be moved one
221221
*> position backward; and entries in the second half
222222
*> must first have NL+1 added to their values.
223223
*> \endverbatim
@@ -451,7 +451,7 @@ SUBROUTINE SLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU,
451451
*
452452
* Check if singular values are close enough to allow deflation.
453453
*
454-
IF( ABS( D( J )-D( JPREV ) ).LE.TOL ) THEN
454+
IF( ( D( J )-D( JPREV ) ).LE.TOL ) THEN
455455
*
456456
* Deflation is possible.
457457
*
@@ -487,7 +487,14 @@ SUBROUTINE SLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU,
487487
END IF
488488
COLTYP( JPREV ) = 4
489489
K2 = K2 - 1
490-
IDXP( K2 ) = JPREV
490+
*
491+
* Insert the deflated index in the correct position in IDXP.
492+
* If J - JPREV is greater than 1, the indices in between
493+
* must be shifted to preserve the correct output order.
494+
*
495+
DO 105 JP = JPREV, J - 1
496+
IDXP( K2 + J - 1 - JP ) = JP
497+
105 CONTINUE
491498
JPREV = J
492499
ELSE
493500
K = K + 1

0 commit comments

Comments
 (0)