410 SUBROUTINE dgesvdq( JOBA, JOBP, JOBR, JOBU, JOBV, M, N, A, LDA,
411 $ S, U, LDU, V, LDV, NUMRANK, IWORK, LIWORK,
412 $ WORK, LWORK, RWORK, LRWORK, INFO )
415 CHARACTER JOBA, JOBP, JOBR, JOBU, JOBV
416 INTEGER M, N, LDA, LDU, LDV, NUMRANK, LIWORK, LWORK, LRWORK,
420 DOUBLE PRECISION A( LDA, * ), U( LDU, * ), V( LDV, * ), WORK( * )
421 DOUBLE PRECISION S( * ), RWORK( * )
427 DOUBLE PRECISION ZERO, ONE
428 PARAMETER ( ZERO = 0.0d0, one = 1.0d0 )
430 INTEGER IERR, IWOFF, NR, N1, OPTRATIO, p, q
431 INTEGER LWCON, LWQP3, LWRK_DGELQF, LWRK_DGESVD, LWRK_DGESVD2,
432 $ lwrk_dgeqp3, lwrk_dgeqrf, lwrk_dormlq, lwrk_dormqr,
433 $ lwrk_dormqr2, lwlqf, lwqrf, lwsvd, lwsvd2, lworq,
434 $ lworq2, lworlq, minwrk, minwrk2, optwrk, optwrk2,
436 LOGICAL ACCLA, ACCLM, ACCLH, ASCALED, CONDA, DNTWU, DNTWV,
437 $ LQUERY, LSVC0, LSVEC, ROWPRM, RSVEC, RTRANS, WNTUA,
438 $ wntuf, wntur, wntus, wntva, wntvr
439 DOUBLE PRECISION BIG, EPSLN, RTMP, SCONDA, SFMIN
441 DOUBLE PRECISION RDUMMY(1)
452 DOUBLE PRECISION DLANGE, DNRM2, DLAMCH
453 EXTERNAL dlange, lsame, idamax, dnrm2, dlamch
457 INTRINSIC abs, max, min, dble, sqrt
461 wntus = lsame( jobu,
'S' ) .OR. lsame( jobu,
'U' )
462 wntur = lsame( jobu,
'R' )
463 wntua = lsame( jobu,
'A' )
464 wntuf = lsame( jobu,
'F' )
465 lsvc0 = wntus .OR. wntur .OR. wntua
466 lsvec = lsvc0 .OR. wntuf
467 dntwu = lsame( jobu,
'N' )
469 wntvr = lsame( jobv,
'R' )
470 wntva = lsame( jobv,
'A' ) .OR. lsame( jobv,
'V' )
471 rsvec = wntvr .OR. wntva
472 dntwv = lsame( jobv,
'N' )
474 accla = lsame( joba,
'A' )
475 acclm = lsame( joba,
'M' )
476 conda = lsame( joba,
'E' )
477 acclh = lsame( joba,
'H' ) .OR. conda
479 rowprm = lsame( jobp,
'P' )
480 rtrans = lsame( jobr,
'T' )
484 iminwrk = max( 1, n + m - 1 + n )
486 iminwrk = max( 1, n + m - 1 )
488 rminwrk = max( 2, m )
491 iminwrk = max( 1, n + n )
493 iminwrk = max( 1, n )
497 lquery = (liwork .EQ. -1 .OR. lwork .EQ. -1 .OR. lrwork .EQ. -1)
499 IF ( .NOT. ( accla .OR. acclm .OR. acclh ) )
THEN
501 ELSE IF ( .NOT.( rowprm .OR. lsame( jobp,
'N' ) ) )
THEN
503 ELSE IF ( .NOT.( rtrans .OR. lsame( jobr,
'N' ) ) )
THEN
505 ELSE IF ( .NOT.( lsvec .OR. dntwu ) )
THEN
507 ELSE IF ( wntur .AND. wntva )
THEN
509 ELSE IF ( .NOT.( rsvec .OR. dntwv ))
THEN
511 ELSE IF ( m.LT.0 )
THEN
513 ELSE IF ( ( n.LT.0 ) .OR. ( n.GT.m ) )
THEN
515 ELSE IF ( lda.LT.max( 1, m ) )
THEN
517 ELSE IF ( ldu.LT.1 .OR. ( lsvc0 .AND. ldu.LT.m ) .OR.
518 $ ( wntuf .AND. ldu.LT.n ) )
THEN
520 ELSE IF ( ldv.LT.1 .OR. ( rsvec .AND. ldv.LT.n ) .OR.
521 $ ( conda .AND. ldv.LT.n ) )
THEN
523 ELSE IF ( liwork .LT. iminwrk .AND. .NOT. lquery )
THEN
528 IF ( info .EQ. 0 )
THEN
538 IF ( wntus .OR. wntur )
THEN
540 ELSE IF ( wntua )
THEN
546 lwsvd = max( 5 * n, 1 )
548 CALL dgeqp3( m, n, a, lda, iwork, rdummy, rdummy, -1,
550 lwrk_dgeqp3 = int( rdummy(1) )
551 IF ( wntus .OR. wntur )
THEN
552 CALL dormqr(
'L',
'N', m, n, n, a, lda, rdummy, u,
553 $ ldu, rdummy, -1, ierr )
554 lwrk_dormqr = int( rdummy(1) )
555 ELSE IF ( wntua )
THEN
556 CALL dormqr(
'L',
'N', m, m, n, a, lda, rdummy, u,
557 $ ldu, rdummy, -1, ierr )
558 lwrk_dormqr = int( rdummy(1) )
565 IF ( .NOT. (lsvec .OR. rsvec ))
THEN
569 minwrk = max( n+lwqp3, lwcon, lwsvd )
571 minwrk = max( n+lwqp3, lwsvd )
574 CALL dgesvd(
'N',
'N', n, n, a, lda, s, u, ldu,
575 $ v, ldv, rdummy, -1, ierr )
576 lwrk_dgesvd = int( rdummy(1) )
578 optwrk = max( n+lwrk_dgeqp3, n+lwcon, lwrk_dgesvd )
580 optwrk = max( n+lwrk_dgeqp3, lwrk_dgesvd )
583 ELSE IF ( lsvec .AND. (.NOT.rsvec) )
THEN
587 minwrk = n + max( lwqp3, lwcon, lwsvd, lworq )
589 minwrk = n + max( lwqp3, lwsvd, lworq )
593 CALL dgesvd(
'N',
'O', n, n, a, lda, s, u, ldu,
594 $ v, ldv, rdummy, -1, ierr )
596 CALL dgesvd(
'O',
'N', n, n, a, lda, s, u, ldu,
597 $ v, ldv, rdummy, -1, ierr )
599 lwrk_dgesvd = int( rdummy(1) )
601 optwrk = n + max( lwrk_dgeqp3, lwcon, lwrk_dgesvd,
604 optwrk = n + max( lwrk_dgeqp3, lwrk_dgesvd,
608 ELSE IF ( rsvec .AND. (.NOT.lsvec) )
THEN
612 minwrk = n + max( lwqp3, lwcon, lwsvd )
614 minwrk = n + max( lwqp3, lwsvd )
618 CALL dgesvd(
'O',
'N', n, n, a, lda, s, u, ldu,
619 $ v, ldv, rdummy, -1, ierr )
621 CALL dgesvd(
'N',
'O', n, n, a, lda, s, u, ldu,
622 $ v, ldv, rdummy, -1, ierr )
624 lwrk_dgesvd = int( rdummy(1) )
626 optwrk = n + max( lwrk_dgeqp3, lwcon, lwrk_dgesvd )
628 optwrk = n + max( lwrk_dgeqp3, lwrk_dgesvd )
635 minwrk = max( lwqp3, lwsvd, lworq )
636 IF ( conda ) minwrk = max( minwrk, lwcon )
640 lwqrf = max( n/2, 1 )
642 lwsvd2 = max( 5 * (n/2), 1 )
644 minwrk2 = max( lwqp3, n/2+lwqrf, n/2+lwsvd2,
645 $ n/2+lworq2, lworq )
646 IF ( conda ) minwrk2 = max( minwrk2, lwcon )
647 minwrk2 = n + minwrk2
648 minwrk = max( minwrk, minwrk2 )
651 minwrk = max( lwqp3, lwsvd, lworq )
652 IF ( conda ) minwrk = max( minwrk, lwcon )
656 lwlqf = max( n/2, 1 )
657 lwsvd2 = max( 5 * (n/2), 1 )
658 lworlq = max( n , 1 )
659 minwrk2 = max( lwqp3, n/2+lwlqf, n/2+lwsvd2,
660 $ n/2+lworlq, lworq )
661 IF ( conda ) minwrk2 = max( minwrk2, lwcon )
662 minwrk2 = n + minwrk2
663 minwrk = max( minwrk, minwrk2 )
668 CALL dgesvd(
'O',
'A', n, n, a, lda, s, u, ldu,
669 $ v, ldv, rdummy, -1, ierr )
670 lwrk_dgesvd = int( rdummy(1) )
671 optwrk = max(lwrk_dgeqp3,lwrk_dgesvd,lwrk_dormqr)
672 IF ( conda ) optwrk = max( optwrk, lwcon )
675 CALL dgeqrf(n,n/2,u,ldu,rdummy,rdummy,-1,ierr)
676 lwrk_dgeqrf = int( rdummy(1) )
677 CALL dgesvd(
'S',
'O', n/2,n/2, v,ldv, s, u,
679 $ v, ldv, rdummy, -1, ierr )
680 lwrk_dgesvd2 = int( rdummy(1) )
681 CALL dormqr(
'R',
'C', n, n, n/2, u, ldu,
683 $ v, ldv, rdummy, -1, ierr )
684 lwrk_dormqr2 = int( rdummy(1) )
685 optwrk2 = max( lwrk_dgeqp3, n/2+lwrk_dgeqrf,
686 $ n/2+lwrk_dgesvd2, n/2+lwrk_dormqr2 )
687 IF ( conda ) optwrk2 = max( optwrk2, lwcon )
688 optwrk2 = n + optwrk2
689 optwrk = max( optwrk, optwrk2 )
692 CALL dgesvd(
'S',
'O', n, n, a, lda, s, u, ldu,
693 $ v, ldv, rdummy, -1, ierr )
694 lwrk_dgesvd = int( rdummy(1) )
695 optwrk = max(lwrk_dgeqp3,lwrk_dgesvd,lwrk_dormqr)
696 IF ( conda ) optwrk = max( optwrk, lwcon )
699 CALL dgelqf(n/2,n,u,ldu,rdummy,rdummy,-1,ierr)
700 lwrk_dgelqf = int( rdummy(1) )
701 CALL dgesvd(
'S',
'O', n/2,n/2, v, ldv, s, u,
703 $ v, ldv, rdummy, -1, ierr )
704 lwrk_dgesvd2 = int( rdummy(1) )
705 CALL dormlq(
'R',
'N', n, n, n/2, u, ldu,
707 $ v, ldv, rdummy,-1,ierr )
708 lwrk_dormlq = int( rdummy(1) )
709 optwrk2 = max( lwrk_dgeqp3, n/2+lwrk_dgelqf,
710 $ n/2+lwrk_dgesvd2, n/2+lwrk_dormlq )
711 IF ( conda ) optwrk2 = max( optwrk2, lwcon )
712 optwrk2 = n + optwrk2
713 optwrk = max( optwrk, optwrk2 )
719 minwrk = max( 2, minwrk )
720 optwrk = max( 2, optwrk )
721 IF ( lwork .LT. minwrk .AND. (.NOT.lquery) ) info = -19
725 IF (info .EQ. 0 .AND. lrwork .LT. rminwrk .AND. .NOT. lquery)
THEN
729 CALL xerbla(
'DGESVDQ', -info )
731 ELSE IF ( lquery )
THEN
744 IF( ( m.EQ.0 ) .OR. ( n.EQ.0 ) )
THEN
760 rwork(p) = dlange(
'M', 1, n, a(p,1), lda, rdummy )
762 IF ( ( rwork(p) .NE. rwork(p) ) .OR.
763 $ ( (rwork(p)*zero) .NE. zero ) )
THEN
765 CALL xerbla(
'DGESVDQ', -info )
770 q = idamax( m-p+1, rwork(p), 1 ) + p - 1
779 IF ( rwork(1) .EQ. zero )
THEN
782 CALL dlaset(
'G', n, 1, zero, zero, s, n )
783 IF ( wntus )
CALL dlaset(
'G', m, n, zero, one, u, ldu)
784 IF ( wntua )
CALL dlaset(
'G', m, m, zero, one, u, ldu)
785 IF ( wntva )
CALL dlaset(
'G', n, n, zero, one, v, ldv)
787 CALL dlaset(
'G', n, 1, zero, zero, work, n )
788 CALL dlaset(
'G', m, n, zero, one, u, ldu )
794 DO 5002 p = n + 1, n + m - 1
798 IF ( conda ) rwork(1) = -1
803 IF ( rwork(1) .GT. big / sqrt(dble(m)) )
THEN
806 CALL dlascl(
'G',0,0,sqrt(dble(m)),one, m,n, a,lda,
810 CALL dlaswp( n, a, lda, 1, m-1, iwork(n+1), 1 )
818 IF ( .NOT.rowprm )
THEN
819 rtmp = dlange(
'M', m, n, a, lda, rdummy )
820 IF ( ( rtmp .NE. rtmp ) .OR.
821 $ ( (rtmp*zero) .NE. zero ) )
THEN
823 CALL xerbla(
'DGESVDQ', -info )
826 IF ( rtmp .GT. big / sqrt(dble(m)) )
THEN
829 CALL dlascl(
'G',0,0, sqrt(dble(m)),one, m,n, a,lda,
844 CALL dgeqp3( m, n, a, lda, iwork, work, work(n+1), lwork-n,
863 rtmp = sqrt(dble(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 dlacpy(
'U', n, n, a, lda, v, ldv )
908 rtmp = dnrm2( p, v(1,p), 1 )
909 CALL dscal( p, one/rtmp, v(1,p), 1 )
911 IF ( .NOT. ( lsvec .OR. rsvec ) )
THEN
912 CALL dpocon(
'U', nr, v, ldv, one, rtmp,
913 $ work, iwork(n+iwoff), ierr )
915 CALL dpocon(
'U', nr, v, ldv, one, rtmp,
916 $ work(n+1), iwork(n+iwoff), 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 )
946 IF ( q .LE. nr ) a(p,q) = zero
950 CALL dgesvd(
'N',
'N', n, nr, a, lda, s, u, ldu,
951 $ v, ldv, work, lwork, info )
958 $
CALL dlaset(
'L', nr-1,nr-1, zero,zero, a(2,1), lda )
959 CALL dgesvd(
'N',
'N', nr, n, a, lda, s, u, ldu,
960 $ v, ldv, work, lwork, info )
964 ELSE IF ( lsvec .AND. ( .NOT. rsvec) )
THEN
978 $
CALL dlaset(
'U', nr-1,nr-1, zero,zero, u(1,2), ldu )
982 CALL dgesvd(
'N',
'O', n, nr, u, ldu, s, u, ldu,
983 $ u, ldu, work(n+1), lwork-n, info )
986 DO 1120 q = p + 1, nr
996 CALL dlacpy(
'U', nr, n, a, lda, u, ldu )
998 $
CALL dlaset(
'L', nr-1, nr-1, zero, zero, u(2,1),
1002 CALL dgesvd(
'O',
'N', nr, n, u, ldu, s, u, ldu,
1003 $ v, ldv, work(n+1), lwork-n, info )
1011 IF ( ( nr .LT. m ) .AND. ( .NOT.wntuf ) )
THEN
1012 CALL dlaset(
'A', m-nr, nr, zero, zero, u(nr+1,1), ldu)
1013 IF ( nr .LT. n1 )
THEN
1014 CALL dlaset(
'A',nr,n1-nr,zero,zero,u(1,nr+1), ldu )
1015 CALL dlaset(
'A',m-nr,n1-nr,zero,one,
1016 $ u(nr+1,nr+1), ldu )
1024 $
CALL dormqr(
'L',
'N', m, n1, n, a, lda, work, u,
1025 $ ldu, work(n+1), lwork-n, ierr )
1026 IF ( rowprm .AND. .NOT.wntuf )
1027 $
CALL dlaswp( n1, u, ldu, 1, m-1, iwork(n+1), -1 )
1029 ELSE IF ( rsvec .AND. ( .NOT. lsvec ) )
THEN
1042 $
CALL dlaset(
'U', nr-1,nr-1, zero,zero, v(1,2), ldv )
1045 IF ( wntvr .OR. ( nr .EQ. n ) )
THEN
1046 CALL dgesvd(
'O',
'N', n, nr, v, ldv, s, u, ldu,
1047 $ u, ldu, work(n+1), lwork-n, info )
1050 DO 1122 q = p + 1, nr
1057 IF ( nr .LT. n )
THEN
1059 DO 1104 q = nr + 1, n
1064 CALL dlapmt( .false., nr, n, v, ldv, iwork )
1071 CALL dlaset(
'G', n, n-nr, zero, zero, v(1,nr+1), ldv)
1072 CALL dgesvd(
'O',
'N', n, n, v, ldv, s, u, ldu,
1073 $ u, ldu, work(n+1), lwork-n, info )
1076 DO 1124 q = p + 1, n
1082 CALL dlapmt( .false., n, n, v, ldv, iwork )
1088 CALL dlacpy(
'U', nr, n, a, lda, v, ldv )
1090 $
CALL dlaset(
'L', nr-1, nr-1, zero, zero, v(2,1),
1094 IF ( wntvr .OR. ( nr .EQ. n ) )
THEN
1095 CALL dgesvd(
'N',
'O', nr, n, v, ldv, s, u, ldu,
1096 $ v, ldv, work(n+1), lwork-n, info )
1097 CALL dlapmt( .false., nr, n, v, ldv, iwork )
1105 CALL dlaset(
'G', n-nr, n, zero,zero, v(nr+1,1), ldv)
1106 CALL dgesvd(
'N',
'O', n, n, v, ldv, s, u, ldu,
1107 $ v, ldv, work(n+1), lwork-n, info )
1108 CALL dlapmt( .false., n, n, v, ldv, iwork )
1122 IF ( wntvr .OR. ( nr .EQ. n ) )
THEN
1131 $
CALL dlaset(
'U', nr-1,nr-1, zero,zero, v(1,2), ldv )
1135 CALL dgesvd(
'O',
'A', n, nr, v, ldv, s, v, ldv,
1136 $ u, ldu, work(n+1), lwork-n, info )
1139 DO 1116 q = p + 1, nr
1145 IF ( nr .LT. n )
THEN
1152 CALL dlapmt( .false., nr, n, v, ldv, iwork )
1155 DO 1118 q = p + 1, nr
1162 IF ( ( nr .LT. m ) .AND. .NOT.(wntuf))
THEN
1163 CALL dlaset(
'A', m-nr,nr, zero,zero, u(nr+1,1),
1165 IF ( nr .LT. n1 )
THEN
1166 CALL dlaset(
'A',nr,n1-nr,zero,zero,u(1,nr+1),
1168 CALL dlaset(
'A',m-nr,n1-nr,zero,one,
1169 $ u(nr+1,nr+1), ldu )
1183 IF ( optratio*nr .GT. n )
THEN
1190 $
CALL dlaset(
'U',nr-1,nr-1, zero,zero, v(1,2),ldv)
1192 CALL dlaset(
'A',n,n-nr,zero,zero,v(1,nr+1),ldv)
1193 CALL dgesvd(
'O',
'A', n, n, v, ldv, s, v, ldv,
1194 $ u, ldu, work(n+1), lwork-n, info )
1197 DO 1114 q = p + 1, n
1203 CALL dlapmt( .false., n, n, v, ldv, iwork )
1208 DO 1112 q = p + 1, n
1215 IF ( ( n .LT. m ) .AND. .NOT.(wntuf))
THEN
1216 CALL dlaset(
'A',m-n,n,zero,zero,u(n+1,1),ldu)
1217 IF ( n .LT. n1 )
THEN
1218 CALL dlaset(
'A',n,n1-n,zero,zero,u(1,n+1),
1220 CALL dlaset(
'A',m-n,n1-n,zero,one,
1233 $
CALL dlaset(
'U',nr-1,nr-1,zero,zero,u(1,nr+2),ldu)
1234 CALL dgeqrf( n, nr, u(1,nr+1), ldu, work(n+1),
1235 $ work(n+nr+1), lwork-n-nr, ierr )
1241 CALL dlaset(
'U',nr-1,nr-1,zero,zero,v(1,2),ldv)
1242 CALL dgesvd(
'S',
'O', nr, nr, v, ldv, s, u, ldu,
1243 $ v,ldv, work(n+nr+1),lwork-n-nr, info )
1244 CALL dlaset(
'A',n-nr,nr,zero,zero,v(nr+1,1),ldv)
1245 CALL dlaset(
'A',nr,n-nr,zero,zero,v(1,nr+1),ldv)
1246 CALL dlaset(
'A',n-nr,n-nr,zero,one,v(nr+1,nr+1),
1248 CALL dormqr(
'R',
'C', n, n, nr, u(1,nr+1), ldu,
1249 $ work(n+1),v,ldv,work(n+nr+1),lwork-n-nr,ierr)
1250 CALL dlapmt( .false., n, n, v, ldv, iwork )
1253 IF ( ( nr .LT. m ) .AND. .NOT.(wntuf))
THEN
1254 CALL dlaset(
'A',m-nr,nr,zero,zero,u(nr+1,1),ldu)
1255 IF ( nr .LT. n1 )
THEN
1256 CALL dlaset(
'A',nr,n1-nr,zero,zero,u(1,nr+1),
1258 CALL dlaset(
'A',m-nr,n1-nr,zero,one,
1269 IF ( wntvr .OR. ( nr .EQ. n ) )
THEN
1271 CALL dlacpy(
'U', nr, n, a, lda, v, ldv )
1273 $
CALL dlaset(
'L', nr-1,nr-1, zero,zero, v(2,1), ldv )
1276 CALL dgesvd(
'S',
'O', nr, n, v, ldv, s, u, ldu,
1277 $ v, ldv, work(n+1), lwork-n, info )
1278 CALL dlapmt( .false., nr, n, v, ldv, iwork )
1282 IF ( ( nr .LT. m ) .AND. .NOT.(wntuf))
THEN
1283 CALL dlaset(
'A', m-nr,nr, zero,zero, u(nr+1,1),
1285 IF ( nr .LT. n1 )
THEN
1286 CALL dlaset(
'A',nr,n1-nr,zero,zero,u(1,nr+1),
1288 CALL dlaset(
'A',m-nr,n1-nr,zero,one,
1289 $ u(nr+1,nr+1), ldu )
1303 IF ( optratio * nr .GT. n )
THEN
1304 CALL dlacpy(
'U', nr, n, a, lda, v, ldv )
1306 $
CALL dlaset(
'L', nr-1,nr-1, zero,zero, v(2,1),ldv)
1309 CALL dlaset(
'A', n-nr,n, zero,zero, v(nr+1,1),ldv)
1310 CALL dgesvd(
'S',
'O', n, n, v, ldv, s, u, ldu,
1311 $ v, ldv, work(n+1), lwork-n, info )
1312 CALL dlapmt( .false., n, n, v, ldv, iwork )
1318 IF ( ( n .LT. m ) .AND. .NOT.(wntuf))
THEN
1319 CALL dlaset(
'A',m-n,n,zero,zero,u(n+1,1),ldu)
1320 IF ( n .LT. n1 )
THEN
1321 CALL dlaset(
'A',n,n1-n,zero,zero,u(1,n+1),
1323 CALL dlaset(
'A',m-n,n1-n,zero,one,
1328 CALL dlacpy(
'U', nr, n, a, lda, u(nr+1,1), ldu )
1330 $
CALL dlaset(
'L',nr-1,nr-1,zero,zero,u(nr+2,1),ldu)
1331 CALL dgelqf( nr, n, u(nr+1,1), ldu, work(n+1),
1332 $ work(n+nr+1), lwork-n-nr, ierr )
1333 CALL dlacpy(
'L',nr,nr,u(nr+1,1),ldu,v,ldv)
1335 $
CALL dlaset(
'U',nr-1,nr-1,zero,zero,v(1,2),ldv)
1336 CALL dgesvd(
'S',
'O', nr, nr, v, ldv, s, u, ldu,
1337 $ v, ldv, work(n+nr+1), lwork-n-nr, info )
1338 CALL dlaset(
'A',n-nr,nr,zero,zero,v(nr+1,1),ldv)
1339 CALL dlaset(
'A',nr,n-nr,zero,zero,v(1,nr+1),ldv)
1340 CALL dlaset(
'A',n-nr,n-nr,zero,one,v(nr+1,nr+1),
1342 CALL dormlq(
'R',
'N',n,n,nr,u(nr+1,1),ldu,work(n+1),
1343 $ v, ldv, work(n+nr+1),lwork-n-nr,ierr)
1344 CALL dlapmt( .false., n, n, v, ldv, iwork )
1347 IF ( ( nr .LT. m ) .AND. .NOT.(wntuf))
THEN
1348 CALL dlaset(
'A',m-nr,nr,zero,zero,u(nr+1,1),ldu)
1349 IF ( nr .LT. n1 )
THEN
1350 CALL dlaset(
'A',nr,n1-nr,zero,zero,u(1,nr+1),
1352 CALL dlaset(
'A',m-nr,n1-nr,zero,one,
1353 $ u(nr+1,nr+1), ldu )
1365 $
CALL dormqr(
'L',
'N', m, n1, n, a, lda, work, u,
1366 $ ldu, work(n+1), lwork-n, ierr )
1367 IF ( rowprm .AND. .NOT.wntuf )
1368 $
CALL dlaswp( n1, u, ldu, 1, m-1, iwork(n+1), -1 )
1376 DO 4001 q = p, 1, -1
1377 IF ( s(q) .GT. zero )
GO TO 4002
1384 IF ( nr .LT. n )
CALL dlaset(
'G', n-nr,1, zero,zero, s(nr+1),
1389 $
CALL dlascl(
'G',0,0, one,sqrt(dble(m)), nr,1, s, n, ierr )
1390 IF ( conda ) rwork(1) = sconda