LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ zgglse()

subroutine zgglse ( integer m,
integer n,
integer p,
complex*16, dimension( lda, * ) a,
integer lda,
complex*16, dimension( ldb, * ) b,
integer ldb,
complex*16, dimension( * ) c,
complex*16, dimension( * ) d,
complex*16, dimension( * ) x,
complex*16, dimension( * ) work,
integer lwork,
integer info )

ZGGLSE solves overdetermined or underdetermined systems for OTHER matrices

Download ZGGLSE + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> ZGGLSE solves the linear equality-constrained least squares (LSE)
!> problem:
!>
!>         minimize || c - A*x ||_2   subject to   B*x = d
!>
!> where A is an M-by-N matrix, B is a P-by-N matrix, c is a given
!> M-vector, and d is a given P-vector. It is assumed that
!> P <= N <= M+P, and
!>
!>          rank(B) = P and  rank( (A) ) = N.
!>                               ( (B) )
!>
!> These conditions ensure that the LSE problem has a unique solution,
!> which is obtained using a generalized RQ factorization of the
!> matrices (B, A) given by
!>
!>    B = (0 R)*Q,   A = Z*T*Q.
!>
!> Callers of this subroutine should note that the singularity/rank-deficiency checks
!> implemented in this subroutine are rudimentary. The ZTRTRS subroutine called by this
!> subroutine only signals a failure due to singularity if the problem is exactly singular.
!>
!> It is conceivable for one (or more) of the factors involved in the generalized RQ
!> factorization of the pair (B, A) to be subnormally close to singularity without this
!> subroutine signalling an error. The solutions computed for such almost-rank-deficient
!> problems may be less accurate due to a loss of numerical precision.
!> 
!> 
Parameters
[in]M
!>          M is INTEGER
!>          The number of rows of the matrix A.  M >= 0.
!> 
[in]N
!>          N is INTEGER
!>          The number of columns of the matrices A and B. N >= 0.
!> 
[in]P
!>          P is INTEGER
!>          The number of rows of the matrix B. 0 <= P <= N <= M+P.
!> 
[in,out]A
!>          A is COMPLEX*16 array, dimension (LDA,N)
!>          On entry, the M-by-N matrix A.
!>          On exit, the elements on and above the diagonal of the array
!>          contain the min(M,N)-by-N upper trapezoidal matrix T.
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A. LDA >= max(1,M).
!> 
[in,out]B
!>          B is COMPLEX*16 array, dimension (LDB,N)
!>          On entry, the P-by-N matrix B.
!>          On exit, the upper triangle of the subarray B(1:P,N-P+1:N)
!>          contains the P-by-P upper triangular matrix R.
!> 
[in]LDB
!>          LDB is INTEGER
!>          The leading dimension of the array B. LDB >= max(1,P).
!> 
[in,out]C
!>          C is COMPLEX*16 array, dimension (M)
!>          On entry, C contains the right hand side vector for the
!>          least squares part of the LSE problem.
!>          On exit, the residual sum of squares for the solution
!>          is given by the sum of squares of elements N-P+1 to M of
!>          vector C.
!> 
[in,out]D
!>          D is COMPLEX*16 array, dimension (P)
!>          On entry, D contains the right hand side vector for the
!>          constrained equation.
!>          On exit, D is destroyed.
!> 
[out]X
!>          X is COMPLEX*16 array, dimension (N)
!>          On exit, X is the solution of the LSE problem.
!> 
[out]WORK
!>          WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
!>          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
!> 
[in]LWORK
!>          LWORK is INTEGER
!>          The dimension of the array WORK. LWORK >= max(1,M+N+P).
!>          For optimum performance LWORK >= P+min(M,N)+max(M,N)*NB,
!>          where NB is an upper bound for the optimal blocksizes for
!>          ZGEQRF, CGERQF, ZUNMQR and CUNMRQ.
!>
!>          If LWORK = -1, then a workspace query is assumed; the routine
!>          only calculates the optimal size of the WORK array, returns
!>          this value as the first entry of the WORK array, and no error
!>          message related to LWORK is issued by XERBLA.
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit.
!>          < 0:  if INFO = -i, the i-th argument had an illegal value.
!>          = 1:  the upper triangular factor R associated with B in the
!>                generalized RQ factorization of the pair (B, A) is exactly
!>                singular, so that rank(B) < P; the least squares
!>                solution could not be computed.
!>          = 2:  the (N-P) by (N-P) part of the upper trapezoidal factor
!>                T associated with A in the generalized RQ factorization
!>                of the pair (B, A) is exactly singular, so that
!>                rank( (A) ) < N; the least squares solution could not
!>                    ( (B) )
!>                be computed.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 186 of file zgglse.f.

