160 SUBROUTINE dgetsls( TRANS, M, N, NRHS, A, LDA, B, LDB,
161 $ WORK, LWORK, INFO )
169 INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS
172 DOUBLE PRECISION A( LDA, * ), B( LDB, * ), WORK( * )
179 DOUBLE PRECISION ZERO, ONE
180 parameter( zero = 0.0d0, one = 1.0d0 )
184 INTEGER I, IASCL, IBSCL, J, MAXMN, BROW,
185 $ scllen, tszo, tszm, lwo, lwm, lw1, lw2,
186 $ wsizeo, wsizem, info2
187 DOUBLE PRECISION ANRM, BIGNUM, BNRM, SMLNUM, TQ( 5 ), WORKQ( 1 )
191 DOUBLE PRECISION DLAMCH, DLANGE
192 EXTERNAL lsame, dlamch, dlange
199 INTRINSIC dble, 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 dgeqr( m, n, a, lda, tq, -1, workq, -1, info2 )
231 tszo = int( tq( 1 ) )
232 lwo = int( workq( 1 ) )
233 CALL dgemqr(
'L', trans, m, nrhs, n, a, lda, tq,
234 $ tszo, b, ldb, workq, -1, info2 )
235 lwo = max( lwo, int( workq( 1 ) ) )
236 CALL dgeqr( m, n, a, lda, tq, -2, workq, -2, info2 )
237 tszm = int( tq( 1 ) )
238 lwm = int( workq( 1 ) )
239 CALL dgemqr(
'L', trans, m, nrhs, n, a, lda, tq,
240 $ tszm, b, ldb, workq, -1, info2 )
241 lwm = max( lwm, int( workq( 1 ) ) )
245 CALL dgelq( m, n, a, lda, tq, -1, workq, -1, info2 )
246 tszo = int( tq( 1 ) )
247 lwo = int( workq( 1 ) )
248 CALL dgemlq(
'L', trans, n, nrhs, m, a, lda, tq,
249 $ tszo, b, ldb, workq, -1, info2 )
250 lwo = max( lwo, int( workq( 1 ) ) )
251 CALL dgelq( m, n, a, lda, tq, -2, workq, -2, info2 )
252 tszm = int( tq( 1 ) )
253 lwm = int( workq( 1 ) )
254 CALL dgemlq(
'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 ) = dble( wsizeo )
270 CALL xerbla(
'DGETSLS', -info )
274 IF( lwork.EQ.-2 ) work( 1 ) = dble( wsizem )
277 IF( lwork.LT.wsizeo )
THEN
287 IF( min( m, n, nrhs ).EQ.0 )
THEN
288 CALL dlaset(
'FULL', max( m, n ), nrhs, zero, zero,
295 smlnum = dlamch(
'S' ) / dlamch(
'P' )
296 bignum = one / smlnum
300 anrm = dlange(
'M', m, n, a, lda, work )
302 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
306 CALL dlascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, info )
308 ELSE IF( anrm.GT.bignum )
THEN
312 CALL dlascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, info )
314 ELSE IF( anrm.EQ.zero )
THEN
318 CALL dlaset(
'F', maxmn, nrhs, zero, zero, b, ldb )
326 bnrm = dlange(
'M', brow, nrhs, b, ldb, work )
328 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
332 CALL dlascl(
'G', 0, 0, bnrm, smlnum, brow, nrhs, b, ldb,
335 ELSE IF( bnrm.GT.bignum )
THEN
339 CALL dlascl(
'G', 0, 0, bnrm, bignum, brow, nrhs, b, ldb,
348 CALL dgeqr( m, n, a, lda, work( lw2+1 ), lw1,
349 $ work( 1 ), lw2, info )
350 IF ( .NOT.tran )
THEN
356 CALL dgemqr(
'L' ,
'T', m, nrhs, n, a, lda,
357 $ work( lw2+1 ), lw1, b, ldb, work( 1 ), lw2,
362 CALL dtrtrs(
'U',
'N',
'N', n, nrhs,
363 $ a, lda, b, ldb, info )
374 CALL dtrtrs(
'U',
'T',
'N', n, nrhs,
375 $ a, lda, b, ldb, info )
391 CALL dgemqr(
'L',
'N', m, nrhs, n, a, lda,
392 $ work( lw2+1 ), lw1, b, ldb, work( 1 ), lw2,
403 CALL dgelq( m, n, a, lda, work( lw2+1 ), lw1,
404 $ work( 1 ), lw2, info )
414 CALL dtrtrs(
'L',
'N',
'N', m, nrhs,
415 $ a, lda, b, ldb, info )
431 CALL dgemlq(
'L',
'T', n, nrhs, m, a, lda,
432 $ work( lw2+1 ), lw1, b, ldb, work( 1 ), lw2,
445 CALL dgemlq(
'L',
'N', n, nrhs, m, a, lda,
446 $ work( lw2+1 ), lw1, b, ldb, work( 1 ), lw2,
453 CALL dtrtrs(
'Lower',
'Transpose',
'Non-unit', m, nrhs,
454 $ a, lda, b, ldb, info )
468 IF( iascl.EQ.1 )
THEN
469 CALL dlascl(
'G', 0, 0, anrm, smlnum, scllen, nrhs, b, ldb,
471 ELSE IF( iascl.EQ.2 )
THEN
472 CALL dlascl(
'G', 0, 0, anrm, bignum, scllen, nrhs, b, ldb,
475 IF( ibscl.EQ.1 )
THEN
476 CALL dlascl(
'G', 0, 0, smlnum, bnrm, scllen, nrhs, b, ldb,
478 ELSE IF( ibscl.EQ.2 )
THEN
479 CALL dlascl(
'G', 0, 0, bignum, bnrm, scllen, nrhs, b, ldb,
484 work( 1 ) = dble( tszo + lwo )
subroutine xerbla(srname, info)
subroutine dgelq(m, n, a, lda, t, tsize, work, lwork, info)
DGELQ
subroutine dgemlq(side, trans, m, n, k, a, lda, t, tsize, c, ldc, work, lwork, info)
DGEMLQ
subroutine dgemqr(side, trans, m, n, k, a, lda, t, tsize, c, ldc, work, lwork, info)
DGEMQR
subroutine dgeqr(m, n, a, lda, t, tsize, work, lwork, info)
DGEQR
subroutine dgetsls(trans, m, n, nrhs, a, lda, b, ldb, work, lwork, info)
DGETSLS
subroutine dlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
DLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine dlaset(uplo, m, n, alpha, beta, a, lda)
DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine dtrtrs(uplo, trans, diag, n, nrhs, a, lda, b, ldb, info)
DTRTRS