5 * SUBROUTINE DGELQ( M, N, A, LDA, WORK1, LWORK1, WORK2, LWORK2,
8 * .. Scalar Arguments ..
9 * INTEGER INFO, LDA, M, N, LWORK1, LWORK2
11 * .. Array Arguments ..
12 * DOUBLE PRECISION A( LDA, * ), WORK1( * ), WORK2( * )
21 *> DGELQ computes an LQ factorization of an M-by-N matrix A,
22 *> using DLASWLQ when A is short and wide
23 *> (N sufficiently greater than M), and otherwise DGELQT:
33 *> The number of rows of the matrix A. M >= 0.
39 *> The number of columns of the matrix A. N >= 0.
44 *> A is DOUBLE PRECISION array, dimension (LDA,N)
45 *> On entry, the M-by-N matrix A.
46 *> On exit, the elements on and below the diagonal of the array
47 *> contain the M-by-min(M,N) lower trapezoidal matrix L
48 *> (L is lower triangular if M <= N);
49 *> the elements above the diagonal are the rows of
50 *> blocked V representing Q (see Further Details).
56 *> The leading dimension of the array A. LDA >= max(1,M).
61 *> WORK1 is DOUBLE PRECISION array, dimension (MAX(1,LWORK1))
62 *> WORK1 contains part of the data structure used to store Q.
63 *> WORK1(1): algorithm type = 1, to indicate output from
65 *> WORK1(2): optimum size of WORK1
66 *> WORK1(3): minimum size of WORK1
67 *> WORK1(4): horizontal block size
68 *> WORK1(5): vertical block size
69 *> WORK1(6:LWORK1): data structure needed for Q, computed by
76 *> The dimension of the array WORK1.
77 *> If LWORK1 = -1, then a query is assumed. In this case the
78 *> routine calculates the optimal size of WORK1 and
79 *> returns this value in WORK1(2), and calculates the minimum
80 *> size of WORK1 and returns this value in WORK1(3).
81 *> No error message related to LWORK1 is issued by XERBLA when
87 *> (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK2))
93 *> The dimension of the array WORK2.
94 *> If LWORK2 = -1, then a query is assumed. In this case the
95 *> routine calculates the optimal size of WORK2 and
96 *> returns this value in WORK2(1), and calculates the minimum
97 *> size of WORK2 and returns this value in WORK2(2).
98 *> No error message related to LWORK2 is issued by XERBLA when
105 *> = 0: successful exit
106 *> < 0: if INFO = -i, the i-th argument had an illegal value
112 *> \author Univ. of Tennessee
113 *> \author Univ. of California Berkeley
114 *> \author Univ. of Colorado Denver
117 *> \par Further Details:
118 * =====================
121 *> Depending on the matrix dimensions M and N, and row and column
122 *> block sizes MB and NB returned by ILAENV, GELQ will use either
123 *> LASWLQ(if the matrix is short-and-wide) or GELQT to compute
124 *> the LQ decomposition.
125 *> The output of LASWLQ or GELQT representing Q is stored in A and in
126 *> array WORK1(6:LWORK1) for later use.
127 *> WORK1(2:5) contains the matrix dimensions M,N and block sizes MB, NB
128 *> which are needed to interpret A and WORK1(6:LWORK1) for later use.
129 *> WORK1(1)=1 indicates that the code needed to take WORK1(2:5) and
130 *> decide whether LASWLQ or GELQT was used is the same as used below in
131 *> GELQ. For a detailed description of A and WORK1(6:LWORK1), see
132 *> Further Details in LASWLQ or GELQT.
136 * =====================================================================
137 SUBROUTINE DGELQ( M, N, A, LDA, WORK1, LWORK1, WORK2, LWORK2,
140 * -- LAPACK computational routine (version 3.5.0) --
141 * -- LAPACK is a software package provided by Univ. of Tennessee, --
142 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd. --
145 * .. Scalar Arguments ..
146 INTEGER INFO, LDA, M, N, LWORK1, LWORK2
148 * .. Array Arguments ..
149 DOUBLE PRECISION A( LDA, * ), WORK1( * ), WORK2( * )
152 * =====================================================================
155 * .. Local Scalars ..
156 LOGICAL LQUERY, LMINWS
157 INTEGER MB, NB, I, II, KK, MINLW1, NBLCKS
159 * .. EXTERNAL FUNCTIONS ..
162 * .. EXTERNAL SUBROUTINES ..
163 EXTERNAL DGELQT, DLASWLQ, XERBLA
164 * .. INTRINSIC FUNCTIONS ..
165 INTRINSIC MAX, MIN, MOD
167 * .. EXTERNAL FUNCTIONS ..
171 * .. EXECUTABLE STATEMENTS ..
173 * TEST THE INPUT ARGUMENTS
177 LQUERY = ( LWORK1.EQ.-1 .OR. LWORK2.EQ.-1 )
179 * Determine the block size
181 IF ( MIN(M,N).GT.0 ) THEN
182 MB = ILAENV( 1, 'DGELQ ', ' ', M, N, 1, -1)
183 NB = ILAENV( 1, 'DGELQ ', ' ', M, N, 2, -1)
188 IF( MB.GT.MIN(M,N).OR.MB.LT.1) MB = 1
189 IF( NB.GT.N.OR.NB.LE.M) NB = N
191 IF ((NB.GT.M).AND.(N.GT.M)) THEN
192 IF(MOD(N-M, NB-M).EQ.0) THEN
193 NBLCKS = (N-M)/(NB-M)
195 NBLCKS = (N-M)/(NB-M) + 1
201 * Determine if the workspace size satisfies minimum size
204 IF((LWORK1.LT.MAX(1,MB*M*NBLCKS+5)
205 $ .OR.(LWORK2.LT.MB*M)).AND.(LWORK2.GE.M).AND.(LWORK1.GE.M+5)
206 $ .AND.(.NOT.LQUERY)) THEN
207 IF (LWORK1.LT.MAX(1,MB*M*NBLCKS+5)) THEN
211 IF (LWORK1.LT.MAX(1,M*NBLCKS+5)) THEN
215 IF (LWORK2.LT.MB*M) THEN
223 ELSE IF( N.LT.0 ) THEN
225 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
227 ELSE IF( LWORK1.LT.MAX( 1, MB*M*NBLCKS+5 )
228 $ .AND.(.NOT.LQUERY).AND. (.NOT.LMINWS)) THEN
230 ELSE IF( (LWORK2.LT.MAX(1,M*MB)).AND.(.NOT.LQUERY)
231 $ .AND.(.NOT.LMINWS) ) THEN
237 WORK1(2) = MB*M*NBLCKS+5
245 CALL XERBLA( 'DGELQ', -INFO )
247 ELSE IF (LQUERY) THEN
251 * Quick return if possible
253 IF( MIN(M,N).EQ.0 ) THEN
257 * The LQ Decomposition
259 IF((N.LE.M).OR.(NB.LE.M).OR.(NB.GE.N)) THEN
260 CALL DGELQT( M, N, MB, A, LDA, WORK1(6), MB, WORK2, INFO)
262 CALL DLASWLQ( M, N, MB, NB, A, LDA, WORK1(6), MB, WORK2,