178 SUBROUTINE dgelsx( M, N, NRHS, A, LDA, B, LDB, JPVT, RCOND, RANK,
187 INTEGER INFO, LDA, LDB, M, N, NRHS, RANK
188 DOUBLE PRECISION RCOND
192 DOUBLE PRECISION A( lda, * ), B( ldb, * ), WORK( * )
199 parameter ( imax = 1, imin = 2 )
200 DOUBLE PRECISION ZERO, ONE, DONE, NTDONE
201 parameter ( zero = 0.0d0, one = 1.0d0, done = zero,
205 INTEGER I, IASCL, IBSCL, ISMAX, ISMIN, J, K, MN
206 DOUBLE PRECISION ANRM, BIGNUM, BNRM, C1, C2, S1, S2, SMAX,
207 $ smaxpr, smin, sminpr, smlnum, t1, t2
210 DOUBLE PRECISION DLAMCH, DLANGE
211 EXTERNAL dlamch, dlange
218 INTRINSIC abs, max, min
231 ELSE IF( n.LT.0 )
THEN
233 ELSE IF( nrhs.LT.0 )
THEN
235 ELSE IF( lda.LT.max( 1, m ) )
THEN
237 ELSE IF( ldb.LT.max( 1, m, n ) )
THEN
242 CALL xerbla(
'DGELSX', -info )
248 IF( min( m, n, nrhs ).EQ.0 )
THEN
255 smlnum = dlamch(
'S' ) / dlamch(
'P' )
256 bignum = one / smlnum
257 CALL dlabad( smlnum, bignum )
261 anrm = dlange(
'M', m, n, a, lda, work )
263 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
267 CALL dlascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, info )
269 ELSE IF( anrm.GT.bignum )
THEN
273 CALL dlascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, info )
275 ELSE IF( anrm.EQ.zero )
THEN
279 CALL dlaset(
'F', max( m, n ), nrhs, zero, zero, b, ldb )
284 bnrm = dlange(
'M', m, nrhs, b, ldb, work )
286 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
290 CALL dlascl(
'G', 0, 0, bnrm, smlnum, m, nrhs, b, ldb, info )
292 ELSE IF( bnrm.GT.bignum )
THEN
296 CALL dlascl(
'G', 0, 0, bnrm, bignum, m, nrhs, b, ldb, info )
303 CALL dgeqpf( m, n, a, lda, jpvt, work( 1 ), work( mn+1 ), info )
312 smax = abs( a( 1, 1 ) )
314 IF( abs( a( 1, 1 ) ).EQ.zero )
THEN
316 CALL dlaset(
'F', max( m, n ), nrhs, zero, zero, b, ldb )
323 IF( rank.LT.mn )
THEN
325 CALL dlaic1( imin, rank, work( ismin ), smin, a( 1, i ),
326 $ a( i, i ), sminpr, s1, c1 )
327 CALL dlaic1( imax, rank, work( ismax ), smax, a( 1, i ),
328 $ a( i, i ), smaxpr, s2, c2 )
330 IF( smaxpr*rcond.LE.sminpr )
THEN
332 work( ismin+i-1 ) = s1*work( ismin+i-1 )
333 work( ismax+i-1 ) = s2*work( ismax+i-1 )
335 work( ismin+rank ) = c1
336 work( ismax+rank ) = c2
351 $
CALL dtzrqf( rank, n, a, lda, work( mn+1 ), info )
357 CALL dorm2r(
'Left',
'Transpose', m, nrhs, mn, a, lda, work( 1 ),
358 $ b, ldb, work( 2*mn+1 ), info )
364 CALL dtrsm(
'Left',
'Upper',
'No transpose',
'Non-unit', rank,
365 $ nrhs, one, a, lda, b, ldb )
367 DO 40 i = rank + 1, n
377 CALL dlatzm(
'Left', n-rank+1, nrhs, a( i, rank+1 ), lda,
378 $ work( mn+i ), b( i, 1 ), b( rank+1, 1 ), ldb,
389 work( 2*mn+i ) = ntdone
392 IF( work( 2*mn+i ).EQ.ntdone )
THEN
393 IF( jpvt( i ).NE.i )
THEN
396 t2 = b( jpvt( k ), j )
398 b( jpvt( k ), j ) = t1
399 work( 2*mn+k ) = done
402 t2 = b( jpvt( k ), j )
406 work( 2*mn+k ) = done
414 IF( iascl.EQ.1 )
THEN
415 CALL dlascl(
'G', 0, 0, anrm, smlnum, n, nrhs, b, ldb, info )
416 CALL dlascl(
'U', 0, 0, smlnum, anrm, rank, rank, a, lda,
418 ELSE IF( iascl.EQ.2 )
THEN
419 CALL dlascl(
'G', 0, 0, anrm, bignum, n, nrhs, b, ldb, info )
420 CALL dlascl(
'U', 0, 0, bignum, anrm, rank, rank, a, lda,
423 IF( ibscl.EQ.1 )
THEN
424 CALL dlascl(
'G', 0, 0, smlnum, bnrm, n, nrhs, b, ldb, info )
425 ELSE IF( ibscl.EQ.2 )
THEN
426 CALL dlascl(
'G', 0, 0, bignum, bnrm, n, nrhs, b, ldb, info )
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 dtrsm(SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA, B, LDB)
DTRSM
subroutine dtzrqf(M, N, A, LDA, TAU, INFO)
DTZRQF
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 dlaic1(JOB, J, X, SEST, W, GAMMA, SESTPR, S, C)
DLAIC1 applies one step of incremental condition estimation.
subroutine xerbla(SRNAME, INFO)
XERBLA
subroutine dlabad(SMALL, LARGE)
DLABAD
subroutine dlatzm(SIDE, M, N, V, INCV, TAU, C1, C2, LDC, WORK)
DLATZM
subroutine dgelsx(M, N, NRHS, A, LDA, B, LDB, JPVT, RCOND, RANK, WORK, INFO)
DGELSX solves overdetermined or underdetermined systems for GE matrices
subroutine dgeqpf(M, N, A, LDA, JPVT, TAU, WORK, INFO)
DGEQPF
subroutine dorm2r(SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, INFO)
DORM2R multiplies a general matrix by the orthogonal matrix from a QR factorization determined by sge...