diff --git a/SRC/cgelsd.f b/SRC/cgelsd.f index b4315ddfd..a6b6ece4f 100644 --- a/SRC/cgelsd.f +++ b/SRC/cgelsd.f @@ -391,7 +391,7 @@ SUBROUTINE CGELSD( M, N, NRHS, A, LDA, B, LDB, S, RCOND, RANK, * * Quick return if possible. * - IF( M.EQ.0 .OR. N.EQ.0 ) THEN + IF( M.EQ.0 .OR. N.EQ.0 .OR. NRHS.EQ.0 ) THEN RANK = 0 RETURN END IF @@ -530,14 +530,14 @@ SUBROUTINE CGELSD( M, N, NRHS, A, LDA, B, LDB, S, RCOND, RANK, $ B, LDB, WORK( NWORK ), LWORK-NWORK+1, INFO ) * ELSE IF( N.GE.MNTHR .AND. LWORK.GE.4*M+M*M+ - $ MAX( M, 2*M-4, NRHS, N-3*M ) ) THEN + $ MAX( M, 2*M-4, NRHS, N-3*M, M*NRHS ) ) THEN * * Path 2a - underdetermined, with many more columns than rows * and sufficient workspace for an efficient algorithm. * LDWORK = M - IF( LWORK.GE.MAX( 4*M+M*LDA+MAX( M, 2*M-4, NRHS, N-3*M ), - $ M*LDA+M+M*NRHS ) )LDWORK = LDA + IF( LWORK.GE.MAX( 4*M+M*LDA+MAX( M, 2*M-4, NRHS, N-3*M, + $ M*NRHS ), M*LDA+M+M*NRHS ) )LDWORK = LDA ITAU = 1 NWORK = M + 1 * diff --git a/SRC/dgelsd.f b/SRC/dgelsd.f index cc79987ad..96e17c41a 100644 --- a/SRC/dgelsd.f +++ b/SRC/dgelsd.f @@ -367,7 +367,7 @@ SUBROUTINE DGELSD( M, N, NRHS, A, LDA, B, LDB, S, RCOND, RANK, * * Quick return if possible. * - IF( M.EQ.0 .OR. N.EQ.0 ) THEN + IF( M.EQ.0 .OR. N.EQ.0 .OR. NRHS.EQ.0 ) THEN RANK = 0 RETURN END IF diff --git a/SRC/sgelsd.f b/SRC/sgelsd.f index b219f338c..a09698e36 100644 --- a/SRC/sgelsd.f +++ b/SRC/sgelsd.f @@ -372,7 +372,7 @@ SUBROUTINE SGELSD( M, N, NRHS, A, LDA, B, LDB, S, RCOND, * * Quick return if possible. * - IF( M.EQ.0 .OR. N.EQ.0 ) THEN + IF( M.EQ.0 .OR. N.EQ.0 .OR. NRHS.EQ.0 ) THEN RANK = 0 RETURN END IF diff --git a/SRC/zgelsd.f b/SRC/zgelsd.f index 57c47792a..7d87de67c 100644 --- a/SRC/zgelsd.f +++ b/SRC/zgelsd.f @@ -390,7 +390,7 @@ SUBROUTINE ZGELSD( M, N, NRHS, A, LDA, B, LDB, S, RCOND, RANK, * * Quick return if possible. * - IF( M.EQ.0 .OR. N.EQ.0 ) THEN + IF( M.EQ.0 .OR. N.EQ.0 .OR. NRHS.EQ.0 ) THEN RANK = 0 RETURN END IF @@ -529,14 +529,14 @@ SUBROUTINE ZGELSD( M, N, NRHS, A, LDA, B, LDB, S, RCOND, RANK, $ B, LDB, WORK( NWORK ), LWORK-NWORK+1, INFO ) * ELSE IF( N.GE.MNTHR .AND. LWORK.GE.4*M+M*M+ - $ MAX( M, 2*M-4, NRHS, N-3*M ) ) THEN + $ MAX( M, 2*M-4, NRHS, N-3*M, M*NRHS ) ) THEN * * Path 2a - underdetermined, with many more columns than rows * and sufficient workspace for an efficient algorithm. * LDWORK = M - IF( LWORK.GE.MAX( 4*M+M*LDA+MAX( M, 2*M-4, NRHS, N-3*M ), - $ M*LDA+M+M*NRHS ) )LDWORK = LDA + IF( LWORK.GE.MAX( 4*M+M*LDA+MAX( M, 2*M-4, NRHS, N-3*M, + $ M*NRHS ), M*LDA+M+M*NRHS ) )LDWORK = LDA ITAU = 1 NWORK = M + 1 *