Skip to content

Commit

Permalink
xORBDB5/xUNBDB5: ensure xORBDB6 input has unit norm
Browse files Browse the repository at this point in the history
Call sites may run into problems when this subroutine computes nonzero
vectors that are very small in norm.
  • Loading branch information
christoph-conrads committed Nov 10, 2023
1 parent 7eb4057 commit 5b0bc5e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
9 changes: 8 additions & 1 deletion SRC/cunbdb5.f
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ SUBROUTINE CUNBDB5( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,
REAL EPS, NORM, SCL, SSQ
* ..
* .. External Subroutines ..
EXTERNAL CLASSQ, CUNBDB6, XERBLA
EXTERNAL CLASSQ, CUNBDB6, CSCAL, XERBLA
* ..
* .. External Functions ..
REAL SLAMCH, SCNRM2
Expand Down Expand Up @@ -227,6 +227,13 @@ SUBROUTINE CUNBDB5( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,
NORM = SCL * SQRT( SSQ )
*
IF( NORM .GT. N * EPS ) THEN
* Scale vector to unit norm to avoid problems in the caller code.
* Computing the reciprocal is undesirable but
* * xLASCL cannot be used because of the vector increments and
* * the round-off error has a negligible impact on
* orthogonalization.
CALL CSCAL( M1, ONE / NORM, X1, INCX1 )
CALL CSCAL( M2, ONE / NORM, X2, INCX2 )
CALL CUNBDB6( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,
$ LDQ2, WORK, LWORK, CHILDINFO )
*
Expand Down
9 changes: 8 additions & 1 deletion SRC/dorbdb5.f
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ SUBROUTINE DORBDB5( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,
DOUBLE PRECISION EPS, NORM, SCL, SSQ
* ..
* .. External Subroutines ..
EXTERNAL DLASSQ, DORBDB6, XERBLA
EXTERNAL DLASSQ, DORBDB6, DSCAL, XERBLA
* ..
* .. External Functions ..
DOUBLE PRECISION DLAMCH, DNRM2
Expand Down Expand Up @@ -227,6 +227,13 @@ SUBROUTINE DORBDB5( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,
NORM = SCL * SQRT( SSQ )
*
IF( NORM .GT. N * EPS ) THEN
* Scale vector to unit norm to avoid problems in the caller code.
* Computing the reciprocal is undesirable but
* * xLASCL cannot be used because of the vector increments and
* * the round-off error has a negligible impact on
* orthogonalization.
CALL DSCAL( M1, ONE / NORM, X1, INCX1 )
CALL DSCAL( M2, ONE / NORM, X2, INCX2 )
CALL DORBDB6( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,
$ LDQ2, WORK, LWORK, CHILDINFO )
*
Expand Down
9 changes: 8 additions & 1 deletion SRC/sorbdb5.f
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ SUBROUTINE SORBDB5( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,
REAL EPS, NORM, SCL, SSQ
* ..
* .. External Subroutines ..
EXTERNAL SLASSQ, SORBDB6, XERBLA
EXTERNAL SLASSQ, SORBDB6, SSCAL, XERBLA
* ..
* .. External Functions ..
REAL SLAMCH, SNRM2
Expand Down Expand Up @@ -227,6 +227,13 @@ SUBROUTINE SORBDB5( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,
NORM = SCL * SQRT( SSQ )
*
IF( NORM .GT. N * EPS ) THEN
* Scale vector to unit norm to avoid problems in the caller code.
* Computing the reciprocal is undesirable but
* * xLASCL cannot be used because of the vector increments and
* * the round-off error has a negligible impact on
* orthogonalization.
CALL SSCAL( M1, ONE / NORM, X1, INCX1 )
CALL SSCAL( M2, ONE / NORM, X2, INCX2 )
CALL SORBDB6( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,
$ LDQ2, WORK, LWORK, CHILDINFO )
*
Expand Down
9 changes: 8 additions & 1 deletion SRC/zunbdb5.f
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ SUBROUTINE ZUNBDB5( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,
DOUBLE PRECISION EPS, NORM, SCL, SSQ
* ..
* .. External Subroutines ..
EXTERNAL ZLASSQ, ZUNBDB6, XERBLA
EXTERNAL ZLASSQ, ZUNBDB6, ZSCAL, XERBLA
* ..
* .. External Functions ..
DOUBLE PRECISION DLAMCH, DZNRM2
Expand Down Expand Up @@ -227,6 +227,13 @@ SUBROUTINE ZUNBDB5( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,
NORM = SCL * SQRT( SSQ )
*
IF( NORM .GT. N * EPS ) THEN
* Scale vector to unit norm to avoid problems in the caller code.
* Computing the reciprocal is undesirable but
* * xLASCL cannot be used because of the vector increments and
* * the round-off error has a negligible impact on
* orthogonalization.
CALL ZSCAL( M1, ONE / NORM, X1, INCX1 )
CALL ZSCAL( M2, ONE / NORM, X2, INCX2 )
CALL ZUNBDB6( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,
$ LDQ2, WORK, LWORK, CHILDINFO )
*
Expand Down

0 comments on commit 5b0bc5e

Please sign in to comment.