Skip to content

Commit efdff96

Browse files
committed
SRC: detect all-zero Y columns in GEDMD scaling
Add the missing all-zero column check to the JOBS='Y' scaling path in the GEDMD routines. The existing JOBS='S'/'C' path detects when all columns of X are zero and returns INFO=-8, but the corresponding JOBS='Y' path did not count zero columns of Y or return early when all Y columns are zero. Return INFO=-10 for the all-zero Y case, matching Y as the 10th argument and the existing SCCOLY error handling. Update the routine documentation to describe this condition.
1 parent 774b05d commit efdff96

4 files changed

Lines changed: 56 additions & 4 deletions

File tree

SRC/cgedmd.f90

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@
117117
!> 'Y' :: The data snapshots matrices X and Y are multiplied
118118
!> by a diagonal matrix D so that Y*D has unit
119119
!> nonzero columns (in the Euclidean 2-norm)
120+
!> If all columns of Y are zero, the procedure returns
121+
!> with INFO = -10.
120122
!> 'N' :: No data scaling.
121123
!> \endverbatim
122124
!.....
@@ -467,7 +469,8 @@
467469
!> \verbatim
468470
!> INFO (output) INTEGER
469471
!> -i < 0 :: On entry, the i-th argument had an
470-
!> illegal value
472+
!> illegal value. If JOBS == 'Y' and all columns
473+
!> of Y are zero, INFO = -10.
471474
!> = 0 :: Successful return.
472475
!> = 1 :: Void input. Quick exit (M=0 or N=0).
473476
!> = 2 :: The SVD computation of X did not converge.
@@ -833,6 +836,7 @@ SUBROUTINE CGEDMD( JOBS, JOBZ, JOBR, JOBF, WHTSVD, &
833836
! The columns of Y will be normalized.
834837
! To prevent overflows, the column norms of Y are
835838
! carefully computed using CLASSQ.
839+
K = 0
836840
DO i = 1, N
837841
!RWORK(i) = SCNRM2( M, Y(1,i), 1 )
838842
SSUM = ONE
@@ -868,8 +872,17 @@ SUBROUTINE CGEDMD( JOBS, JOBZ, JOBR, JOBF, WHTSVD, &
868872
END IF
869873
ELSE
870874
RWORK(i) = ZERO
875+
K = K + 1
871876
END IF
872877
END DO
878+
IF ( K == N ) THEN
879+
! All columns of Y are zero. Return error code -10.
880+
! (the 10th input variable had an illegal value)
881+
K = 0
882+
INFO = -10
883+
CALL XERBLA('CGEDMD',-INFO)
884+
RETURN
885+
END IF
873886
DO i = 1, N
874887
! Now, apply the same scaling to the columns of X.
875888
IF ( RWORK(i) > ZERO ) THEN

SRC/dgedmd.f90

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@
115115
!> 'Y' :: The data snapshots matrices X and Y are multiplied
116116
!> by a diagonal matrix D so that Y*D has unit
117117
!> nonzero columns (in the Euclidean 2-norm)
118+
!> If all columns of Y are zero, the procedure returns
119+
!> with INFO = -10.
118120
!> 'N' :: No data scaling.
119121
!> \endverbatim
120122
!.....
@@ -501,7 +503,8 @@
501503
!> \verbatim
502504
!> INFO (output) INTEGER
503505
!> -i < 0 :: On entry, the i-th argument had an
504-
!> illegal value
506+
!> illegal value. If JOBS == 'Y' and all columns
507+
!> of Y are zero, INFO = -10.
505508
!> = 0 :: Successful return.
506509
!> = 1 :: Void input. Quick exit (M=0 or N=0).
507510
!> = 2 :: The SVD computation of X did not converge.
@@ -854,6 +857,7 @@ SUBROUTINE DGEDMD( JOBS, JOBZ, JOBR, JOBF, WHTSVD, &
854857
! The columns of Y will be normalized.
855858
! To prevent overflows, the column norms of Y are
856859
! carefully computed using DLASSQ.
860+
K = 0
857861
DO i = 1, N
858862
!WORK(i) = DNRM2( M, Y(1,i), 1 )
859863
SSUM = ONE
@@ -889,8 +893,17 @@ SUBROUTINE DGEDMD( JOBS, JOBZ, JOBR, JOBF, WHTSVD, &
889893
END IF
890894
ELSE
891895
WORK(i) = ZERO
896+
K = K + 1
892897
END IF
893898
END DO
899+
IF ( K == N ) THEN
900+
! All columns of Y are zero. Return error code -10.
901+
! (the 10th input variable had an illegal value)
902+
K = 0
903+
INFO = -10
904+
CALL XERBLA('DGEDMD',-INFO)
905+
RETURN
906+
END IF
894907
DO i = 1, N
895908
! Now, apply the same scaling to the columns of X.
896909
IF ( WORK(i) > ZERO ) THEN

SRC/sgedmd.f90

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@
116116
!> 'Y' :: The data snapshots matrices X and Y are multiplied
117117
!> by a diagonal matrix D so that Y*D has unit
118118
!> nonzero columns (in the Euclidean 2-norm)
119+
!> If all columns of Y are zero, the procedure returns
120+
!> with INFO = -10.
119121
!> 'N' :: No data scaling.
120122
!> \endverbatim
121123
!.....
@@ -501,7 +503,8 @@
501503
!> \verbatim
502504
!> INFO (output) INTEGER
503505
!> -i < 0 :: On entry, the i-th argument had an
504-
!> illegal value
506+
!> illegal value. If JOBS == 'Y' and all columns
507+
!> of Y are zero, INFO = -10.
505508
!> = 0 :: Successful return.
506509
!> = 1 :: Void input. Quick exit (M=0 or N=0).
507510
!> = 2 :: The SVD computation of X did not converge.
@@ -854,6 +857,7 @@ SUBROUTINE SGEDMD( JOBS, JOBZ, JOBR, JOBF, WHTSVD, &
854857
! The columns of Y will be normalized.
855858
! To prevent overflows, the column norms of Y are
856859
! carefully computed using SLASSQ.
860+
K = 0
857861
DO i = 1, N
858862
!WORK(i) = DNRM2( M, Y(1,i), 1 )
859863
SSUM = ONE
@@ -889,8 +893,17 @@ SUBROUTINE SGEDMD( JOBS, JOBZ, JOBR, JOBF, WHTSVD, &
889893
END IF
890894
ELSE
891895
WORK(i) = ZERO
896+
K = K + 1
892897
END IF
893898
END DO
899+
IF ( K == N ) THEN
900+
! All columns of Y are zero. Return error code -10.
901+
! (the 10th input variable had an illegal value)
902+
K = 0
903+
INFO = -10
904+
CALL XERBLA('SGEDMD',-INFO)
905+
RETURN
906+
END IF
894907
DO i = 1, N
895908
! Now, apply the same scaling to the columns of X.
896909
IF ( WORK(i) > ZERO ) THEN

SRC/zgedmd.f90

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@
117117
!> 'Y' :: The data snapshots matrices X and Y are multiplied
118118
!> by a diagonal matrix D so that Y*D has unit
119119
!> nonzero columns (in the Euclidean 2-norm)
120+
!> If all columns of Y are zero, the procedure returns
121+
!> with INFO = -10.
120122
!> 'N' :: No data scaling.
121123
!> \endverbatim
122124
!.....
@@ -467,7 +469,8 @@
467469
!> \verbatim
468470
!> INFO (output) INTEGER
469471
!> -i < 0 :: On entry, the i-th argument had an
470-
!> illegal value
472+
!> illegal value. If JOBS == 'Y' and all columns
473+
!> of Y are zero, INFO = -10.
471474
!> = 0 :: Successful return.
472475
!> = 1 :: Void input. Quick exit (M=0 or N=0).
473476
!> = 2 :: The SVD computation of X did not converge.
@@ -833,6 +836,7 @@ SUBROUTINE ZGEDMD( JOBS, JOBZ, JOBR, JOBF, WHTSVD, &
833836
! The columns of Y will be normalized.
834837
! To prevent overflows, the column norms of Y are
835838
! carefully computed using ZLASSQ.
839+
K = 0
836840
DO i = 1, N
837841
!RWORK(i) = DZNRM2( M, Y(1,i), 1 )
838842
SSUM = ONE
@@ -868,8 +872,17 @@ SUBROUTINE ZGEDMD( JOBS, JOBZ, JOBR, JOBF, WHTSVD, &
868872
END IF
869873
ELSE
870874
RWORK(i) = ZERO
875+
K = K + 1
871876
END IF
872877
END DO
878+
IF ( K == N ) THEN
879+
! All columns of Y are zero. Return error code -10.
880+
! (the 10th input variable had an illegal value)
881+
K = 0
882+
INFO = -10
883+
CALL XERBLA('ZGEDMD',-INFO)
884+
RETURN
885+
END IF
873886
DO i = 1, N
874887
! Now, apply the same scaling to the columns of X.
875888
IF ( RWORK(i) > ZERO ) THEN

0 commit comments

Comments
 (0)