182 SUBROUTINE zgelsx( M, N, NRHS, A, LDA, B, LDB, JPVT, RCOND, RANK,
183 $ WORK, RWORK, INFO )
190 INTEGER INFO, LDA, LDB, M, N, NRHS, RANK
191 DOUBLE PRECISION RCOND
195 DOUBLE PRECISION RWORK( * )
196 COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )
203 parameter( imax = 1, imin = 2 )
204 DOUBLE PRECISION ZERO, ONE, DONE, NTDONE
205 parameter( zero = 0.0d+0, one = 1.0d+0, done = zero,
207 COMPLEX*16 CZERO, CONE
208 parameter( czero = ( 0.0d+0, 0.0d+0 ),
209 $ cone = ( 1.0d+0, 0.0d+0 ) )
212 INTEGER I, IASCL, IBSCL, ISMAX, ISMIN, J, K, MN
213 DOUBLE PRECISION ANRM, BIGNUM, BNRM, SMAX, SMAXPR, SMIN, SMINPR,
215 COMPLEX*16 C1, C2, S1, S2, T1, T2
222 DOUBLE PRECISION DLAMCH, ZLANGE
223 EXTERNAL dlamch, zlange
226 INTRINSIC abs, dconjg, max, min
239 ELSE IF( n.LT.0 )
THEN
241 ELSE IF( nrhs.LT.0 )
THEN
243 ELSE IF( lda.LT.max( 1, m ) )
THEN
245 ELSE IF( ldb.LT.max( 1, m, n ) )
THEN
250 CALL xerbla(
'ZGELSX', -info )
256 IF( min( m, n, nrhs ).EQ.0 )
THEN
263 smlnum = dlamch(
'S' ) / dlamch(
'P' )
264 bignum = one / smlnum
268 anrm = zlange(
'M', m, n, a, lda, rwork )
270 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
274 CALL zlascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, info )
276 ELSE IF( anrm.GT.bignum )
THEN
280 CALL zlascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, info )
282 ELSE IF( anrm.EQ.zero )
THEN
286 CALL zlaset(
'F', max( m, n ), nrhs, czero, czero, b, ldb )
291 bnrm = zlange(
'M', m, nrhs, b, ldb, rwork )
293 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
297 CALL zlascl(
'G', 0, 0, bnrm, smlnum, m, nrhs, b, ldb, info )
299 ELSE IF( bnrm.GT.bignum )
THEN
303 CALL zlascl(
'G', 0, 0, bnrm, bignum, m, nrhs, b, ldb, info )
310 CALL zgeqpf( m, n, a, lda, jpvt, work( 1 ), work( mn+1 ), rwork,
320 smax = abs( a( 1, 1 ) )
322 IF( abs( a( 1, 1 ) ).EQ.zero )
THEN
324 CALL zlaset(
'F', max( m, n ), nrhs, czero, czero, b, ldb )
331 IF( rank.LT.mn )
THEN
333 CALL zlaic1( imin, rank, work( ismin ), smin, a( 1, i ),
334 $ a( i, i ), sminpr, s1, c1 )
335 CALL zlaic1( imax, rank, work( ismax ), smax, a( 1, i ),
336 $ a( i, i ), smaxpr, s2, c2 )
338 IF( smaxpr*rcond.LE.sminpr )
THEN
340 work( ismin+i-1 ) = s1*work( ismin+i-1 )
341 work( ismax+i-1 ) = s2*work( ismax+i-1 )
343 work( ismin+rank ) = c1
344 work( ismax+rank ) = c2
359 $
CALL ztzrqf( rank, n, a, lda, work( mn+1 ), info )
365 CALL zunm2r(
'Left',
'Conjugate transpose', m, nrhs, mn, a, lda,
366 $ work( 1 ), b, ldb, work( 2*mn+1 ), info )
372 CALL ztrsm(
'Left',
'Upper',
'No transpose',
'Non-unit', rank,
373 $ nrhs, cone, a, lda, b, ldb )
375 DO 40 i = rank + 1, n
385 CALL zlatzm(
'Left', n-rank+1, nrhs, a( i, rank+1 ), lda,
386 $ dconjg( work( mn+i ) ), b( i, 1 ),
387 $ b( rank+1, 1 ), ldb, work( 2*mn+1 ) )
397 work( 2*mn+i ) = ntdone
400 IF( work( 2*mn+i ).EQ.ntdone )
THEN
401 IF( jpvt( i ).NE.i )
THEN
404 t2 = b( jpvt( k ), j )
406 b( jpvt( k ), j ) = t1
407 work( 2*mn+k ) = done
410 t2 = b( jpvt( k ), j )
414 work( 2*mn+k ) = done
422 IF( iascl.EQ.1 )
THEN
423 CALL zlascl(
'G', 0, 0, anrm, smlnum, n, nrhs, b, ldb, info )
424 CALL zlascl(
'U', 0, 0, smlnum, anrm, rank, rank, a, lda,
426 ELSE IF( iascl.EQ.2 )
THEN
427 CALL zlascl(
'G', 0, 0, anrm, bignum, n, nrhs, b, ldb, info )
428 CALL zlascl(
'U', 0, 0, bignum, anrm, rank, rank, a, lda,
431 IF( ibscl.EQ.1 )
THEN
432 CALL zlascl(
'G', 0, 0, smlnum, bnrm, n, nrhs, b, ldb, info )
433 ELSE IF( ibscl.EQ.2 )
THEN
434 CALL zlascl(
'G', 0, 0, bignum, bnrm, n, nrhs, b, ldb, info )
subroutine xerbla(srname, info)
subroutine zlaic1(job, j, x, sest, w, gamma, sestpr, s, c)
ZLAIC1 applies one step of incremental condition estimation.
subroutine zlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
ZLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine zlaset(uplo, m, n, alpha, beta, a, lda)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine ztrsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
ZTRSM
subroutine zunm2r(side, trans, m, n, k, a, lda, tau, c, ldc, work, info)
ZUNM2R multiplies a general matrix by the unitary matrix from a QR factorization determined by cgeqrf...
subroutine zgelsx(m, n, nrhs, a, lda, b, ldb, jpvt, rcond, rank, work, rwork, info)
ZGELSX solves overdetermined or underdetermined systems for GE matrices
subroutine zgeqpf(m, n, a, lda, jpvt, tau, work, rwork, info)
ZGEQPF
subroutine zlatzm(side, m, n, v, incv, tau, c1, c2, ldc, work)
ZLATZM
subroutine ztzrqf(m, n, a, lda, tau, info)
ZTZRQF