516 SUBROUTINE zgejsv( JOBA, JOBU, JOBV, JOBR, JOBT, JOBP,
517 $ m, n, a, lda, sva, u, ldu, v, ldv,
518 $ cwork, lwork, rwork, lrwork, iwork, info )
527 INTEGER INFO, LDA, LDU, LDV, LWORK, LRWORK, M, N
530 COMPLEX*16 A( lda, * ), U( ldu, * ), V( ldv, * ),
532 DOUBLE PRECISION SVA( n ), RWORK( * )
534 CHARACTER*1 JOBA, JOBP, JOBR, JOBT, JOBU, JOBV
540 DOUBLE PRECISION ZERO, ONE
541 parameter( zero = 0.0d0, one = 1.0d0 )
542 COMPLEX*16 CZERO, CONE
543 parameter( czero = ( 0.0d0, 0.0d0 ), cone = ( 1.0d0, 0.0d0 ) )
547 DOUBLE PRECISION AAPP, AAQQ, AATMAX, AATMIN, BIG, BIG1,
548 $ cond_ok, condr1, condr2, entra, entrat, epsln,
549 $ maxprj, scalem, sconda, sfmin, small, temp1,
550 $ uscal1, uscal2, xsc
551 INTEGER IERR, N1, NR, NUMRANK, p, q, WARNING
552 LOGICAL ALMORT, DEFR, ERREST, GOSCAL, JRACC, KILL, LSVEC,
553 $ l2aber, l2kill, l2pert, l2rank, l2tran,
554 $ noscal, rowpiv, rsvec, transp
557 INTRINSIC abs, dcmplx, dconjg, dlog, dmax1, dmin1, dble,
558 $ max0, min0, nint, dsqrt
561 DOUBLE PRECISION DLAMCH, DZNRM2
562 INTEGER IDAMAX, IZAMAX
564 EXTERNAL idamax, izamax, lsame, dlamch, dznrm2
577 lsvec = lsame( jobu,
'U' ) .OR. lsame( jobu,
'F' )
578 jracc = lsame( jobv,
'J' )
579 rsvec = lsame( jobv,
'V' ) .OR. jracc
580 rowpiv = lsame( joba,
'F' ) .OR. lsame( joba,
'G' )
581 l2rank = lsame( joba,
'R' )
582 l2aber = lsame( joba,
'A' )
583 errest = lsame( joba,
'E' ) .OR. lsame( joba,
'G' )
584 l2tran = lsame( jobt,
'T' )
585 l2kill = lsame( jobr,
'R' )
586 defr = lsame( jobr,
'N' )
587 l2pert = lsame( jobp,
'P' )
589 IF ( .NOT.(rowpiv .OR. l2rank .OR. l2aber .OR.
590 $ errest .OR. lsame( joba,
'C' ) ))
THEN
592 ELSE IF ( .NOT.( lsvec .OR. lsame( jobu,
'N' ) .OR.
593 $ lsame( jobu,
'W' )) )
THEN
595 ELSE IF ( .NOT.( rsvec .OR. lsame( jobv,
'N' ) .OR.
596 $ lsame( jobv,
'W' )) .OR. ( jracc .AND. (.NOT.lsvec) ) )
THEN
598 ELSE IF ( .NOT. ( l2kill .OR. defr ) )
THEN
600 ELSE IF ( .NOT. ( l2tran .OR. lsame( jobt,
'N' ) ) )
THEN
602 ELSE IF ( .NOT. ( l2pert .OR. lsame( jobp,
'N' ) ) )
THEN
604 ELSE IF ( m .LT. 0 )
THEN
606 ELSE IF ( ( n .LT. 0 ) .OR. ( n .GT. m ) )
THEN
608 ELSE IF ( lda .LT. m )
THEN
610 ELSE IF ( lsvec .AND. ( ldu .LT. m ) )
THEN
612 ELSE IF ( rsvec .AND. ( ldv .LT. n ) )
THEN
614 ELSE IF ( (.NOT.(lsvec .OR. rsvec .OR. errest).AND.
615 $ (lwork .LT. 2*n+1)) .OR.
616 $ (.NOT.(lsvec .OR. rsvec) .AND. errest .AND.
617 $ (lwork .LT. n*n+3*n)) .OR.
618 $ (lsvec .AND. (.NOT.rsvec) .AND. (lwork .LT. 3*n))
620 $ (rsvec .AND. (.NOT.lsvec) .AND. (lwork .LT. 3*n))
622 $ (lsvec .AND. rsvec .AND. (.NOT.jracc) .AND.
623 $ (lwork.LT.5*n+2*n*n))
624 $ .OR. (lsvec .AND. rsvec .AND. jracc .AND.
628 ELSE IF ( lrwork.LT. max0(n+2*m,7))
THEN
635 IF ( info .NE. 0 )
THEN
637 CALL xerbla(
'ZGEJSV', - info )
643 IF ( ( m .EQ. 0 ) .OR. ( n .EQ. 0 ) )
THEN
653 IF ( lsame( jobu,
'F' ) ) n1 = m
660 epsln = dlamch(
'Epsilon')
661 sfmin = dlamch(
'SafeMinimum')
662 small = sfmin / epsln
672 scalem = one / dsqrt(dble(m)*dble(n))
678 CALL zlassq( m, a(1,p), 1, aapp, aaqq )
679 IF ( aapp .GT. big )
THEN
681 CALL xerbla(
'ZGEJSV', -info )
685 IF ( ( aapp .LT. (big / aaqq) ) .AND. noscal )
THEN
689 sva(p) = aapp * ( aaqq * scalem )
692 CALL dscal( p-1, scalem, sva, 1 )
697 IF ( noscal ) scalem = one
702 aapp = dmax1( aapp, sva(p) )
703 IF ( sva(p) .NE. zero ) aaqq = dmin1( aaqq, sva(p) )
708 IF ( aapp .EQ. zero )
THEN
709 IF ( lsvec )
CALL zlaset(
'G', m, n1, czero, cone, u, ldu )
710 IF ( rsvec )
CALL zlaset(
'G', n, n, czero, cone, v, ldv )
713 IF ( errest ) rwork(3) = one
714 IF ( lsvec .AND. rsvec )
THEN
733 IF ( aaqq .LE. sfmin )
THEN
744 CALL zlascl(
'G',0,0,sva(1),scalem, m,1,a(1,1),lda,ierr )
745 CALL zlacpy(
'A', m, 1, a, lda, u, ldu )
747 IF ( n1 .NE. n )
THEN
748 CALL zgeqrf( m, n, u,ldu, cwork, cwork(n+1),lwork-n,ierr )
749 CALL zungqr( m,n1,1, u,ldu,cwork,cwork(n+1),lwork-n,ierr )
750 CALL zcopy( m, a(1,1), 1, u(1,1), 1 )
756 IF ( sva(1) .LT. (big*scalem) )
THEN
757 sva(1) = sva(1) / scalem
760 rwork(1) = one / scalem
762 IF ( sva(1) .NE. zero )
THEN
764 IF ( ( sva(1) / scalem) .GE. sfmin )
THEN
774 IF ( errest ) rwork(3) = one
775 IF ( lsvec .AND. rsvec )
THEN
788 l2tran = l2tran .AND. ( m .EQ. n )
792 IF ( rowpiv .OR. l2tran )
THEN
803 CALL zlassq( n, a(p,1), lda, xsc, temp1 )
806 rwork(m+n+p) = xsc * scalem
807 rwork(n+p) = xsc * (scalem*dsqrt(temp1))
808 aatmax = dmax1( aatmax, rwork(n+p) )
809 IF (rwork(n+p) .NE. zero)
810 $ aatmin = dmin1(aatmin,rwork(n+p))
814 rwork(m+n+p) = scalem*abs( a(p,izamax(n,a(p,1),lda)) )
815 aatmax = dmax1( aatmax, rwork(m+n+p) )
816 aatmin = dmin1( aatmin, rwork(m+n+p) )
835 CALL dlassq( n, sva, 1, xsc, temp1 )
840 big1 = ( ( sva(p) / xsc )**2 ) * temp1
841 IF ( big1 .NE. zero ) entra = entra + big1 * dlog(big1)
843 entra = - entra / dlog(dble(n))
853 big1 = ( ( rwork(p) / xsc )**2 ) * temp1
854 IF ( big1 .NE. zero ) entrat = entrat + big1 * dlog(big1)
856 entrat = - entrat / dlog(dble(m))
861 transp = ( entrat .LT. entra )
870 a(p,p) = dconjg(a(p,p))
872 ctemp = dconjg(a(q,p))
873 a(q,p) = dconjg(a(p,q))
877 a(n,n) = dconjg(a(n,n))
879 rwork(m+n+p) = sva(p)
912 temp1 = dsqrt( big / dble(n) )
914 CALL dlascl(
'G', 0, 0, aapp, temp1, n, 1, sva, n, ierr )
915 IF ( aaqq .GT. (aapp * sfmin) )
THEN
916 aaqq = ( aaqq / aapp ) * temp1
918 aaqq = ( aaqq * temp1 ) / aapp
920 temp1 = temp1 * scalem
921 CALL zlascl(
'G', 0, 0, aapp, temp1, m, n, a, lda, ierr )
945 IF ( ( aaqq.LT.dsqrt(sfmin) ) .AND. lsvec .AND. rsvec )
THEN
950 IF ( aaqq .LT. xsc )
THEN
952 IF ( sva(p) .LT. xsc )
THEN
953 CALL zlaset(
'A', m, 1, czero, czero, a(1,p), lda )
968 q = idamax( m-p+1, rwork(m+n+p), 1 ) + p - 1
972 rwork(m+n+p) = rwork(m+n+q)
976 CALL zlaswp( n, a, lda, 1, m-1, iwork(2*n+1), 1 )
999 CALL zgeqp3( m, n, a, lda, iwork, cwork, cwork(n+1), lwork-n,
1016 temp1 = dsqrt(dble(n))*epsln
1018 IF ( abs(a(p,p)) .GE. (temp1*abs(a(1,1))) )
THEN
1025 ELSE IF ( l2rank )
THEN
1029 temp1 = dsqrt(sfmin)
1031 IF ( ( abs(a(p,p)) .LT. (epsln*abs(a(p-1,p-1))) ) .OR.
1032 $ ( abs(a(p,p)) .LT. small ) .OR.
1033 $ ( l2kill .AND. (abs(a(p,p)) .LT. temp1) ) )
GO TO 3402
1046 temp1 = dsqrt(sfmin)
1048 IF ( ( abs(a(p,p)) .LT. small ) .OR.
1049 $ ( l2kill .AND. (abs(a(p,p)) .LT. temp1) ) )
GO TO 3302
1057 IF ( nr .EQ. n )
THEN
1060 temp1 = abs(a(p,p)) / sva(iwork(p))
1061 maxprj = dmin1( maxprj, temp1 )
1063 IF ( maxprj**2 .GE. one - dble(n)*epsln ) almort = .true.
1072 IF ( n .EQ. nr )
THEN
1075 CALL zlacpy(
'U', n, n, a, lda, v, ldv )
1077 temp1 = sva(iwork(p))
1078 CALL zdscal( p, one/temp1, v(1,p), 1 )
1080 CALL zpocon(
'U', n, v, ldv, one, temp1,
1081 $ cwork(n+1), rwork, ierr )
1083 ELSE IF ( lsvec )
THEN
1085 CALL zlacpy(
'U', n, n, a, lda, u, ldu )
1087 temp1 = sva(iwork(p))
1088 CALL zdscal( p, one/temp1, u(1,p), 1 )
1090 CALL zpocon(
'U', n, u, ldu, one, temp1,
1091 $ cwork(n+1), rwork, ierr )
1093 CALL zlacpy(
'U', n, n, a, lda, cwork(n+1), n )
1095 temp1 = sva(iwork(p))
1096 CALL zdscal( p, one/temp1, cwork(n+(p-1)*n+1), 1 )
1099 CALL zpocon(
'U', n, cwork(n+1), n, one, temp1,
1100 $ cwork(n+n*n+1), rwork, ierr )
1103 sconda = one / dsqrt(temp1)
1111 l2pert = l2pert .AND. ( abs( a(1,1)/a(nr,nr) ) .GT. dsqrt(big1) )
1116 IF ( .NOT. ( rsvec .OR. lsvec ) )
THEN
1121 DO 1946 p = 1, min0( n-1, nr )
1122 CALL zcopy( n-p, a(p,p+1), lda, a(p+1,p), 1 )
1123 CALL zlacgv( n-p+1, a(p,p), 1 )
1125 IF ( nr .EQ. n ) a(n,n) = dconjg(a(n,n))
1139 IF ( .NOT. almort )
THEN
1143 xsc = epsln / dble(n)
1145 ctemp = dcmplx(xsc*abs(a(q,q)),zero)
1147 IF ( ( (p.GT.q) .AND. (abs(a(p,q)).LE.temp1) )
1148 $ .OR. ( p .LT. q ) )
1154 CALL zlaset(
'U', nr-1,nr-1, czero,czero, a(1,2),lda )
1159 CALL zgeqrf( n,nr, a,lda, cwork, cwork(n+1),lwork-n, ierr )
1162 DO 1948 p = 1, nr - 1
1163 CALL zcopy( nr-p, a(p,p+1), lda, a(p+1,p), 1 )
1164 CALL zlacgv( nr-p+1, a(p,p), 1 )
1175 xsc = epsln / dble(n)
1177 ctemp = dcmplx(xsc*abs(a(q,q)),zero)
1179 IF ( ( (p.GT.q) .AND. (abs(a(p,q)).LE.temp1) )
1180 $ .OR. ( p .LT. q ) )
1186 CALL zlaset(
'U', nr-1, nr-1, czero, czero, a(1,2), lda )
1193 CALL zgesvj(
'L',
'NoU',
'NoV', nr, nr, a, lda, sva,
1194 $ n, v, ldv, cwork, lwork, rwork, lrwork, info )
1197 numrank = nint(rwork(2))
1200 ELSE IF ( rsvec .AND. ( .NOT. lsvec ) )
THEN
1208 CALL zcopy( n-p+1, a(p,p), lda, v(p,p), 1 )
1209 CALL zlacgv( n-p+1, v(p,p), 1 )
1211 CALL zlaset(
'Upper', nr-1,nr-1, czero, czero, v(1,2), ldv )
1213 CALL zgesvj(
'L',
'U',
'N', n, nr, v,ldv, sva, nr, a,lda,
1214 $ cwork, lwork, rwork, lrwork, info )
1216 numrank = nint(rwork(2))
1223 CALL zlaset(
'Lower', nr-1,nr-1, czero, czero, a(2,1), lda )
1224 CALL zgelqf( nr,n, a, lda, cwork, cwork(n+1), lwork-n, ierr)
1225 CALL zlacpy(
'Lower', nr, nr, a, lda, v, ldv )
1226 CALL zlaset(
'Upper', nr-1,nr-1, czero, czero, v(1,2), ldv )
1227 CALL zgeqrf( nr, nr, v, ldv, cwork(n+1), cwork(2*n+1),
1230 CALL zcopy( nr-p+1, v(p,p), ldv, v(p,p), 1 )
1231 CALL zlacgv( nr-p+1, v(p,p), 1 )
1233 CALL zlaset(
'Upper', nr-1, nr-1, czero, czero, v(1,2), ldv)
1235 CALL zgesvj(
'Lower',
'U',
'N', nr, nr, v,ldv, sva, nr, u,
1236 $ ldu, cwork(n+1), lwork-n, rwork, lrwork, info )
1238 numrank = nint(rwork(2))
1239 IF ( nr .LT. n )
THEN
1240 CALL zlaset(
'A',n-nr, nr, czero,czero, v(nr+1,1), ldv )
1241 CALL zlaset(
'A',nr, n-nr, czero,czero, v(1,nr+1), ldv )
1242 CALL zlaset(
'A',n-nr,n-nr,czero,cone, v(nr+1,nr+1),ldv )
1245 CALL zunmlq(
'Left',
'C', n, n, nr, a, lda, cwork,
1246 $ v, ldv, cwork(n+1), lwork-n, ierr )
1251 CALL zcopy( n, v(p,1), ldv, a(iwork(p),1), lda )
1253 CALL zlacpy(
'All', n, n, a, lda, v, ldv )
1256 CALL zlacpy(
'All', n, n, v, ldv, u, ldu )
1259 ELSE IF ( lsvec .AND. ( .NOT. rsvec ) )
THEN
1266 CALL zcopy( n-p+1, a(p,p), lda, u(p,p), 1 )
1267 CALL zlacgv( n-p+1, u(p,p), 1 )
1269 CALL zlaset(
'Upper', nr-1, nr-1, czero, czero, u(1,2), ldu )
1271 CALL zgeqrf( n, nr, u, ldu, cwork(n+1), cwork(2*n+1),
1274 DO 1967 p = 1, nr - 1
1275 CALL zcopy( nr-p, u(p,p+1), ldu, u(p+1,p), 1 )
1276 CALL zlacgv( n-p+1, u(p,p), 1 )
1278 CALL zlaset(
'Upper', nr-1, nr-1, czero, czero, u(1,2), ldu )
1280 CALL zgesvj(
'Lower',
'U',
'N', nr,nr, u, ldu, sva, nr, a,
1281 $ lda, cwork(n+1), lwork-n, rwork, lrwork, info )
1283 numrank = nint(rwork(2))
1285 IF ( nr .LT. m )
THEN
1286 CALL zlaset(
'A', m-nr, nr,czero, czero, u(nr+1,1), ldu )
1287 IF ( nr .LT. n1 )
THEN
1288 CALL zlaset(
'A',nr, n1-nr, czero, czero, u(1,nr+1),ldu )
1289 CALL zlaset(
'A',m-nr,n1-nr,czero,cone,u(nr+1,nr+1),ldu )
1293 CALL zunmqr(
'Left',
'No Tr', m, n1, n, a, lda, cwork, u,
1294 $ ldu, cwork(n+1), lwork-n, ierr )
1297 $
CALL zlaswp( n1, u, ldu, 1, m-1, iwork(2*n+1), -1 )
1300 xsc = one / dznrm2( m, u(1,p), 1 )
1301 CALL zdscal( m, xsc, u(1,p), 1 )
1305 CALL zlacpy(
'All', n, n, u, ldu, v, ldv )
1312 IF ( .NOT. jracc )
THEN
1314 IF ( .NOT. almort )
THEN
1324 CALL zcopy( n-p+1, a(p,p), lda, v(p,p), 1 )
1325 CALL zlacgv( n-p+1, v(p,p), 1 )
1343 ctemp = dcmplx(xsc*abs( v(q,q) ),zero)
1345 IF ( ( p .GT. q ) .AND. ( abs(v(p,q)) .LE. temp1 )
1346 $ .OR. ( p .LT. q ) )
1349 IF ( p .LT. q ) v(p,q) = - v(p,q)
1353 CALL zlaset(
'U', nr-1, nr-1, czero, czero, v(1,2), ldv )
1360 CALL zlacpy(
'L', nr, nr, v, ldv, cwork(2*n+1), nr )
1362 temp1 = dznrm2(nr-p+1,cwork(2*n+(p-1)*nr+p),1)
1363 CALL zdscal(nr-p+1,one/temp1,cwork(2*n+(p-1)*nr+p),1)
1365 CALL zpocon(
'Lower',nr,cwork(2*n+1),nr,one,temp1,
1366 $ cwork(2*n+nr*nr+1),rwork,ierr)
1367 condr1 = one / dsqrt(temp1)
1373 cond_ok = dsqrt(dsqrt(dble(nr)))
1376 IF ( condr1 .LT. cond_ok )
THEN
1381 CALL zgeqrf( n, nr, v, ldv, cwork(n+1), cwork(2*n+1),
1385 xsc = dsqrt(small)/epsln
1387 DO 3958 q = 1, p - 1
1388 ctemp=dcmplx(xsc*dmin1(abs(v(p,p)),abs(v(q,q))),
1390 IF ( abs(v(q,p)) .LE. temp1 )
1398 $
CALL zlacpy(
'A', n, nr, v, ldv, cwork(2*n+1), n )
1402 DO 1969 p = 1, nr - 1
1403 CALL zcopy( nr-p, v(p,p+1), ldv, v(p+1,p), 1 )
1404 CALL zlacgv(nr-p+1, v(p,p), 1 )
1406 v(nr,nr)=dconjg(v(nr,nr))
1423 CALL zgeqp3( n, nr, v, ldv, iwork(n+1), cwork(n+1),
1424 $ cwork(2*n+1), lwork-2*n, rwork, ierr )
1430 DO 3968 q = 1, p - 1
1431 ctemp=dcmplx(xsc*dmin1(abs(v(p,p)),abs(v(q,q))),
1433 IF ( abs(v(q,p)) .LE. temp1 )
1440 CALL zlacpy(
'A', n, nr, v, ldv, cwork(2*n+1), n )
1445 DO 8971 q = 1, p - 1
1446 ctemp=dcmplx(xsc*dmin1(abs(v(p,p)),abs(v(q,q))),
1453 CALL zlaset(
'L',nr-1,nr-1,czero,czero,v(2,1),ldv )
1456 CALL zgelqf( nr, nr, v, ldv, cwork(2*n+n*nr+1),
1457 $ cwork(2*n+n*nr+nr+1), lwork-2*n-n*nr-nr, ierr )
1459 CALL zlacpy(
'L',nr,nr,v,ldv,cwork(2*n+n*nr+nr+1),nr )
1461 temp1 = dznrm2( p, cwork(2*n+n*nr+nr+p), nr )
1462 CALL zdscal( p, one/temp1, cwork(2*n+n*nr+nr+p), nr )
1464 CALL zpocon(
'L',nr,cwork(2*n+n*nr+nr+1),nr,one,temp1,
1465 $ cwork(2*n+n*nr+nr+nr*nr+1),rwork,ierr )
1466 condr2 = one / dsqrt(temp1)
1469 IF ( condr2 .GE. cond_ok )
THEN
1474 CALL zlacpy(
'U', nr, nr, v, ldv, cwork(2*n+1), n )
1484 ctemp = xsc * v(q,q)
1485 DO 4969 p = 1, q - 1
1491 CALL zlaset(
'U', nr-1,nr-1, czero,czero, v(1,2), ldv )
1500 IF ( condr1 .LT. cond_ok )
THEN
1502 CALL zgesvj(
'L',
'U',
'N',nr,nr,v,ldv,sva,nr,u, ldu,
1503 $ cwork(2*n+n*nr+nr+1),lwork-2*n-n*nr-nr,rwork,
1506 numrank = nint(rwork(2))
1508 CALL zcopy( nr, v(1,p), 1, u(1,p), 1 )
1509 CALL zdscal( nr, sva(p), v(1,p), 1 )
1514 IF ( nr .EQ. n )
THEN
1519 CALL ztrsm(
'L',
'U',
'N',
'N', nr,nr,cone, a,lda, v,ldv)
1525 CALL ztrsm(
'L',
'U',
'C',
'N',nr,nr,cone,cwork(2*n+1),
1527 IF ( nr .LT. n )
THEN
1528 CALL zlaset(
'A',n-nr,nr,czero,czero,v(nr+1,1),ldv)
1529 CALL zlaset(
'A',nr,n-nr,czero,czero,v(1,nr+1),ldv)
1530 CALL zlaset(
'A',n-nr,n-nr,czero,cone,v(nr+1,nr+1),ldv)
1532 CALL zunmqr(
'L',
'N',n,n,nr,cwork(2*n+1),n,cwork(n+1),
1533 $ v,ldv,cwork(2*n+n*nr+nr+1),lwork-2*n-n*nr-nr,ierr)
1536 ELSE IF ( condr2 .LT. cond_ok )
THEN
1542 CALL zgesvj(
'L',
'U',
'N', nr, nr, v, ldv, sva, nr, u,
1543 $ ldu, cwork(2*n+n*nr+nr+1), lwork-2*n-n*nr-nr,
1544 $ rwork, lrwork, info )
1546 numrank = nint(rwork(2))
1548 CALL zcopy( nr, v(1,p), 1, u(1,p), 1 )
1549 CALL zdscal( nr, sva(p), u(1,p), 1 )
1551 CALL ztrsm(
'L',
'U',
'N',
'N',nr,nr,cone,cwork(2*n+1),n,
1556 cwork(2*n+n*nr+nr+iwork(n+p)) = u(p,q)
1559 u(p,q) = cwork(2*n+n*nr+nr+p)
1562 IF ( nr .LT. n )
THEN
1563 CALL zlaset(
'A',n-nr,nr,czero,czero,v(nr+1,1),ldv )
1564 CALL zlaset(
'A',nr,n-nr,czero,czero,v(1,nr+1),ldv )
1565 CALL zlaset(
'A',n-nr,n-nr,czero,cone,v(nr+1,nr+1),ldv)
1567 CALL zunmqr(
'L',
'N',n,n,nr,cwork(2*n+1),n,cwork(n+1),
1568 $ v,ldv,cwork(2*n+n*nr+nr+1),lwork-2*n-n*nr-nr,ierr )
1581 CALL zgesvj(
'L',
'U',
'V', nr, nr, v, ldv, sva, nr, u,
1582 $ ldu, cwork(2*n+n*nr+nr+1), lwork-2*n-n*nr-nr,
1583 $ rwork, lrwork, info )
1585 numrank = nint(rwork(2))
1586 IF ( nr .LT. n )
THEN
1587 CALL zlaset(
'A',n-nr,nr,czero,czero,v(nr+1,1),ldv )
1588 CALL zlaset(
'A',nr,n-nr,czero,czero,v(1,nr+1),ldv )
1589 CALL zlaset(
'A',n-nr,n-nr,czero,cone,v(nr+1,nr+1),ldv)
1591 CALL zunmqr(
'L',
'N',n,n,nr,cwork(2*n+1),n,cwork(n+1),
1592 $ v,ldv,cwork(2*n+n*nr+nr+1),lwork-2*n-n*nr-nr,ierr )
1594 CALL zunmlq(
'L',
'C', nr, nr, nr, cwork(2*n+1), n,
1595 $ cwork(2*n+n*nr+1), u, ldu, cwork(2*n+n*nr+nr+1),
1596 $ lwork-2*n-n*nr-nr, ierr )
1599 cwork(2*n+n*nr+nr+iwork(n+p)) = u(p,q)
1602 u(p,q) = cwork(2*n+n*nr+nr+p)
1612 temp1 = dsqrt(dble(n)) * epsln
1615 cwork(2*n+n*nr+nr+iwork(p)) = v(p,q)
1618 v(p,q) = cwork(2*n+n*nr+nr+p)
1620 xsc = one / dznrm2( n, v(1,q), 1 )
1621 IF ( (xsc .LT. (one-temp1)) .OR. (xsc .GT. (one+temp1)) )
1622 $
CALL zdscal( n, xsc, v(1,q), 1 )
1626 IF ( nr .LT. m )
THEN
1627 CALL zlaset(
'A', m-nr, nr, czero, czero, u(nr+1,1), ldu)
1628 IF ( nr .LT. n1 )
THEN
1629 CALL zlaset(
'A',nr,n1-nr,czero,czero,u(1,nr+1),ldu)
1630 CALL zlaset(
'A',m-nr,n1-nr,czero,cone,
1638 CALL zunmqr(
'Left',
'No_Tr', m, n1, n, a, lda, cwork, u,
1639 $ ldu, cwork(n+1), lwork-n, ierr )
1642 temp1 = dsqrt(dble(m)) * epsln
1644 xsc = one / dznrm2( m, u(1,p), 1 )
1645 IF ( (xsc .LT. (one-temp1)) .OR. (xsc .GT. (one+temp1)) )
1646 $
CALL zdscal( m, xsc, u(1,p), 1 )
1653 $
CALL zlaswp( n1, u, ldu, 1, m-1, iwork(2*n+1), -1 )
1660 CALL zlacpy(
'Upper', n, n, a, lda, cwork(n+1), n )
1664 ctemp = xsc * cwork( n + (p-1)*n + p )
1665 DO 5971 q = 1, p - 1
1668 cwork(n+(q-1)*n+p)=-ctemp
1672 CALL zlaset(
'Lower',n-1,n-1,czero,czero,cwork(n+2),n )
1675 CALL zgesvj(
'Upper',
'U',
'N', n, n, cwork(n+1), n, sva,
1676 $ n, u, ldu, cwork(n+n*n+1), lwork-n-n*n, rwork, lrwork,
1680 numrank = nint(rwork(2))
1682 CALL zcopy( n, cwork(n+(p-1)*n+1), 1, u(1,p), 1 )
1683 CALL zdscal( n, sva(p), cwork(n+(p-1)*n+1), 1 )
1686 CALL ztrsm(
'Left',
'Upper',
'NoTrans',
'No UD', n, n,
1687 $ cone, a, lda, cwork(n+1), n )
1689 CALL zcopy( n, cwork(n+p), n, v(iwork(p),1), ldv )
1691 temp1 = dsqrt(dble(n))*epsln
1693 xsc = one / dznrm2( n, v(1,p), 1 )
1694 IF ( (xsc .LT. (one-temp1)) .OR. (xsc .GT. (one+temp1)) )
1695 $
CALL zdscal( n, xsc, v(1,p), 1 )
1700 IF ( n .LT. m )
THEN
1701 CALL zlaset(
'A', m-n, n, czero, czero, u(n+1,1), ldu )
1702 IF ( n .LT. n1 )
THEN
1703 CALL zlaset(
'A',n, n1-n, czero, czero, u(1,n+1),ldu)
1704 CALL zlaset(
'A',m-n,n1-n, czero, cone,u(n+1,n+1),ldu)
1707 CALL zunmqr(
'Left',
'No Tr', m, n1, n, a, lda, cwork, u,
1708 $ ldu, cwork(n+1), lwork-n, ierr )
1709 temp1 = dsqrt(dble(m))*epsln
1711 xsc = one / dznrm2( m, u(1,p), 1 )
1712 IF ( (xsc .LT. (one-temp1)) .OR. (xsc .GT. (one+temp1)) )
1713 $
CALL zdscal( m, xsc, u(1,p), 1 )
1717 $
CALL zlaswp( n1, u, ldu, 1, m-1, iwork(2*n+1), -1 )
1736 CALL zcopy( n-p+1, a(p,p), lda, v(p,p), 1 )
1737 CALL zlacgv( n-p+1, v(p,p), 1 )
1741 xsc = dsqrt(small/epsln)
1743 ctemp = dcmplx(xsc*abs( v(q,q) ),zero)
1745 IF ( ( p .GT. q ) .AND. ( abs(v(p,q)) .LE. temp1 )
1746 $ .OR. ( p .LT. q ) )
1749 IF ( p .LT. q ) v(p,q) = - v(p,q)
1753 CALL zlaset(
'U', nr-1, nr-1, czero, czero, v(1,2), ldv )
1756 CALL zgeqrf( n, nr, v, ldv, cwork(n+1), cwork(2*n+1),
1758 CALL zlacpy(
'L', n, nr, v, ldv, cwork(2*n+1), n )
1761 CALL zcopy( nr-p+1, v(p,p), ldv, u(p,p), 1 )
1762 CALL zlacgv( nr-p+1, u(p,p), 1 )
1766 xsc = dsqrt(small/epsln)
1768 DO 9971 p = 1, q - 1
1769 ctemp = dcmplx(xsc * dmin1(abs(u(p,p)),abs(u(q,q))),
1776 CALL zlaset(
'U', nr-1, nr-1, czero, czero, u(1,2), ldu )
1779 CALL zgesvj(
'L',
'U',
'V', nr, nr, u, ldu, sva,
1780 $ n, v, ldv, cwork(2*n+n*nr+1), lwork-2*n-n*nr,
1781 $ rwork, lrwork, info )
1783 numrank = nint(rwork(2))
1785 IF ( nr .LT. n )
THEN
1786 CALL zlaset(
'A',n-nr,nr,czero,czero,v(nr+1,1),ldv )
1787 CALL zlaset(
'A',nr,n-nr,czero,czero,v(1,nr+1),ldv )
1788 CALL zlaset(
'A',n-nr,n-nr,czero,cone,v(nr+1,nr+1),ldv )
1791 CALL zunmqr(
'L',
'N',n,n,nr,cwork(2*n+1),n,cwork(n+1),
1792 $ v,ldv,cwork(2*n+n*nr+nr+1),lwork-2*n-n*nr-nr,ierr )
1798 temp1 = dsqrt(dble(n)) * epsln
1801 cwork(2*n+n*nr+nr+iwork(p)) = v(p,q)
1804 v(p,q) = cwork(2*n+n*nr+nr+p)
1806 xsc = one / dznrm2( n, v(1,q), 1 )
1807 IF ( (xsc .LT. (one-temp1)) .OR. (xsc .GT. (one+temp1)) )
1808 $
CALL zdscal( n, xsc, v(1,q), 1 )
1814 IF ( nr .LT. m )
THEN
1815 CALL zlaset(
'A', m-nr, nr, czero, czero, u(nr+1,1), ldu )
1816 IF ( nr .LT. n1 )
THEN
1817 CALL zlaset(
'A',nr, n1-nr, czero, czero, u(1,nr+1),ldu)
1818 CALL zlaset(
'A',m-nr,n1-nr, czero, cone,u(nr+1,nr+1),ldu)
1822 CALL zunmqr(
'Left',
'No Tr', m, n1, n, a, lda, cwork, u,
1823 $ ldu, cwork(n+1), lwork-n, ierr )
1826 $
CALL zlaswp( n1, u, ldu, 1, m-1, iwork(2*n+1), -1 )
1833 CALL zswap( n, u(1,p), 1, v(1,p), 1 )
1842 IF ( uscal2 .LE. (big/sva(1))*uscal1 )
THEN
1843 CALL dlascl(
'G', 0, 0, uscal1, uscal2, nr, 1, sva, n, ierr )
1848 IF ( nr .LT. n )
THEN
1854 rwork(1) = uscal2 * scalem
1856 IF ( errest ) rwork(3) = sconda
1857 IF ( lsvec .AND. rsvec )
THEN
subroutine zlacpy(UPLO, M, N, A, LDA, B, LDB)
ZLACPY copies all or part of one two-dimensional array to another.
subroutine zcopy(N, ZX, INCX, ZY, INCY)
ZCOPY
subroutine zlaswp(N, A, LDA, K1, K2, IPIV, INCX)
ZLASWP performs a series of row interchanges on a general rectangular matrix.
subroutine zgeqrf(M, N, A, LDA, TAU, WORK, LWORK, INFO)
ZGEQRF VARIANT: left-looking Level 3 BLAS of the algorithm.
subroutine zswap(N, ZX, INCX, ZY, INCY)
ZSWAP
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 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 xerbla(SRNAME, INFO)
XERBLA
subroutine zlassq(N, X, INCX, SCALE, SUMSQ)
ZLASSQ updates a sum of squares represented in scaled form.
subroutine zunmqr(SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
ZUNMQR
subroutine zgesvj(JOBA, JOBU, JOBV, M, N, A, LDA, SVA, MV, V, LDV, CWORK, LWORK, RWORK, LRWORK, INFO)
ZGESVJ
subroutine zgejsv(JOBA, JOBU, JOBV, JOBR, JOBT, JOBP, M, N, A, LDA, SVA, U, LDU, V, LDV, CWORK, LWORK, RWORK, LRWORK, IWORK, INFO)
ZGEJSV
subroutine zungqr(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
ZUNGQR
subroutine zunmlq(SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
ZUNMLQ
subroutine dscal(N, DA, DX, INCX)
DSCAL
subroutine zgeqp3(M, N, A, LDA, JPVT, TAU, WORK, LWORK, RWORK, INFO)
ZGEQP3
subroutine zdscal(N, DA, ZX, INCX)
ZDSCAL
subroutine dlassq(N, X, INCX, SCALE, SUMSQ)
DLASSQ updates a sum of squares represented in scaled form.
subroutine zgelqf(M, N, A, LDA, TAU, WORK, LWORK, INFO)
ZGELQF
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 zpocon(UPLO, N, A, LDA, ANORM, RCOND, WORK, RWORK, INFO)
ZPOCON
subroutine ztrsm(SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA, B, LDB)
ZTRSM
subroutine zlacgv(N, X, INCX)
ZLACGV conjugates a complex vector.