192 SUBROUTINE sgelst( TRANS, M, N, NRHS, A, LDA, B, LDB, WORK, LWORK,
201 INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS
204 REAL A( LDA, * ), B( LDB, * ), WORK( * )
211 parameter( zero = 0.0e+0, one = 1.0e+0 )
215 INTEGER BROW, I, IASCL, IBSCL, J, LWOPT, MN, MNNRHS,
217 REAL ANRM, BIGNUM, BNRM, SMLNUM
225 REAL SLAMCH, SLANGE, SROUNDUP_LWORK
226 EXTERNAL lsame, ilaenv, slamch, slange, sroundup_lwork
241 lquery = ( lwork.EQ.-1 )
242 IF( .NOT.( lsame( trans,
'N' ) .OR. lsame( trans,
'T' ) ) )
THEN
244 ELSE IF( m.LT.0 )
THEN
246 ELSE IF( n.LT.0 )
THEN
248 ELSE IF( nrhs.LT.0 )
THEN
250 ELSE IF( lda.LT.max( 1, m ) )
THEN
252 ELSE IF( ldb.LT.max( 1, m, n ) )
THEN
254 ELSE IF( lwork.LT.max( 1, mn+max( mn, nrhs ) ) .AND. .NOT.lquery )
261 IF( info.EQ.0 .OR. info.EQ.-10 )
THEN
264 IF( lsame( trans,
'N' ) )
267 nb = ilaenv( 1,
'SGELST',
' ', m, n, -1, -1 )
269 mnnrhs = max( mn, nrhs )
270 lwopt = max( 1, (mn+mnnrhs)*nb )
271 work( 1 ) = sroundup_lwork( lwopt )
276 CALL xerbla(
'SGELST ', -info )
278 ELSE IF( lquery )
THEN
284 IF( min( m, n, nrhs ).EQ.0 )
THEN
285 CALL slaset(
'Full', max( m, n ), nrhs, zero, zero, b, ldb )
286 work( 1 ) = sroundup_lwork( lwopt )
292 IF( nb.GT.mn ) nb = mn
298 nb = min( nb, lwork/( mn + mnnrhs ) )
302 nbmin = max( 2, ilaenv( 2,
'SGELST',
' ', m, n, -1, -1 ) )
304 IF( nb.LT.nbmin )
THEN
310 smlnum = slamch(
'S' ) / slamch(
'P' )
311 bignum = one / smlnum
315 anrm = slange(
'M', m, n, a, lda, rwork )
317 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
321 CALL slascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, info )
323 ELSE IF( anrm.GT.bignum )
THEN
327 CALL slascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, info )
329 ELSE IF( anrm.EQ.zero )
THEN
333 CALL slaset(
'Full', max( m, n ), nrhs, zero, zero, b, ldb )
334 work( 1 ) = sroundup_lwork( lwopt )
341 bnrm = slange(
'M', brow, nrhs, b, ldb, rwork )
343 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
347 CALL slascl(
'G', 0, 0, bnrm, smlnum, brow, nrhs, b, ldb,
350 ELSE IF( bnrm.GT.bignum )
THEN
354 CALL slascl(
'G', 0, 0, bnrm, bignum, brow, nrhs, b, ldb,
366 CALL sgeqrt( m, n, nb, a, lda, work( 1 ), nb,
367 $ work( mn*nb+1 ), info )
379 CALL sgemqrt(
'Left',
'Transpose', m, nrhs, n, nb, a, lda,
380 $ work( 1 ), nb, b, ldb, work( mn*nb+1 ),
385 CALL strtrs(
'Upper',
'No transpose',
'Non-unit', n, nrhs,
386 $ a, lda, b, ldb, info )
404 CALL strtrs(
'Upper',
'Transpose',
'Non-unit', n, nrhs,
405 $ a, lda, b, ldb, info )
424 CALL sgemqrt(
'Left',
'No transpose', m, nrhs, n, nb,
425 $ a, lda, work( 1 ), nb, b, ldb,
426 $ work( mn*nb+1 ), info )
439 CALL sgelqt( m, n, nb, a, lda, work( 1 ), nb,
440 $ work( mn*nb+1 ), info )
452 CALL strtrs(
'Lower',
'No transpose',
'Non-unit', m, nrhs,
453 $ a, lda, b, ldb, info )
472 CALL sgemlqt(
'Left',
'Transpose', n, nrhs, m, nb, a, lda,
473 $ work( 1 ), nb, b, ldb,
474 $ work( mn*nb+1 ), info )
488 CALL sgemlqt(
'Left',
'No transpose', n, nrhs, m, nb,
489 $ a, lda, work( 1 ), nb, b, ldb,
490 $ work( mn*nb+1), info )
494 CALL strtrs(
'Lower',
'Transpose',
'Non-unit', m, nrhs,
495 $ a, lda, b, ldb, info )
509 IF( iascl.EQ.1 )
THEN
510 CALL slascl(
'G', 0, 0, anrm, smlnum, scllen, nrhs, b, ldb,
512 ELSE IF( iascl.EQ.2 )
THEN
513 CALL slascl(
'G', 0, 0, anrm, bignum, scllen, nrhs, b, ldb,
516 IF( ibscl.EQ.1 )
THEN
517 CALL slascl(
'G', 0, 0, smlnum, bnrm, scllen, nrhs, b, ldb,
519 ELSE IF( ibscl.EQ.2 )
THEN
520 CALL slascl(
'G', 0, 0, bignum, bnrm, scllen, nrhs, b, ldb,
524 work( 1 ) = sroundup_lwork( lwopt )
subroutine xerbla(srname, info)
subroutine sgelqt(m, n, mb, a, lda, t, ldt, work, info)
SGELQT
subroutine sgelst(trans, m, n, nrhs, a, lda, b, ldb, work, lwork, info)
SGELST solves overdetermined or underdetermined systems for GE matrices using QR or LQ factorization ...
subroutine sgemlqt(side, trans, m, n, k, mb, v, ldv, t, ldt, c, ldc, work, info)
SGEMLQT
subroutine sgemqrt(side, trans, m, n, k, nb, v, ldv, t, ldt, c, ldc, work, info)
SGEMQRT
subroutine sgeqrt(m, n, nb, a, lda, t, ldt, work, info)
SGEQRT
subroutine slascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
SLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine slaset(uplo, m, n, alpha, beta, a, lda)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine strtrs(uplo, trans, diag, n, nrhs, a, lda, b, ldb, info)
STRTRS