180 SUBROUTINE zgels( TRANS, M, N, NRHS, A, LDA, B, LDB, WORK, LWORK,
189 INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS
192 COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )
198 DOUBLE PRECISION ZERO, ONE
199 parameter( zero = 0.0d+0, one = 1.0d+0 )
201 parameter( czero = ( 0.0d+0, 0.0d+0 ) )
205 INTEGER BROW, I, IASCL, IBSCL, J, MN, NB, SCLLEN, WSIZE
206 DOUBLE PRECISION ANRM, BIGNUM, BNRM, SMLNUM
209 DOUBLE PRECISION RWORK( 1 )
214 DOUBLE PRECISION DLAMCH, ZLANGE
215 EXTERNAL lsame, ilaenv, dlamch, zlange
222 INTRINSIC dble, max, min
230 lquery = ( lwork.EQ.-1 )
231 IF( .NOT.( lsame( trans,
'N' ) .OR. lsame( trans,
'C' ) ) )
THEN
233 ELSE IF( m.LT.0 )
THEN
235 ELSE IF( n.LT.0 )
THEN
237 ELSE IF( nrhs.LT.0 )
THEN
239 ELSE IF( lda.LT.max( 1, m ) )
THEN
241 ELSE IF( ldb.LT.max( 1, m, n ) )
THEN
243 ELSE IF( lwork.LT.max( 1, mn+max( mn, nrhs ) ) .AND. .NOT.lquery )
250 IF( info.EQ.0 .OR. info.EQ.-10 )
THEN
253 IF( lsame( trans,
'N' ) )
257 nb = ilaenv( 1,
'ZGEQRF',
' ', m, n, -1, -1 )
259 nb = max( nb, ilaenv( 1,
'ZUNMQR',
'LN', m, nrhs, n,
262 nb = max( nb, ilaenv( 1,
'ZUNMQR',
'LC', m, nrhs, n,
266 nb = ilaenv( 1,
'ZGELQF',
' ', m, n, -1, -1 )
268 nb = max( nb, ilaenv( 1,
'ZUNMLQ',
'LC', n, nrhs, m,
271 nb = max( nb, ilaenv( 1,
'ZUNMLQ',
'LN', n, nrhs, m,
276 wsize = max( 1, mn+max( mn, nrhs )*nb )
277 work( 1 ) = dble( wsize )
282 CALL xerbla(
'ZGELS ', -info )
284 ELSE IF( lquery )
THEN
290 IF( min( m, n, nrhs ).EQ.0 )
THEN
291 CALL zlaset(
'Full', max( m, n ), nrhs, czero, czero, b, ldb )
297 smlnum = dlamch(
'S' ) / dlamch(
'P' )
298 bignum = one / smlnum
302 anrm = zlange(
'M', m, n, a, lda, rwork )
304 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
308 CALL zlascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, info )
310 ELSE IF( anrm.GT.bignum )
THEN
314 CALL zlascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, info )
316 ELSE IF( anrm.EQ.zero )
THEN
320 CALL zlaset(
'F', max( m, n ), nrhs, czero, czero, b, ldb )
327 bnrm = zlange(
'M', brow, nrhs, b, ldb, rwork )
329 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
333 CALL zlascl(
'G', 0, 0, bnrm, smlnum, brow, nrhs, b, ldb,
336 ELSE IF( bnrm.GT.bignum )
THEN
340 CALL zlascl(
'G', 0, 0, bnrm, bignum, brow, nrhs, b, ldb,
349 CALL zgeqrf( m, n, a, lda, work( 1 ), work( mn+1 ), lwork-mn,
360 CALL zunmqr(
'Left',
'Conjugate transpose', m, nrhs, n, a,
361 $ lda, work( 1 ), b, ldb, work( mn+1 ), lwork-mn,
368 CALL ztrtrs(
'Upper',
'No transpose',
'Non-unit', n, nrhs,
369 $ a, lda, b, ldb, info )
383 CALL ztrtrs(
'Upper',
'Conjugate transpose',
'Non-unit',
384 $ n, nrhs, a, lda, b, ldb, info )
400 CALL zunmqr(
'Left',
'No transpose', m, nrhs, n, a, lda,
401 $ work( 1 ), b, ldb, work( mn+1 ), lwork-mn,
414 CALL zgelqf( m, n, a, lda, work( 1 ), work( mn+1 ), lwork-mn,
425 CALL ztrtrs(
'Lower',
'No transpose',
'Non-unit', m, nrhs,
426 $ a, lda, b, ldb, info )
442 CALL zunmlq(
'Left',
'Conjugate transpose', n, nrhs, m, a,
443 $ lda, work( 1 ), b, ldb, work( mn+1 ), lwork-mn,
456 CALL zunmlq(
'Left',
'No transpose', n, nrhs, m, a, lda,
457 $ work( 1 ), b, ldb, work( mn+1 ), lwork-mn,
464 CALL ztrtrs(
'Lower',
'Conjugate transpose',
'Non-unit',
465 $ m, nrhs, a, lda, b, ldb, info )
479 IF( iascl.EQ.1 )
THEN
480 CALL zlascl(
'G', 0, 0, anrm, smlnum, scllen, nrhs, b, ldb,
482 ELSE IF( iascl.EQ.2 )
THEN
483 CALL zlascl(
'G', 0, 0, anrm, bignum, scllen, nrhs, b, ldb,
486 IF( ibscl.EQ.1 )
THEN
487 CALL zlascl(
'G', 0, 0, smlnum, bnrm, scllen, nrhs, b, ldb,
489 ELSE IF( ibscl.EQ.2 )
THEN
490 CALL zlascl(
'G', 0, 0, bignum, bnrm, scllen, nrhs, b, ldb,
495 work( 1 ) = dble( wsize )
subroutine xerbla(srname, info)
subroutine zgelqf(m, n, a, lda, tau, work, lwork, info)
ZGELQF
subroutine zgels(trans, m, n, nrhs, a, lda, b, ldb, work, lwork, info)
ZGELS solves overdetermined or underdetermined systems for GE matrices
subroutine zgeqrf(m, n, a, lda, tau, work, lwork, info)
ZGEQRF
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 ztrtrs(uplo, trans, diag, n, nrhs, a, lda, b, ldb, info)
ZTRTRS
subroutine zunmlq(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
ZUNMLQ
subroutine zunmqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
ZUNMQR