From d1f15f53c4744f44d777876f1f6d18bfbe86c22a Mon Sep 17 00:00:00 2001 From: Maarten Baert Date: Wed, 25 Jun 2025 14:17:53 +0200 Subject: [PATCH 1/6] Fix documentation error and ordering bug in DLASD7 --- SRC/dlasd7.f | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/SRC/dlasd7.f b/SRC/dlasd7.f index a4ea5ae38..5f02b6e7d 100644 --- a/SRC/dlasd7.f +++ b/SRC/dlasd7.f @@ -99,7 +99,7 @@ *> On entry D contains the singular values of the two submatrices *> to be combined. On exit D contains the trailing (N-K) updated *> singular values (those which were deflated) sorted into -*> increasing order. +*> decreasing order. *> \endverbatim *> *> \param[out] Z @@ -453,7 +453,7 @@ SUBROUTINE DLASD7( ICOMPQ, NL, NR, SQRE, K, D, Z, ZW, VF, VFW, * * Check if singular values are close enough to allow deflation. * - IF( ABS( D( J )-D( JPREV ) ).LE.TOL ) THEN + IF( ( D( J )-D( JPREV ) ).LE.TOL ) THEN * * Deflation is possible. * @@ -489,7 +489,14 @@ SUBROUTINE DLASD7( ICOMPQ, NL, NR, SQRE, K, D, Z, ZW, VF, VFW, CALL DROT( 1, VF( JPREV ), 1, VF( J ), 1, C, S ) CALL DROT( 1, VL( JPREV ), 1, VL( J ), 1, C, S ) K2 = K2 - 1 - IDXP( K2 ) = JPREV +* +* Insert the deflated index in the correct position in IDXP. +* If J - JPREV is greater than 1, the indices in between +* must be shifted to preserve the correct output order. +* + DO 130 JP = JPREV, J - 1 + IDXP( K2 + J - 1 - JP ) = JP + 130 CONTINUE JPREV = J ELSE K = K + 1 From 319d40ec153421923e2f15243011caacee95b0ec Mon Sep 17 00:00:00 2001 From: Maarten Baert Date: Sat, 28 Jun 2025 12:26:09 +0200 Subject: [PATCH 2/6] Change new label number in DLASD7 to keep the order consistent --- SRC/dlasd7.f | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SRC/dlasd7.f b/SRC/dlasd7.f index 5f02b6e7d..522b57d8a 100644 --- a/SRC/dlasd7.f +++ b/SRC/dlasd7.f @@ -494,9 +494,9 @@ SUBROUTINE DLASD7( ICOMPQ, NL, NR, SQRE, K, D, Z, ZW, VF, VFW, * If J - JPREV is greater than 1, the indices in between * must be shifted to preserve the correct output order. * - DO 130 JP = JPREV, J - 1 + DO 85 JP = JPREV, J - 1 IDXP( K2 + J - 1 - JP ) = JP - 130 CONTINUE + 85 CONTINUE JPREV = J ELSE K = K + 1 From fd0ebf6cd4221b2d75c6a0e2eb101f9c9d884de1 Mon Sep 17 00:00:00 2001 From: Maarten Baert Date: Sat, 28 Jun 2025 12:26:54 +0200 Subject: [PATCH 3/6] Fix documentation error and ordering bug in SLASD7 --- SRC/slasd7.f | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/SRC/slasd7.f b/SRC/slasd7.f index 0bff53e76..63fa1423c 100644 --- a/SRC/slasd7.f +++ b/SRC/slasd7.f @@ -99,7 +99,7 @@ *> On entry D contains the singular values of the two submatrices *> to be combined. On exit D contains the trailing (N-K) updated *> singular values (those which were deflated) sorted into -*> increasing order. +*> decreasing order. *> \endverbatim *> *> \param[out] Z @@ -489,7 +489,14 @@ SUBROUTINE SLASD7( ICOMPQ, NL, NR, SQRE, K, D, Z, ZW, VF, VFW, CALL SROT( 1, VF( JPREV ), 1, VF( J ), 1, C, S ) CALL SROT( 1, VL( JPREV ), 1, VL( J ), 1, C, S ) K2 = K2 - 1 - IDXP( K2 ) = JPREV +* +* Insert the deflated index in the correct position in IDXP. +* If J - JPREV is greater than 1, the indices in between +* must be shifted to preserve the correct output order. +* + DO 85 JP = JPREV, J - 1 + IDXP( K2 + J - 1 - JP ) = JP + 85 CONTINUE JPREV = J ELSE K = K + 1 From 7c8604c5501534dc29da439b26a6897b881393d5 Mon Sep 17 00:00:00 2001 From: Maarten Baert Date: Sat, 28 Jun 2025 12:45:35 +0200 Subject: [PATCH 4/6] Fix documentation error and ordering bug in SLASD2 and DLASD2 --- SRC/dlasd2.f | 15 +++++++++++---- SRC/slasd2.f | 15 +++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/SRC/dlasd2.f b/SRC/dlasd2.f index 72803bd74..a88b9b457 100644 --- a/SRC/dlasd2.f +++ b/SRC/dlasd2.f @@ -86,7 +86,7 @@ *> On entry D contains the singular values of the two submatrices *> to be combined. On exit D contains the trailing (N-K) updated *> singular values (those which were deflated) sorted into -*> increasing order. +*> decreasing order. *> \endverbatim *> *> \param[out] Z @@ -217,7 +217,7 @@ *> IDXQ is INTEGER array, dimension(N) *> This contains the permutation which separately sorts the two *> sub-problems in D into ascending order. Note that entries in -*> the first hlaf of this permutation must first be moved one +*> the first half of this permutation must first be moved one *> position backward; and entries in the second half *> must first have NL+1 added to their values. *> \endverbatim @@ -451,7 +451,7 @@ SUBROUTINE DLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, * * Check if singular values are close enough to allow deflation. * - IF( ABS( D( J )-D( JPREV ) ).LE.TOL ) THEN + IF( ( D( J )-D( JPREV ) ).LE.TOL ) THEN * * Deflation is possible. * @@ -487,7 +487,14 @@ SUBROUTINE DLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, END IF COLTYP( JPREV ) = 4 K2 = K2 - 1 - IDXP( K2 ) = JPREV +* +* Insert the deflated index in the correct position in IDXP. +* If J - JPREV is greater than 1, the indices in between +* must be shifted to preserve the correct output order. +* + DO 105 JP = JPREV, J - 1 + IDXP( K2 + J - 1 - JP ) = JP + 105 CONTINUE JPREV = J ELSE K = K + 1 diff --git a/SRC/slasd2.f b/SRC/slasd2.f index dfb203af4..116d42b2d 100644 --- a/SRC/slasd2.f +++ b/SRC/slasd2.f @@ -86,7 +86,7 @@ *> On entry D contains the singular values of the two submatrices *> to be combined. On exit D contains the trailing (N-K) updated *> singular values (those which were deflated) sorted into -*> increasing order. +*> decreasing order. *> \endverbatim *> *> \param[out] Z @@ -217,7 +217,7 @@ *> IDXQ is INTEGER array, dimension (N) *> This contains the permutation which separately sorts the two *> sub-problems in D into ascending order. Note that entries in -*> the first hlaf of this permutation must first be moved one +*> the first half of this permutation must first be moved one *> position backward; and entries in the second half *> must first have NL+1 added to their values. *> \endverbatim @@ -451,7 +451,7 @@ SUBROUTINE SLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, * * Check if singular values are close enough to allow deflation. * - IF( ABS( D( J )-D( JPREV ) ).LE.TOL ) THEN + IF( ( D( J )-D( JPREV ) ).LE.TOL ) THEN * * Deflation is possible. * @@ -487,7 +487,14 @@ SUBROUTINE SLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, END IF COLTYP( JPREV ) = 4 K2 = K2 - 1 - IDXP( K2 ) = JPREV +* +* Insert the deflated index in the correct position in IDXP. +* If J - JPREV is greater than 1, the indices in between +* must be shifted to preserve the correct output order. +* + DO 105 JP = JPREV, J - 1 + IDXP( K2 + J - 1 - JP ) = JP + 105 CONTINUE JPREV = J ELSE K = K + 1 From c4ca73c6f2edb646feb4b920b00d43d63d0d1368 Mon Sep 17 00:00:00 2001 From: Maarten Baert Date: Sat, 28 Jun 2025 13:08:20 +0200 Subject: [PATCH 5/6] Fix documentation error in SLAED2, DLAED2, SLAED8 and DLAED8 --- SRC/dlaed2.f | 2 +- SRC/dlaed8.f | 2 +- SRC/slaed2.f | 2 +- SRC/slaed8.f | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SRC/dlaed2.f b/SRC/dlaed2.f index 6d1357df9..9605c7af1 100644 --- a/SRC/dlaed2.f +++ b/SRC/dlaed2.f @@ -73,7 +73,7 @@ *> On entry, D contains the eigenvalues of the two submatrices to *> be combined. *> On exit, D contains the trailing (N-K) updated eigenvalues -*> (those which were deflated) sorted into increasing order. +*> (those which were deflated) sorted into decreasing order. *> \endverbatim *> *> \param[in,out] Q diff --git a/SRC/dlaed8.f b/SRC/dlaed8.f index 367f8d9f5..94ac0a9df 100644 --- a/SRC/dlaed8.f +++ b/SRC/dlaed8.f @@ -83,7 +83,7 @@ *> D is DOUBLE PRECISION array, dimension (N) *> On entry, the eigenvalues of the two submatrices to be *> combined. On exit, the trailing (N-K) updated eigenvalues -*> (those which were deflated) sorted into increasing order. +*> (those which were deflated) sorted into decreasing order. *> \endverbatim *> *> \param[in,out] Q diff --git a/SRC/slaed2.f b/SRC/slaed2.f index 9150bea15..24c62d5cf 100644 --- a/SRC/slaed2.f +++ b/SRC/slaed2.f @@ -73,7 +73,7 @@ *> On entry, D contains the eigenvalues of the two submatrices to *> be combined. *> On exit, D contains the trailing (N-K) updated eigenvalues -*> (those which were deflated) sorted into increasing order. +*> (those which were deflated) sorted into decreasing order. *> \endverbatim *> *> \param[in,out] Q diff --git a/SRC/slaed8.f b/SRC/slaed8.f index 47684d387..c51ccc934 100644 --- a/SRC/slaed8.f +++ b/SRC/slaed8.f @@ -83,7 +83,7 @@ *> D is REAL array, dimension (N) *> On entry, the eigenvalues of the two submatrices to be *> combined. On exit, the trailing (N-K) updated eigenvalues -*> (those which were deflated) sorted into increasing order. +*> (those which were deflated) sorted into decreasing order. *> \endverbatim *> *> \param[in,out] Q From fd9092e9b7a4bc07a31cf8b567682d17a31f9d4e Mon Sep 17 00:00:00 2001 From: Maarten Baert Date: Sat, 28 Jun 2025 13:12:25 +0200 Subject: [PATCH 6/6] Remove redundant/harmful ABS in SLASD7 --- SRC/slasd7.f | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SRC/slasd7.f b/SRC/slasd7.f index 63fa1423c..4c850dc75 100644 --- a/SRC/slasd7.f +++ b/SRC/slasd7.f @@ -453,7 +453,7 @@ SUBROUTINE SLASD7( ICOMPQ, NL, NR, SQRE, K, D, Z, ZW, VF, VFW, * * Check if singular values are close enough to allow deflation. * - IF( ABS( D( J )-D( JPREV ) ).LE.TOL ) THEN + IF( ( D( J )-D( JPREV ) ).LE.TOL ) THEN * * Deflation is possible. *