178 SUBROUTINE cgglse( M, N, P, A, LDA, B, LDB, C, D, X, WORK, LWORK,
186 INTEGER INFO, LDA, LDB, LWORK, M, N, P
189 COMPLEX A( LDA, * ), B( LDB, * ), C( * ), D( * ),
197 parameter( cone = ( 1.0e+0, 0.0e+0 ) )
201 INTEGER LOPT, LWKMIN, LWKOPT, MN, NB, NB1, NB2, NB3,
211 EXTERNAL ilaenv, sroundup_lwork
214 INTRINSIC int, max, min
222 lquery = ( lwork.EQ.-1 )
225 ELSE IF( n.LT.0 )
THEN
227 ELSE IF( p.LT.0 .OR. p.GT.n .OR. p.LT.n-m )
THEN
229 ELSE IF( lda.LT.max( 1, m ) )
THEN
231 ELSE IF( ldb.LT.max( 1, p ) )
THEN
242 nb1 = ilaenv( 1,
'CGEQRF',
' ', m, n, -1, -1 )
243 nb2 = ilaenv( 1,
'CGERQF',
' ', m, n, -1, -1 )
244 nb3 = ilaenv( 1,
'CUNMQR',
' ', m, n, p, -1 )
245 nb4 = ilaenv( 1,
'CUNMRQ',
' ', m, n, p, -1 )
246 nb = max( nb1, nb2, nb3, nb4 )
248 lwkopt = p + mn + max( m, n )*nb
250 work( 1 ) = sroundup_lwork(lwkopt)
252 IF( lwork.LT.lwkmin .AND. .NOT.lquery )
THEN
258 CALL xerbla(
'CGGLSE', -info )
260 ELSE IF( lquery )
THEN
278 CALL cggrqf( p, m, n, b, ldb, work, a, lda, work( p+1 ),
279 $ work( p+mn+1 ), lwork-p-mn, info )
280 lopt = int( work( p+mn+1 ) )
285 CALL cunmqr(
'Left',
'Conjugate Transpose', m, 1, mn, a, lda,
286 $ work( p+1 ), c, max( 1, m ), work( p+mn+1 ),
288 lopt = max( lopt, int( work( p+mn+1 ) ) )
293 CALL ctrtrs(
'Upper',
'No transpose',
'Non-unit', p, 1,
294 $ b( 1, n-p+1 ), ldb, d, p, info )
303 CALL ccopy( p, d, 1, x( n-p+1 ), 1 )
307 CALL cgemv(
'No transpose', n-p, p, -cone, a( 1, n-p+1 ), lda,
314 CALL ctrtrs(
'Upper',
'No transpose',
'Non-unit', n-p, 1,
315 $ a, lda, c, n-p, info )
324 CALL ccopy( n-p, c, 1, x, 1 )
332 $
CALL cgemv(
'No transpose', nr, n-m, -cone, a( n-p+1, m+1 ),
333 $ lda, d( nr+1 ), 1, cone, c( n-p+1 ), 1 )
338 CALL ctrmv(
'Upper',
'No transpose',
'Non unit', nr,
339 $ a( n-p+1, n-p+1 ), lda, d, 1 )
340 CALL caxpy( nr, -cone, d, 1, c( n-p+1 ), 1 )
345 CALL cunmrq(
'Left',
'Conjugate Transpose', n, 1, p, b, ldb,
346 $ work( 1 ), x, n, work( p+mn+1 ), lwork-p-mn, info )
347 work( 1 ) = p + mn + max( lopt, int( work( p+mn+1 ) ) )
subroutine xerbla(srname, info)
subroutine caxpy(n, ca, cx, incx, cy, incy)
CAXPY
subroutine ccopy(n, cx, incx, cy, incy)
CCOPY
subroutine cgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
CGEMV
subroutine cgglse(m, n, p, a, lda, b, ldb, c, d, x, work, lwork, info)
CGGLSE solves overdetermined or underdetermined systems for OTHER matrices
subroutine cggrqf(m, p, n, a, lda, taua, b, ldb, taub, work, lwork, info)
CGGRQF
subroutine ctrmv(uplo, trans, diag, n, a, lda, x, incx)
CTRMV
subroutine ctrtrs(uplo, trans, diag, n, nrhs, a, lda, b, ldb, info)
CTRTRS
subroutine cunmqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
CUNMQR
subroutine cunmrq(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
CUNMRQ