408 SUBROUTINE cgesvdq( 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 A( LDA, * ), U( LDU, * ), V( LDV, * ), CWORK( * )
419 REAL S( * ), RWORK( * )
426 PARAMETER ( ZERO = 0.0e0, one = 1.0e0 )
428 parameter( czero = ( 0.0e0, 0.0e0 ), cone = ( 1.0e0, 0.0e0 ) )
431 INTEGER IERR, NR, N1, OPTRATIO, p, q
432 INTEGER LWCON, LWQP3, LWRK_CGELQF, LWRK_CGESVD, LWRK_CGESVD2,
433 $ lwrk_cgeqp3, lwrk_cgeqrf, lwrk_cunmlq, lwrk_cunmqr,
434 $ lwrk_cunmqr2, 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 REAL BIG, EPSLN, RTMP, SCONDA, SFMIN
456 REAL CLANGE, SCNRM2, SLAMCH
457 EXTERNAL clange, lsame, isamax, scnrm2, slamch
460 INTRINSIC abs, conjg, max, min, real, 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
537 IF ( wntus .OR. wntur )
THEN
539 ELSE IF ( wntua )
THEN
545 lwsvd = max( 3 * n, 1 )
547 CALL cgeqp3( m, n, a, lda, iwork, cdummy, cdummy, -1,
549 lwrk_cgeqp3 = int( cdummy(1) )
550 IF ( wntus .OR. wntur )
THEN
551 CALL cunmqr(
'L',
'N', m, n, n, a, lda, cdummy, u,
552 $ ldu, cdummy, -1, ierr )
553 lwrk_cunmqr = int( cdummy(1) )
554 ELSE IF ( wntua )
THEN
555 CALL cunmqr(
'L',
'N', m, m, n, a, lda, cdummy, u,
556 $ ldu, cdummy, -1, ierr )
557 lwrk_cunmqr = int( cdummy(1) )
564 IF ( .NOT. (lsvec .OR. rsvec ))
THEN
568 minwrk = max( n+lwqp3, lwcon, lwsvd )
570 minwrk = max( n+lwqp3, lwsvd )
573 CALL cgesvd(
'N',
'N', n, n, a, lda, s, u, ldu,
574 $ v, ldv, cdummy, -1, rdummy, ierr )
575 lwrk_cgesvd = int( cdummy(1) )
577 optwrk = max( n+lwrk_cgeqp3, n+lwcon, lwrk_cgesvd )
579 optwrk = max( n+lwrk_cgeqp3, lwrk_cgesvd )
582 ELSE IF ( lsvec .AND. (.NOT.rsvec) )
THEN
586 minwrk = n + max( lwqp3, lwcon, lwsvd, lwunq )
588 minwrk = n + max( lwqp3, lwsvd, lwunq )
592 CALL cgesvd(
'N',
'O', n, n, a, lda, s, u, ldu,
593 $ v, ldv, cdummy, -1, rdummy, ierr )
595 CALL cgesvd(
'O',
'N', n, n, a, lda, s, u, ldu,
596 $ v, ldv, cdummy, -1, rdummy, ierr )
598 lwrk_cgesvd = int( cdummy(1) )
600 optwrk = n + max( lwrk_cgeqp3, lwcon, lwrk_cgesvd,
603 optwrk = n + max( lwrk_cgeqp3, lwrk_cgesvd,
607 ELSE IF ( rsvec .AND. (.NOT.lsvec) )
THEN
611 minwrk = n + max( lwqp3, lwcon, lwsvd )
613 minwrk = n + max( lwqp3, lwsvd )
617 CALL cgesvd(
'O',
'N', n, n, a, lda, s, u, ldu,
618 $ v, ldv, cdummy, -1, rdummy, ierr )
620 CALL cgesvd(
'N',
'O', n, n, a, lda, s, u, ldu,
621 $ v, ldv, cdummy, -1, rdummy, ierr )
623 lwrk_cgesvd = int( cdummy(1) )
625 optwrk = n + max( lwrk_cgeqp3, lwcon, lwrk_cgesvd )
627 optwrk = n + max( lwrk_cgeqp3, lwrk_cgesvd )
634 minwrk = max( lwqp3, lwsvd, lwunq )
635 IF ( conda ) minwrk = max( minwrk, lwcon )
639 lwqrf = max( n/2, 1 )
641 lwsvd2 = max( 3 * (n/2), 1 )
643 minwrk2 = max( lwqp3, n/2+lwqrf, n/2+lwsvd2,
644 $ n/2+lwunq2, lwunq )
645 IF ( conda ) minwrk2 = max( minwrk2, lwcon )
646 minwrk2 = n + minwrk2
647 minwrk = max( minwrk, minwrk2 )
650 minwrk = max( lwqp3, lwsvd, lwunq )
651 IF ( conda ) minwrk = max( minwrk, lwcon )
655 lwlqf = max( n/2, 1 )
656 lwsvd2 = max( 3 * (n/2), 1 )
657 lwunlq = max( n , 1 )
658 minwrk2 = max( lwqp3, n/2+lwlqf, n/2+lwsvd2,
659 $ n/2+lwunlq, lwunq )
660 IF ( conda ) minwrk2 = max( minwrk2, lwcon )
661 minwrk2 = n + minwrk2
662 minwrk = max( minwrk, minwrk2 )
667 CALL cgesvd(
'O',
'A', n, n, a, lda, s, u, ldu,
668 $ v, ldv, cdummy, -1, rdummy, ierr )
669 lwrk_cgesvd = int( cdummy(1) )
670 optwrk = max(lwrk_cgeqp3,lwrk_cgesvd,lwrk_cunmqr)
671 IF ( conda ) optwrk = max( optwrk, lwcon )
674 CALL cgeqrf(n,n/2,u,ldu,cdummy,cdummy,-1,ierr)
675 lwrk_cgeqrf = int( cdummy(1) )
676 CALL cgesvd(
'S',
'O', n/2,n/2, v,ldv, s, u,
678 $ v, ldv, cdummy, -1, rdummy, ierr )
679 lwrk_cgesvd2 = int( cdummy(1) )
680 CALL cunmqr(
'R',
'C', n, n, n/2, u, ldu,
682 $ v, ldv, cdummy, -1, ierr )
683 lwrk_cunmqr2 = int( cdummy(1) )
684 optwrk2 = max( lwrk_cgeqp3, n/2+lwrk_cgeqrf,
685 $ n/2+lwrk_cgesvd2, n/2+lwrk_cunmqr2 )
686 IF ( conda ) optwrk2 = max( optwrk2, lwcon )
687 optwrk2 = n + optwrk2
688 optwrk = max( optwrk, optwrk2 )
691 CALL cgesvd(
'S',
'O', n, n, a, lda, s, u, ldu,
692 $ v, ldv, cdummy, -1, rdummy, ierr )
693 lwrk_cgesvd = int( cdummy(1) )
694 optwrk = max(lwrk_cgeqp3,lwrk_cgesvd,lwrk_cunmqr)
695 IF ( conda ) optwrk = max( optwrk, lwcon )
698 CALL cgelqf(n/2,n,u,ldu,cdummy,cdummy,-1,ierr)
699 lwrk_cgelqf = int( cdummy(1) )
700 CALL cgesvd(
'S',
'O', n/2,n/2, v, ldv, s, u,
702 $ v, ldv, cdummy, -1, rdummy, ierr )
703 lwrk_cgesvd2 = int( cdummy(1) )
704 CALL cunmlq(
'R',
'N', n, n, n/2, u, ldu,
706 $ v, ldv, cdummy,-1,ierr )
707 lwrk_cunmlq = int( cdummy(1) )
708 optwrk2 = max( lwrk_cgeqp3, n/2+lwrk_cgelqf,
709 $ n/2+lwrk_cgesvd2, n/2+lwrk_cunmlq )
710 IF ( conda ) optwrk2 = max( optwrk2, lwcon )
711 optwrk2 = n + optwrk2
712 optwrk = max( optwrk, optwrk2 )
718 minwrk = max( 2, minwrk )
719 optwrk = max( 2, optwrk )
720 IF ( lcwork .LT. minwrk .AND. (.NOT.lquery) ) info = -19
724 IF (info .EQ. 0 .AND. lrwork .LT. rminwrk .AND. .NOT. lquery)
THEN
728 CALL xerbla(
'CGESVDQ', -info )
730 ELSE IF ( lquery )
THEN
735 cwork(1) = cmplx( optwrk )
736 cwork(2) = cmplx( minwrk )
737 rwork(1) = real( rminwrk )
743 IF( ( m.EQ.0 ) .OR. ( n.EQ.0 ) )
THEN
757 rwork(p) = clange(
'M', 1, n, a(p,1), lda, rdummy )
759 IF ( ( rwork(p) .NE. rwork(p) ) .OR.
760 $ ( (rwork(p)*zero) .NE. zero ) )
THEN
762 CALL xerbla(
'CGESVDQ', -info )
767 q = isamax( m-p+1, rwork(p), 1 ) + p - 1
776 IF ( rwork(1) .EQ. zero )
THEN
779 CALL slaset(
'G', n, 1, zero, zero, s, n )
780 IF ( wntus )
CALL claset(
'G', m, n, czero, cone, u,
782 IF ( wntua )
CALL claset(
'G', m, m, czero, cone, u,
784 IF ( wntva )
CALL claset(
'G', n, n, czero, cone, v,
787 CALL claset(
'G', n, 1, czero, czero, cwork, n )
788 CALL claset(
'G', m, n, czero, cone, u, ldu )
794 DO 5002 p = n + 1, n + m - 1
798 IF ( conda ) rwork(1) = -1
803 IF ( rwork(1) .GT. big / sqrt(real(m)) )
THEN
806 CALL clascl(
'G',0,0,sqrt(real(m)),one, m,n, a,lda,
810 CALL claswp( n, a, lda, 1, m-1, iwork(n+1), 1 )
818 IF ( .NOT.rowprm )
THEN
819 rtmp = clange(
'M', m, n, a, lda, rwork )
820 IF ( ( rtmp .NE. rtmp ) .OR.
821 $ ( (rtmp*zero) .NE. zero ) )
THEN
823 CALL xerbla(
'CGESVDQ', -info )
826 IF ( rtmp .GT. big / sqrt(real(m)) )
THEN
829 CALL clascl(
'G',0,0, sqrt(real(m)),one, m,n, a,lda,
844 CALL cgeqp3( m, n, a, lda, iwork, cwork, cwork(n+1), lcwork-n,
863 rtmp = sqrt(real(n))*epsln
865 IF ( abs(a(p,p)) .LT. (rtmp*abs(a(1,1))) )
GO TO 3002
870 ELSEIF ( acclm )
THEN
879 IF ( ( abs(a(p,p)) .LT. (epsln*abs(a(p-1,p-1))) ) .OR.
880 $ ( abs(a(p,p)) .LT. sfmin ) )
GO TO 3402
892 IF ( abs(a(p,p)) .EQ. zero )
GO TO 3502
901 CALL clacpy(
'U', n, n, a, lda, v, ldv )
908 rtmp = scnrm2( p, v(1,p), 1 )
909 CALL csscal( p, one/rtmp, v(1,p), 1 )
911 IF ( .NOT. ( lsvec .OR. rsvec ) )
THEN
912 CALL cpocon(
'U', nr, v, ldv, one, rtmp,
913 $ cwork, rwork, ierr )
915 CALL cpocon(
'U', nr, v, ldv, one, rtmp,
916 $ cwork(n+1), rwork, ierr )
918 sconda = one / sqrt(rtmp)
928 ELSE IF ( wntus .OR. wntuf)
THEN
930 ELSE IF ( wntua )
THEN
934 IF ( .NOT. ( rsvec .OR. lsvec ) )
THEN
943 DO 1146 p = 1, min( n, nr )
944 a(p,p) = conjg(a(p,p))
946 a(q,p) = conjg(a(p,q))
947 IF ( q .LE. nr ) a(p,q) = czero
951 CALL cgesvd(
'N',
'N', n, nr, a, lda, s, u, ldu,
952 $ v, ldv, cwork, lcwork, rwork, info )
959 $
CALL claset(
'L', nr-1,nr-1, czero,czero, a(2,1),
961 CALL cgesvd(
'N',
'N', nr, n, a, lda, s, u, ldu,
962 $ v, ldv, cwork, lcwork, rwork, info )
966 ELSE IF ( lsvec .AND. ( .NOT. rsvec) )
THEN
976 u(q,p) = conjg(a(p,q))
980 $
CALL claset(
'U', nr-1,nr-1, czero,czero, u(1,2),
985 CALL cgesvd(
'N',
'O', n, nr, u, ldu, s, u, ldu,
986 $ u, ldu, cwork(n+1), lcwork-n, rwork, info )
989 u(p,p) = conjg(u(p,p))
990 DO 1120 q = p + 1, nr
992 u(q,p) = conjg(u(p,q))
1000 CALL clacpy(
'U', nr, n, a, lda, u, ldu )
1002 $
CALL claset(
'L', nr-1, nr-1, czero, czero, u(2,1),
1006 CALL cgesvd(
'O',
'N', nr, n, u, ldu, s, u, ldu,
1007 $ v, ldv, cwork(n+1), lcwork-n, rwork, info )
1015 IF ( ( nr .LT. m ) .AND. ( .NOT.wntuf ) )
THEN
1016 CALL claset(
'A', m-nr, nr, czero, czero, u(nr+1,1), ldu)
1017 IF ( nr .LT. n1 )
THEN
1018 CALL claset(
'A',nr,n1-nr,czero,czero,u(1,nr+1),
1020 CALL claset(
'A',m-nr,n1-nr,czero,cone,
1021 $ u(nr+1,nr+1), ldu )
1029 $
CALL cunmqr(
'L',
'N', m, n1, n, a, lda, cwork, u,
1030 $ ldu, cwork(n+1), lcwork-n, ierr )
1031 IF ( rowprm .AND. .NOT.wntuf )
1032 $
CALL claswp( n1, u, ldu, 1, m-1, iwork(n+1), -1 )
1034 ELSE IF ( rsvec .AND. ( .NOT. lsvec ) )
THEN
1043 v(q,p) = conjg(a(p,q))
1047 $
CALL claset(
'U', nr-1,nr-1, czero,czero, v(1,2),
1051 IF ( wntvr .OR. ( nr .EQ. n ) )
THEN
1052 CALL cgesvd(
'O',
'N', n, nr, v, ldv, s, u, ldu,
1053 $ u, ldu, cwork(n+1), lcwork-n, rwork, info )
1056 v(p,p) = conjg(v(p,p))
1057 DO 1122 q = p + 1, nr
1058 ctmp = conjg(v(q,p))
1059 v(q,p) = conjg(v(p,q))
1064 IF ( nr .LT. n )
THEN
1066 DO 1104 q = nr + 1, n
1067 v(p,q) = conjg(v(q,p))
1071 CALL clapmt( .false., nr, n, v, ldv, iwork )
1078 CALL claset(
'G', n, n-nr, czero, czero, v(1,nr+1),
1080 CALL cgesvd(
'O',
'N', n, n, v, ldv, s, u, ldu,
1081 $ u, ldu, cwork(n+1), lcwork-n, rwork, info )
1084 v(p,p) = conjg(v(p,p))
1085 DO 1124 q = p + 1, n
1086 ctmp = conjg(v(q,p))
1087 v(q,p) = conjg(v(p,q))
1091 CALL clapmt( .false., n, n, v, ldv, iwork )
1097 CALL clacpy(
'U', nr, n, a, lda, v, ldv )
1099 $
CALL claset(
'L', nr-1, nr-1, czero, czero, v(2,1),
1103 IF ( wntvr .OR. ( nr .EQ. n ) )
THEN
1104 CALL cgesvd(
'N',
'O', nr, n, v, ldv, s, u, ldu,
1105 $ v, ldv, cwork(n+1), lcwork-n, rwork, info )
1106 CALL clapmt( .false., nr, n, v, ldv, iwork )
1114 CALL claset(
'G', n-nr, n, czero,czero, v(nr+1,1),
1116 CALL cgesvd(
'N',
'O', n, n, v, ldv, s, u, ldu,
1117 $ v, ldv, cwork(n+1), lcwork-n, rwork, info )
1118 CALL clapmt( .false., n, n, v, ldv, iwork )
1132 IF ( wntvr .OR. ( nr .EQ. n ) )
THEN
1137 v(q,p) = conjg(a(p,q))
1141 $
CALL claset(
'U', nr-1,nr-1, czero,czero, v(1,2),
1147 CALL cgesvd(
'O',
'A', n, nr, v, ldv, s, v, ldv,
1148 $ u, ldu, cwork(n+1), lcwork-n, rwork, info )
1151 v(p,p) = conjg(v(p,p))
1152 DO 1116 q = p + 1, nr
1153 ctmp = conjg(v(q,p))
1154 v(q,p) = conjg(v(p,q))
1158 IF ( nr .LT. n )
THEN
1161 v(p,q) = conjg(v(q,p))
1165 CALL clapmt( .false., nr, n, v, ldv, iwork )
1168 u(p,p) = conjg(u(p,p))
1169 DO 1118 q = p + 1, nr
1170 ctmp = conjg(u(q,p))
1171 u(q,p) = conjg(u(p,q))
1176 IF ( ( nr .LT. m ) .AND. .NOT.(wntuf))
THEN
1177 CALL claset(
'A', m-nr,nr, czero,czero, u(nr+1,1),
1179 IF ( nr .LT. n1 )
THEN
1180 CALL claset(
'A',nr,n1-nr,czero,czero,u(1,nr+1),
1182 CALL claset(
'A',m-nr,n1-nr,czero,cone,
1183 $ u(nr+1,nr+1), ldu )
1197 IF ( optratio*nr .GT. n )
THEN
1200 v(q,p) = conjg(a(p,q))
1204 $
CALL claset(
'U',nr-1,nr-1, czero,czero, v(1,2),
1207 CALL claset(
'A',n,n-nr,czero,czero,v(1,nr+1),ldv)
1208 CALL cgesvd(
'O',
'A', n, n, v, ldv, s, v, ldv,
1209 $ u, ldu, cwork(n+1), lcwork-n, rwork, info )
1212 v(p,p) = conjg(v(p,p))
1213 DO 1114 q = p + 1, n
1214 ctmp = conjg(v(q,p))
1215 v(q,p) = conjg(v(p,q))
1219 CALL clapmt( .false., n, n, v, ldv, iwork )
1224 u(p,p) = conjg(u(p,p))
1225 DO 1112 q = p + 1, n
1226 ctmp = conjg(u(q,p))
1227 u(q,p) = conjg(u(p,q))
1232 IF ( ( n .LT. m ) .AND. .NOT.(wntuf))
THEN
1233 CALL claset(
'A',m-n,n,czero,czero,u(n+1,1),ldu)
1234 IF ( n .LT. n1 )
THEN
1235 CALL claset(
'A',n,n1-n,czero,czero,u(1,n+1),
1237 CALL claset(
'A',m-n,n1-n,czero,cone,
1246 u(q,nr+p) = conjg(a(p,q))
1250 $
CALL claset(
'U',nr-1,nr-1,czero,czero,u(1,nr+2),
1252 CALL cgeqrf( n, nr, u(1,nr+1), ldu, cwork(n+1),
1253 $ cwork(n+nr+1), lcwork-n-nr, ierr )
1256 v(q,p) = conjg(u(p,nr+q))
1259 CALL claset(
'U',nr-1,nr-1,czero,czero,v(1,2),ldv)
1260 CALL cgesvd(
'S',
'O', nr, nr, v, ldv, s, u, ldu,
1261 $ v,ldv, cwork(n+nr+1),lcwork-n-nr,rwork, info )
1262 CALL claset(
'A',n-nr,nr,czero,czero,v(nr+1,1),ldv)
1263 CALL claset(
'A',nr,n-nr,czero,czero,v(1,nr+1),ldv)
1264 CALL claset(
'A',n-nr,n-nr,czero,cone,v(nr+1,nr+1),
1266 CALL cunmqr(
'R',
'C', n, n, nr, u(1,nr+1), ldu,
1267 $ cwork(n+1),v,ldv,cwork(n+nr+1),lcwork-n-nr,ierr)
1268 CALL clapmt( .false., n, n, v, ldv, iwork )
1271 IF ( ( nr .LT. m ) .AND. .NOT.(wntuf))
THEN
1272 CALL claset(
'A',m-nr,nr,czero,czero,u(nr+1,1),
1274 IF ( nr .LT. n1 )
THEN
1275 CALL claset(
'A',nr,n1-nr,czero,czero,u(1,nr+1),
1277 CALL claset(
'A',m-nr,n1-nr,czero,cone,
1288 IF ( wntvr .OR. ( nr .EQ. n ) )
THEN
1290 CALL clacpy(
'U', nr, n, a, lda, v, ldv )
1292 $
CALL claset(
'L', nr-1,nr-1, czero,czero, v(2,1),
1296 CALL cgesvd(
'S',
'O', nr, n, v, ldv, s, u, ldu,
1297 $ v, ldv, cwork(n+1), lcwork-n, rwork, info )
1298 CALL clapmt( .false., nr, n, v, ldv, iwork )
1302 IF ( ( nr .LT. m ) .AND. .NOT.(wntuf))
THEN
1303 CALL claset(
'A', m-nr,nr, czero,czero, u(nr+1,1),
1305 IF ( nr .LT. n1 )
THEN
1306 CALL claset(
'A',nr,n1-nr,czero,czero,u(1,nr+1),
1308 CALL claset(
'A',m-nr,n1-nr,czero,cone,
1309 $ u(nr+1,nr+1), ldu )
1323 IF ( optratio * nr .GT. n )
THEN
1324 CALL clacpy(
'U', nr, n, a, lda, v, ldv )
1326 $
CALL claset(
'L', nr-1,nr-1, czero,czero, v(2,1),
1330 CALL claset(
'A', n-nr,n, czero,czero, v(nr+1,1),
1332 CALL cgesvd(
'S',
'O', n, n, v, ldv, s, u, ldu,
1333 $ v, ldv, cwork(n+1), lcwork-n, rwork, info )
1334 CALL clapmt( .false., n, n, v, ldv, iwork )
1340 IF ( ( n .LT. m ) .AND. .NOT.(wntuf))
THEN
1341 CALL claset(
'A',m-n,n,czero,czero,u(n+1,1),ldu)
1342 IF ( n .LT. n1 )
THEN
1343 CALL claset(
'A',n,n1-n,czero,czero,u(1,n+1),
1345 CALL claset(
'A',m-n,n1-n,czero,cone,
1350 CALL clacpy(
'U', nr, n, a, lda, u(nr+1,1), ldu )
1352 $
CALL claset(
'L',nr-1,nr-1,czero,czero,u(nr+2,1),
1354 CALL cgelqf( nr, n, u(nr+1,1), ldu, cwork(n+1),
1355 $ cwork(n+nr+1), lcwork-n-nr, ierr )
1356 CALL clacpy(
'L',nr,nr,u(nr+1,1),ldu,v,ldv)
1358 $
CALL claset(
'U',nr-1,nr-1,czero,czero,v(1,2),ldv)
1359 CALL cgesvd(
'S',
'O', nr, nr, v, ldv, s, u, ldu,
1360 $ v, ldv, cwork(n+nr+1), lcwork-n-nr, rwork, info )
1361 CALL claset(
'A',n-nr,nr,czero,czero,v(nr+1,1),ldv)
1362 CALL claset(
'A',nr,n-nr,czero,czero,v(1,nr+1),ldv)
1363 CALL claset(
'A',n-nr,n-nr,czero,cone,v(nr+1,nr+1),
1365 CALL cunmlq(
'R',
'N',n,n,nr,u(nr+1,1),ldu,
1367 $ v, ldv, cwork(n+nr+1),lcwork-n-nr,ierr)
1368 CALL clapmt( .false., n, n, v, ldv, iwork )
1371 IF ( ( nr .LT. m ) .AND. .NOT.(wntuf))
THEN
1372 CALL claset(
'A',m-nr,nr,czero,czero,u(nr+1,1),
1374 IF ( nr .LT. n1 )
THEN
1375 CALL claset(
'A',nr,n1-nr,czero,czero,u(1,nr+1),
1377 CALL claset(
'A',m-nr,n1-nr,czero,cone,
1378 $ u(nr+1,nr+1), ldu )
1390 $
CALL cunmqr(
'L',
'N', m, n1, n, a, lda, cwork, u,
1391 $ ldu, cwork(n+1), lcwork-n, ierr )
1392 IF ( rowprm .AND. .NOT.wntuf )
1393 $
CALL claswp( n1, u, ldu, 1, m-1, iwork(n+1), -1 )
1401 DO 4001 q = p, 1, -1
1402 IF ( s(q) .GT. zero )
GO TO 4002
1409 IF ( nr .LT. n )
CALL slaset(
'G', n-nr,1, zero,zero, s(nr+1),
1414 $
CALL slascl(
'G',0,0, one,sqrt(real(m)), nr,1, s, n, ierr )
1415 IF ( conda ) rwork(1) = sconda
1416 rwork(2) = real( p - nr )