Skip to content

Commit

Permalink
handle corner case of lwork in evr/evr_2stage and fix output format i…
Browse files Browse the repository at this point in the history
…n chkxer
  • Loading branch information
dklyuchinskiy committed Dec 4, 2023
1 parent f15520d commit 8cba9e5
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 65 deletions.
31 changes: 20 additions & 11 deletions SRC/cheevr.f
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@
*> \param[in] LWORK
*> \verbatim
*> LWORK is INTEGER
*> The length of the array WORK. LWORK >= max(1,2*N).
*> The length of the array WORK.
*> If N <= 1, LWORK >= 1, else LWORK >= 2*N.
*> For optimal efficiency, LWORK >= (NB+1)*N,
*> where NB is the max of the blocksize for CHETRD and for
*> CUNMTR as returned by ILAENV.
Expand All @@ -294,7 +295,8 @@
*> \param[in] LRWORK
*> \verbatim
*> LRWORK is INTEGER
*> The length of the array RWORK. LRWORK >= max(1,24*N).
*> The length of the array RWORK.
*> If N <= 1, LRWORK >= 1, else LRWORK >= 24*N.
*>
*> If LRWORK = -1, then a workspace query is assumed; the
*> routine only calculates the optimal sizes of the WORK, RWORK
Expand All @@ -313,7 +315,8 @@
*> \param[in] LIWORK
*> \verbatim
*> LIWORK is INTEGER
*> The dimension of the array IWORK. LIWORK >= max(1,10*N).
*> The dimension of the array IWORK.
*> If N <= 1, LIWORK >= 1, else LIWORK >= 10*N.
*>
*> If LIWORK = -1, then a workspace query is assumed; the
*> routine only calculates the optimal sizes of the WORK, RWORK
Expand Down Expand Up @@ -417,9 +420,15 @@ SUBROUTINE CHEEVR( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU,
LQUERY = ( ( LWORK.EQ.-1 ) .OR. ( LRWORK.EQ.-1 ) .OR.
$ ( LIWORK.EQ.-1 ) )
*
LRWMIN = MAX( 1, 24*N )
LIWMIN = MAX( 1, 10*N )
LWMIN = MAX( 1, 2*N )
IF( N.LE.1 ) THEN
LWMIN = 1
LRWMIN = 1
LIWMIN = 1

Check warning on line 426 in SRC/cheevr.f

View check run for this annotation

Codecov / codecov/patch

SRC/cheevr.f#L423-L426

Added lines #L423 - L426 were not covered by tests
ELSE
LWMIN = 2*N
LRWMIN = 24*N
LIWMIN = 10*N

Check warning on line 430 in SRC/cheevr.f

View check run for this annotation

Codecov / codecov/patch

SRC/cheevr.f#L428-L430

Added lines #L428 - L430 were not covered by tests
END IF
*
INFO = 0
IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
Expand Down Expand Up @@ -454,8 +463,8 @@ SUBROUTINE CHEEVR( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU,
NB = ILAENV( 1, 'CHETRD', UPLO, N, -1, -1, -1 )
NB = MAX( NB, ILAENV( 1, 'CUNMTR', UPLO, N, -1, -1, -1 ) )
LWKOPT = MAX( ( NB+1 )*N, LWMIN )
WORK( 1 ) = SROUNDUP_LWORK(LWKOPT)
RWORK( 1 ) = LRWMIN
WORK( 1 ) = SROUNDUP_LWORK( LWKOPT )
RWORK( 1 ) = SROUNDUP_LWORK( LRWMIN )

Check warning on line 467 in SRC/cheevr.f

View check run for this annotation

Codecov / codecov/patch

SRC/cheevr.f#L466-L467

Added lines #L466 - L467 were not covered by tests
IWORK( 1 ) = LIWMIN
*
IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
Expand Down Expand Up @@ -483,7 +492,7 @@ SUBROUTINE CHEEVR( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU,
END IF
*
IF( N.EQ.1 ) THEN
WORK( 1 ) = 2
WORK( 1 ) = 1

Check warning on line 495 in SRC/cheevr.f

View check run for this annotation

Codecov / codecov/patch

SRC/cheevr.f#L495

Added line #L495 was not covered by tests
IF( ALLEIG .OR. INDEIG ) THEN
M = 1
W( 1 ) = REAL( A( 1, 1 ) )
Expand Down Expand Up @@ -710,8 +719,8 @@ SUBROUTINE CHEEVR( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU,
*
* Set WORK(1) to optimal workspace size.
*
WORK( 1 ) = SROUNDUP_LWORK(LWKOPT)
RWORK( 1 ) = LRWMIN
WORK( 1 ) = SROUNDUP_LWORK( LWKOPT )
RWORK( 1 ) = SROUNDUP_LWORK( LRWMIN )

Check warning on line 723 in SRC/cheevr.f

View check run for this annotation

Codecov / codecov/patch

SRC/cheevr.f#L722-L723

Added lines #L722 - L723 were not covered by tests
IWORK( 1 ) = LIWMIN
*
RETURN
Expand Down
26 changes: 18 additions & 8 deletions SRC/cheevr_2stage.f
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@
*> \verbatim
*> LWORK is INTEGER
*> The dimension of the array WORK.
*> If N <= 1, LWORK must be at least 1.
*> If JOBZ = 'N' and N > 1, LWORK must be queried.
*> LWORK = MAX(1, 26*N, dimension) where
*> dimension = max(stage1,stage2) + (KD+1)*N + N
Expand Down Expand Up @@ -310,7 +311,8 @@
*> \param[in] LRWORK
*> \verbatim
*> LRWORK is INTEGER
*> The length of the array RWORK. LRWORK >= max(1,24*N).
*> The length of the array RWORK.
*> If N <= 1, LRWORK >= 1, else LRWORK >= 24*N.
*>
*> If LRWORK = -1, then a workspace query is assumed; the
*> routine only calculates the optimal sizes of the WORK, RWORK
Expand All @@ -329,7 +331,8 @@
*> \param[in] LIWORK
*> \verbatim
*> LIWORK is INTEGER
*> The dimension of the array IWORK. LIWORK >= max(1,10*N).
*> The dimension of the array IWORK.
*> If N <= 1, LIWORK >= 1, else LIWORK >= 10*N.
*>
*> If LIWORK = -1, then a workspace query is assumed; the
*> routine only calculates the optimal sizes of the WORK, RWORK
Expand Down Expand Up @@ -473,9 +476,16 @@ SUBROUTINE CHEEVR_2STAGE( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU,
IB = ILAENV2STAGE( 2, 'CHETRD_2STAGE', JOBZ, N, KD, -1, -1 )
LHTRD = ILAENV2STAGE( 3, 'CHETRD_2STAGE', JOBZ, N, KD, IB, -1 )
LWTRD = ILAENV2STAGE( 4, 'CHETRD_2STAGE', JOBZ, N, KD, IB, -1 )
LWMIN = N + LHTRD + LWTRD
LRWMIN = MAX( 1, 24*N )
LIWMIN = MAX( 1, 10*N )
*
IF( N.LE.1 ) THEN
LWMIN = 1
LRWMIN = 1
LIWMIN = 1

Check warning on line 483 in SRC/cheevr_2stage.f

View check run for this annotation

Codecov / codecov/patch

SRC/cheevr_2stage.f#L480-L483

Added lines #L480 - L483 were not covered by tests
ELSE
LWMIN = N + LHTRD + LWTRD
LRWMIN = 24*N
LIWMIN = 10*N

Check warning on line 487 in SRC/cheevr_2stage.f

View check run for this annotation

Codecov / codecov/patch

SRC/cheevr_2stage.f#L485-L487

Added lines #L485 - L487 were not covered by tests
END IF
*
INFO = 0
IF( .NOT.( LSAME( JOBZ, 'N' ) ) ) THEN
Expand Down Expand Up @@ -508,7 +518,7 @@ SUBROUTINE CHEEVR_2STAGE( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU,
*
IF( INFO.EQ.0 ) THEN
WORK( 1 ) = SROUNDUP_LWORK( LWMIN )
RWORK( 1 ) = LRWMIN
RWORK( 1 ) = SROUNDUP_LWORK( LRWMIN )

Check warning on line 521 in SRC/cheevr_2stage.f

View check run for this annotation

Codecov / codecov/patch

SRC/cheevr_2stage.f#L520-L521

Added lines #L520 - L521 were not covered by tests
IWORK( 1 ) = LIWMIN
*
IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
Expand Down Expand Up @@ -536,7 +546,7 @@ SUBROUTINE CHEEVR_2STAGE( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU,
END IF
*
IF( N.EQ.1 ) THEN
WORK( 1 ) = 2
WORK( 1 ) = 1

Check warning on line 549 in SRC/cheevr_2stage.f

View check run for this annotation

Codecov / codecov/patch

SRC/cheevr_2stage.f#L549

Added line #L549 was not covered by tests
IF( ALLEIG .OR. INDEIG ) THEN
M = 1
W( 1 ) = REAL( A( 1, 1 ) )
Expand Down Expand Up @@ -767,7 +777,7 @@ SUBROUTINE CHEEVR_2STAGE( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU,
* Set WORK(1) to optimal workspace size.
*
WORK( 1 ) = SROUNDUP_LWORK( LWMIN )
RWORK( 1 ) = LRWMIN
RWORK( 1 ) = SROUNDUP_LWORK( LRWMIN )

Check warning on line 780 in SRC/cheevr_2stage.f

View check run for this annotation

Codecov / codecov/patch

SRC/cheevr_2stage.f#L779-L780

Added lines #L779 - L780 were not covered by tests
IWORK( 1 ) = LIWMIN
*
RETURN
Expand Down
19 changes: 13 additions & 6 deletions SRC/dsyevr.f
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@
*> \param[in] LWORK
*> \verbatim
*> LWORK is INTEGER
*> The dimension of the array WORK. LWORK >= max(1,26*N).
*> The dimension of the array WORK.
*> If N <= 1, LWORK >= 1, else LWORK >= 26*N.
*> For optimal efficiency, LWORK >= (NB+6)*N,
*> where NB is the max of the blocksize for DSYTRD and DORMTR
*> returned by ILAENV.
Expand All @@ -285,13 +286,14 @@
*> \param[out] IWORK
*> \verbatim
*> IWORK is INTEGER array, dimension (MAX(1,LIWORK))
*> On exit, if INFO = 0, IWORK(1) returns the optimal LWORK.
*> On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
*> \endverbatim
*>
*> \param[in] LIWORK
*> \verbatim
*> LIWORK is INTEGER
*> The dimension of the array IWORK. LIWORK >= max(1,10*N).
*> The dimension of the array IWORK.
*> If N <= 1, LIWORK >= 1, else LIWORK >= 10*N.
*>
*> If LIWORK = -1, then a workspace query is assumed; the
*> routine only calculates the optimal size of the IWORK array,
Expand Down Expand Up @@ -390,8 +392,13 @@ SUBROUTINE DSYEVR( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU,
*
LQUERY = ( ( LWORK.EQ.-1 ) .OR. ( LIWORK.EQ.-1 ) )
*
LWMIN = MAX( 1, 26*N )
LIWMIN = MAX( 1, 10*N )
IF( N.LE.1 ) THEN
LWMIN = 1
LIWMIN = 1

Check warning on line 397 in SRC/dsyevr.f

View check run for this annotation

Codecov / codecov/patch

SRC/dsyevr.f#L395-L397

Added lines #L395 - L397 were not covered by tests
ELSE
LWMIN = 26*N
LIWMIN = 10*N

Check warning on line 400 in SRC/dsyevr.f

View check run for this annotation

Codecov / codecov/patch

SRC/dsyevr.f#L399-L400

Added lines #L399 - L400 were not covered by tests
END IF
*
INFO = 0
IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
Expand Down Expand Up @@ -450,7 +457,7 @@ SUBROUTINE DSYEVR( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU,
END IF
*
IF( N.EQ.1 ) THEN
WORK( 1 ) = 7
WORK( 1 ) = 1

Check warning on line 460 in SRC/dsyevr.f

View check run for this annotation

Codecov / codecov/patch

SRC/dsyevr.f#L460

Added line #L460 was not covered by tests
IF( ALLEIG .OR. INDEIG ) THEN
M = 1
W( 1 ) = A( 1, 1 )
Expand Down
4 changes: 2 additions & 2 deletions SRC/dsyevr_2stage.f
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ SUBROUTINE DSYEVR_2STAGE( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU,
* NB = ILAENV( 1, 'DSYTRD', UPLO, N, -1, -1, -1 )
* NB = MAX( NB, ILAENV( 1, 'DORMTR', UPLO, N, -1, -1, -1 ) )
* LWKOPT = MAX( ( NB+1 )*N, LWMIN )
WORK( 1 ) = LWMIN
WORK( 1 ) = LWMIN

Check warning on line 495 in SRC/dsyevr_2stage.f

View check run for this annotation

Codecov / codecov/patch

SRC/dsyevr_2stage.f#L495

Added line #L495 was not covered by tests
IWORK( 1 ) = LIWMIN
END IF
*
Expand Down Expand Up @@ -735,7 +735,7 @@ SUBROUTINE DSYEVR_2STAGE( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU,
*
* Set WORK(1) to optimal workspace size.
*
WORK( 1 ) = LWMIN
WORK( 1 ) = LWMIN

Check warning on line 738 in SRC/dsyevr_2stage.f

View check run for this annotation

Codecov / codecov/patch

SRC/dsyevr_2stage.f#L738

Added line #L738 was not covered by tests
IWORK( 1 ) = LIWMIN
*
RETURN
Expand Down
15 changes: 11 additions & 4 deletions SRC/ssyevr.f
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@
*> \param[in] LWORK
*> \verbatim
*> LWORK is INTEGER
*> The dimension of the array WORK. LWORK >= max(1,26*N).
*> The dimension of the array WORK.
*> If N <= 1, LWORK >= 1, else LWORK >= 26*N.
*> For optimal efficiency, LWORK >= (NB+6)*N,
*> where NB is the max of the blocksize for SSYTRD and SORMTR
*> returned by ILAENV.
Expand All @@ -292,7 +293,8 @@
*> \param[in] LIWORK
*> \verbatim
*> LIWORK is INTEGER
*> The dimension of the array IWORK. LIWORK >= max(1,10*N).
*> The dimension of the array IWORK.
*> If N <= 1, LIWORK >= 1, else LIWORK >= 10*N.
*>
*> If LIWORK = -1, then a workspace query is assumed; the
*> routine only calculates the optimal sizes of the WORK and
Expand Down Expand Up @@ -392,8 +394,13 @@ SUBROUTINE SSYEVR( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU,
*
LQUERY = ( ( LWORK.EQ.-1 ) .OR. ( LIWORK.EQ.-1 ) )
*
LWMIN = MAX( 1, 26*N )
LIWMIN = MAX( 1, 10*N )
IF( N.LE.1 ) THEN
LWMIN = 1
LIWMIN = 1

Check warning on line 399 in SRC/ssyevr.f

View check run for this annotation

Codecov / codecov/patch

SRC/ssyevr.f#L397-L399

Added lines #L397 - L399 were not covered by tests
ELSE
LWMIN = 26*N
LIWMIN = 10*N

Check warning on line 402 in SRC/ssyevr.f

View check run for this annotation

Codecov / codecov/patch

SRC/ssyevr.f#L401-L402

Added lines #L401 - L402 were not covered by tests
END IF
*
INFO = 0
IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
Expand Down
4 changes: 2 additions & 2 deletions SRC/ssyevr_2stage.f
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ SUBROUTINE SSYEVR_2STAGE( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU,
* NB = ILAENV( 1, 'SSYTRD', UPLO, N, -1, -1, -1 )
* NB = MAX( NB, ILAENV( 1, 'SORMTR', UPLO, N, -1, -1, -1 ) )
* LWKOPT = MAX( ( NB+1 )*N, LWMIN )
WORK( 1 ) = SROUNDUP_LWORK( LWMIN )
WORK( 1 ) = SROUNDUP_LWORK( LWMIN )

Check warning on line 496 in SRC/ssyevr_2stage.f

View check run for this annotation

Codecov / codecov/patch

SRC/ssyevr_2stage.f#L496

Added line #L496 was not covered by tests
IWORK( 1 ) = LIWMIN
END IF
*
Expand Down Expand Up @@ -741,7 +741,7 @@ SUBROUTINE SSYEVR_2STAGE( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU,
*
* Set WORK(1) to optimal workspace size.
*
WORK( 1 ) = SROUNDUP_LWORK( LWMIN )
WORK( 1 ) = SROUNDUP_LWORK( LWMIN )

Check warning on line 744 in SRC/ssyevr_2stage.f

View check run for this annotation

Codecov / codecov/patch

SRC/ssyevr_2stage.f#L744

Added line #L744 was not covered by tests
IWORK( 1 ) = LIWMIN
*
RETURN
Expand Down
27 changes: 18 additions & 9 deletions SRC/zheevr.f
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@
*> \param[in] LWORK
*> \verbatim
*> LWORK is INTEGER
*> The length of the array WORK. LWORK >= max(1,2*N).
*> The length of the array WORK.
*> If N <= 1, LWORK >= 1, else LWORK >= 2*N.
*> For optimal efficiency, LWORK >= (NB+1)*N,
*> where NB is the max of the blocksize for ZHETRD and for
*> ZUNMTR as returned by ILAENV.
Expand All @@ -294,7 +295,8 @@
*> \param[in] LRWORK
*> \verbatim
*> LRWORK is INTEGER
*> The length of the array RWORK. LRWORK >= max(1,24*N).
*> The length of the array RWORK.
*> If N <= 1, LRWORK >= 1, else LRWORK >= 24*N.
*>
*> If LRWORK = -1, then a workspace query is assumed; the
*> routine only calculates the optimal sizes of the WORK, RWORK
Expand All @@ -313,7 +315,8 @@
*> \param[in] LIWORK
*> \verbatim
*> LIWORK is INTEGER
*> The dimension of the array IWORK. LIWORK >= max(1,10*N).
*> The dimension of the array IWORK.
*> If N <= 1, LIWORK >= 1, else LIWORK >= 10*N.
*>
*> If LIWORK = -1, then a workspace query is assumed; the
*> routine only calculates the optimal sizes of the WORK, RWORK
Expand Down Expand Up @@ -417,9 +420,15 @@ SUBROUTINE ZHEEVR( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU,
LQUERY = ( ( LWORK.EQ.-1 ) .OR. ( LRWORK.EQ.-1 ) .OR.
$ ( LIWORK.EQ.-1 ) )
*
LRWMIN = MAX( 1, 24*N )
LIWMIN = MAX( 1, 10*N )
LWMIN = MAX( 1, 2*N )
IF( N.LE.1 ) THEN
LWMIN = 1
LRWMIN = 1
LIWMIN = 1

Check warning on line 426 in SRC/zheevr.f

View check run for this annotation

Codecov / codecov/patch

SRC/zheevr.f#L423-L426

Added lines #L423 - L426 were not covered by tests
ELSE
LWMIN = 2*N
LRWMIN = 24*N
LIWMIN = 10*N

Check warning on line 430 in SRC/zheevr.f

View check run for this annotation

Codecov / codecov/patch

SRC/zheevr.f#L428-L430

Added lines #L428 - L430 were not covered by tests
END IF
*
INFO = 0
IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
Expand Down Expand Up @@ -454,7 +463,7 @@ SUBROUTINE ZHEEVR( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU,
NB = ILAENV( 1, 'ZHETRD', UPLO, N, -1, -1, -1 )
NB = MAX( NB, ILAENV( 1, 'ZUNMTR', UPLO, N, -1, -1, -1 ) )
LWKOPT = MAX( ( NB+1 )*N, LWMIN )
WORK( 1 ) = LWKOPT
WORK( 1 ) = LWKOPT

Check warning on line 466 in SRC/zheevr.f

View check run for this annotation

Codecov / codecov/patch

SRC/zheevr.f#L466

Added line #L466 was not covered by tests
RWORK( 1 ) = LRWMIN
IWORK( 1 ) = LIWMIN
*
Expand Down Expand Up @@ -483,7 +492,7 @@ SUBROUTINE ZHEEVR( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU,
END IF
*
IF( N.EQ.1 ) THEN
WORK( 1 ) = 2
WORK( 1 ) = 1

Check warning on line 495 in SRC/zheevr.f

View check run for this annotation

Codecov / codecov/patch

SRC/zheevr.f#L495

Added line #L495 was not covered by tests
IF( ALLEIG .OR. INDEIG ) THEN
M = 1
W( 1 ) = DBLE( A( 1, 1 ) )
Expand Down Expand Up @@ -710,7 +719,7 @@ SUBROUTINE ZHEEVR( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU,
*
* Set WORK(1) to optimal workspace size.
*
WORK( 1 ) = LWKOPT
WORK( 1 ) = LWKOPT

Check warning on line 722 in SRC/zheevr.f

View check run for this annotation

Codecov / codecov/patch

SRC/zheevr.f#L722

Added line #L722 was not covered by tests
RWORK( 1 ) = LRWMIN
IWORK( 1 ) = LIWMIN
*
Expand Down
Loading

0 comments on commit 8cba9e5

Please sign in to comment.