189*
190* -- LAPACK driver routine --
191* -- LAPACK is a software package provided by Univ. of Tennessee, --
192* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
193*
194* .. Scalar Arguments ..
195 INTEGER INFO, LDA, LDB, LWORK, M, N, P
196* ..
197* .. Array Arguments ..
198 COMPLEX*16 A( LDA, * ), B( LDB, * ), C( * ), D( * ),
199 $ WORK( * ), X( * )
200* ..
201*
202* =====================================================================
203*
204* .. Parameters ..
205 COMPLEX*16 CONE
206 parameter( cone = ( 1.0d+0, 0.0d+0 ) )
207* ..
208* .. Local Scalars ..
209 LOGICAL LQUERY
210 INTEGER LOPT, LWKMIN, LWKOPT, MN, NB, NB1, NB2, NB3,
211 $ NB4, NR
212* ..
213* .. External Subroutines ..
214 EXTERNAL xerbla, zaxpy, zcopy, zgemv, zggrqf,
215 $ ztrmv,
217* ..
218* .. External Functions ..
219 INTEGER ILAENV
220 EXTERNAL ilaenv
221* ..
222* .. Intrinsic Functions ..
223 INTRINSIC int, max, min
224* ..
225* .. Executable Statements ..
226*
227* Test the input parameters
228*
229 info = 0
230 mn = min( m, n )
231 lquery = ( lwork.EQ.-1 )
232 IF( m.LT.0 ) THEN
233 info = -1
234 ELSE IF( n.LT.0 ) THEN
235 info = -2
236 ELSE IF( p.LT.0 .OR. p.GT.n .OR. p.LT.n-m ) THEN
237 info = -3
238 ELSE IF( lda.LT.max( 1, m ) ) THEN
239 info = -5
240 ELSE IF( ldb.LT.max( 1, p ) ) THEN
241 info = -7
242 END IF
243*
244* Calculate workspace
245*
246 IF( info.EQ.0) THEN
247 IF( n.EQ.0 ) THEN
248 lwkmin = 1
249 lwkopt = 1
250 ELSE
251 nb1 = ilaenv( 1, 'ZGEQRF', ' ', m, n, -1, -1 )
252 nb2 = ilaenv( 1, 'ZGERQF', ' ', m, n, -1, -1 )
253 nb3 = ilaenv( 1, 'ZUNMQR', ' ', m, n, p, -1 )
254 nb4 = ilaenv( 1, 'ZUNMRQ', ' ', m, n, p, -1 )
255 nb = max( nb1, nb2, nb3, nb4 )
256 lwkmin = m + n + p
257 lwkopt = p + mn + max( m, n )*nb
258 END IF
259 work( 1 ) = lwkopt
260*
261 IF( lwork.LT.lwkmin .AND. .NOT.lquery ) THEN
262 info = -12
263 END IF
264 END IF
265*
266 IF( info.NE.0 ) THEN
267 CALL xerbla( 'ZGGLSE', -info )
268 RETURN
269 ELSE IF( lquery ) THEN
270 RETURN
271 END IF
272*
273* Quick return if possible
274*
275 IF( n.EQ.0 )
276 $ RETURN
277*
278* Compute the GRQ factorization of matrices B and A:
279*
280* B*Q**H = ( 0 T12 ) P Z**H*A*Q**H = ( R11 R12 ) N-P
281* N-P P ( 0 R22 ) M+P-N
282* N-P P
283*
284* where T12 and R11 are upper triangular, and Q and Z are
285* unitary.
286*
287 CALL zggrqf( p, m, n, b, ldb, work, a, lda, work( p+1 ),
288 $ work( p+mn+1 ), lwork-p-mn, info )
289 lopt = int( work( p+mn+1 ) )
290*
291* Update c = Z**H *c = ( c1 ) N-P
292* ( c2 ) M+P-N
293*
294 CALL zunmqr( 'Left', 'Conjugate Transpose', m, 1, mn, a, lda,
295 $ work( p+1 ), c, max( 1, m ), work( p+mn+1 ),
296 $ lwork-p-mn, info )
297 lopt = max( lopt, int( work( p+mn+1 ) ) )
298*
299* Solve T12*x2 = d for x2
300*
301 IF( p.GT.0 ) THEN
302 CALL ztrtrs( 'Upper', 'No transpose', 'Non-unit', p, 1,
303 $ b( 1, n-p+1 ), ldb, d, p, info )
304*
305 IF( info.GT.0 ) THEN
306 info = 1
307 RETURN
308 END IF
309*
310* Put the solution in X
311*
312 CALL zcopy( p, d, 1, x( n-p+1 ), 1 )
313*
314* Update c1
315*
316 CALL zgemv( 'No transpose', n-p, p, -cone, a( 1, n-p+1 ),
317 $ lda,
318 $ d, 1, cone, c, 1 )
319 END IF
320*
321* Solve R11*x1 = c1 for x1
322*
323 IF( n.GT.p ) THEN
324 CALL ztrtrs( 'Upper', 'No transpose', 'Non-unit', n-p, 1,
325 $ a, lda, c, n-p, info )
326*
327 IF( info.GT.0 ) THEN
328 info = 2
329 RETURN
330 END IF
331*
332* Put the solutions in X
333*
334 CALL zcopy( n-p, c, 1, x, 1 )
335 END IF
336*
337* Compute the residual vector:
338*
339 IF( m.LT.n ) THEN
340 nr = m + p - n
341 IF( nr.GT.0 )
342 $ CALL zgemv( 'No transpose', nr, n-m, -cone, a( n-p+1,
343 $ m+1 ),
344 $ lda, d( nr+1 ), 1, cone, c( n-p+1 ), 1 )
345 ELSE
346 nr = p
347 END IF
348 IF( nr.GT.0 ) THEN
349 CALL ztrmv( 'Upper', 'No transpose', 'Non unit', nr,
350 $ a( n-p+1, n-p+1 ), lda, d, 1 )
351 CALL zaxpy( nr, -cone, d, 1, c( n-p+1 ), 1 )
352 END IF
353*
354* Backward transformation x = Q**H*x
355*
356 CALL zunmrq( 'Left', 'Conjugate Transpose', n, 1, p, b, ldb,
357 $ work( 1 ), x, n, work( p+mn+1 ), lwork-p-mn, info )
358 work( 1 ) = p + mn + max( lopt, int( work( p+mn+1 ) ) )
359*
360 RETURN
361*
362* End of ZGGLSE
363*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zaxpy(n, za, zx, incx, zy, incy)
ZAXPY
Definition zaxpy.f:88
subroutine zcopy(n, zx, incx, zy, incy)
ZCOPY
Definition zcopy.f:81
subroutine zgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
ZGEMV
Definition zgemv.f:160
subroutine zggrqf(m, p, n, a, lda, taua, b, ldb, taub, work, lwork, info)
ZGGRQF
Definition zggrqf.f:212
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
Definition ilaenv.f:160
subroutine ztrmv(uplo, trans, diag, n, a, lda, x, incx)
ZTRMV
Definition ztrmv.f:147
subroutine ztrtrs(uplo, trans, diag, n, nrhs, a, lda, b, ldb, info)
ZTRTRS
Definition ztrtrs.f:144
subroutine zunmqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
ZUNMQR
Definition zunmqr.f:165
subroutine zunmrq(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
ZUNMRQ
Definition zunmrq.f:165
Here is the call graph for this function:
Here is the caller graph for this function: