179 SUBROUTINE zlalsd( UPLO, SMLSIZ, N, NRHS, D, E, B, LDB, RCOND,
180 $ RANK, WORK, RWORK, IWORK, INFO )
188 INTEGER INFO, LDB, N, NRHS, RANK, SMLSIZ
189 DOUBLE PRECISION RCOND
193 DOUBLE PRECISION D( * ), E( * ), RWORK( * )
194 COMPLEX*16 B( LDB, * ), WORK( * )
200 DOUBLE PRECISION ZERO, ONE, TWO
201 parameter( zero = 0.0d0, one = 1.0d0, two = 2.0d0 )
203 parameter( czero = ( 0.0d0, 0.0d0 ) )
206 INTEGER BX, BXST, C, DIFL, DIFR, GIVCOL, GIVNUM,
207 $ givptr, i, icmpq1, icmpq2, irwb, irwib, irwrb,
208 $ irwu, irwvt, irwwrk, iwk, j, jcol, jimag,
209 $ jreal, jrow, k, nlvl, nm1, nrwork, nsize, nsub,
210 $ perm, poles, s, sizei, smlszp, sqre, st, st1,
212 DOUBLE PRECISION CS, EPS, ORGNRM, RCND, R, SN, TOL
216 DOUBLE PRECISION DLAMCH, DLANST
217 EXTERNAL idamax, dlamch, dlanst
225 INTRINSIC abs, dble, dcmplx, dimag, int, log, sign
235 ELSE IF( nrhs.LT.1 )
THEN
237 ELSE IF( ( ldb.LT.1 ) .OR. ( ldb.LT.n ) )
THEN
241 CALL xerbla(
'ZLALSD', -info )
245 eps = dlamch(
'Epsilon' )
249 IF( ( rcond.LE.zero ) .OR. ( rcond.GE.one ) )
THEN
261 ELSE IF( n.EQ.1 )
THEN
262 IF( d( 1 ).EQ.zero )
THEN
263 CALL zlaset(
'A', 1, nrhs, czero, czero, b, ldb )
266 CALL zlascl(
'G', 0, 0, d( 1 ), one, 1, nrhs, b, ldb, info )
267 d( 1 ) = abs( d( 1 ) )
274 IF( uplo.EQ.
'L' )
THEN
276 CALL dlartg( d( i ), e( i ), cs, sn, r )
279 d( i+1 ) = cs*d( i+1 )
281 CALL zdrot( 1, b( i, 1 ), 1, b( i+1, 1 ), 1, cs, sn )
292 CALL zdrot( 1, b( j, i ), 1, b( j+1, i ), 1, cs, sn )
301 orgnrm = dlanst(
'M', n, d, e )
302 IF( orgnrm.EQ.zero )
THEN
303 CALL zlaset(
'A', n, nrhs, czero, czero, b, ldb )
307 CALL dlascl(
'G', 0, 0, orgnrm, one, n, 1, d, n, info )
308 CALL dlascl(
'G', 0, 0, orgnrm, one, nm1, 1, e, nm1, info )
313 IF( n.LE.smlsiz )
THEN
318 irwib = irwrb + n*nrhs
319 irwb = irwib + n*nrhs
320 CALL dlaset(
'A', n, n, zero, one, rwork( irwu ), n )
321 CALL dlaset(
'A', n, n, zero, one, rwork( irwvt ), n )
322 CALL dlasdq(
'U', 0, n, n, n, 0, d, e, rwork( irwvt ), n,
323 $ rwork( irwu ), n, rwork( irwwrk ), 1,
324 $ rwork( irwwrk ), info )
337 rwork( j ) = dble( b( jrow, jcol ) )
340 CALL dgemm(
'T',
'N', n, nrhs, n, one, rwork( irwu ), n,
341 $ rwork( irwb ), n, zero, rwork( irwrb ), n )
346 rwork( j ) = dimag( b( jrow, jcol ) )
349 CALL dgemm(
'T',
'N', n, nrhs, n, one, rwork( irwu ), n,
350 $ rwork( irwb ), n, zero, rwork( irwib ), n )
357 b( jrow, jcol ) = dcmplx( rwork( jreal ),
362 tol = rcnd*abs( d( idamax( n, d, 1 ) ) )
364 IF( d( i ).LE.tol )
THEN
365 CALL zlaset(
'A', 1, nrhs, czero, czero, b( i, 1 ), ldb )
367 CALL zlascl(
'G', 0, 0, d( i ), one, 1, nrhs, b( i, 1 ),
381 DO 120 jcol = 1, nrhs
384 rwork( j ) = dble( b( jrow, jcol ) )
387 CALL dgemm(
'T',
'N', n, nrhs, n, one, rwork( irwvt ), n,
388 $ rwork( irwb ), n, zero, rwork( irwrb ), n )
390 DO 140 jcol = 1, nrhs
393 rwork( j ) = dimag( b( jrow, jcol ) )
396 CALL dgemm(
'T',
'N', n, nrhs, n, one, rwork( irwvt ), n,
397 $ rwork( irwb ), n, zero, rwork( irwib ), n )
400 DO 160 jcol = 1, nrhs
404 b( jrow, jcol ) = dcmplx( rwork( jreal ),
411 CALL dlascl(
'G', 0, 0, one, orgnrm, n, 1, d, n, info )
412 CALL dlasrt(
'D', n, d, info )
413 CALL zlascl(
'G', 0, 0, orgnrm, one, n, nrhs, b, ldb, info )
420 nlvl = int( log( dble( n ) / dble( smlsiz+1 ) ) / log( two ) ) + 1
432 givnum = poles + 2*nlvl*n
433 nrwork = givnum + 2*nlvl*n
437 irwib = irwrb + smlsiz*nrhs
438 irwb = irwib + smlsiz*nrhs
444 givcol = perm + nlvl*n
445 iwk = givcol + nlvl*n*2
454 IF( abs( d( i ) ).LT.eps )
THEN
455 d( i ) = sign( eps, d( i ) )
460 IF( ( abs( e( i ) ).LT.eps ) .OR. ( i.EQ.nm1 ) )
THEN
472 iwork( sizei+nsub-1 ) = nsize
473 ELSE IF( abs( e( i ) ).GE.eps )
THEN
478 iwork( sizei+nsub-1 ) = nsize
486 iwork( sizei+nsub-1 ) = nsize
489 iwork( sizei+nsub-1 ) = 1
490 CALL zcopy( nrhs, b( n, 1 ), ldb, work( bx+nm1 ), n )
493 IF( nsize.EQ.1 )
THEN
498 CALL zcopy( nrhs, b( st, 1 ), ldb, work( bx+st1 ), n )
499 ELSE IF( nsize.LE.smlsiz )
THEN
503 CALL dlaset(
'A', nsize, nsize, zero, one,
504 $ rwork( vt+st1 ), n )
505 CALL dlaset(
'A', nsize, nsize, zero, one,
506 $ rwork( u+st1 ), n )
507 CALL dlasdq(
'U', 0, nsize, nsize, nsize, 0, d( st ),
508 $ e( st ), rwork( vt+st1 ), n, rwork( u+st1 ),
509 $ n, rwork( nrwork ), 1, rwork( nrwork ),
520 DO 190 jcol = 1, nrhs
521 DO 180 jrow = st, st + nsize - 1
523 rwork( j ) = dble( b( jrow, jcol ) )
526 CALL dgemm(
'T',
'N', nsize, nrhs, nsize, one,
527 $ rwork( u+st1 ), n, rwork( irwb ), nsize,
528 $ zero, rwork( irwrb ), nsize )
530 DO 210 jcol = 1, nrhs
531 DO 200 jrow = st, st + nsize - 1
533 rwork( j ) = dimag( b( jrow, jcol ) )
536 CALL dgemm(
'T',
'N', nsize, nrhs, nsize, one,
537 $ rwork( u+st1 ), n, rwork( irwb ), nsize,
538 $ zero, rwork( irwib ), nsize )
541 DO 230 jcol = 1, nrhs
542 DO 220 jrow = st, st + nsize - 1
545 b( jrow, jcol ) = dcmplx( rwork( jreal ),
550 CALL zlacpy(
'A', nsize, nrhs, b( st, 1 ), ldb,
551 $ work( bx+st1 ), n )
556 CALL dlasda( icmpq1, smlsiz, nsize, sqre, d( st ),
557 $ e( st ), rwork( u+st1 ), n, rwork( vt+st1 ),
558 $ iwork( k+st1 ), rwork( difl+st1 ),
559 $ rwork( difr+st1 ), rwork( z+st1 ),
560 $ rwork( poles+st1 ), iwork( givptr+st1 ),
561 $ iwork( givcol+st1 ), n, iwork( perm+st1 ),
562 $ rwork( givnum+st1 ), rwork( c+st1 ),
563 $ rwork( s+st1 ), rwork( nrwork ),
564 $ iwork( iwk ), info )
569 CALL zlalsa( icmpq2, smlsiz, nsize, nrhs, b( st, 1 ),
570 $ ldb, work( bxst ), n, rwork( u+st1 ), n,
571 $ rwork( vt+st1 ), iwork( k+st1 ),
572 $ rwork( difl+st1 ), rwork( difr+st1 ),
573 $ rwork( z+st1 ), rwork( poles+st1 ),
574 $ iwork( givptr+st1 ), iwork( givcol+st1 ), n,
575 $ iwork( perm+st1 ), rwork( givnum+st1 ),
576 $ rwork( c+st1 ), rwork( s+st1 ),
577 $ rwork( nrwork ), iwork( iwk ), info )
588 tol = rcnd*abs( d( idamax( n, d, 1 ) ) )
595 IF( abs( d( i ) ).LE.tol )
THEN
596 CALL zlaset(
'A', 1, nrhs, czero, czero, work( bx+i-1 ), n )
599 CALL zlascl(
'G', 0, 0, d( i ), one, 1, nrhs,
600 $ work( bx+i-1 ), n, info )
602 d( i ) = abs( d( i ) )
611 nsize = iwork( sizei+i-1 )
613 IF( nsize.EQ.1 )
THEN
614 CALL zcopy( nrhs, work( bxst ), n, b( st, 1 ), ldb )
615 ELSE IF( nsize.LE.smlsiz )
THEN
626 DO 270 jcol = 1, nrhs
628 DO 260 jrow = 1, nsize
630 rwork( jreal ) = dble( work( j+jrow ) )
633 CALL dgemm(
'T',
'N', nsize, nrhs, nsize, one,
634 $ rwork( vt+st1 ), n, rwork( irwb ), nsize, zero,
635 $ rwork( irwrb ), nsize )
638 DO 290 jcol = 1, nrhs
640 DO 280 jrow = 1, nsize
642 rwork( jimag ) = dimag( work( j+jrow ) )
645 CALL dgemm(
'T',
'N', nsize, nrhs, nsize, one,
646 $ rwork( vt+st1 ), n, rwork( irwb ), nsize, zero,
647 $ rwork( irwib ), nsize )
650 DO 310 jcol = 1, nrhs
651 DO 300 jrow = st, st + nsize - 1
654 b( jrow, jcol ) = dcmplx( rwork( jreal ),
659 CALL zlalsa( icmpq2, smlsiz, nsize, nrhs, work( bxst ), n,
660 $ b( st, 1 ), ldb, rwork( u+st1 ), n,
661 $ rwork( vt+st1 ), iwork( k+st1 ),
662 $ rwork( difl+st1 ), rwork( difr+st1 ),
663 $ rwork( z+st1 ), rwork( poles+st1 ),
664 $ iwork( givptr+st1 ), iwork( givcol+st1 ), n,
665 $ iwork( perm+st1 ), rwork( givnum+st1 ),
666 $ rwork( c+st1 ), rwork( s+st1 ),
667 $ rwork( nrwork ), iwork( iwk ), info )
676 CALL dlascl(
'G', 0, 0, one, orgnrm, n, 1, d, n, info )
677 CALL dlasrt(
'D', n, d, info )
678 CALL zlascl(
'G', 0, 0, orgnrm, one, n, nrhs, b, ldb, info )
subroutine xerbla(srname, info)
subroutine zcopy(n, zx, incx, zy, incy)
ZCOPY
subroutine dgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
DGEMM
subroutine zlacpy(uplo, m, n, a, lda, b, ldb)
ZLACPY copies all or part of one two-dimensional array to another.
subroutine zlalsa(icompq, smlsiz, n, nrhs, b, ldb, bx, ldbx, u, ldu, vt, k, difl, difr, z, poles, givptr, givcol, ldgcol, perm, givnum, c, s, rwork, iwork, info)
ZLALSA computes the SVD of the coefficient matrix in compact form. Used by sgelsd.
subroutine zlalsd(uplo, smlsiz, n, nrhs, d, e, b, ldb, rcond, rank, work, rwork, iwork, info)
ZLALSD uses the singular value decomposition of A to solve the least squares problem.
subroutine dlartg(f, g, c, s, r)
DLARTG generates a plane rotation with real cosine and real sine.
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 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 dlasda(icompq, smlsiz, n, sqre, d, e, u, ldu, vt, k, difl, difr, z, poles, givptr, givcol, ldgcol, perm, givnum, c, s, work, iwork, info)
DLASDA computes the singular value decomposition (SVD) of a real upper bidiagonal matrix with diagona...
subroutine dlasdq(uplo, sqre, n, ncvt, nru, ncc, d, e, vt, ldvt, u, ldu, c, ldc, work, info)
DLASDQ computes the SVD of a real bidiagonal matrix with diagonal d and off-diagonal e....
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 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 dlasrt(id, n, d, info)
DLASRT sorts numbers in increasing or decreasing order.
subroutine zdrot(n, zx, incx, zy, incy, c, s)
ZDROT