Skip to content

Commit

Permalink
add missed usage of sroundup_lwork in several functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dklyuchinskiy committed Dec 4, 2023
1 parent cd7523d commit 280e161
Show file tree
Hide file tree
Showing 25 changed files with 42 additions and 32 deletions.
2 changes: 1 addition & 1 deletion SRC/cgehrd.f
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ SUBROUTINE CGEHRD( N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO )
*
* Determine if workspace is large enough for blocked code
*
IF( LWORK.LT.N*NB+TSIZE ) THEN
IF( LWORK.LT.LWKOPT ) THEN
*
* Not enough workspace to use optimal NB: determine the
* minimum value of NB, and reduce NB or force use of
Expand Down
2 changes: 1 addition & 1 deletion SRC/cgeqr.f
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ SUBROUTINE CGEQR( M, N, A, LDA, T, TSIZE, WORK, LWORK,
ELSE IF( TSIZE.LT.MAX( 1, NB*N*NBLCKS + 5 )
$ .AND. ( .NOT.LQUERY ) .AND. ( .NOT.LMINWS ) ) THEN
INFO = -6
ELSE IF( ( LWORK.LT.MAX( 1, N*NB ) ) .AND. ( .NOT.LQUERY )
ELSE IF( ( LWORK.LT.LWREQ ) .AND. ( .NOT.LQUERY )
$ .AND. ( .NOT.LMINWS ) ) THEN
INFO = -8
END IF
Expand Down
10 changes: 5 additions & 5 deletions SRC/cgesvdx.f
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
*> \param[out] WORK
*> \verbatim
*> WORK is COMPLEX array, dimension (MAX(1,LWORK))
*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK;
*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
*> \endverbatim
*>
*> \param[in] LWORK
Expand Down Expand Up @@ -312,8 +312,8 @@ SUBROUTINE CGESVDX( JOBU, JOBVT, RANGE, M, N, A, LDA, VL, VU,
* .. External Functions ..
LOGICAL LSAME
INTEGER ILAENV
REAL SLAMCH, CLANGE
EXTERNAL LSAME, ILAENV, SLAMCH, CLANGE
REAL SLAMCH, CLANGE, SROUNDUP_LWORK
EXTERNAL LSAME, ILAENV, SLAMCH, CLANGE, SROUNDUP_LWORK
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX, MIN, SQRT
Expand Down Expand Up @@ -448,7 +448,7 @@ SUBROUTINE CGESVDX( JOBU, JOBVT, RANGE, M, N, A, LDA, VL, VU,
END IF
END IF
MAXWRK = MAX( MAXWRK, MINWRK )
WORK( 1 ) = CMPLX( REAL( MAXWRK ), ZERO )
WORK( 1 ) = SROUNDUP_LWORK( MAXWRK )
*
IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
INFO = -19
Expand Down Expand Up @@ -846,7 +846,7 @@ SUBROUTINE CGESVDX( JOBU, JOBVT, RANGE, M, N, A, LDA, VL, VU,
*
* Return optimal workspace in WORK(1)
*
WORK( 1 ) = CMPLX( REAL( MAXWRK ), ZERO )
WORK( 1 ) = SROUNDUP_LWORK( MAXWRK )
*
RETURN
*
Expand Down
3 changes: 2 additions & 1 deletion SRC/cgghd3.f
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,8 @@ SUBROUTINE CGGHD3( COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB, Q,
IF ( JCOL.LT.IHI )
$ CALL CGGHRD( COMPQ2, COMPZ2, N, JCOL, IHI, A, LDA, B, LDB, Q,
$ LDQ, Z, LDZ, IERR )
WORK( 1 ) = CMPLX( LWKOPT )
*
WORK( 1 ) = SROUNDUP_LWORK( LWKOPT )
*
RETURN
*
Expand Down
8 changes: 4 additions & 4 deletions SRC/cheevd.f
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ SUBROUTINE CHEEVD( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, RWORK,
LROPT = LRWMIN
LIOPT = LIWMIN
END IF
WORK( 1 ) = SROUNDUP_LWORK(LOPT)
RWORK( 1 ) = LROPT
WORK( 1 ) = SROUNDUP_LWORK( LOPT )
RWORK( 1 ) = SROUNDUP_LWORK( LROPT )
IWORK( 1 ) = LIOPT
*
IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
Expand Down Expand Up @@ -377,8 +377,8 @@ SUBROUTINE CHEEVD( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, RWORK,
CALL SSCAL( IMAX, ONE / SIGMA, W, 1 )
END IF
*
WORK( 1 ) = SROUNDUP_LWORK(LOPT)
RWORK( 1 ) = LROPT
WORK( 1 ) = SROUNDUP_LWORK( LOPT )
RWORK( 1 ) = SROUNDUP_LWORK( LROPT )
IWORK( 1 ) = LIOPT
*
RETURN
Expand Down
2 changes: 1 addition & 1 deletion SRC/chetrf.f
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ SUBROUTINE CHETRF( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
* Determine the block size
*
NB = ILAENV( 1, 'CHETRF', UPLO, N, -1, -1, -1 )
LWKOPT = N*NB
LWKOPT = MAX( 1, N*NB )
WORK( 1 ) = SROUNDUP_LWORK( LWKOPT )
END IF
*
Expand Down
2 changes: 1 addition & 1 deletion SRC/chetrf_rk.f
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ SUBROUTINE CHETRF_RK( UPLO, N, A, LDA, E, IPIV, WORK, LWORK,
* Determine the block size
*
NB = ILAENV( 1, 'CHETRF_RK', UPLO, N, -1, -1, -1 )
LWKOPT = N*NB
LWKOPT = MAX( 1, N*NB )
WORK( 1 ) = SROUNDUP_LWORK( LWKOPT )
END IF
*
Expand Down
5 changes: 3 additions & 2 deletions SRC/chetri2.f
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ SUBROUTINE CHETRI2( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
INFO = -2
ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
INFO = -4
ELSE IF ( LWORK.LT.MINSIZE .AND. .NOT.LQUERY ) THEN
ELSE IF( LWORK.LT.MINSIZE .AND. .NOT.LQUERY ) THEN
INFO = -7
END IF
*
Expand All @@ -195,11 +195,12 @@ SUBROUTINE CHETRI2( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
IF( N.EQ.0 )
$ RETURN

IF( NBMAX .GE. N ) THEN
IF( NBMAX.GE.N ) THEN
CALL CHETRI( UPLO, N, A, LDA, IPIV, WORK, INFO )
ELSE
CALL CHETRI2X( UPLO, N, A, LDA, IPIV, WORK, NBMAX, INFO )
END IF
*
RETURN
*
* End of CHETRI2
Expand Down
2 changes: 1 addition & 1 deletion SRC/chetrs_aa.f
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ SUBROUTINE CHETRS_AA( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
*
* Quick return if possible
*
IF( N.EQ.0 .OR. NRHS.EQ.0 )
IF( MIN( N, NRHS ).EQ.0 )
$ RETURN
*
IF( UPPER ) THEN
Expand Down
2 changes: 1 addition & 1 deletion SRC/dgehrd.f
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ SUBROUTINE DGEHRD( N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO )
*
* Determine if workspace is large enough for blocked code
*
IF( LWORK.LT.N*NB+TSIZE ) THEN
IF( LWORK.LT.LWKOPT ) THEN
*
* Not enough workspace to use optimal NB: determine the
* minimum value of NB, and reduce NB or force use of
Expand Down
1 change: 1 addition & 0 deletions SRC/dgghd3.f
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,7 @@ SUBROUTINE DGGHD3( COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB, Q,
IF ( JCOL.LT.IHI )
$ CALL DGGHRD( COMPQ2, COMPZ2, N, JCOL, IHI, A, LDA, B, LDB, Q,
$ LDQ, Z, LDZ, IERR )
*
WORK( 1 ) = DBLE( LWKOPT )
*
RETURN
Expand Down
1 change: 1 addition & 0 deletions SRC/dsytrf.f
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ SUBROUTINE DSYTRF( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
END IF
*
40 CONTINUE
*
WORK( 1 ) = LWKOPT
RETURN
*
Expand Down
7 changes: 4 additions & 3 deletions SRC/dsytri2.f
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ SUBROUTINE DSYTRI2( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
NBMAX = ILAENV( 1, 'DSYTRI2', UPLO, N, -1, -1, -1 )
IF( N.EQ.0 ) THEN
MINSIZE = 1
ELSE IF ( NBMAX.GE.N ) THEN
ELSE IF( NBMAX.GE.N ) THEN
MINSIZE = N
ELSE
MINSIZE = (N+NBMAX+1)*(NBMAX+3)
Expand All @@ -177,7 +177,7 @@ SUBROUTINE DSYTRI2( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
INFO = -2
ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
INFO = -4
ELSE IF ( LWORK.LT.MINSIZE .AND. .NOT.LQUERY ) THEN
ELSE IF( LWORK.LT.MINSIZE .AND. .NOT.LQUERY ) THEN
INFO = -7
END IF
*
Expand All @@ -194,11 +194,12 @@ SUBROUTINE DSYTRI2( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
IF( N.EQ.0 )
$ RETURN

IF( NBMAX .GE. N ) THEN
IF( NBMAX.GE.N ) THEN
CALL DSYTRI( UPLO, N, A, LDA, IPIV, WORK, INFO )
ELSE
CALL DSYTRI2X( UPLO, N, A, LDA, IPIV, WORK, NBMAX, INFO )
END IF
*
RETURN
*
* End of DSYTRI2
Expand Down
2 changes: 1 addition & 1 deletion SRC/sgehrd.f
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ SUBROUTINE SGEHRD( N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO )
*
* Determine if workspace is large enough for blocked code
*
IF( LWORK.LT.N*NB+TSIZE ) THEN
IF( LWORK.LT.LWKOPT ) THEN
*
* Not enough workspace to use optimal NB: determine the
* minimum value of NB, and reduce NB or force use of
Expand Down
2 changes: 1 addition & 1 deletion SRC/sgeqp3rk.f
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ SUBROUTINE SGEQP3RK( M, N, NRHS, KMAX, ABSTOL, RELTOL, A, LDA,
DO J = 1, MINMN
TAU( J ) = ZERO
END DO
WORK( 1 ) = REAL( LWKOPT )
WORK( 1 ) = SROUNDUP_LWORK( LWKOPT )
RETURN
END IF
*
Expand Down
5 changes: 3 additions & 2 deletions SRC/ssytrf.f
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ SUBROUTINE SSYTRF( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
*
NB = ILAENV( 1, 'SSYTRF', UPLO, N, -1, -1, -1 )
LWKOPT = MAX( 1, N*NB )
WORK( 1 ) = SROUNDUP_LWORK(LWKOPT)
WORK( 1 ) = SROUNDUP_LWORK( LWKOPT )
END IF
*
IF( INFO.NE.0 ) THEN
Expand Down Expand Up @@ -353,7 +353,8 @@ SUBROUTINE SSYTRF( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
END IF
*
40 CONTINUE
WORK( 1 ) = SROUNDUP_LWORK(LWKOPT)
*
WORK( 1 ) = SROUNDUP_LWORK( LWKOPT )
RETURN
*
* End of SSYTRF
Expand Down
1 change: 1 addition & 0 deletions SRC/ssytri2.f
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ SUBROUTINE SSYTRI2( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
ELSE
CALL SSYTRI2X( UPLO, N, A, LDA, IPIV, WORK, NBMAX, INFO )
END IF
*
RETURN
*
* End of SSYTRI2
Expand Down
2 changes: 1 addition & 1 deletion SRC/zgehrd.f
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ SUBROUTINE ZGEHRD( N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO )
*
* Determine if workspace is large enough for blocked code
*
IF( LWORK.LT.N*NB+TSIZE ) THEN
IF( LWORK.LT.LWKOPT ) THEN
*
* Not enough workspace to use optimal NB: determine the
* minimum value of NB, and reduce NB or force use of
Expand Down
2 changes: 1 addition & 1 deletion SRC/zgeqr.f
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ SUBROUTINE ZGEQR( M, N, A, LDA, T, TSIZE, WORK, LWORK,
ELSE IF( TSIZE.LT.MAX( 1, NB*N*NBLCKS + 5 )
$ .AND. ( .NOT.LQUERY ) .AND. ( .NOT.LMINWS ) ) THEN
INFO = -6
ELSE IF( ( LWORK.LT.MAX( 1, N*NB ) ) .AND. ( .NOT.LQUERY )
ELSE IF( ( LWORK.LT.LWREQ ) .AND. ( .NOT.LQUERY )
$ .AND. ( .NOT.LMINWS ) ) THEN
INFO = -8
END IF
Expand Down
1 change: 1 addition & 0 deletions SRC/zgghd3.f
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,7 @@ SUBROUTINE ZGGHD3( COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB, Q,
IF ( JCOL.LT.IHI )
$ CALL ZGGHRD( COMPQ2, COMPZ2, N, JCOL, IHI, A, LDA, B, LDB, Q,
$ LDQ, Z, LDZ, IERR )
*
WORK( 1 ) = DCMPLX( LWKOPT )
*
RETURN
Expand Down
3 changes: 2 additions & 1 deletion SRC/zhetrf.f
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ SUBROUTINE ZHETRF( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
* Determine the block size
*
NB = ILAENV( 1, 'ZHETRF', UPLO, N, -1, -1, -1 )
LWKOPT = N*NB
LWKOPT = MAX( 1, N*NB )
WORK( 1 ) = LWKOPT
END IF
*
Expand Down Expand Up @@ -346,6 +346,7 @@ SUBROUTINE ZHETRF( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
END IF
*
40 CONTINUE
*
WORK( 1 ) = LWKOPT
RETURN
*
Expand Down
2 changes: 1 addition & 1 deletion SRC/zhetrf_rk.f
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ SUBROUTINE ZHETRF_RK( UPLO, N, A, LDA, E, IPIV, WORK, LWORK,
* Determine the block size
*
NB = ILAENV( 1, 'ZHETRF_RK', UPLO, N, -1, -1, -1 )
LWKOPT = N*NB
LWKOPT = MAX( 1, N*NB )
WORK( 1 ) = LWKOPT
END IF
*
Expand Down
1 change: 1 addition & 0 deletions SRC/zhetri2.f
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ SUBROUTINE ZHETRI2( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
ELSE
CALL ZHETRI2X( UPLO, N, A, LDA, IPIV, WORK, NBMAX, INFO )
END IF
*
RETURN
*
* End of ZHETRI2
Expand Down
2 changes: 1 addition & 1 deletion SRC/zhetrs_aa.f
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ SUBROUTINE ZHETRS_AA( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
*
* Quick return if possible
*
IF( N.EQ.0 .OR. NRHS.EQ.0 )
IF( MIN( N, NRHS ).EQ.0 )
$ RETURN
*
IF( UPPER ) THEN
Expand Down
4 changes: 2 additions & 2 deletions SRC/zlatsqr.f
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
*> LWORK >= 1, if MIN(M,N) = 0, and LWORK >= NB*N, otherwise.
*>
*> If LWORK = -1, then a workspace query is assumed; the routine
*> only calculates the optimal size of the WORK array, returns
*> only calculates the minimal size of the WORK array, returns
*> this value as the first entry of the WORK array, and no error
*> message related to LWORK is issued by XERBLA.
*> \endverbatim
Expand Down Expand Up @@ -252,7 +252,7 @@ SUBROUTINE ZLATSQR( M, N, MB, NB, A, LDA, T, LDT, WORK,
RETURN
END IF
KK = MOD((M-N),(MB-N))
II=M-KK+1
II = M-KK+1
*
* Compute the QR factorization of the first block A(1:MB,1:N)
*
Expand Down

0 comments on commit 280e161

Please sign in to comment.