516 SUBROUTINE cgejsv( 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 A( lda, * ), U( ldu, * ), V( ldv, * ), CWORK( lwork )
531 REAL SVA( n ), RWORK( * )
533 CHARACTER*1 JOBA, JOBP, JOBR, JOBT, JOBU, JOBV
540 parameter( zero = 0.0e0, one = 1.0e0 )
542 parameter( czero = ( 0.0e0, 0.0e0 ), cone = ( 1.0e0, 0.0e0 ) )
546 REAL AAPP, AAQQ, AATMAX, AATMIN, BIG, BIG1, COND_OK,
547 $ condr1, condr2, entra, entrat, epsln, maxprj, scalem,
548 $ sconda, sfmin, small, temp1, uscal1, uscal2, xsc
549 INTEGER IERR, N1, NR, NUMRANK, p, q, WARNING
550 LOGICAL ALMORT, DEFR, ERREST, GOSCAL, JRACC, KILL, LSVEC,
551 $ l2aber, l2kill, l2pert, l2rank, l2tran,
552 $ noscal, rowpiv, rsvec, transp
555 INTRINSIC abs, conjg, alog, amax1, amin1, cmplx, float,
556 $ max0, min0, nint, sign, sqrt
560 INTEGER ISAMAX, ICAMAX
562 EXTERNAL isamax, icamax, lsame, slamch, scnrm2
574 lsvec = lsame( jobu,
'U' ) .OR. lsame( jobu,
'F' )
575 jracc = lsame( jobv,
'J' )
576 rsvec = lsame( jobv,
'V' ) .OR. jracc
577 rowpiv = lsame( joba,
'F' ) .OR. lsame( joba,
'G' )
578 l2rank = lsame( joba,
'R' )
579 l2aber = lsame( joba,
'A' )
580 errest = lsame( joba,
'E' ) .OR. lsame( joba,
'G' )
581 l2tran = lsame( jobt,
'T' )
582 l2kill = lsame( jobr,
'R' )
583 defr = lsame( jobr,
'N' )
584 l2pert = lsame( jobp,
'P' )
586 IF ( .NOT.(rowpiv .OR. l2rank .OR. l2aber .OR.
587 $ errest .OR. lsame( joba,
'C' ) ))
THEN
589 ELSE IF ( .NOT.( lsvec .OR. lsame( jobu,
'N' ) .OR.
590 $ lsame( jobu,
'W' )) )
THEN
592 ELSE IF ( .NOT.( rsvec .OR. lsame( jobv,
'N' ) .OR.
593 $ lsame( jobv,
'W' )) .OR. ( jracc .AND. (.NOT.lsvec) ) )
THEN
595 ELSE IF ( .NOT. ( l2kill .OR. defr ) )
THEN
597 ELSE IF ( .NOT. ( l2tran .OR. lsame( jobt,
'N' ) ) )
THEN
599 ELSE IF ( .NOT. ( l2pert .OR. lsame( jobp,
'N' ) ) )
THEN
601 ELSE IF ( m .LT. 0 )
THEN
603 ELSE IF ( ( n .LT. 0 ) .OR. ( n .GT. m ) )
THEN
605 ELSE IF ( lda .LT. m )
THEN
607 ELSE IF ( lsvec .AND. ( ldu .LT. m ) )
THEN
609 ELSE IF ( rsvec .AND. ( ldv .LT. n ) )
THEN
611 ELSE IF ( (.NOT.(lsvec .OR. rsvec .OR. errest).AND.
612 $ (lwork .LT. 2*n+1)) .OR.
613 $ (.NOT.(lsvec .OR. rsvec) .AND. errest .AND.
614 $ (lwork .LT. n*n+3*n)) .OR.
615 $ (lsvec .AND. (.NOT.rsvec) .AND. (lwork .LT. 3*n))
617 $ (rsvec .AND. (.NOT.lsvec) .AND. (lwork .LT. 3*n))
619 $ (lsvec .AND. rsvec .AND. (.NOT.jracc) .AND.
620 $ (lwork.LT.5*n+2*n*n))
621 $ .OR. (lsvec .AND. rsvec .AND. jracc .AND.
625 ELSE IF ( lrwork.LT. max0(n+2*m,7))
THEN
632 IF ( info .NE. 0 )
THEN
634 CALL xerbla(
'CGEJSV', - info )
640 IF ( ( m .EQ. 0 ) .OR. ( n .EQ. 0 ) )
THEN
650 IF ( lsame( jobu,
'F' ) ) n1 = m
657 epsln = slamch(
'Epsilon')
658 sfmin = slamch(
'SafeMinimum')
659 small = sfmin / epsln
669 scalem = one / sqrt(float(m)*float(n))
675 CALL classq( m, a(1,p), 1, aapp, aaqq )
676 IF ( aapp .GT. big )
THEN
678 CALL xerbla(
'CGEJSV', -info )
682 IF ( ( aapp .LT. (big / aaqq) ) .AND. noscal )
THEN
686 sva(p) = aapp * ( aaqq * scalem )
689 CALL sscal( p-1, scalem, sva, 1 )
694 IF ( noscal ) scalem = one
699 aapp = amax1( aapp, sva(p) )
700 IF ( sva(p) .NE. zero ) aaqq = amin1( aaqq, sva(p) )
705 IF ( aapp .EQ. zero )
THEN
706 IF ( lsvec )
CALL claset(
'G', m, n1, czero, cone, u, ldu )
707 IF ( rsvec )
CALL claset(
'G', n, n, czero, cone, v, ldv )
710 IF ( errest ) rwork(3) = one
711 IF ( lsvec .AND. rsvec )
THEN
730 IF ( aaqq .LE. sfmin )
THEN
741 CALL clascl(
'G',0,0,sva(1),scalem, m,1,a(1,1),lda,ierr )
742 CALL clacpy(
'A', m, 1, a, lda, u, ldu )
744 IF ( n1 .NE. n )
THEN
745 CALL cgeqrf( m, n, u,ldu, cwork, cwork(n+1),lwork-n,ierr )
746 CALL cungqr( m,n1,1, u,ldu,cwork,cwork(n+1),lwork-n,ierr )
747 CALL ccopy( m, a(1,1), 1, u(1,1), 1 )
753 IF ( sva(1) .LT. (big*scalem) )
THEN
754 sva(1) = sva(1) / scalem
757 rwork(1) = one / scalem
759 IF ( sva(1) .NE. zero )
THEN
761 IF ( ( sva(1) / scalem) .GE. sfmin )
THEN
771 IF ( errest ) rwork(3) = one
772 IF ( lsvec .AND. rsvec )
THEN
785 l2tran = l2tran .AND. ( m .EQ. n )
789 IF ( rowpiv .OR. l2tran )
THEN
800 CALL classq( n, a(p,1), lda, xsc, temp1 )
803 rwork(m+n+p) = xsc * scalem
804 rwork(n+p) = xsc * (scalem*sqrt(temp1))
805 aatmax = amax1( aatmax, rwork(n+p) )
806 IF (rwork(n+p) .NE. zero)
807 $ aatmin = amin1(aatmin,rwork(n+p))
811 rwork(m+n+p) = scalem*abs( a(p,icamax(n,a(p,1),lda)) )
812 aatmax = amax1( aatmax, rwork(m+n+p) )
813 aatmin = amin1( aatmin, rwork(m+n+p) )
832 CALL slassq( n, sva, 1, xsc, temp1 )
837 big1 = ( ( sva(p) / xsc )**2 ) * temp1
838 IF ( big1 .NE. zero ) entra = entra + big1 * alog(big1)
840 entra = - entra / alog(float(n))
850 big1 = ( ( rwork(p) / xsc )**2 ) * temp1
851 IF ( big1 .NE. zero ) entrat = entrat + big1 * alog(big1)
853 entrat = - entrat / alog(float(m))
858 transp = ( entrat .LT. entra )
867 a(p,p) = conjg(a(p,p))
869 ctemp = conjg(a(q,p))
870 a(q,p) = conjg(a(p,q))
874 a(n,n) = conjg(a(n,n))
876 rwork(m+n+p) = sva(p)
909 temp1 = sqrt( big / float(n) )
911 CALL slascl(
'G', 0, 0, aapp, temp1, n, 1, sva, n, ierr )
912 IF ( aaqq .GT. (aapp * sfmin) )
THEN
913 aaqq = ( aaqq / aapp ) * temp1
915 aaqq = ( aaqq * temp1 ) / aapp
917 temp1 = temp1 * scalem
918 CALL clascl(
'G', 0, 0, aapp, temp1, m, n, a, lda, ierr )
942 IF ( ( aaqq.LT.sqrt(sfmin) ) .AND. lsvec .AND. rsvec )
THEN
947 IF ( aaqq .LT. xsc )
THEN
949 IF ( sva(p) .LT. xsc )
THEN
950 CALL claset(
'A', m, 1, czero, czero, a(1,p), lda )
965 q = isamax( m-p+1, rwork(m+n+p), 1 ) + p - 1
969 rwork(m+n+p) = rwork(m+n+q)
973 CALL claswp( n, a, lda, 1, m-1, iwork(2*n+1), 1 )
995 CALL cgeqp3( m, n, a, lda, iwork, cwork, cwork(n+1), lwork-n,
1012 temp1 = sqrt(float(n))*epsln
1014 IF ( abs(a(p,p)) .GE. (temp1*abs(a(1,1))) )
THEN
1021 ELSE IF ( l2rank )
THEN
1027 IF ( ( abs(a(p,p)) .LT. (epsln*abs(a(p-1,p-1))) ) .OR.
1028 $ ( abs(a(p,p)) .LT. small ) .OR.
1029 $ ( l2kill .AND. (abs(a(p,p)) .LT. temp1) ) )
GO TO 3402
1044 IF ( ( abs(a(p,p)) .LT. small ) .OR.
1045 $ ( l2kill .AND. (abs(a(p,p)) .LT. temp1) ) )
GO TO 3302
1053 IF ( nr .EQ. n )
THEN
1056 temp1 = abs(a(p,p)) / sva(iwork(p))
1057 maxprj = amin1( maxprj, temp1 )
1059 IF ( maxprj**2 .GE. one - float(n)*epsln ) almort = .true.
1068 IF ( n .EQ. nr )
THEN
1071 CALL clacpy(
'U', n, n, a, lda, v, ldv )
1073 temp1 = sva(iwork(p))
1074 CALL csscal( p, one/temp1, v(1,p), 1 )
1076 CALL cpocon(
'U', n, v, ldv, one, temp1,
1077 $ cwork(n+1), rwork, ierr )
1079 ELSE IF ( lsvec )
THEN
1081 CALL clacpy(
'U', n, n, a, lda, u, ldu )
1083 temp1 = sva(iwork(p))
1084 CALL csscal( p, one/temp1, u(1,p), 1 )
1086 CALL cpocon(
'U', n, u, ldu, one, temp1,
1087 $ cwork(n+1), rwork, ierr )
1089 CALL clacpy(
'U', n, n, a, lda, cwork(n+1), n )
1091 temp1 = sva(iwork(p))
1092 CALL csscal( p, one/temp1, cwork(n+(p-1)*n+1), 1 )
1095 CALL cpocon(
'U', n, cwork(n+1), n, one, temp1,
1096 $ cwork(n+n*n+1), rwork, ierr )
1099 sconda = one / sqrt(temp1)
1107 l2pert = l2pert .AND. ( abs( a(1,1)/a(nr,nr) ) .GT. sqrt(big1) )
1112 IF ( .NOT. ( rsvec .OR. lsvec ) )
THEN
1117 DO 1946 p = 1, min0( n-1, nr )
1118 CALL ccopy( n-p, a(p,p+1), lda, a(p+1,p), 1 )
1119 CALL clacgv( n-p+1, a(p,p), 1 )
1121 IF ( nr .EQ. n ) a(n,n) = conjg(a(n,n))
1135 IF ( .NOT. almort )
THEN
1139 xsc = epsln / float(n)
1141 ctemp = cmplx(xsc*abs(a(q,q)),zero)
1143 IF ( ( (p.GT.q) .AND. (abs(a(p,q)).LE.temp1) )
1144 $ .OR. ( p .LT. q ) )
1150 CALL claset(
'U', nr-1,nr-1, czero,czero, a(1,2),lda )
1155 CALL cgeqrf( n,nr, a,lda, cwork, cwork(n+1),lwork-n, ierr )
1158 DO 1948 p = 1, nr - 1
1159 CALL ccopy( nr-p, a(p,p+1), lda, a(p+1,p), 1 )
1160 CALL clacgv( nr-p+1, a(p,p), 1 )
1171 xsc = epsln / float(n)
1173 ctemp = cmplx(xsc*abs(a(q,q)),zero)
1175 IF ( ( (p.GT.q) .AND. (abs(a(p,q)).LE.temp1) )
1176 $ .OR. ( p .LT. q ) )
1182 CALL claset(
'U', nr-1, nr-1, czero, czero, a(1,2), lda )
1189 CALL cgesvj(
'L',
'NoU',
'NoV', nr, nr, a, lda, sva,
1190 $ n, v, ldv, cwork, lwork, rwork, lrwork, info )
1193 numrank = nint(rwork(2))
1196 ELSE IF ( rsvec .AND. ( .NOT. lsvec ) )
THEN
1204 CALL ccopy( n-p+1, a(p,p), lda, v(p,p), 1 )
1205 CALL clacgv( n-p+1, v(p,p), 1 )
1207 CALL claset(
'Upper', nr-1,nr-1, czero, czero, v(1,2), ldv )
1209 CALL cgesvj(
'L',
'U',
'N', n, nr, v,ldv, sva, nr, a,lda,
1210 $ cwork, lwork, rwork, lrwork, info )
1212 numrank = nint(rwork(2))
1219 CALL claset(
'Lower', nr-1,nr-1, czero, czero, a(2,1), lda )
1220 CALL cgelqf( nr,n, a, lda, cwork, cwork(n+1), lwork-n, ierr)
1221 CALL clacpy(
'Lower', nr, nr, a, lda, v, ldv )
1222 CALL claset(
'Upper', nr-1,nr-1, czero, czero, v(1,2), ldv )
1223 CALL cgeqrf( nr, nr, v, ldv, cwork(n+1), cwork(2*n+1),
1226 CALL ccopy( nr-p+1, v(p,p), ldv, v(p,p), 1 )
1227 CALL clacgv( nr-p+1, v(p,p), 1 )
1229 CALL claset(
'Upper', nr-1, nr-1, czero, czero, v(1,2), ldv)
1231 CALL cgesvj(
'Lower',
'U',
'N', nr, nr, v,ldv, sva, nr, u,
1232 $ ldu, cwork(n+1), lwork-n, rwork, lrwork, info )
1234 numrank = nint(rwork(2))
1235 IF ( nr .LT. n )
THEN
1236 CALL claset(
'A',n-nr, nr, czero,czero, v(nr+1,1), ldv )
1237 CALL claset(
'A',nr, n-nr, czero,czero, v(1,nr+1), ldv )
1238 CALL claset(
'A',n-nr,n-nr,czero,cone, v(nr+1,nr+1),ldv )
1241 CALL cunmlq(
'Left',
'C', n, n, nr, a, lda, cwork,
1242 $ v, ldv, cwork(n+1), lwork-n, ierr )
1247 CALL ccopy( n, v(p,1), ldv, a(iwork(p),1), lda )
1249 CALL clacpy(
'All', n, n, a, lda, v, ldv )
1252 CALL clacpy(
'All', n, n, v, ldv, u, ldu )
1255 ELSE IF ( lsvec .AND. ( .NOT. rsvec ) )
THEN
1262 CALL ccopy( n-p+1, a(p,p), lda, u(p,p), 1 )
1263 CALL clacgv( n-p+1, u(p,p), 1 )
1265 CALL claset(
'Upper', nr-1, nr-1, czero, czero, u(1,2), ldu )
1267 CALL cgeqrf( n, nr, u, ldu, cwork(n+1), cwork(2*n+1),
1270 DO 1967 p = 1, nr - 1
1271 CALL ccopy( nr-p, u(p,p+1), ldu, u(p+1,p), 1 )
1272 CALL clacgv( n-p+1, u(p,p), 1 )
1274 CALL claset(
'Upper', nr-1, nr-1, czero, czero, u(1,2), ldu )
1276 CALL cgesvj(
'Lower',
'U',
'N', nr,nr, u, ldu, sva, nr, a,
1277 $ lda, cwork(n+1), lwork-n, rwork, lrwork, info )
1279 numrank = nint(rwork(2))
1281 IF ( nr .LT. m )
THEN
1282 CALL claset(
'A', m-nr, nr,czero, czero, u(nr+1,1), ldu )
1283 IF ( nr .LT. n1 )
THEN
1284 CALL claset(
'A',nr, n1-nr, czero, czero, u(1,nr+1),ldu )
1285 CALL claset(
'A',m-nr,n1-nr,czero,cone,u(nr+1,nr+1),ldu )
1289 CALL cunmqr(
'Left',
'No Tr', m, n1, n, a, lda, cwork, u,
1290 $ ldu, cwork(n+1), lwork-n, ierr )
1293 $
CALL claswp( n1, u, ldu, 1, m-1, iwork(2*n+1), -1 )
1296 xsc = one / scnrm2( m, u(1,p), 1 )
1297 CALL csscal( m, xsc, u(1,p), 1 )
1301 CALL clacpy(
'All', n, n, u, ldu, v, ldv )
1308 IF ( .NOT. jracc )
THEN
1310 IF ( .NOT. almort )
THEN
1320 CALL ccopy( n-p+1, a(p,p), lda, v(p,p), 1 )
1321 CALL clacgv( n-p+1, v(p,p), 1 )
1339 ctemp = cmplx(xsc*abs( v(q,q) ),zero)
1341 IF ( ( p .GT. q ) .AND. ( abs(v(p,q)) .LE. temp1 )
1342 $ .OR. ( p .LT. q ) )
1345 IF ( p .LT. q ) v(p,q) = - v(p,q)
1349 CALL claset(
'U', nr-1, nr-1, czero, czero, v(1,2), ldv )
1356 CALL clacpy(
'L', nr, nr, v, ldv, cwork(2*n+1), nr )
1358 temp1 = scnrm2(nr-p+1,cwork(2*n+(p-1)*nr+p),1)
1359 CALL csscal(nr-p+1,one/temp1,cwork(2*n+(p-1)*nr+p),1)
1361 CALL cpocon(
'Lower',nr,cwork(2*n+1),nr,one,temp1,
1362 $ cwork(2*n+nr*nr+1),rwork,ierr)
1363 condr1 = one / sqrt(temp1)
1369 cond_ok = sqrt(sqrt(float(nr)))
1372 IF ( condr1 .LT. cond_ok )
THEN
1377 CALL cgeqrf( n, nr, v, ldv, cwork(n+1), cwork(2*n+1),
1381 xsc = sqrt(small)/epsln
1383 DO 3958 q = 1, p - 1
1384 ctemp=cmplx(xsc*amin1(abs(v(p,p)),abs(v(q,q))),
1386 IF ( abs(v(q,p)) .LE. temp1 )
1394 $
CALL clacpy(
'A', n, nr, v, ldv, cwork(2*n+1), n )
1398 DO 1969 p = 1, nr - 1
1399 CALL ccopy( nr-p, v(p,p+1), ldv, v(p+1,p), 1 )
1400 CALL clacgv(nr-p+1, v(p,p), 1 )
1402 v(nr,nr)=conjg(v(nr,nr))
1419 CALL cgeqp3( n, nr, v, ldv, iwork(n+1), cwork(n+1),
1420 $ cwork(2*n+1), lwork-2*n, rwork, ierr )
1426 DO 3968 q = 1, p - 1
1427 ctemp=cmplx(xsc*amin1(abs(v(p,p)),abs(v(q,q))),
1429 IF ( abs(v(q,p)) .LE. temp1 )
1436 CALL clacpy(
'A', n, nr, v, ldv, cwork(2*n+1), n )
1441 DO 8971 q = 1, p - 1
1442 ctemp=cmplx(xsc*amin1(abs(v(p,p)),abs(v(q,q))),
1449 CALL claset(
'L',nr-1,nr-1,czero,czero,v(2,1),ldv )
1452 CALL cgelqf( nr, nr, v, ldv, cwork(2*n+n*nr+1),
1453 $ cwork(2*n+n*nr+nr+1), lwork-2*n-n*nr-nr, ierr )
1455 CALL clacpy(
'L',nr,nr,v,ldv,cwork(2*n+n*nr+nr+1),nr )
1457 temp1 = scnrm2( p, cwork(2*n+n*nr+nr+p), nr )
1458 CALL csscal( p, one/temp1, cwork(2*n+n*nr+nr+p), nr )
1460 CALL cpocon(
'L',nr,cwork(2*n+n*nr+nr+1),nr,one,temp1,
1461 $ cwork(2*n+n*nr+nr+nr*nr+1),rwork,ierr )
1462 condr2 = one / sqrt(temp1)
1465 IF ( condr2 .GE. cond_ok )
THEN
1470 CALL clacpy(
'U', nr, nr, v, ldv, cwork(2*n+1), n )
1480 ctemp = xsc * v(q,q)
1481 DO 4969 p = 1, q - 1
1488 CALL claset(
'U', nr-1,nr-1, czero,czero, v(1,2), ldv )
1497 IF ( condr1 .LT. cond_ok )
THEN
1499 CALL cgesvj(
'L',
'U',
'N',nr,nr,v,ldv,sva,nr,u, ldu,
1500 $ cwork(2*n+n*nr+nr+1),lwork-2*n-n*nr-nr,rwork,
1503 numrank = nint(rwork(2))
1505 CALL ccopy( nr, v(1,p), 1, u(1,p), 1 )
1506 CALL csscal( nr, sva(p), v(1,p), 1 )
1511 IF ( nr .EQ. n )
THEN
1516 CALL ctrsm(
'L',
'U',
'N',
'N', nr,nr,cone, a,lda, v,ldv)
1522 CALL ctrsm(
'L',
'U',
'C',
'N',nr,nr,cone,cwork(2*n+1),
1524 IF ( nr .LT. n )
THEN
1525 CALL claset(
'A',n-nr,nr,czero,czero,v(nr+1,1),ldv)
1526 CALL claset(
'A',nr,n-nr,czero,czero,v(1,nr+1),ldv)
1527 CALL claset(
'A',n-nr,n-nr,czero,cone,v(nr+1,nr+1),ldv)
1529 CALL cunmqr(
'L',
'N',n,n,nr,cwork(2*n+1),n,cwork(n+1),
1530 $ v,ldv,cwork(2*n+n*nr+nr+1),lwork-2*n-n*nr-nr,ierr)
1533 ELSE IF ( condr2 .LT. cond_ok )
THEN
1539 CALL cgesvj(
'L',
'U',
'N', nr, nr, v, ldv, sva, nr, u,
1540 $ ldu, cwork(2*n+n*nr+nr+1), lwork-2*n-n*nr-nr,
1541 $ rwork, lrwork, info )
1543 numrank = nint(rwork(2))
1545 CALL ccopy( nr, v(1,p), 1, u(1,p), 1 )
1546 CALL csscal( nr, sva(p), u(1,p), 1 )
1548 CALL ctrsm(
'L',
'U',
'N',
'N',nr,nr,cone,cwork(2*n+1),n,
1553 cwork(2*n+n*nr+nr+iwork(n+p)) = u(p,q)
1556 u(p,q) = cwork(2*n+n*nr+nr+p)
1559 IF ( nr .LT. n )
THEN
1560 CALL claset(
'A',n-nr,nr,czero,czero,v(nr+1,1),ldv )
1561 CALL claset(
'A',nr,n-nr,czero,czero,v(1,nr+1),ldv )
1562 CALL claset(
'A',n-nr,n-nr,czero,cone,v(nr+1,nr+1),ldv)
1564 CALL cunmqr(
'L',
'N',n,n,nr,cwork(2*n+1),n,cwork(n+1),
1565 $ v,ldv,cwork(2*n+n*nr+nr+1),lwork-2*n-n*nr-nr,ierr )
1578 CALL cgesvj(
'L',
'U',
'V', nr, nr, v, ldv, sva, nr, u,
1579 $ ldu, cwork(2*n+n*nr+nr+1), lwork-2*n-n*nr-nr,
1580 $ rwork, lrwork, info )
1582 numrank = nint(rwork(2))
1583 IF ( nr .LT. n )
THEN
1584 CALL claset(
'A',n-nr,nr,czero,czero,v(nr+1,1),ldv )
1585 CALL claset(
'A',nr,n-nr,czero,czero,v(1,nr+1),ldv )
1586 CALL claset(
'A',n-nr,n-nr,czero,cone,v(nr+1,nr+1),ldv)
1588 CALL cunmqr(
'L',
'N',n,n,nr,cwork(2*n+1),n,cwork(n+1),
1589 $ v,ldv,cwork(2*n+n*nr+nr+1),lwork-2*n-n*nr-nr,ierr )
1591 CALL cunmlq(
'L',
'C', nr, nr, nr, cwork(2*n+1), n,
1592 $ cwork(2*n+n*nr+1), u, ldu, cwork(2*n+n*nr+nr+1),
1593 $ lwork-2*n-n*nr-nr, ierr )
1596 cwork(2*n+n*nr+nr+iwork(n+p)) = u(p,q)
1599 u(p,q) = cwork(2*n+n*nr+nr+p)
1609 temp1 = sqrt(float(n)) * epsln
1612 cwork(2*n+n*nr+nr+iwork(p)) = v(p,q)
1615 v(p,q) = cwork(2*n+n*nr+nr+p)
1617 xsc = one / scnrm2( n, v(1,q), 1 )
1618 IF ( (xsc .LT. (one-temp1)) .OR. (xsc .GT. (one+temp1)) )
1619 $
CALL csscal( n, xsc, v(1,q), 1 )
1623 IF ( nr .LT. m )
THEN
1624 CALL claset(
'A', m-nr, nr, czero, czero, u(nr+1,1), ldu)
1625 IF ( nr .LT. n1 )
THEN
1626 CALL claset(
'A',nr,n1-nr,czero,czero,u(1,nr+1),ldu)
1627 CALL claset(
'A',m-nr,n1-nr,czero,cone,
1635 CALL cunmqr(
'Left',
'No_Tr', m, n1, n, a, lda, cwork, u,
1636 $ ldu, cwork(n+1), lwork-n, ierr )
1639 temp1 = sqrt(float(m)) * epsln
1641 xsc = one / scnrm2( m, u(1,p), 1 )
1642 IF ( (xsc .LT. (one-temp1)) .OR. (xsc .GT. (one+temp1)) )
1643 $
CALL csscal( m, xsc, u(1,p), 1 )
1650 $
CALL claswp( n1, u, ldu, 1, m-1, iwork(2*n+1), -1 )
1657 CALL clacpy(
'Upper', n, n, a, lda, cwork(n+1), n )
1661 ctemp = xsc * cwork( n + (p-1)*n + p )
1662 DO 5971 q = 1, p - 1
1665 cwork(n+(q-1)*n+p)=-ctemp
1669 CALL claset(
'Lower',n-1,n-1,czero,czero,cwork(n+2),n )
1672 CALL cgesvj(
'Upper',
'U',
'N', n, n, cwork(n+1), n, sva,
1673 $ n, u, ldu, cwork(n+n*n+1), lwork-n-n*n, rwork, lrwork,
1677 numrank = nint(rwork(2))
1679 CALL ccopy( n, cwork(n+(p-1)*n+1), 1, u(1,p), 1 )
1680 CALL csscal( n, sva(p), cwork(n+(p-1)*n+1), 1 )
1683 CALL ctrsm(
'Left',
'Upper',
'NoTrans',
'No UD', n, n,
1684 $ cone, a, lda, cwork(n+1), n )
1686 CALL ccopy( n, cwork(n+p), n, v(iwork(p),1), ldv )
1688 temp1 = sqrt(float(n))*epsln
1690 xsc = one / scnrm2( n, v(1,p), 1 )
1691 IF ( (xsc .LT. (one-temp1)) .OR. (xsc .GT. (one+temp1)) )
1692 $
CALL csscal( n, xsc, v(1,p), 1 )
1697 IF ( n .LT. m )
THEN
1698 CALL claset(
'A', m-n, n, czero, czero, u(n+1,1), ldu )
1699 IF ( n .LT. n1 )
THEN
1700 CALL claset(
'A',n, n1-n, czero, czero, u(1,n+1),ldu)
1701 CALL claset(
'A',m-n,n1-n, czero, cone,u(n+1,n+1),ldu)
1704 CALL cunmqr(
'Left',
'No Tr', m, n1, n, a, lda, cwork, u,
1705 $ ldu, cwork(n+1), lwork-n, ierr )
1706 temp1 = sqrt(float(m))*epsln
1708 xsc = one / scnrm2( m, u(1,p), 1 )
1709 IF ( (xsc .LT. (one-temp1)) .OR. (xsc .GT. (one+temp1)) )
1710 $
CALL csscal( m, xsc, u(1,p), 1 )
1714 $
CALL claswp( n1, u, ldu, 1, m-1, iwork(2*n+1), -1 )
1733 CALL ccopy( n-p+1, a(p,p), lda, v(p,p), 1 )
1734 CALL clacgv( n-p+1, v(p,p), 1 )
1738 xsc = sqrt(small/epsln)
1740 ctemp = cmplx(xsc*abs( v(q,q) ),zero)
1742 IF ( ( p .GT. q ) .AND. ( abs(v(p,q)) .LE. temp1 )
1743 $ .OR. ( p .LT. q ) )
1746 IF ( p .LT. q ) v(p,q) = - v(p,q)
1750 CALL claset(
'U', nr-1, nr-1, czero, czero, v(1,2), ldv )
1753 CALL cgeqrf( n, nr, v, ldv, cwork(n+1), cwork(2*n+1),
1755 CALL clacpy(
'L', n, nr, v, ldv, cwork(2*n+1), n )
1758 CALL ccopy( nr-p+1, v(p,p), ldv, u(p,p), 1 )
1759 CALL clacgv( nr-p+1, u(p,p), 1 )
1763 xsc = sqrt(small/epsln)
1765 DO 9971 p = 1, q - 1
1766 ctemp = cmplx(xsc * amin1(abs(u(p,p)),abs(u(q,q))),
1773 CALL claset(
'U', nr-1, nr-1, czero, czero, u(1,2), ldu )
1776 CALL cgesvj(
'L',
'U',
'V', nr, nr, u, ldu, sva,
1777 $ n, v, ldv, cwork(2*n+n*nr+1), lwork-2*n-n*nr,
1778 $ rwork, lrwork, info )
1780 numrank = nint(rwork(2))
1782 IF ( nr .LT. n )
THEN
1783 CALL claset(
'A',n-nr,nr,czero,czero,v(nr+1,1),ldv )
1784 CALL claset(
'A',nr,n-nr,czero,czero,v(1,nr+1),ldv )
1785 CALL claset(
'A',n-nr,n-nr,czero,cone,v(nr+1,nr+1),ldv )
1788 CALL cunmqr(
'L',
'N',n,n,nr,cwork(2*n+1),n,cwork(n+1),
1789 $ v,ldv,cwork(2*n+n*nr+nr+1),lwork-2*n-n*nr-nr,ierr )
1795 temp1 = sqrt(float(n)) * epsln
1798 cwork(2*n+n*nr+nr+iwork(p)) = v(p,q)
1801 v(p,q) = cwork(2*n+n*nr+nr+p)
1803 xsc = one / scnrm2( n, v(1,q), 1 )
1804 IF ( (xsc .LT. (one-temp1)) .OR. (xsc .GT. (one+temp1)) )
1805 $
CALL csscal( n, xsc, v(1,q), 1 )
1811 IF ( nr .LT. m )
THEN
1812 CALL claset(
'A', m-nr, nr, czero, czero, u(nr+1,1), ldu )
1813 IF ( nr .LT. n1 )
THEN
1814 CALL claset(
'A',nr, n1-nr, czero, czero, u(1,nr+1),ldu)
1815 CALL claset(
'A',m-nr,n1-nr, czero, cone,u(nr+1,nr+1),ldu)
1819 CALL cunmqr(
'Left',
'No Tr', m, n1, n, a, lda, cwork, u,
1820 $ ldu, cwork(n+1), lwork-n, ierr )
1823 $
CALL claswp( n1, u, ldu, 1, m-1, iwork(2*n+1), -1 )
1830 CALL cswap( n, u(1,p), 1, v(1,p), 1 )
1839 IF ( uscal2 .LE. (big/sva(1))*uscal1 )
THEN
1840 CALL slascl(
'G', 0, 0, uscal1, uscal2, nr, 1, sva, n, ierr )
1845 IF ( nr .LT. n )
THEN
1851 rwork(1) = uscal2 * scalem
1853 IF ( errest ) rwork(3) = sconda
1854 IF ( lsvec .AND. rsvec )
THEN
subroutine slassq(N, X, INCX, SCALE, SUMSQ)
SLASSQ updates a sum of squares represented in scaled form.
subroutine clascl(TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
CLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine slascl(TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
SLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine classq(N, X, INCX, SCALE, SUMSQ)
CLASSQ updates a sum of squares represented in scaled form.
subroutine xerbla(SRNAME, INFO)
XERBLA
subroutine cpocon(UPLO, N, A, LDA, ANORM, RCOND, WORK, RWORK, INFO)
CPOCON
subroutine ctrsm(SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA, B, LDB)
CTRSM
subroutine cunmqr(SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
CUNMQR
subroutine cgelqf(M, N, A, LDA, TAU, WORK, LWORK, INFO)
CGELQF
subroutine claset(UPLO, M, N, ALPHA, BETA, A, LDA)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values...
subroutine cgeqp3(M, N, A, LDA, JPVT, TAU, WORK, LWORK, RWORK, INFO)
CGEQP3
subroutine cgeqrf(M, N, A, LDA, TAU, WORK, LWORK, INFO)
CGEQRF
subroutine cgejsv(JOBA, JOBU, JOBV, JOBR, JOBT, JOBP, M, N, A, LDA, SVA, U, LDU, V, LDV, CWORK, LWORK, RWORK, LRWORK, IWORK, INFO)
CGEJSV
subroutine cgesvj(JOBA, JOBU, JOBV, M, N, A, LDA, SVA, MV, V, LDV, CWORK, LWORK, RWORK, LRWORK, INFO)
CGESVJ
subroutine clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
subroutine sscal(N, SA, SX, INCX)
SSCAL
subroutine cunmlq(SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
CUNMLQ
subroutine ccopy(N, CX, INCX, CY, INCY)
CCOPY
subroutine clacgv(N, X, INCX)
CLACGV conjugates a complex vector.
subroutine cswap(N, CX, INCX, CY, INCY)
CSWAP
subroutine cungqr(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
CUNGQR
subroutine claswp(N, A, LDA, K1, K2, IPIV, INCX)
CLASWP performs a series of row interchanges on a general rectangular matrix.
subroutine csscal(N, SA, CX, INCX)
CSSCAL