192 SUBROUTINE cgelst( TRANS, M, N, NRHS, A, LDA, B, LDB, WORK, LWORK,
201 INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS
204 COMPLEX A( LDA, * ), B( LDB, * ), WORK( * )
211 parameter( zero = 0.0e+0, one = 1.0e+0 )
213 parameter( czero = ( 0.0e+0, 0.0e+0 ) )
217 INTEGER BROW, I, IASCL, IBSCL, J, LWOPT, MN, MNNRHS,
219 REAL ANRM, BIGNUM, BNRM, SMLNUM
227 REAL SLAMCH, CLANGE, SROUNDUP_LWORK
228 EXTERNAL lsame, ilaenv, slamch, clange, sroundup_lwork
243 lquery = ( lwork.EQ.-1 )
244 IF( .NOT.( lsame( trans,
'N' ) .OR. lsame( trans,
'C' ) ) )
THEN
246 ELSE IF( m.LT.0 )
THEN
248 ELSE IF( n.LT.0 )
THEN
250 ELSE IF( nrhs.LT.0 )
THEN
252 ELSE IF( lda.LT.max( 1, m ) )
THEN
254 ELSE IF( ldb.LT.max( 1, m, n ) )
THEN
256 ELSE IF( lwork.LT.max( 1, mn+max( mn, nrhs ) ) .AND. .NOT.lquery )
263 IF( info.EQ.0 .OR. info.EQ.-10 )
THEN
266 IF( lsame( trans,
'N' ) )
269 nb = ilaenv( 1,
'CGELST',
' ', m, n, -1, -1 )
271 mnnrhs = max( mn, nrhs )
272 lwopt = max( 1, (mn+mnnrhs)*nb )
273 work( 1 ) = sroundup_lwork( lwopt )
278 CALL xerbla(
'CGELST ', -info )
280 ELSE IF( lquery )
THEN
286 IF( min( m, n, nrhs ).EQ.0 )
THEN
287 CALL claset(
'Full', max( m, n ), nrhs, czero, czero, b, ldb )
288 work( 1 ) = sroundup_lwork( lwopt )
294 IF( nb.GT.mn ) nb = mn
300 nb = min( nb, lwork/( mn + mnnrhs ) )
304 nbmin = max( 2, ilaenv( 2,
'CGELST',
' ', m, n, -1, -1 ) )
306 IF( nb.LT.nbmin )
THEN
312 smlnum = slamch(
'S' ) / slamch(
'P' )
313 bignum = one / smlnum
317 anrm = clange(
'M', m, n, a, lda, rwork )
319 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
323 CALL clascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, info )
325 ELSE IF( anrm.GT.bignum )
THEN
329 CALL clascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, info )
331 ELSE IF( anrm.EQ.zero )
THEN
335 CALL claset(
'Full', max( m, n ), nrhs, czero, czero, b, ldb )
336 work( 1 ) = sroundup_lwork( lwopt )
343 bnrm = clange(
'M', brow, nrhs, b, ldb, rwork )
345 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
349 CALL clascl(
'G', 0, 0, bnrm, smlnum, brow, nrhs, b, ldb,
352 ELSE IF( bnrm.GT.bignum )
THEN
356 CALL clascl(
'G', 0, 0, bnrm, bignum, brow, nrhs, b, ldb,
368 CALL cgeqrt( m, n, nb, a, lda, work( 1 ), nb,
369 $ work( mn*nb+1 ), info )
381 CALL cgemqrt(
'Left',
'Conjugate transpose', m, nrhs, n, nb,
382 $ a, lda, work( 1 ), nb, b, ldb,
383 $ work( mn*nb+1 ), info )
387 CALL ctrtrs(
'Upper',
'No transpose',
'Non-unit', n, nrhs,
388 $ a, lda, b, ldb, info )
406 CALL ctrtrs(
'Upper',
'Conjugate transpose',
'Non-unit',
407 $ n, nrhs, a, lda, b, ldb, info )
426 CALL cgemqrt(
'Left',
'No transpose', m, nrhs, n, nb,
427 $ a, lda, work( 1 ), nb, b, ldb,
428 $ work( mn*nb+1 ), info )
441 CALL cgelqt( m, n, nb, a, lda, work( 1 ), nb,
442 $ work( mn*nb+1 ), info )
454 CALL ctrtrs(
'Lower',
'No transpose',
'Non-unit', m, nrhs,
455 $ a, lda, b, ldb, info )
474 CALL cgemlqt(
'Left',
'Conjugate transpose', n, nrhs, m, nb,
475 $ a, lda, work( 1 ), nb, b, ldb,
476 $ work( mn*nb+1 ), info )
490 CALL cgemlqt(
'Left',
'No transpose', n, nrhs, m, nb,
491 $ a, lda, work( 1 ), nb, b, ldb,
492 $ work( mn*nb+1), info )
496 CALL ctrtrs(
'Lower',
'Conjugate transpose',
'Non-unit',
497 $ m, nrhs, a, lda, b, ldb, info )
511 IF( iascl.EQ.1 )
THEN
512 CALL clascl(
'G', 0, 0, anrm, smlnum, scllen, nrhs, b, ldb,
514 ELSE IF( iascl.EQ.2 )
THEN
515 CALL clascl(
'G', 0, 0, anrm, bignum, scllen, nrhs, b, ldb,
518 IF( ibscl.EQ.1 )
THEN
519 CALL clascl(
'G', 0, 0, smlnum, bnrm, scllen, nrhs, b, ldb,
521 ELSE IF( ibscl.EQ.2 )
THEN
522 CALL clascl(
'G', 0, 0, bignum, bnrm, scllen, nrhs, b, ldb,
526 work( 1 ) = sroundup_lwork( lwopt )
subroutine xerbla(srname, info)
subroutine cgelqt(m, n, mb, a, lda, t, ldt, work, info)
CGELQT
subroutine cgelst(trans, m, n, nrhs, a, lda, b, ldb, work, lwork, info)
CGELST solves overdetermined or underdetermined systems for GE matrices using QR or LQ factorization ...
subroutine cgemlqt(side, trans, m, n, k, mb, v, ldv, t, ldt, c, ldc, work, info)
CGEMLQT
subroutine cgemqrt(side, trans, m, n, k, nb, v, ldv, t, ldt, c, ldc, work, info)
CGEMQRT
subroutine cgeqrt(m, n, nb, a, lda, t, ldt, work, info)
CGEQRT
subroutine clascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
CLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine claset(uplo, m, n, alpha, beta, a, lda)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine ctrtrs(uplo, trans, diag, n, nrhs, a, lda, b, ldb, info)
CTRTRS