408 SUBROUTINE zgesvdq( JOBA, JOBP, JOBR, JOBU, JOBV, M, N, A, LDA,
409 $ S, U, LDU, V, LDV, NUMRANK, IWORK, LIWORK,
410 $ CWORK, LCWORK, RWORK, LRWORK, INFO )
413 CHARACTER JOBA, JOBP, JOBR, JOBU, JOBV
414 INTEGER M, N, LDA, LDU, LDV, NUMRANK, LIWORK, LCWORK, LRWORK,
418 COMPLEX*16 A( LDA, * ), U( LDU, * ), V( LDV, * ), CWORK( * )
419 DOUBLE PRECISION S( * ), RWORK( * )
425 DOUBLE PRECISION ZERO, ONE
426 PARAMETER ( ZERO = 0.0d0, one = 1.0d0 )
427 COMPLEX*16 CZERO, CONE
428 parameter( czero = (0.0d0,0.0d0), cone = (1.0d0,0.0d0) )
431 INTEGER IERR, NR, N1, OPTRATIO, p, q
432 INTEGER LWCON, LWQP3, LWRK_ZGELQF, LWRK_ZGESVD, LWRK_ZGESVD2,
433 $ lwrk_zgeqp3, lwrk_zgeqrf, lwrk_zunmlq, lwrk_zunmqr,
434 $ lwrk_zunmqr2, lwlqf, lwqrf, lwsvd, lwsvd2, lwunq,
435 $ lwunq2, lwunlq, minwrk, minwrk2, optwrk, optwrk2,
437 LOGICAL ACCLA, ACCLM, ACCLH, ASCALED, CONDA, DNTWU, DNTWV,
438 $ LQUERY, LSVC0, LSVEC, ROWPRM, RSVEC, RTRANS, WNTUA,
439 $ wntuf, wntur, wntus, wntva, wntvr
440 DOUBLE PRECISION BIG, EPSLN, RTMP, SCONDA, SFMIN
445 DOUBLE PRECISION RDUMMY(1)
456 DOUBLE PRECISION ZLANGE, DZNRM2, DLAMCH
457 EXTERNAL lsame, zlange, idamax, dznrm2, dlamch
460 INTRINSIC abs, conjg, max, min, dble, sqrt
466 wntus = lsame( jobu,
'S' ) .OR. lsame( jobu,
'U' )
467 wntur = lsame( jobu,
'R' )
468 wntua = lsame( jobu,
'A' )
469 wntuf = lsame( jobu,
'F' )
470 lsvc0 = wntus .OR. wntur .OR. wntua
471 lsvec = lsvc0 .OR. wntuf
472 dntwu = lsame( jobu,
'N' )
474 wntvr = lsame( jobv,
'R' )
475 wntva = lsame( jobv,
'A' ) .OR. lsame( jobv,
'V' )
476 rsvec = wntvr .OR. wntva
477 dntwv = lsame( jobv,
'N' )
479 accla = lsame( joba,
'A' )
480 acclm = lsame( joba,
'M' )
481 conda = lsame( joba,
'E' )
482 acclh = lsame( joba,
'H' ) .OR. conda
484 rowprm = lsame( jobp,
'P' )
485 rtrans = lsame( jobr,
'T' )
488 iminwrk = max( 1, n + m - 1 )
489 rminwrk = max( 2, m, 5*n )
491 iminwrk = max( 1, n )
492 rminwrk = max( 2, 5*n )
494 lquery = (liwork .EQ. -1 .OR. lcwork .EQ. -1 .OR. lrwork .EQ. -1)
496 IF ( .NOT. ( accla .OR. acclm .OR. acclh ) )
THEN
498 ELSE IF ( .NOT.( rowprm .OR. lsame( jobp,
'N' ) ) )
THEN
500 ELSE IF ( .NOT.( rtrans .OR. lsame( jobr,
'N' ) ) )
THEN
502 ELSE IF ( .NOT.( lsvec .OR. dntwu ) )
THEN
504 ELSE IF ( wntur .AND. wntva )
THEN
506 ELSE IF ( .NOT.( rsvec .OR. dntwv ))
THEN
508 ELSE IF ( m.LT.0 )
THEN
510 ELSE IF ( ( n.LT.0 ) .OR. ( n.GT.m ) )
THEN
512 ELSE IF ( lda.LT.max( 1, m ) )
THEN
514 ELSE IF ( ldu.LT.1 .OR. ( lsvc0 .AND. ldu.LT.m ) .OR.
515 $ ( wntuf .AND. ldu.LT.n ) )
THEN
517 ELSE IF ( ldv.LT.1 .OR. ( rsvec .AND. ldv.LT.n ) .OR.
518 $ ( conda .AND. ldv.LT.n ) )
THEN
520 ELSE IF ( liwork .LT. iminwrk .AND. .NOT. lquery )
THEN
525 IF ( info .EQ. 0 )
THEN
535 IF ( wntus .OR. wntur )
THEN
537 ELSE IF ( wntua )
THEN
543 lwsvd = max( 3 * n, 1 )
545 CALL zgeqp3( m, n, a, lda, iwork, cdummy, cdummy, -1,
547 lwrk_zgeqp3 = int( cdummy(1) )
548 IF ( wntus .OR. wntur )
THEN
549 CALL zunmqr(
'L',
'N', m, n, n, a, lda, cdummy, u,
550 $ ldu, cdummy, -1, ierr )
551 lwrk_zunmqr = int( cdummy(1) )
552 ELSE IF ( wntua )
THEN
553 CALL zunmqr(
'L',
'N', m, m, n, a, lda, cdummy, u,
554 $ ldu, cdummy, -1, ierr )
555 lwrk_zunmqr = int( cdummy(1) )
562 IF ( .NOT. (lsvec .OR. rsvec ) )
THEN
566 minwrk = max( n+lwqp3, lwcon, lwsvd )
568 minwrk = max( n+lwqp3, lwsvd )
571 CALL zgesvd(
'N',
'N', n, n, a, lda, s, u, ldu,
572 $ v, ldv, cdummy, -1, rdummy, ierr )
573 lwrk_zgesvd = int( cdummy(1) )
575 optwrk = max( n+lwrk_zgeqp3, n+lwcon, lwrk_zgesvd )
577 optwrk = max( n+lwrk_zgeqp3, lwrk_zgesvd )
580 ELSE IF ( lsvec .AND. (.NOT.rsvec) )
THEN
584 minwrk = n + max( lwqp3, lwcon, lwsvd, lwunq )
586 minwrk = n + max( lwqp3, lwsvd, lwunq )
590 CALL zgesvd(
'N',
'O', n, n, a, lda, s, u, ldu,
591 $ v, ldv, cdummy, -1, rdummy, ierr )
593 CALL zgesvd(
'O',
'N', n, n, a, lda, s, u, ldu,
594 $ v, ldv, cdummy, -1, rdummy, ierr )
596 lwrk_zgesvd = int( cdummy(1) )
598 optwrk = n + max( lwrk_zgeqp3, lwcon, lwrk_zgesvd,
601 optwrk = n + max( lwrk_zgeqp3, lwrk_zgesvd,
605 ELSE IF ( rsvec .AND. (.NOT.lsvec) )
THEN
609 minwrk = n + max( lwqp3, lwcon, lwsvd )
611 minwrk = n + max( lwqp3, lwsvd )
615 CALL zgesvd(
'O',
'N', n, n, a, lda, s, u, ldu,
616 $ v, ldv, cdummy, -1, rdummy, ierr )
618 CALL zgesvd(
'N',
'O', n, n, a, lda, s, u, ldu,
619 $ v, ldv, cdummy, -1, rdummy, ierr )
621 lwrk_zgesvd = int( cdummy(1) )
623 optwrk = n + max( lwrk_zgeqp3, lwcon, lwrk_zgesvd )
625 optwrk = n + max( lwrk_zgeqp3, lwrk_zgesvd )
632 minwrk = max( lwqp3, lwsvd, lwunq )
633 IF ( conda ) minwrk = max( minwrk, lwcon )
637 lwqrf = max( n/2, 1 )
639 lwsvd2 = max( 3 * (n/2), 1 )
641 minwrk2 = max( lwqp3, n/2+lwqrf, n/2+lwsvd2,
642 $ n/2+lwunq2, lwunq )
643 IF ( conda ) minwrk2 = max( minwrk2, lwcon )
644 minwrk2 = n + minwrk2
645 minwrk = max( minwrk, minwrk2 )
648 minwrk = max( lwqp3, lwsvd, lwunq )
649 IF ( conda ) minwrk = max( minwrk, lwcon )
653 lwlqf = max( n/2, 1 )
654 lwsvd2 = max( 3 * (n/2), 1 )
655 lwunlq = max( n , 1 )
656 minwrk2 = max( lwqp3, n/2+lwlqf, n/2+lwsvd2,
657 $ n/2+lwunlq, lwunq )
658 IF ( conda ) minwrk2 = max( minwrk2, lwcon )
659 minwrk2 = n + minwrk2
660 minwrk = max( minwrk, minwrk2 )
665 CALL zgesvd(
'O',
'A', n, n, a, lda, s, u, ldu,
666 $ v, ldv, cdummy, -1, rdummy, ierr )
667 lwrk_zgesvd = int( cdummy(1) )
668 optwrk = max(lwrk_zgeqp3,lwrk_zgesvd,lwrk_zunmqr)
669 IF ( conda ) optwrk = max( optwrk, lwcon )
672 CALL zgeqrf(n,n/2,u,ldu,cdummy,cdummy,-1,ierr)
673 lwrk_zgeqrf = int( cdummy(1) )
674 CALL zgesvd(
'S',
'O', n/2,n/2, v,ldv, s, u,
676 $ v, ldv, cdummy, -1, rdummy, ierr )
677 lwrk_zgesvd2 = int( cdummy(1) )
678 CALL zunmqr(
'R',
'C', n, n, n/2, u, ldu,
680 $ v, ldv, cdummy, -1, ierr )
681 lwrk_zunmqr2 = int( cdummy(1) )
682 optwrk2 = max( lwrk_zgeqp3, n/2+lwrk_zgeqrf,
683 $ n/2+lwrk_zgesvd2, n/2+lwrk_zunmqr2 )
684 IF ( conda ) optwrk2 = max( optwrk2, lwcon )
685 optwrk2 = n + optwrk2
686 optwrk = max( optwrk, optwrk2 )
689 CALL zgesvd(
'S',
'O', n, n, a, lda, s, u, ldu,
690 $ v, ldv, cdummy, -1, rdummy, ierr )
691 lwrk_zgesvd = int( cdummy(1) )
692 optwrk = max(lwrk_zgeqp3,lwrk_zgesvd,lwrk_zunmqr)
693 IF ( conda ) optwrk = max( optwrk, lwcon )
696 CALL zgelqf(n/2,n,u,ldu,cdummy,cdummy,-1,ierr)
697 lwrk_zgelqf = int( cdummy(1) )
698 CALL zgesvd(
'S',
'O', n/2,n/2, v, ldv, s, u,
700 $ v, ldv, cdummy, -1, rdummy, ierr )
701 lwrk_zgesvd2 = int( cdummy(1) )
702 CALL zunmlq(
'R',
'N', n, n, n/2, u, ldu,
704 $ v, ldv, cdummy,-1,ierr )
705 lwrk_zunmlq = int( cdummy(1) )
706 optwrk2 = max( lwrk_zgeqp3, n/2+lwrk_zgelqf,
707 $ n/2+lwrk_zgesvd2, n/2+lwrk_zunmlq )
708 IF ( conda ) optwrk2 = max( optwrk2, lwcon )
709 optwrk2 = n + optwrk2
710 optwrk = max( optwrk, optwrk2 )
716 minwrk = max( 2, minwrk )
717 optwrk = max( 2, optwrk )
718 IF ( lcwork .LT. minwrk .AND. (.NOT.lquery) ) info = -19
722 IF (info .EQ. 0 .AND. lrwork .LT. rminwrk .AND. .NOT. lquery)
THEN
726 CALL xerbla(
'ZGESVDQ', -info )
728 ELSE IF ( lquery )
THEN
741 IF( ( m.EQ.0 ) .OR. ( n.EQ.0 ) )
THEN
755 rwork(p) = zlange(
'M', 1, n, a(p,1), lda, rdummy )
757 IF ( ( rwork(p) .NE. rwork(p) ) .OR.
758 $ ( (rwork(p)*zero) .NE. zero ) )
THEN
760 CALL xerbla(
'ZGESVDQ', -info )
765 q = idamax( m-p+1, rwork(p), 1 ) + p - 1
774 IF ( rwork(1) .EQ. zero )
THEN
777 CALL dlaset(
'G', n, 1, zero, zero, s, n )
778 IF ( wntus )
CALL zlaset(
'G', m, n, czero, cone, u,
780 IF ( wntua )
CALL zlaset(
'G', m, m, czero, cone, u,
782 IF ( wntva )
CALL zlaset(
'G', n, n, czero, cone, v,
785 CALL zlaset(
'G', n, 1, czero, czero, cwork, n )
786 CALL zlaset(
'G', m, n, czero, cone, u, ldu )
792 DO 5002 p = n + 1, n + m - 1
796 IF ( conda ) rwork(1) = -1
801 IF ( rwork(1) .GT. big / sqrt(dble(m)) )
THEN
804 CALL zlascl(
'G',0,0,sqrt(dble(m)),one, m,n, a,lda,
808 CALL zlaswp( n, a, lda, 1, m-1, iwork(n+1), 1 )
816 IF ( .NOT.rowprm )
THEN
817 rtmp = zlange(
'M', m, n, a, lda, rwork )
818 IF ( ( rtmp .NE. rtmp ) .OR.
819 $ ( (rtmp*zero) .NE. zero ) )
THEN
821 CALL xerbla(
'ZGESVDQ', -info )
824 IF ( rtmp .GT. big / sqrt(dble(m)) )
THEN
827 CALL zlascl(
'G',0,0, sqrt(dble(m)),one, m,n, a,lda,
842 CALL zgeqp3( m, n, a, lda, iwork, cwork, cwork(n+1), lcwork-n,
861 rtmp = sqrt(dble(n))*epsln
863 IF ( abs(a(p,p)) .LT. (rtmp*abs(a(1,1))) )
GO TO 3002
868 ELSEIF ( acclm )
THEN
877 IF ( ( abs(a(p,p)) .LT. (epsln*abs(a(p-1,p-1))) ) .OR.
878 $ ( abs(a(p,p)) .LT. sfmin ) )
GO TO 3402
890 IF ( abs(a(p,p)) .EQ. zero )
GO TO 3502
899 CALL zlacpy(
'U', n, n, a, lda, v, ldv )
906 rtmp = dznrm2( p, v(1,p), 1 )
907 CALL zdscal( p, one/rtmp, v(1,p), 1 )
909 IF ( .NOT. ( lsvec .OR. rsvec ) )
THEN
910 CALL zpocon(
'U', nr, v, ldv, one, rtmp,
911 $ cwork, rwork, ierr )
913 CALL zpocon(
'U', nr, v, ldv, one, rtmp,
914 $ cwork(n+1), rwork, ierr )
916 sconda = one / sqrt(rtmp)
926 ELSE IF ( wntus .OR. wntuf)
THEN
928 ELSE IF ( wntua )
THEN
932 IF ( .NOT. ( rsvec .OR. lsvec ) )
THEN
941 DO 1146 p = 1, min( n, nr )
942 a(p,p) = conjg(a(p,p))
944 a(q,p) = conjg(a(p,q))
945 IF ( q .LE. nr ) a(p,q) = czero
949 CALL zgesvd(
'N',
'N', n, nr, a, lda, s, u, ldu,
950 $ v, ldv, cwork, lcwork, rwork, info )
957 $
CALL zlaset(
'L', nr-1,nr-1, czero,czero, a(2,1),
959 CALL zgesvd(
'N',
'N', nr, n, a, lda, s, u, ldu,
960 $ v, ldv, cwork, lcwork, rwork, info )
964 ELSE IF ( lsvec .AND. ( .NOT. rsvec) )
THEN
974 u(q,p) = conjg(a(p,q))
978 $
CALL zlaset(
'U', nr-1,nr-1, czero,czero, u(1,2),
983 CALL zgesvd(
'N',
'O', n, nr, u, ldu, s, u, ldu,
984 $ u, ldu, cwork(n+1), lcwork-n, rwork, info )
987 u(p,p) = conjg(u(p,p))
988 DO 1120 q = p + 1, nr
990 u(q,p) = conjg(u(p,q))
998 CALL zlacpy(
'U', nr, n, a, lda, u, ldu )
1000 $
CALL zlaset(
'L', nr-1, nr-1, czero, czero, u(2,1),
1004 CALL zgesvd(
'O',
'N', nr, n, u, ldu, s, u, ldu,
1005 $ v, ldv, cwork(n+1), lcwork-n, rwork, info )
1013 IF ( ( nr .LT. m ) .AND. ( .NOT.wntuf ) )
THEN
1014 CALL zlaset(
'A', m-nr, nr, czero, czero, u(nr+1,1), ldu)
1015 IF ( nr .LT. n1 )
THEN
1016 CALL zlaset(
'A',nr,n1-nr,czero,czero,u(1,nr+1),
1018 CALL zlaset(
'A',m-nr,n1-nr,czero,cone,
1019 $ u(nr+1,nr+1), ldu )
1027 $
CALL zunmqr(
'L',
'N', m, n1, n, a, lda, cwork, u,
1028 $ ldu, cwork(n+1), lcwork-n, ierr )
1029 IF ( rowprm .AND. .NOT.wntuf )
1030 $
CALL zlaswp( n1, u, ldu, 1, m-1, iwork(n+1), -1 )
1032 ELSE IF ( rsvec .AND. ( .NOT. lsvec ) )
THEN
1041 v(q,p) = conjg(a(p,q))
1045 $
CALL zlaset(
'U', nr-1,nr-1, czero,czero, v(1,2),
1049 IF ( wntvr .OR. ( nr .EQ. n ) )
THEN
1050 CALL zgesvd(
'O',
'N', n, nr, v, ldv, s, u, ldu,
1051 $ u, ldu, cwork(n+1), lcwork-n, rwork, info )
1054 v(p,p) = conjg(v(p,p))
1055 DO 1122 q = p + 1, nr
1056 ctmp = conjg(v(q,p))
1057 v(q,p) = conjg(v(p,q))
1062 IF ( nr .LT. n )
THEN
1064 DO 1104 q = nr + 1, n
1065 v(p,q) = conjg(v(q,p))
1069 CALL zlapmt( .false., nr, n, v, ldv, iwork )
1076 CALL zlaset(
'G', n, n-nr, czero, czero, v(1,nr+1),
1078 CALL zgesvd(
'O',
'N', n, n, v, ldv, s, u, ldu,
1079 $ u, ldu, cwork(n+1), lcwork-n, rwork, info )
1082 v(p,p) = conjg(v(p,p))
1083 DO 1124 q = p + 1, n
1084 ctmp = conjg(v(q,p))
1085 v(q,p) = conjg(v(p,q))
1089 CALL zlapmt( .false., n, n, v, ldv, iwork )
1095 CALL zlacpy(
'U', nr, n, a, lda, v, ldv )
1097 $
CALL zlaset(
'L', nr-1, nr-1, czero, czero, v(2,1),
1101 IF ( wntvr .OR. ( nr .EQ. n ) )
THEN
1102 CALL zgesvd(
'N',
'O', nr, n, v, ldv, s, u, ldu,
1103 $ v, ldv, cwork(n+1), lcwork-n, rwork, info )
1104 CALL zlapmt( .false., nr, n, v, ldv, iwork )
1112 CALL zlaset(
'G', n-nr, n, czero,czero, v(nr+1,1),
1114 CALL zgesvd(
'N',
'O', n, n, v, ldv, s, u, ldu,
1115 $ v, ldv, cwork(n+1), lcwork-n, rwork, info )
1116 CALL zlapmt( .false., n, n, v, ldv, iwork )
1130 IF ( wntvr .OR. ( nr .EQ. n ) )
THEN
1135 v(q,p) = conjg(a(p,q))
1139 $
CALL zlaset(
'U', nr-1,nr-1, czero,czero, v(1,2),
1145 CALL zgesvd(
'O',
'A', n, nr, v, ldv, s, v, ldv,
1146 $ u, ldu, cwork(n+1), lcwork-n, rwork, info )
1149 v(p,p) = conjg(v(p,p))
1150 DO 1116 q = p + 1, nr
1151 ctmp = conjg(v(q,p))
1152 v(q,p) = conjg(v(p,q))
1156 IF ( nr .LT. n )
THEN
1159 v(p,q) = conjg(v(q,p))
1163 CALL zlapmt( .false., nr, n, v, ldv, iwork )
1166 u(p,p) = conjg(u(p,p))
1167 DO 1118 q = p + 1, nr
1168 ctmp = conjg(u(q,p))
1169 u(q,p) = conjg(u(p,q))
1174 IF ( ( nr .LT. m ) .AND. .NOT.(wntuf))
THEN
1175 CALL zlaset(
'A', m-nr,nr, czero,czero, u(nr+1,1),
1177 IF ( nr .LT. n1 )
THEN
1178 CALL zlaset(
'A',nr,n1-nr,czero,czero,u(1,nr+1),
1180 CALL zlaset(
'A',m-nr,n1-nr,czero,cone,
1181 $ u(nr+1,nr+1), ldu )
1195 IF ( optratio*nr .GT. n )
THEN
1198 v(q,p) = conjg(a(p,q))
1202 $
CALL zlaset(
'U',nr-1,nr-1, czero,czero, v(1,2),
1205 CALL zlaset(
'A',n,n-nr,czero,czero,v(1,nr+1),ldv)
1206 CALL zgesvd(
'O',
'A', n, n, v, ldv, s, v, ldv,
1207 $ u, ldu, cwork(n+1), lcwork-n, rwork, info )
1210 v(p,p) = conjg(v(p,p))
1211 DO 1114 q = p + 1, n
1212 ctmp = conjg(v(q,p))
1213 v(q,p) = conjg(v(p,q))
1217 CALL zlapmt( .false., n, n, v, ldv, iwork )
1222 u(p,p) = conjg(u(p,p))
1223 DO 1112 q = p + 1, n
1224 ctmp = conjg(u(q,p))
1225 u(q,p) = conjg(u(p,q))
1230 IF ( ( n .LT. m ) .AND. .NOT.(wntuf))
THEN
1231 CALL zlaset(
'A',m-n,n,czero,czero,u(n+1,1),ldu)
1232 IF ( n .LT. n1 )
THEN
1233 CALL zlaset(
'A',n,n1-n,czero,czero,u(1,n+1),
1235 CALL zlaset(
'A',m-n,n1-n,czero,cone,
1244 u(q,nr+p) = conjg(a(p,q))
1248 $
CALL zlaset(
'U',nr-1,nr-1,czero,czero,u(1,nr+2),
1250 CALL zgeqrf( n, nr, u(1,nr+1), ldu, cwork(n+1),
1251 $ cwork(n+nr+1), lcwork-n-nr, ierr )
1254 v(q,p) = conjg(u(p,nr+q))
1257 CALL zlaset(
'U',nr-1,nr-1,czero,czero,v(1,2),ldv)
1258 CALL zgesvd(
'S',
'O', nr, nr, v, ldv, s, u, ldu,
1259 $ v,ldv, cwork(n+nr+1),lcwork-n-nr,rwork, info )
1260 CALL zlaset(
'A',n-nr,nr,czero,czero,v(nr+1,1),ldv)
1261 CALL zlaset(
'A',nr,n-nr,czero,czero,v(1,nr+1),ldv)
1262 CALL zlaset(
'A',n-nr,n-nr,czero,cone,v(nr+1,nr+1),
1264 CALL zunmqr(
'R',
'C', n, n, nr, u(1,nr+1), ldu,
1265 $ cwork(n+1),v,ldv,cwork(n+nr+1),lcwork-n-nr,ierr)
1266 CALL zlapmt( .false., n, n, v, ldv, iwork )
1269 IF ( ( nr .LT. m ) .AND. .NOT.(wntuf))
THEN
1270 CALL zlaset(
'A',m-nr,nr,czero,czero,u(nr+1,1),
1272 IF ( nr .LT. n1 )
THEN
1273 CALL zlaset(
'A',nr,n1-nr,czero,czero,u(1,nr+1),
1275 CALL zlaset(
'A',m-nr,n1-nr,czero,cone,
1286 IF ( wntvr .OR. ( nr .EQ. n ) )
THEN
1288 CALL zlacpy(
'U', nr, n, a, lda, v, ldv )
1290 $
CALL zlaset(
'L', nr-1,nr-1, czero,czero, v(2,1),
1294 CALL zgesvd(
'S',
'O', nr, n, v, ldv, s, u, ldu,
1295 $ v, ldv, cwork(n+1), lcwork-n, rwork, info )
1296 CALL zlapmt( .false., nr, n, v, ldv, iwork )
1300 IF ( ( nr .LT. m ) .AND. .NOT.(wntuf))
THEN
1301 CALL zlaset(
'A', m-nr,nr, czero,czero, u(nr+1,1),
1303 IF ( nr .LT. n1 )
THEN
1304 CALL zlaset(
'A',nr,n1-nr,czero,czero,u(1,nr+1),
1306 CALL zlaset(
'A',m-nr,n1-nr,czero,cone,
1307 $ u(nr+1,nr+1), ldu )
1321 IF ( optratio * nr .GT. n )
THEN
1322 CALL zlacpy(
'U', nr, n, a, lda, v, ldv )
1324 $
CALL zlaset(
'L', nr-1,nr-1, czero,czero, v(2,1),
1328 CALL zlaset(
'A', n-nr,n, czero,czero, v(nr+1,1),
1330 CALL zgesvd(
'S',
'O', n, n, v, ldv, s, u, ldu,
1331 $ v, ldv, cwork(n+1), lcwork-n, rwork, info )
1332 CALL zlapmt( .false., n, n, v, ldv, iwork )
1338 IF ( ( n .LT. m ) .AND. .NOT.(wntuf))
THEN
1339 CALL zlaset(
'A',m-n,n,czero,czero,u(n+1,1),ldu)
1340 IF ( n .LT. n1 )
THEN
1341 CALL zlaset(
'A',n,n1-n,czero,czero,u(1,n+1),
1343 CALL zlaset(
'A',m-n,n1-n,czero,cone,
1348 CALL zlacpy(
'U', nr, n, a, lda, u(nr+1,1), ldu )
1350 $
CALL zlaset(
'L',nr-1,nr-1,czero,czero,u(nr+2,1),
1352 CALL zgelqf( nr, n, u(nr+1,1), ldu, cwork(n+1),
1353 $ cwork(n+nr+1), lcwork-n-nr, ierr )
1354 CALL zlacpy(
'L',nr,nr,u(nr+1,1),ldu,v,ldv)
1356 $
CALL zlaset(
'U',nr-1,nr-1,czero,czero,v(1,2),ldv)
1357 CALL zgesvd(
'S',
'O', nr, nr, v, ldv, s, u, ldu,
1358 $ v, ldv, cwork(n+nr+1), lcwork-n-nr, rwork, info )
1359 CALL zlaset(
'A',n-nr,nr,czero,czero,v(nr+1,1),ldv)
1360 CALL zlaset(
'A',nr,n-nr,czero,czero,v(1,nr+1),ldv)
1361 CALL zlaset(
'A',n-nr,n-nr,czero,cone,v(nr+1,nr+1),
1363 CALL zunmlq(
'R',
'N',n,n,nr,u(nr+1,1),ldu,
1365 $ v, ldv, cwork(n+nr+1),lcwork-n-nr,ierr)
1366 CALL zlapmt( .false., n, n, v, ldv, iwork )
1369 IF ( ( nr .LT. m ) .AND. .NOT.(wntuf))
THEN
1370 CALL zlaset(
'A',m-nr,nr,czero,czero,u(nr+1,1),
1372 IF ( nr .LT. n1 )
THEN
1373 CALL zlaset(
'A',nr,n1-nr,czero,czero,u(1,nr+1),
1375 CALL zlaset(
'A',m-nr,n1-nr,czero,cone,
1376 $ u(nr+1,nr+1), ldu )
1388 $
CALL zunmqr(
'L',
'N', m, n1, n, a, lda, cwork, u,
1389 $ ldu, cwork(n+1), lcwork-n, ierr )
1390 IF ( rowprm .AND. .NOT.wntuf )
1391 $
CALL zlaswp( n1, u, ldu, 1, m-1, iwork(n+1), -1 )
1399 DO 4001 q = p, 1, -1
1400 IF ( s(q) .GT. zero )
GO TO 4002
1407 IF ( nr .LT. n )
CALL dlaset(
'G', n-nr,1, zero,zero, s(nr+1),
1412 $
CALL dlascl(
'G',0,0, one,sqrt(dble(m)), nr,1, s, n, ierr )
1413 IF ( conda ) rwork(1) = sconda