410 SUBROUTINE sgesvdq( 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 REAL A( LDA, * ), U( LDU, * ), V( LDV, * ), WORK( * )
421 REAL S( * ), RWORK( * )
428 PARAMETER ( ZERO = 0.0e0, one = 1.0e0 )
431 INTEGER IERR, IWOFF, NR, N1, OPTRATIO, p, q
432 INTEGER LWCON, LWQP3, LWRK_SGELQF, LWRK_SGESVD, LWRK_SGESVD2,
433 $ lwrk_sgeqp3, lwrk_sgeqrf, lwrk_sormlq, lwrk_sormqr,
434 $ lwrk_sormqr2, lwlqf, lwqrf, lwsvd, lwsvd2, lworq,
435 $ lworq2, 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
453 REAL SLANGE, SNRM2, SLAMCH
454 EXTERNAL slange, lsame, isamax, snrm2, slamch
457 INTRINSIC abs, max, min, real, sqrt
463 wntus = lsame( jobu,
'S' ) .OR. lsame( jobu,
'U' )
464 wntur = lsame( jobu,
'R' )
465 wntua = lsame( jobu,
'A' )
466 wntuf = lsame( jobu,
'F' )
467 lsvc0 = wntus .OR. wntur .OR. wntua
468 lsvec = lsvc0 .OR. wntuf
469 dntwu = lsame( jobu,
'N' )
471 wntvr = lsame( jobv,
'R' )
472 wntva = lsame( jobv,
'A' ) .OR. lsame( jobv,
'V' )
473 rsvec = wntvr .OR. wntva
474 dntwv = lsame( jobv,
'N' )
476 accla = lsame( joba,
'A' )
477 acclm = lsame( joba,
'M' )
478 conda = lsame( joba,
'E' )
479 acclh = lsame( joba,
'H' ) .OR. conda
481 rowprm = lsame( jobp,
'P' )
482 rtrans = lsame( jobr,
'T' )
486 iminwrk = max( 1, n + m - 1 + n )
488 iminwrk = max( 1, n + m - 1 )
490 rminwrk = max( 2, m )
493 iminwrk = max( 1, n + n )
495 iminwrk = max( 1, n )
499 lquery = (liwork .EQ. -1 .OR. lwork .EQ. -1 .OR. lrwork .EQ. -1)
501 IF ( .NOT. ( accla .OR. acclm .OR. acclh ) )
THEN
503 ELSE IF ( .NOT.( rowprm .OR. lsame( jobp,
'N' ) ) )
THEN
505 ELSE IF ( .NOT.( rtrans .OR. lsame( jobr,
'N' ) ) )
THEN
507 ELSE IF ( .NOT.( lsvec .OR. dntwu ) )
THEN
509 ELSE IF ( wntur .AND. wntva )
THEN
511 ELSE IF ( .NOT.( rsvec .OR. dntwv ))
THEN
513 ELSE IF ( m.LT.0 )
THEN
515 ELSE IF ( ( n.LT.0 ) .OR. ( n.GT.m ) )
THEN
517 ELSE IF ( lda.LT.max( 1, m ) )
THEN
519 ELSE IF ( ldu.LT.1 .OR. ( lsvc0 .AND. ldu.LT.m ) .OR.
520 $ ( wntuf .AND. ldu.LT.n ) )
THEN
522 ELSE IF ( ldv.LT.1 .OR. ( rsvec .AND. ldv.LT.n ) .OR.
523 $ ( conda .AND. ldv.LT.n ) )
THEN
525 ELSE IF ( liwork .LT. iminwrk .AND. .NOT. lquery )
THEN
530 IF ( info .EQ. 0 )
THEN
540 IF ( wntus .OR. wntur )
THEN
542 ELSE IF ( wntua )
THEN
548 lwsvd = max( 5 * n, 1 )
550 CALL sgeqp3( m, n, a, lda, iwork, rdummy, rdummy, -1,
552 lwrk_sgeqp3 = int( rdummy(1) )
553 IF ( wntus .OR. wntur )
THEN
554 CALL sormqr(
'L',
'N', m, n, n, a, lda, rdummy, u,
555 $ ldu, rdummy, -1, ierr )
556 lwrk_sormqr = int( rdummy(1) )
557 ELSE IF ( wntua )
THEN
558 CALL sormqr(
'L',
'N', m, m, n, a, lda, rdummy, u,
559 $ ldu, rdummy, -1, ierr )
560 lwrk_sormqr = int( rdummy(1) )
567 IF ( .NOT. (lsvec .OR. rsvec ))
THEN
571 minwrk = max( n+lwqp3, lwcon, lwsvd )
573 minwrk = max( n+lwqp3, lwsvd )
576 CALL sgesvd(
'N',
'N', n, n, a, lda, s, u, ldu,
577 $ v, ldv, rdummy, -1, ierr )
578 lwrk_sgesvd = int( rdummy(1) )
580 optwrk = max( n+lwrk_sgeqp3, n+lwcon, lwrk_sgesvd )
582 optwrk = max( n+lwrk_sgeqp3, lwrk_sgesvd )
585 ELSE IF ( lsvec .AND. (.NOT.rsvec) )
THEN
589 minwrk = n + max( lwqp3, lwcon, lwsvd, lworq )
591 minwrk = n + max( lwqp3, lwsvd, lworq )
595 CALL sgesvd(
'N',
'O', n, n, a, lda, s, u, ldu,
596 $ v, ldv, rdummy, -1, ierr )
598 CALL sgesvd(
'O',
'N', n, n, a, lda, s, u, ldu,
599 $ v, ldv, rdummy, -1, ierr )
601 lwrk_sgesvd = int( rdummy(1) )
603 optwrk = n + max( lwrk_sgeqp3, lwcon, lwrk_sgesvd,
606 optwrk = n + max( lwrk_sgeqp3, lwrk_sgesvd,
610 ELSE IF ( rsvec .AND. (.NOT.lsvec) )
THEN
614 minwrk = n + max( lwqp3, lwcon, lwsvd )
616 minwrk = n + max( lwqp3, lwsvd )
620 CALL sgesvd(
'O',
'N', n, n, a, lda, s, u, ldu,
621 $ v, ldv, rdummy, -1, ierr )
623 CALL sgesvd(
'N',
'O', n, n, a, lda, s, u, ldu,
624 $ v, ldv, rdummy, -1, ierr )
626 lwrk_sgesvd = int( rdummy(1) )
628 optwrk = n + max( lwrk_sgeqp3, lwcon, lwrk_sgesvd )
630 optwrk = n + max( lwrk_sgeqp3, lwrk_sgesvd )
637 minwrk = max( lwqp3, lwsvd, lworq )
638 IF ( conda ) minwrk = max( minwrk, lwcon )
642 lwqrf = max( n/2, 1 )
644 lwsvd2 = max( 5 * (n/2), 1 )
646 minwrk2 = max( lwqp3, n/2+lwqrf, n/2+lwsvd2,
647 $ n/2+lworq2, lworq )
648 IF ( conda ) minwrk2 = max( minwrk2, lwcon )
649 minwrk2 = n + minwrk2
650 minwrk = max( minwrk, minwrk2 )
653 minwrk = max( lwqp3, lwsvd, lworq )
654 IF ( conda ) minwrk = max( minwrk, lwcon )
658 lwlqf = max( n/2, 1 )
659 lwsvd2 = max( 5 * (n/2), 1 )
660 lwunlq = max( n , 1 )
661 minwrk2 = max( lwqp3, n/2+lwlqf, n/2+lwsvd2,
662 $ n/2+lwunlq, lworq )
663 IF ( conda ) minwrk2 = max( minwrk2, lwcon )
664 minwrk2 = n + minwrk2
665 minwrk = max( minwrk, minwrk2 )
670 CALL sgesvd(
'O',
'A', n, n, a, lda, s, u, ldu,
671 $ v, ldv, rdummy, -1, ierr )
672 lwrk_sgesvd = int( rdummy(1) )
673 optwrk = max(lwrk_sgeqp3,lwrk_sgesvd,lwrk_sormqr)
674 IF ( conda ) optwrk = max( optwrk, lwcon )
677 CALL sgeqrf(n,n/2,u,ldu,rdummy,rdummy,-1,ierr)
678 lwrk_sgeqrf = int( rdummy(1) )
679 CALL sgesvd(
'S',
'O', n/2,n/2, v,ldv, s, u,
681 $ v, ldv, rdummy, -1, ierr )
682 lwrk_sgesvd2 = int( rdummy(1) )
683 CALL sormqr(
'R',
'C', n, n, n/2, u, ldu,
685 $ v, ldv, rdummy, -1, ierr )
686 lwrk_sormqr2 = int( rdummy(1) )
687 optwrk2 = max( lwrk_sgeqp3, n/2+lwrk_sgeqrf,
688 $ n/2+lwrk_sgesvd2, n/2+lwrk_sormqr2 )
689 IF ( conda ) optwrk2 = max( optwrk2, lwcon )
690 optwrk2 = n + optwrk2
691 optwrk = max( optwrk, optwrk2 )
694 CALL sgesvd(
'S',
'O', n, n, a, lda, s, u, ldu,
695 $ v, ldv, rdummy, -1, ierr )
696 lwrk_sgesvd = int( rdummy(1) )
697 optwrk = max(lwrk_sgeqp3,lwrk_sgesvd,lwrk_sormqr)
698 IF ( conda ) optwrk = max( optwrk, lwcon )
701 CALL sgelqf(n/2,n,u,ldu,rdummy,rdummy,-1,ierr)
702 lwrk_sgelqf = int( rdummy(1) )
703 CALL sgesvd(
'S',
'O', n/2,n/2, v, ldv, s, u,
705 $ v, ldv, rdummy, -1, ierr )
706 lwrk_sgesvd2 = int( rdummy(1) )
707 CALL sormlq(
'R',
'N', n, n, n/2, u, ldu,
709 $ v, ldv, rdummy,-1,ierr )
710 lwrk_sormlq = int( rdummy(1) )
711 optwrk2 = max( lwrk_sgeqp3, n/2+lwrk_sgelqf,
712 $ n/2+lwrk_sgesvd2, n/2+lwrk_sormlq )
713 IF ( conda ) optwrk2 = max( optwrk2, lwcon )
714 optwrk2 = n + optwrk2
715 optwrk = max( optwrk, optwrk2 )
721 minwrk = max( 2, minwrk )
722 optwrk = max( 2, optwrk )
723 IF ( lwork .LT. minwrk .AND. (.NOT.lquery) ) info = -19
727 IF (info .EQ. 0 .AND. lrwork .LT. rminwrk .AND. .NOT. lquery)
THEN
731 CALL xerbla(
'SGESVDQ', -info )
733 ELSE IF ( lquery )
THEN
738 work(1) = real( optwrk )
739 work(2) = real( minwrk )
740 rwork(1) = real( rminwrk )
746 IF( ( m.EQ.0 ) .OR. ( n.EQ.0 ) )
THEN
762 rwork(p) = slange(
'M', 1, n, a(p,1), lda, rdummy )
764 IF ( ( rwork(p) .NE. rwork(p) ) .OR.
765 $ ( (rwork(p)*zero) .NE. zero ) )
THEN
767 CALL xerbla(
'SGESVDQ', -info )
772 q = isamax( m-p+1, rwork(p), 1 ) + p - 1
781 IF ( rwork(1) .EQ. zero )
THEN
784 CALL slaset(
'G', n, 1, zero, zero, s, n )
785 IF ( wntus )
CALL slaset(
'G', m, n, zero, one, u, ldu)
786 IF ( wntua )
CALL slaset(
'G', m, m, zero, one, u, ldu)
787 IF ( wntva )
CALL slaset(
'G', n, n, zero, one, v, ldv)
789 CALL slaset(
'G', n, 1, zero, zero, work, n )
790 CALL slaset(
'G', m, n, zero, one, u, ldu )
796 DO 5002 p = n + 1, n + m - 1
800 IF ( conda ) rwork(1) = -1
805 IF ( rwork(1) .GT. big / sqrt(real(m)) )
THEN
808 CALL slascl(
'G',0,0,sqrt(real(m)),one, m,n, a,lda,
812 CALL slaswp( n, a, lda, 1, m-1, iwork(n+1), 1 )
820 IF ( .NOT.rowprm )
THEN
821 rtmp = slange(
'M', m, n, a, lda, rdummy )
822 IF ( ( rtmp .NE. rtmp ) .OR.
823 $ ( (rtmp*zero) .NE. zero ) )
THEN
825 CALL xerbla(
'SGESVDQ', -info )
828 IF ( rtmp .GT. big / sqrt(real(m)) )
THEN
831 CALL slascl(
'G',0,0, sqrt(real(m)),one, m,n, a,lda,
846 CALL sgeqp3( m, n, a, lda, iwork, work, work(n+1), lwork-n,
865 rtmp = sqrt(real(n))*epsln
867 IF ( abs(a(p,p)) .LT. (rtmp*abs(a(1,1))) )
GO TO 3002
872 ELSEIF ( acclm )
THEN
881 IF ( ( abs(a(p,p)) .LT. (epsln*abs(a(p-1,p-1))) ) .OR.
882 $ ( abs(a(p,p)) .LT. sfmin ) )
GO TO 3402
894 IF ( abs(a(p,p)) .EQ. zero )
GO TO 3502
903 CALL slacpy(
'U', n, n, a, lda, v, ldv )
910 rtmp = snrm2( p, v(1,p), 1 )
911 CALL sscal( p, one/rtmp, v(1,p), 1 )
913 IF ( .NOT. ( lsvec .OR. rsvec ) )
THEN
914 CALL spocon(
'U', nr, v, ldv, one, rtmp,
915 $ work, iwork(n+iwoff), ierr )
917 CALL spocon(
'U', nr, v, ldv, one, rtmp,
918 $ work(n+1), iwork(n+iwoff), ierr )
920 sconda = one / sqrt(rtmp)
930 ELSE IF ( wntus .OR. wntuf)
THEN
932 ELSE IF ( wntua )
THEN
936 IF ( .NOT. ( rsvec .OR. lsvec ) )
THEN
945 DO 1146 p = 1, min( n, nr )
948 IF ( q .LE. nr ) a(p,q) = zero
952 CALL sgesvd(
'N',
'N', n, nr, a, lda, s, u, ldu,
953 $ v, ldv, work, lwork, info )
960 $
CALL slaset(
'L', nr-1,nr-1, zero,zero, a(2,1), lda )
961 CALL sgesvd(
'N',
'N', nr, n, a, lda, s, u, ldu,
962 $ v, ldv, work, lwork, info )
966 ELSE IF ( lsvec .AND. ( .NOT. rsvec) )
THEN
980 $
CALL slaset(
'U', nr-1,nr-1, zero,zero, u(1,2), ldu )
984 CALL sgesvd(
'N',
'O', n, nr, u, ldu, s, u, ldu,
985 $ u, ldu, work(n+1), lwork-n, info )
988 DO 1120 q = p + 1, nr
998 CALL slacpy(
'U', nr, n, a, lda, u, ldu )
1000 $
CALL slaset(
'L', nr-1, nr-1, zero, zero, u(2,1),
1004 CALL sgesvd(
'O',
'N', nr, n, u, ldu, s, u, ldu,
1005 $ v, ldv, work(n+1), lwork-n, info )
1013 IF ( ( nr .LT. m ) .AND. ( .NOT.wntuf ) )
THEN
1014 CALL slaset(
'A', m-nr, nr, zero, zero, u(nr+1,1), ldu)
1015 IF ( nr .LT. n1 )
THEN
1016 CALL slaset(
'A',nr,n1-nr,zero,zero,u(1,nr+1), ldu )
1017 CALL slaset(
'A',m-nr,n1-nr,zero,one,
1018 $ u(nr+1,nr+1), ldu )
1026 $
CALL sormqr(
'L',
'N', m, n1, n, a, lda, work, u,
1027 $ ldu, work(n+1), lwork-n, ierr )
1028 IF ( rowprm .AND. .NOT.wntuf )
1029 $
CALL slaswp( n1, u, ldu, 1, m-1, iwork(n+1), -1 )
1031 ELSE IF ( rsvec .AND. ( .NOT. lsvec ) )
THEN
1044 $
CALL slaset(
'U', nr-1,nr-1, zero,zero, v(1,2), ldv )
1047 IF ( wntvr .OR. ( nr .EQ. n ) )
THEN
1048 CALL sgesvd(
'O',
'N', n, nr, v, ldv, s, u, ldu,
1049 $ u, ldu, work(n+1), lwork-n, info )
1052 DO 1122 q = p + 1, nr
1059 IF ( nr .LT. n )
THEN
1061 DO 1104 q = nr + 1, n
1066 CALL slapmt( .false., nr, n, v, ldv, iwork )
1073 CALL slaset(
'G', n, n-nr, zero, zero, v(1,nr+1), ldv)
1074 CALL sgesvd(
'O',
'N', n, n, v, ldv, s, u, ldu,
1075 $ u, ldu, work(n+1), lwork-n, info )
1078 DO 1124 q = p + 1, n
1084 CALL slapmt( .false., n, n, v, ldv, iwork )
1090 CALL slacpy(
'U', nr, n, a, lda, v, ldv )
1092 $
CALL slaset(
'L', nr-1, nr-1, zero, zero, v(2,1),
1096 IF ( wntvr .OR. ( nr .EQ. n ) )
THEN
1097 CALL sgesvd(
'N',
'O', nr, n, v, ldv, s, u, ldu,
1098 $ v, ldv, work(n+1), lwork-n, info )
1099 CALL slapmt( .false., nr, n, v, ldv, iwork )
1107 CALL slaset(
'G', n-nr, n, zero,zero, v(nr+1,1), ldv)
1108 CALL sgesvd(
'N',
'O', n, n, v, ldv, s, u, ldu,
1109 $ v, ldv, work(n+1), lwork-n, info )
1110 CALL slapmt( .false., n, n, v, ldv, iwork )
1124 IF ( wntvr .OR. ( nr .EQ. n ) )
THEN
1133 $
CALL slaset(
'U', nr-1,nr-1, zero,zero, v(1,2), ldv )
1137 CALL sgesvd(
'O',
'A', n, nr, v, ldv, s, v, ldv,
1138 $ u, ldu, work(n+1), lwork-n, info )
1141 DO 1116 q = p + 1, nr
1147 IF ( nr .LT. n )
THEN
1154 CALL slapmt( .false., nr, n, v, ldv, iwork )
1157 DO 1118 q = p + 1, nr
1164 IF ( ( nr .LT. m ) .AND. .NOT.(wntuf))
THEN
1165 CALL slaset(
'A', m-nr,nr, zero,zero, u(nr+1,1),
1167 IF ( nr .LT. n1 )
THEN
1168 CALL slaset(
'A',nr,n1-nr,zero,zero,u(1,nr+1),
1170 CALL slaset(
'A',m-nr,n1-nr,zero,one,
1171 $ u(nr+1,nr+1), ldu )
1185 IF ( optratio*nr .GT. n )
THEN
1192 $
CALL slaset(
'U',nr-1,nr-1, zero,zero, v(1,2),ldv)
1194 CALL slaset(
'A',n,n-nr,zero,zero,v(1,nr+1),ldv)
1195 CALL sgesvd(
'O',
'A', n, n, v, ldv, s, v, ldv,
1196 $ u, ldu, work(n+1), lwork-n, info )
1199 DO 1114 q = p + 1, n
1205 CALL slapmt( .false., n, n, v, ldv, iwork )
1210 DO 1112 q = p + 1, n
1217 IF ( ( n .LT. m ) .AND. .NOT.(wntuf))
THEN
1218 CALL slaset(
'A',m-n,n,zero,zero,u(n+1,1),ldu)
1219 IF ( n .LT. n1 )
THEN
1220 CALL slaset(
'A',n,n1-n,zero,zero,u(1,n+1),
1222 CALL slaset(
'A',m-n,n1-n,zero,one,
1235 $
CALL slaset(
'U',nr-1,nr-1,zero,zero,u(1,nr+2),ldu)
1236 CALL sgeqrf( n, nr, u(1,nr+1), ldu, work(n+1),
1237 $ work(n+nr+1), lwork-n-nr, ierr )
1243 CALL slaset(
'U',nr-1,nr-1,zero,zero,v(1,2),ldv)
1244 CALL sgesvd(
'S',
'O', nr, nr, v, ldv, s, u, ldu,
1245 $ v,ldv, work(n+nr+1),lwork-n-nr, info )
1246 CALL slaset(
'A',n-nr,nr,zero,zero,v(nr+1,1),ldv)
1247 CALL slaset(
'A',nr,n-nr,zero,zero,v(1,nr+1),ldv)
1248 CALL slaset(
'A',n-nr,n-nr,zero,one,v(nr+1,nr+1),
1250 CALL sormqr(
'R',
'C', n, n, nr, u(1,nr+1), ldu,
1251 $ work(n+1),v,ldv,work(n+nr+1),lwork-n-nr,ierr)
1252 CALL slapmt( .false., n, n, v, ldv, iwork )
1255 IF ( ( nr .LT. m ) .AND. .NOT.(wntuf))
THEN
1256 CALL slaset(
'A',m-nr,nr,zero,zero,u(nr+1,1),ldu)
1257 IF ( nr .LT. n1 )
THEN
1258 CALL slaset(
'A',nr,n1-nr,zero,zero,u(1,nr+1),
1260 CALL slaset(
'A',m-nr,n1-nr,zero,one,
1271 IF ( wntvr .OR. ( nr .EQ. n ) )
THEN
1273 CALL slacpy(
'U', nr, n, a, lda, v, ldv )
1275 $
CALL slaset(
'L', nr-1,nr-1, zero,zero, v(2,1), ldv )
1278 CALL sgesvd(
'S',
'O', nr, n, v, ldv, s, u, ldu,
1279 $ v, ldv, work(n+1), lwork-n, info )
1280 CALL slapmt( .false., nr, n, v, ldv, iwork )
1284 IF ( ( nr .LT. m ) .AND. .NOT.(wntuf))
THEN
1285 CALL slaset(
'A', m-nr,nr, zero,zero, u(nr+1,1),
1287 IF ( nr .LT. n1 )
THEN
1288 CALL slaset(
'A',nr,n1-nr,zero,zero,u(1,nr+1),
1290 CALL slaset(
'A',m-nr,n1-nr,zero,one,
1291 $ u(nr+1,nr+1), ldu )
1305 IF ( optratio * nr .GT. n )
THEN
1306 CALL slacpy(
'U', nr, n, a, lda, v, ldv )
1308 $
CALL slaset(
'L', nr-1,nr-1, zero,zero, v(2,1),ldv)
1311 CALL slaset(
'A', n-nr,n, zero,zero, v(nr+1,1),ldv)
1312 CALL sgesvd(
'S',
'O', n, n, v, ldv, s, u, ldu,
1313 $ v, ldv, work(n+1), lwork-n, info )
1314 CALL slapmt( .false., n, n, v, ldv, iwork )
1320 IF ( ( n .LT. m ) .AND. .NOT.(wntuf))
THEN
1321 CALL slaset(
'A',m-n,n,zero,zero,u(n+1,1),ldu)
1322 IF ( n .LT. n1 )
THEN
1323 CALL slaset(
'A',n,n1-n,zero,zero,u(1,n+1),
1325 CALL slaset(
'A',m-n,n1-n,zero,one,
1330 CALL slacpy(
'U', nr, n, a, lda, u(nr+1,1), ldu )
1332 $
CALL slaset(
'L',nr-1,nr-1,zero,zero,u(nr+2,1),ldu)
1333 CALL sgelqf( nr, n, u(nr+1,1), ldu, work(n+1),
1334 $ work(n+nr+1), lwork-n-nr, ierr )
1335 CALL slacpy(
'L',nr,nr,u(nr+1,1),ldu,v,ldv)
1337 $
CALL slaset(
'U',nr-1,nr-1,zero,zero,v(1,2),ldv)
1338 CALL sgesvd(
'S',
'O', nr, nr, v, ldv, s, u, ldu,
1339 $ v, ldv, work(n+nr+1), lwork-n-nr, info )
1340 CALL slaset(
'A',n-nr,nr,zero,zero,v(nr+1,1),ldv)
1341 CALL slaset(
'A',nr,n-nr,zero,zero,v(1,nr+1),ldv)
1342 CALL slaset(
'A',n-nr,n-nr,zero,one,v(nr+1,nr+1),
1344 CALL sormlq(
'R',
'N',n,n,nr,u(nr+1,1),ldu,work(n+1),
1345 $ v, ldv, work(n+nr+1),lwork-n-nr,ierr)
1346 CALL slapmt( .false., n, n, v, ldv, iwork )
1349 IF ( ( nr .LT. m ) .AND. .NOT.(wntuf))
THEN
1350 CALL slaset(
'A',m-nr,nr,zero,zero,u(nr+1,1),ldu)
1351 IF ( nr .LT. n1 )
THEN
1352 CALL slaset(
'A',nr,n1-nr,zero,zero,u(1,nr+1),
1354 CALL slaset(
'A',m-nr,n1-nr,zero,one,
1355 $ u(nr+1,nr+1), ldu )
1367 $
CALL sormqr(
'L',
'N', m, n1, n, a, lda, work, u,
1368 $ ldu, work(n+1), lwork-n, ierr )
1369 IF ( rowprm .AND. .NOT.wntuf )
1370 $
CALL slaswp( n1, u, ldu, 1, m-1, iwork(n+1), -1 )
1378 DO 4001 q = p, 1, -1
1379 IF ( s(q) .GT. zero )
GO TO 4002
1386 IF ( nr .LT. n )
CALL slaset(
'G', n-nr,1, zero,zero, s(nr+1),
1391 $
CALL slascl(
'G',0,0, one,sqrt(real(m)), nr,1, s, n, ierr )
1392 IF ( conda ) rwork(1) = sconda
1393 rwork(2) = real( p - nr )