181 SUBROUTINE sgels( TRANS, M, N, NRHS, A, LDA, B, LDB, WORK, LWORK,
190 INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS
193 REAL A( LDA, * ), B( LDB, * ), WORK( * )
200 parameter( zero = 0.0e0, one = 1.0e0 )
204 INTEGER BROW, I, IASCL, IBSCL, J, MN, NB, SCLLEN, WSIZE
205 REAL ANRM, BIGNUM, BNRM, SMLNUM
213 REAL SLAMCH, SLANGE, SROUNDUP_LWORK
214 EXTERNAL lsame, ilaenv, slamch, slange, sroundup_lwork
229 lquery = ( lwork.EQ.-1 )
230 IF( .NOT.( lsame( trans,
'N' ) .OR. lsame( trans,
'T' ) ) )
THEN
232 ELSE IF( m.LT.0 )
THEN
234 ELSE IF( n.LT.0 )
THEN
236 ELSE IF( nrhs.LT.0 )
THEN
238 ELSE IF( lda.LT.max( 1, m ) )
THEN
240 ELSE IF( ldb.LT.max( 1, m, n ) )
THEN
242 ELSE IF( lwork.LT.max( 1, mn + max( mn, nrhs ) ) .AND.
249 IF( info.EQ.0 .OR. info.EQ.-10 )
THEN
252 IF( lsame( trans,
'N' ) )
256 nb = ilaenv( 1,
'SGEQRF',
' ', m, n, -1, -1 )
258 nb = max( nb, ilaenv( 1,
'SORMQR',
'LN', m, nrhs, n,
261 nb = max( nb, ilaenv( 1,
'SORMQR',
'LT', m, nrhs, n,
265 nb = ilaenv( 1,
'SGELQF',
' ', m, n, -1, -1 )
267 nb = max( nb, ilaenv( 1,
'SORMLQ',
'LT', n, nrhs, m,
270 nb = max( nb, ilaenv( 1,
'SORMLQ',
'LN', n, nrhs, m,
275 wsize = max( 1, mn + max( mn, nrhs )*nb )
276 work( 1 ) = sroundup_lwork( wsize )
281 CALL xerbla(
'SGELS ', -info )
283 ELSE IF( lquery )
THEN
289 IF( min( m, n, nrhs ).EQ.0 )
THEN
290 CALL slaset(
'Full', max( m, n ), nrhs, zero, zero, b, ldb )
296 smlnum = slamch(
'S' ) / slamch(
'P' )
297 bignum = one / smlnum
301 anrm = slange(
'M', m, n, a, lda, rwork )
303 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
307 CALL slascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, info )
309 ELSE IF( anrm.GT.bignum )
THEN
313 CALL slascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, info )
315 ELSE IF( anrm.EQ.zero )
THEN
319 CALL slaset(
'F', max( m, n ), nrhs, zero, zero, b, ldb )
326 bnrm = slange(
'M', brow, nrhs, b, ldb, rwork )
328 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
332 CALL slascl(
'G', 0, 0, bnrm, smlnum, brow, nrhs, b, ldb,
335 ELSE IF( bnrm.GT.bignum )
THEN
339 CALL slascl(
'G', 0, 0, bnrm, bignum, brow, nrhs, b, ldb,
348 CALL sgeqrf( m, n, a, lda, work( 1 ), work( mn+1 ), lwork-mn,
359 CALL sormqr(
'Left',
'Transpose', m, nrhs, n, a, lda,
360 $ work( 1 ), b, ldb, work( mn+1 ), lwork-mn,
367 CALL strtrs(
'Upper',
'No transpose',
'Non-unit', n, nrhs,
368 $ a, lda, b, ldb, info )
382 CALL strtrs(
'Upper',
'Transpose',
'Non-unit', n, nrhs,
383 $ a, lda, b, ldb, info )
399 CALL sormqr(
'Left',
'No transpose', m, nrhs, n, a, lda,
400 $ work( 1 ), b, ldb, work( mn+1 ), lwork-mn,
413 CALL sgelqf( m, n, a, lda, work( 1 ), work( mn+1 ), lwork-mn,
424 CALL strtrs(
'Lower',
'No transpose',
'Non-unit', m, nrhs,
425 $ a, lda, b, ldb, info )
441 CALL sormlq(
'Left',
'Transpose', n, nrhs, m, a, lda,
442 $ work( 1 ), b, ldb, work( mn+1 ), lwork-mn,
455 CALL sormlq(
'Left',
'No transpose', n, nrhs, m, a, lda,
456 $ work( 1 ), b, ldb, work( mn+1 ), lwork-mn,
463 CALL strtrs(
'Lower',
'Transpose',
'Non-unit', m, nrhs,
464 $ a, lda, b, ldb, info )
478 IF( iascl.EQ.1 )
THEN
479 CALL slascl(
'G', 0, 0, anrm, smlnum, scllen, nrhs, b, ldb,
481 ELSE IF( iascl.EQ.2 )
THEN
482 CALL slascl(
'G', 0, 0, anrm, bignum, scllen, nrhs, b, ldb,
485 IF( ibscl.EQ.1 )
THEN
486 CALL slascl(
'G', 0, 0, smlnum, bnrm, scllen, nrhs, b, ldb,
488 ELSE IF( ibscl.EQ.2 )
THEN
489 CALL slascl(
'G', 0, 0, bignum, bnrm, scllen, nrhs, b, ldb,
494 work( 1 ) = sroundup_lwork( wsize )
subroutine xerbla(srname, info)
subroutine sgelqf(m, n, a, lda, tau, work, lwork, info)
SGELQF
subroutine sgels(trans, m, n, nrhs, a, lda, b, ldb, work, lwork, info)
SGELS solves overdetermined or underdetermined systems for GE matrices
subroutine sgeqrf(m, n, a, lda, tau, work, lwork, info)
SGEQRF
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
subroutine sormlq(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
SORMLQ
subroutine sormqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
SORMQR