160 SUBROUTINE sgetsls( TRANS, M, N, NRHS, A, LDA, B, LDB,
161 $ WORK, LWORK, INFO )
169 INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS
172 REAL A( LDA, * ), B( LDB, * ), WORK( * )
180 parameter( zero = 0.0e0, one = 1.0e0 )
184 INTEGER I, IASCL, IBSCL, J, MAXMN, BROW,
185 $ scllen, tszo, tszm, lwo, lwm, lw1, lw2,
186 $ wsizeo, wsizem, info2
187 REAL ANRM, BIGNUM, BNRM, SMLNUM, TQ( 5 ), WORKQ( 1 )
191 REAL SLAMCH, SLANGE, SROUNDUP_LWORK
192 EXTERNAL lsame, slamch, slange, sroundup_lwork
199 INTRINSIC max, min, int
207 tran = lsame( trans,
'T' )
209 lquery = ( lwork.EQ.-1 .OR. lwork.EQ.-2 )
210 IF( .NOT.( lsame( trans,
'N' ) .OR.
211 $ lsame( trans,
'T' ) ) )
THEN
213 ELSE IF( m.LT.0 )
THEN
215 ELSE IF( n.LT.0 )
THEN
217 ELSE IF( nrhs.LT.0 )
THEN
219 ELSE IF( lda.LT.max( 1, m ) )
THEN
221 ELSE IF( ldb.LT.max( 1, m, n ) )
THEN
230 CALL sgeqr( m, n, a, lda, tq, -1, workq, -1, info2 )
231 tszo = int( tq( 1 ) )
232 lwo = int( workq( 1 ) )
233 CALL sgemqr(
'L', trans, m, nrhs, n, a, lda, tq,
234 $ tszo, b, ldb, workq, -1, info2 )
235 lwo = max( lwo, int( workq( 1 ) ) )
236 CALL sgeqr( m, n, a, lda, tq, -2, workq, -2, info2 )
237 tszm = int( tq( 1 ) )
238 lwm = int( workq( 1 ) )
239 CALL sgemqr(
'L', trans, m, nrhs, n, a, lda, tq,
240 $ tszm, b, ldb, workq, -1, info2 )
241 lwm = max( lwm, int( workq( 1 ) ) )
245 CALL sgelq( m, n, a, lda, tq, -1, workq, -1, info2 )
246 tszo = int( tq( 1 ) )
247 lwo = int( workq( 1 ) )
248 CALL sgemlq(
'L', trans, n, nrhs, m, a, lda, tq,
249 $ tszo, b, ldb, workq, -1, info2 )
250 lwo = max( lwo, int( workq( 1 ) ) )
251 CALL sgelq( m, n, a, lda, tq, -2, workq, -2, info2 )
252 tszm = int( tq( 1 ) )
253 lwm = int( workq( 1 ) )
254 CALL sgemlq(
'L', trans, n, nrhs, m, a, lda, tq,
255 $ tszm, b, ldb, workq, -1, info2 )
256 lwm = max( lwm, int( workq( 1 ) ) )
261 IF( ( lwork.LT.wsizem ).AND.( .NOT.lquery ) )
THEN
265 work( 1 ) = sroundup_lwork( wsizeo )
270 CALL xerbla(
'SGETSLS', -info )
274 IF( lwork.EQ.-2 ) work( 1 ) = sroundup_lwork( wsizem )
277 IF( lwork.LT.wsizeo )
THEN
287 IF( min( m, n, nrhs ).EQ.0 )
THEN
288 CALL slaset(
'FULL', max( m, n ), nrhs, zero, zero,
295 smlnum = slamch(
'S' ) / slamch(
'P' )
296 bignum = one / smlnum
300 anrm = slange(
'M', m, n, a, lda, work )
302 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
306 CALL slascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, info )
308 ELSE IF( anrm.GT.bignum )
THEN
312 CALL slascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, info )
314 ELSE IF( anrm.EQ.zero )
THEN
318 CALL slaset(
'F', maxmn, nrhs, zero, zero, b, ldb )
326 bnrm = slange(
'M', brow, nrhs, b, ldb, work )
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 sgeqr( m, n, a, lda, work( lw2+1 ), lw1,
349 $ work( 1 ), lw2, info )
350 IF ( .NOT.tran )
THEN
356 CALL sgemqr(
'L' ,
'T', m, nrhs, n, a, lda,
357 $ work( lw2+1 ), lw1, b, ldb, work( 1 ), lw2,
362 CALL strtrs(
'U',
'N',
'N', n, nrhs,
363 $ a, lda, b, ldb, info )
374 CALL strtrs(
'U',
'T',
'N', n, nrhs,
375 $ a, lda, b, ldb, info )
391 CALL sgemqr(
'L',
'N', m, nrhs, n, a, lda,
392 $ work( lw2+1 ), lw1, b, ldb, work( 1 ), lw2,
403 CALL sgelq( m, n, a, lda, work( lw2+1 ), lw1,
404 $ work( 1 ), lw2, info )
414 CALL strtrs(
'L',
'N',
'N', m, nrhs,
415 $ a, lda, b, ldb, info )
431 CALL sgemlq(
'L',
'T', n, nrhs, m, a, lda,
432 $ work( lw2+1 ), lw1, b, ldb, work( 1 ), lw2,
445 CALL sgemlq(
'L',
'N', n, nrhs, m, a, lda,
446 $ work( lw2+1 ), lw1, b, ldb, work( 1 ), lw2,
453 CALL strtrs(
'Lower',
'Transpose',
'Non-unit', m, nrhs,
454 $ a, lda, b, ldb, info )
468 IF( iascl.EQ.1 )
THEN
469 CALL slascl(
'G', 0, 0, anrm, smlnum, scllen, nrhs, b, ldb,
471 ELSE IF( iascl.EQ.2 )
THEN
472 CALL slascl(
'G', 0, 0, anrm, bignum, scllen, nrhs, b, ldb,
475 IF( ibscl.EQ.1 )
THEN
476 CALL slascl(
'G', 0, 0, smlnum, bnrm, scllen, nrhs, b, ldb,
478 ELSE IF( ibscl.EQ.2 )
THEN
479 CALL slascl(
'G', 0, 0, bignum, bnrm, scllen, nrhs, b, ldb,
484 work( 1 ) = sroundup_lwork( tszo + lwo )
subroutine xerbla(srname, info)
subroutine sgelq(m, n, a, lda, t, tsize, work, lwork, info)
SGELQ
subroutine sgemlq(side, trans, m, n, k, a, lda, t, tsize, c, ldc, work, lwork, info)
SGEMLQ
subroutine sgemqr(side, trans, m, n, k, a, lda, t, tsize, c, ldc, work, lwork, info)
SGEMQR
subroutine sgeqr(m, n, a, lda, t, tsize, work, lwork, info)
SGEQR
subroutine sgetsls(trans, m, n, nrhs, a, lda, b, ldb, work, lwork, info)
SGETSLS
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