111111* >
112112* > \param[out] WORK
113113* > \verbatim
114- * > (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
114+ * > (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
115+ * > On exit, if INFO = 0, WORK(1) returns the minimal LWORK.
115116* > \endverbatim
116117* >
117118* > \param[in] LWORK
118119* > \verbatim
119120* > LWORK is INTEGER
120- * > The dimension of the array WORK.
121+ * > The dimension of the array WORK. LWORK >= 1.
121122* > If LWORK = -1, then a workspace query is assumed. The routine
122123* > only calculates the size of the WORK array, returns this
123- * > value as WORK(1), and no error message related to WORK
124+ * > value as WORK(1), and no error message related to WORK
124125* > is issued by XERBLA.
125126* > \endverbatim
126127* >
144145* >
145146* > \verbatim
146147* >
147- * > These details are particular for this LAPACK implementation. Users should not
148+ * > These details are particular for this LAPACK implementation. Users should not
148149* > take them for granted. These details may change in the future, and are not likely
149150* > true for another LAPACK implementation. These details are relevant if one wants
150151* > to try to understand the code. They are not part of the interface.
160161* > block sizes MB and NB returned by ILAENV, DGELQ will use either
161162* > DLASWLQ (if the matrix is wide-and-short) or DGELQT to compute
162163* > the LQ factorization.
163- * > This version of DGEMLQ will use either DLAMSWLQ or DGEMLQT to
164+ * > This version of DGEMLQ will use either DLAMSWLQ or DGEMLQT to
164165* > multiply matrix Q by another matrix.
165166* > Further Details in DLAMSWLQ or DGEMLQT.
166167* > \endverbatim
167168* >
169+ * > \ingroup gemlq
170+ * >
168171* =====================================================================
169172 SUBROUTINE DGEMLQ ( SIDE , TRANS , M , N , K , A , LDA , T , TSIZE ,
170173 $ C , LDC , WORK , LWORK , INFO )
@@ -186,7 +189,7 @@ SUBROUTINE DGEMLQ( SIDE, TRANS, M, N, K, A, LDA, T, TSIZE,
186189* ..
187190* .. Local Scalars ..
188191 LOGICAL LEFT, RIGHT, TRAN, NOTRAN, LQUERY
189- INTEGER MB, NB, LW, NBLCKS, MN
192+ INTEGER MB, NB, LW, NBLCKS, MN, MINMNK, LWMIN
190193* ..
191194* .. External Functions ..
192195 LOGICAL LSAME
@@ -202,7 +205,7 @@ SUBROUTINE DGEMLQ( SIDE, TRANS, M, N, K, A, LDA, T, TSIZE,
202205*
203206* Test the input arguments
204207*
205- LQUERY = LWORK.EQ. - 1
208+ LQUERY = ( LWORK.EQ. - 1 )
206209 NOTRAN = LSAME( TRANS, ' N' )
207210 TRAN = LSAME( TRANS, ' T' )
208211 LEFT = LSAME( SIDE, ' L' )
@@ -217,6 +220,13 @@ SUBROUTINE DGEMLQ( SIDE, TRANS, M, N, K, A, LDA, T, TSIZE,
217220 LW = M * MB
218221 MN = N
219222 END IF
223+ *
224+ MINMNK = MIN ( M, N, K )
225+ IF ( MINMNK.EQ. 0 ) THEN
226+ LWMIN = 1
227+ ELSE
228+ LWMIN = MAX ( 1 , LW )
229+ END IF
220230*
221231 IF ( ( NB.GT. K ) .AND. ( MN.GT. K ) ) THEN
222232 IF ( MOD ( MN - K, NB - K ) .EQ. 0 ) THEN
@@ -245,12 +255,12 @@ SUBROUTINE DGEMLQ( SIDE, TRANS, M, N, K, A, LDA, T, TSIZE,
245255 INFO = - 9
246256 ELSE IF ( LDC.LT. MAX ( 1 , M ) ) THEN
247257 INFO = - 11
248- ELSE IF ( ( LWORK.LT. MAX ( 1 , LW ) ) .AND. ( .NOT. LQUERY ) ) THEN
258+ ELSE IF ( LWORK.LT. LWMIN .AND. .NOT. LQUERY ) THEN
249259 INFO = - 13
250260 END IF
251261*
252262 IF ( INFO.EQ. 0 ) THEN
253- WORK( 1 ) = LW
263+ WORK( 1 ) = LWMIN
254264 END IF
255265*
256266 IF ( INFO.NE. 0 ) THEN
@@ -262,7 +272,7 @@ SUBROUTINE DGEMLQ( SIDE, TRANS, M, N, K, A, LDA, T, TSIZE,
262272*
263273* Quick return if possible
264274*
265- IF ( MIN ( M, N, K ) .EQ. 0 ) THEN
275+ IF ( MINMNK .EQ. 0 ) THEN
266276 RETURN
267277 END IF
268278*
@@ -275,7 +285,7 @@ SUBROUTINE DGEMLQ( SIDE, TRANS, M, N, K, A, LDA, T, TSIZE,
275285 $ MB, C, LDC, WORK, LWORK, INFO )
276286 END IF
277287*
278- WORK( 1 ) = LW
288+ WORK( 1 ) = LWMIN
279289*
280290 RETURN
281291*
0 commit comments