183 SUBROUTINE sgels( TRANS, M, N, NRHS, A, LDA, B, LDB, WORK, LWORK,
193 INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS
196 REAL A( lda, * ), B( ldb, * ), WORK( * )
203 parameter ( zero = 0.0e0, one = 1.0e0 )
207 INTEGER BROW, I, IASCL, IBSCL, J, MN, NB, SCLLEN, WSIZE
208 REAL ANRM, BIGNUM, BNRM, SMLNUM
217 EXTERNAL lsame, ilaenv, slamch, slange
224 INTRINSIC max, min, real
232 lquery = ( lwork.EQ.-1 )
233 IF( .NOT.( lsame( trans,
'N' ) .OR. lsame( trans,
'T' ) ) )
THEN
235 ELSE IF( m.LT.0 )
THEN
237 ELSE IF( n.LT.0 )
THEN
239 ELSE IF( nrhs.LT.0 )
THEN
241 ELSE IF( lda.LT.max( 1, m ) )
THEN
243 ELSE IF( ldb.LT.max( 1, m, n ) )
THEN
245 ELSE IF( lwork.LT.max( 1, mn + max( mn, nrhs ) ) .AND.
252 IF( info.EQ.0 .OR. info.EQ.-10 )
THEN
255 IF( lsame( trans,
'N' ) )
259 nb = ilaenv( 1,
'SGEQRF',
' ', m, n, -1, -1 )
261 nb = max( nb, ilaenv( 1,
'SORMQR',
'LN', m, nrhs, n,
264 nb = max( nb, ilaenv( 1,
'SORMQR',
'LT', m, nrhs, n,
268 nb = ilaenv( 1,
'SGELQF',
' ', m, n, -1, -1 )
270 nb = max( nb, ilaenv( 1,
'SORMLQ',
'LT', n, nrhs, m,
273 nb = max( nb, ilaenv( 1,
'SORMLQ',
'LN', n, nrhs, m,
278 wsize = max( 1, mn + max( mn, nrhs )*nb )
279 work( 1 ) =
REAL( wsize )
284 CALL xerbla(
'SGELS ', -info )
286 ELSE IF( lquery )
THEN
292 IF( min( m, n, nrhs ).EQ.0 )
THEN
293 CALL slaset(
'Full', max( m, n ), nrhs, zero, zero, b, ldb )
299 smlnum = slamch(
'S' ) / slamch(
'P' )
300 bignum = one / smlnum
301 CALL slabad( smlnum, bignum )
305 anrm = slange(
'M', m, n, a, lda, rwork )
307 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
311 CALL slascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, info )
313 ELSE IF( anrm.GT.bignum )
THEN
317 CALL slascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, info )
319 ELSE IF( anrm.EQ.zero )
THEN
323 CALL slaset(
'F', max( m, n ), nrhs, zero, zero, b, ldb )
330 bnrm = slange(
'M', brow, nrhs, b, ldb, rwork )
332 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
336 CALL slascl(
'G', 0, 0, bnrm, smlnum, brow, nrhs, b, ldb,
339 ELSE IF( bnrm.GT.bignum )
THEN
343 CALL slascl(
'G', 0, 0, bnrm, bignum, brow, nrhs, b, ldb,
352 CALL sgeqrf( m, n, a, lda, work( 1 ), work( mn+1 ), lwork-mn,
363 CALL sormqr(
'Left',
'Transpose', m, nrhs, n, a, lda,
364 $ work( 1 ), b, ldb, work( mn+1 ), lwork-mn,
371 CALL strtrs(
'Upper',
'No transpose',
'Non-unit', n, nrhs,
372 $ a, lda, b, ldb, info )
386 CALL strtrs(
'Upper',
'Transpose',
'Non-unit', n, nrhs,
387 $ a, lda, b, ldb, info )
403 CALL sormqr(
'Left',
'No transpose', m, nrhs, n, a, lda,
404 $ work( 1 ), b, ldb, work( mn+1 ), lwork-mn,
417 CALL sgelqf( m, n, a, lda, work( 1 ), work( mn+1 ), lwork-mn,
428 CALL strtrs(
'Lower',
'No transpose',
'Non-unit', m, nrhs,
429 $ a, lda, b, ldb, info )
445 CALL sormlq(
'Left',
'Transpose', n, nrhs, m, a, lda,
446 $ work( 1 ), b, ldb, work( mn+1 ), lwork-mn,
459 CALL sormlq(
'Left',
'No transpose', n, nrhs, m, a, lda,
460 $ work( 1 ), b, ldb, work( mn+1 ), lwork-mn,
467 CALL strtrs(
'Lower',
'Transpose',
'Non-unit', m, nrhs,
468 $ a, lda, b, ldb, info )
482 IF( iascl.EQ.1 )
THEN
483 CALL slascl(
'G', 0, 0, anrm, smlnum, scllen, nrhs, b, ldb,
485 ELSE IF( iascl.EQ.2 )
THEN
486 CALL slascl(
'G', 0, 0, anrm, bignum, scllen, nrhs, b, ldb,
489 IF( ibscl.EQ.1 )
THEN
490 CALL slascl(
'G', 0, 0, smlnum, bnrm, scllen, nrhs, b, ldb,
492 ELSE IF( ibscl.EQ.2 )
THEN
493 CALL slascl(
'G', 0, 0, bignum, bnrm, scllen, nrhs, b, ldb,
498 work( 1 ) =
REAL( wsize )
subroutine sormqr(SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
SORMQR
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 slabad(SMALL, LARGE)
SLABAD
subroutine strtrs(UPLO, TRANS, DIAG, N, NRHS, A, LDA, B, LDB, INFO)
STRTRS
subroutine sgeqrf(M, N, A, LDA, TAU, WORK, LWORK, INFO)
SGEQRF
subroutine xerbla(SRNAME, INFO)
XERBLA
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 sormlq(SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
SORMLQ
subroutine sgels(TRANS, M, N, NRHS, A, LDA, B, LDB, WORK, LWORK, INFO)
SGELS solves overdetermined or underdetermined systems for GE matrices
subroutine sgelqf(M, N, A, LDA, TAU, WORK, LWORK, INFO)
SGELQF