217 SUBROUTINE dgesdd( JOBZ, M, N, A, LDA, S, U, LDU, VT, LDVT, WORK,
218 $ lwork, iwork, info )
227 INTEGER info, lda, ldu, ldvt, lwork, m, n
231 DOUBLE PRECISION a( lda, * ), s( * ), u( ldu, * ),
232 $ vt( ldvt, * ), work( * )
238 DOUBLE PRECISION zero, one
239 parameter( zero = 0.0d0, one = 1.0d0 )
242 LOGICAL lquery, wntqa, wntqas, wntqn, wntqo, wntqs
243 INTEGER bdspac, blk, chunk, i, ie, ierr, il,
244 $ ir, iscl, itau, itaup, itauq, iu, ivt, ldwkvt,
245 $ ldwrkl, ldwrkr, ldwrku, maxwrk, minmn, minwrk,
246 $ mnthr, nwork, wrkbl
247 DOUBLE PRECISION anrm, bignum, eps, smlnum
251 DOUBLE PRECISION dum( 1 )
265 INTRINSIC int, max, min, sqrt
273 wntqa =
lsame( jobz,
'A' )
274 wntqs =
lsame( jobz,
'S' )
275 wntqas = wntqa .OR. wntqs
276 wntqo =
lsame( jobz,
'O' )
277 wntqn =
lsame( jobz,
'N' )
278 lquery = ( lwork.EQ.-1 )
280 IF( .NOT.( wntqa .OR. wntqs .OR. wntqo .OR. wntqn ) )
THEN
282 ELSE IF( m.LT.0 )
THEN
284 ELSE IF( n.LT.0 )
THEN
286 ELSE IF( lda.LT.max( 1, m ) )
THEN
288 ELSE IF( ldu.LT.1 .OR. ( wntqas .AND. ldu.LT.m ) .OR.
289 $ ( wntqo .AND. m.LT.n .AND. ldu.LT.m ) )
THEN
291 ELSE IF( ldvt.LT.1 .OR. ( wntqa .AND. ldvt.LT.n ) .OR.
292 $ ( wntqs .AND. ldvt.LT.minmn ) .OR.
293 $ ( wntqo .AND. m.GE.n .AND. ldvt.LT.n ) )
THEN
307 IF( m.GE.n .AND. minmn.GT.0 )
THEN
311 mnthr = int( minmn*11.0d0 / 6.0d0 )
317 IF( m.GE.mnthr )
THEN
322 wrkbl = n + n*
ilaenv( 1,
'DGEQRF',
' ', m, n, -1,
324 wrkbl = max( wrkbl, 3*n+2*n*
325 $
ilaenv( 1,
'DGEBRD',
' ', n, n, -1, -1 ) )
326 maxwrk = max( wrkbl, bdspac+n )
328 ELSE IF( wntqo )
THEN
332 wrkbl = n + n*
ilaenv( 1,
'DGEQRF',
' ', m, n, -1, -1 )
333 wrkbl = max( wrkbl, n+n*
ilaenv( 1,
'DORGQR',
' ', m,
335 wrkbl = max( wrkbl, 3*n+2*n*
336 $
ilaenv( 1,
'DGEBRD',
' ', n, n, -1, -1 ) )
337 wrkbl = max( wrkbl, 3*n+n*
338 $
ilaenv( 1,
'DORMBR',
'QLN', n, n, n, -1 ) )
339 wrkbl = max( wrkbl, 3*n+n*
340 $
ilaenv( 1,
'DORMBR',
'PRT', n, n, n, -1 ) )
341 wrkbl = max( wrkbl, bdspac+3*n )
342 maxwrk = wrkbl + 2*n*n
343 minwrk = bdspac + 2*n*n + 3*n
344 ELSE IF( wntqs )
THEN
348 wrkbl = n + n*
ilaenv( 1,
'DGEQRF',
' ', m, n, -1, -1 )
349 wrkbl = max( wrkbl, n+n*
ilaenv( 1,
'DORGQR',
' ', m,
351 wrkbl = max( wrkbl, 3*n+2*n*
352 $
ilaenv( 1,
'DGEBRD',
' ', n, n, -1, -1 ) )
353 wrkbl = max( wrkbl, 3*n+n*
354 $
ilaenv( 1,
'DORMBR',
'QLN', n, n, n, -1 ) )
355 wrkbl = max( wrkbl, 3*n+n*
356 $
ilaenv( 1,
'DORMBR',
'PRT', n, n, n, -1 ) )
357 wrkbl = max( wrkbl, bdspac+3*n )
359 minwrk = bdspac + n*n + 3*n
360 ELSE IF( wntqa )
THEN
364 wrkbl = n + n*
ilaenv( 1,
'DGEQRF',
' ', m, n, -1, -1 )
365 wrkbl = max( wrkbl, n+m*
ilaenv( 1,
'DORGQR',
' ', m,
367 wrkbl = max( wrkbl, 3*n+2*n*
368 $
ilaenv( 1,
'DGEBRD',
' ', n, n, -1, -1 ) )
369 wrkbl = max( wrkbl, 3*n+n*
370 $
ilaenv( 1,
'DORMBR',
'QLN', n, n, n, -1 ) )
371 wrkbl = max( wrkbl, 3*n+n*
372 $
ilaenv( 1,
'DORMBR',
'PRT', n, n, n, -1 ) )
373 wrkbl = max( wrkbl, bdspac+3*n )
375 minwrk = bdspac + n*n + 2*n + m
381 wrkbl = 3*n + ( m+n )*
ilaenv( 1,
'DGEBRD',
' ', m, n, -1,
384 maxwrk = max( wrkbl, bdspac+3*n )
385 minwrk = 3*n + max( m, bdspac )
386 ELSE IF( wntqo )
THEN
387 wrkbl = max( wrkbl, 3*n+n*
388 $
ilaenv( 1,
'DORMBR',
'QLN', m, n, n, -1 ) )
389 wrkbl = max( wrkbl, 3*n+n*
390 $
ilaenv( 1,
'DORMBR',
'PRT', n, n, n, -1 ) )
391 wrkbl = max( wrkbl, bdspac+3*n )
393 minwrk = 3*n + max( m, n*n+bdspac )
394 ELSE IF( wntqs )
THEN
395 wrkbl = max( wrkbl, 3*n+n*
396 $
ilaenv( 1,
'DORMBR',
'QLN', m, n, n, -1 ) )
397 wrkbl = max( wrkbl, 3*n+n*
398 $
ilaenv( 1,
'DORMBR',
'PRT', n, n, n, -1 ) )
399 maxwrk = max( wrkbl, bdspac+3*n )
400 minwrk = 3*n + max( m, bdspac )
401 ELSE IF( wntqa )
THEN
402 wrkbl = max( wrkbl, 3*n+m*
403 $
ilaenv( 1,
'DORMBR',
'QLN', m, m, n, -1 ) )
404 wrkbl = max( wrkbl, 3*n+n*
405 $
ilaenv( 1,
'DORMBR',
'PRT', n, n, n, -1 ) )
406 maxwrk = max( maxwrk, bdspac+3*n )
407 minwrk = 3*n + max( m, bdspac )
410 ELSE IF( minmn.GT.0 )
THEN
414 mnthr = int( minmn*11.0d0 / 6.0d0 )
420 IF( n.GE.mnthr )
THEN
425 wrkbl = m + m*
ilaenv( 1,
'DGELQF',
' ', m, n, -1,
427 wrkbl = max( wrkbl, 3*m+2*m*
428 $
ilaenv( 1,
'DGEBRD',
' ', m, m, -1, -1 ) )
429 maxwrk = max( wrkbl, bdspac+m )
431 ELSE IF( wntqo )
THEN
435 wrkbl = m + m*
ilaenv( 1,
'DGELQF',
' ', m, n, -1, -1 )
436 wrkbl = max( wrkbl, m+m*
ilaenv( 1,
'DORGLQ',
' ', m,
438 wrkbl = max( wrkbl, 3*m+2*m*
439 $
ilaenv( 1,
'DGEBRD',
' ', m, m, -1, -1 ) )
440 wrkbl = max( wrkbl, 3*m+m*
441 $
ilaenv( 1,
'DORMBR',
'QLN', m, m, m, -1 ) )
442 wrkbl = max( wrkbl, 3*m+m*
443 $
ilaenv( 1,
'DORMBR',
'PRT', m, m, m, -1 ) )
444 wrkbl = max( wrkbl, bdspac+3*m )
445 maxwrk = wrkbl + 2*m*m
446 minwrk = bdspac + 2*m*m + 3*m
447 ELSE IF( wntqs )
THEN
451 wrkbl = m + m*
ilaenv( 1,
'DGELQF',
' ', m, n, -1, -1 )
452 wrkbl = max( wrkbl, m+m*
ilaenv( 1,
'DORGLQ',
' ', m,
454 wrkbl = max( wrkbl, 3*m+2*m*
455 $
ilaenv( 1,
'DGEBRD',
' ', m, m, -1, -1 ) )
456 wrkbl = max( wrkbl, 3*m+m*
457 $
ilaenv( 1,
'DORMBR',
'QLN', m, m, m, -1 ) )
458 wrkbl = max( wrkbl, 3*m+m*
459 $
ilaenv( 1,
'DORMBR',
'PRT', m, m, m, -1 ) )
460 wrkbl = max( wrkbl, bdspac+3*m )
462 minwrk = bdspac + m*m + 3*m
463 ELSE IF( wntqa )
THEN
467 wrkbl = m + m*
ilaenv( 1,
'DGELQF',
' ', m, n, -1, -1 )
468 wrkbl = max( wrkbl, m+n*
ilaenv( 1,
'DORGLQ',
' ', n,
470 wrkbl = max( wrkbl, 3*m+2*m*
471 $
ilaenv( 1,
'DGEBRD',
' ', m, m, -1, -1 ) )
472 wrkbl = max( wrkbl, 3*m+m*
473 $
ilaenv( 1,
'DORMBR',
'QLN', m, m, m, -1 ) )
474 wrkbl = max( wrkbl, 3*m+m*
475 $
ilaenv( 1,
'DORMBR',
'PRT', m, m, m, -1 ) )
476 wrkbl = max( wrkbl, bdspac+3*m )
478 minwrk = bdspac + m*m + 3*m
484 wrkbl = 3*m + ( m+n )*
ilaenv( 1,
'DGEBRD',
' ', m, n, -1,
487 maxwrk = max( wrkbl, bdspac+3*m )
488 minwrk = 3*m + max( n, bdspac )
489 ELSE IF( wntqo )
THEN
490 wrkbl = max( wrkbl, 3*m+m*
491 $
ilaenv( 1,
'DORMBR',
'QLN', m, m, n, -1 ) )
492 wrkbl = max( wrkbl, 3*m+m*
493 $
ilaenv( 1,
'DORMBR',
'PRT', m, n, m, -1 ) )
494 wrkbl = max( wrkbl, bdspac+3*m )
496 minwrk = 3*m + max( n, m*m+bdspac )
497 ELSE IF( wntqs )
THEN
498 wrkbl = max( wrkbl, 3*m+m*
499 $
ilaenv( 1,
'DORMBR',
'QLN', m, m, n, -1 ) )
500 wrkbl = max( wrkbl, 3*m+m*
501 $
ilaenv( 1,
'DORMBR',
'PRT', m, n, m, -1 ) )
502 maxwrk = max( wrkbl, bdspac+3*m )
503 minwrk = 3*m + max( n, bdspac )
504 ELSE IF( wntqa )
THEN
505 wrkbl = max( wrkbl, 3*m+m*
506 $
ilaenv( 1,
'DORMBR',
'QLN', m, m, n, -1 ) )
507 wrkbl = max( wrkbl, 3*m+m*
508 $
ilaenv( 1,
'DORMBR',
'PRT', n, n, m, -1 ) )
509 maxwrk = max( wrkbl, bdspac+3*m )
510 minwrk = 3*m + max( n, bdspac )
514 maxwrk = max( maxwrk, minwrk )
517 IF( lwork.LT.minwrk .AND. .NOT.lquery )
THEN
523 CALL
xerbla(
'DGESDD', -info )
525 ELSE IF( lquery )
THEN
531 IF( m.EQ.0 .OR. n.EQ.0 )
THEN
538 smlnum = sqrt(
dlamch(
'S' ) ) / eps
539 bignum = one / smlnum
543 anrm =
dlange(
'M', m, n, a, lda, dum )
545 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
547 CALL
dlascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, ierr )
548 ELSE IF( anrm.GT.bignum )
THEN
550 CALL
dlascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, ierr )
559 IF( m.GE.mnthr )
THEN
572 CALL
dgeqrf( m, n, a, lda, work( itau ), work( nwork ),
573 $ lwork-nwork+1, ierr )
577 CALL
dlaset(
'L', n-1, n-1, zero, zero, a( 2, 1 ), lda )
586 CALL
dgebrd( n, n, a, lda, s, work( ie ), work( itauq ),
587 $ work( itaup ), work( nwork ), lwork-nwork+1,
594 CALL
dbdsdc(
'U',
'N', n, s, work( ie ), dum, 1, dum, 1,
595 $ dum, idum, work( nwork ), iwork, info )
597 ELSE IF( wntqo )
THEN
607 IF( lwork.GE.lda*n+n*n+3*n+bdspac )
THEN
610 ldwrkr = ( lwork-n*n-3*n-bdspac ) / n
618 CALL
dgeqrf( m, n, a, lda, work( itau ), work( nwork ),
619 $ lwork-nwork+1, ierr )
623 CALL
dlacpy(
'U', n, n, a, lda, work( ir ), ldwrkr )
624 CALL
dlaset(
'L', n-1, n-1, zero, zero, work( ir+1 ),
630 CALL
dorgqr( m, n, n, a, lda, work( itau ),
631 $ work( nwork ), lwork-nwork+1, ierr )
640 CALL
dgebrd( n, n, work( ir ), ldwrkr, s, work( ie ),
641 $ work( itauq ), work( itaup ), work( nwork ),
642 $ lwork-nwork+1, ierr )
654 CALL
dbdsdc(
'U',
'I', n, s, work( ie ), work( iu ), n,
655 $ vt, ldvt, dum, idum, work( nwork ), iwork,
662 CALL
dormbr(
'Q',
'L',
'N', n, n, n, work( ir ), ldwrkr,
663 $ work( itauq ), work( iu ), n, work( nwork ),
664 $ lwork-nwork+1, ierr )
665 CALL
dormbr(
'P',
'R',
'T', n, n, n, work( ir ), ldwrkr,
666 $ work( itaup ), vt, ldvt, work( nwork ),
667 $ lwork-nwork+1, ierr )
673 DO 10 i = 1, m, ldwrkr
674 chunk = min( m-i+1, ldwrkr )
675 CALL
dgemm(
'N',
'N', chunk, n, n, one, a( i, 1 ),
676 $ lda, work( iu ), n, zero, work( ir ),
678 CALL
dlacpy(
'F', chunk, n, work( ir ), ldwrkr,
682 ELSE IF( wntqs )
THEN
699 CALL
dgeqrf( m, n, a, lda, work( itau ), work( nwork ),
700 $ lwork-nwork+1, ierr )
704 CALL
dlacpy(
'U', n, n, a, lda, work( ir ), ldwrkr )
705 CALL
dlaset(
'L', n-1, n-1, zero, zero, work( ir+1 ),
711 CALL
dorgqr( m, n, n, a, lda, work( itau ),
712 $ work( nwork ), lwork-nwork+1, ierr )
721 CALL
dgebrd( n, n, work( ir ), ldwrkr, s, work( ie ),
722 $ work( itauq ), work( itaup ), work( nwork ),
723 $ lwork-nwork+1, ierr )
730 CALL
dbdsdc(
'U',
'I', n, s, work( ie ), u, ldu, vt,
731 $ ldvt, dum, idum, work( nwork ), iwork,
738 CALL
dormbr(
'Q',
'L',
'N', n, n, n, work( ir ), ldwrkr,
739 $ work( itauq ), u, ldu, work( nwork ),
740 $ lwork-nwork+1, ierr )
742 CALL
dormbr(
'P',
'R',
'T', n, n, n, work( ir ), ldwrkr,
743 $ work( itaup ), vt, ldvt, work( nwork ),
744 $ lwork-nwork+1, ierr )
750 CALL
dlacpy(
'F', n, n, u, ldu, work( ir ), ldwrkr )
751 CALL
dgemm(
'N',
'N', m, n, n, one, a, lda, work( ir ),
752 $ ldwrkr, zero, u, ldu )
754 ELSE IF( wntqa )
THEN
771 CALL
dgeqrf( m, n, a, lda, work( itau ), work( nwork ),
772 $ lwork-nwork+1, ierr )
773 CALL
dlacpy(
'L', m, n, a, lda, u, ldu )
777 CALL
dorgqr( m, m, n, u, ldu, work( itau ),
778 $ work( nwork ), lwork-nwork+1, ierr )
782 CALL
dlaset(
'L', n-1, n-1, zero, zero, a( 2, 1 ), lda )
791 CALL
dgebrd( n, n, a, lda, s, work( ie ), work( itauq ),
792 $ work( itaup ), work( nwork ), lwork-nwork+1,
800 CALL
dbdsdc(
'U',
'I', n, s, work( ie ), work( iu ), n,
801 $ vt, ldvt, dum, idum, work( nwork ), iwork,
808 CALL
dormbr(
'Q',
'L',
'N', n, n, n, a, lda,
809 $ work( itauq ), work( iu ), ldwrku,
810 $ work( nwork ), lwork-nwork+1, ierr )
811 CALL
dormbr(
'P',
'R',
'T', n, n, n, a, lda,
812 $ work( itaup ), vt, ldvt, work( nwork ),
813 $ lwork-nwork+1, ierr )
819 CALL
dgemm(
'N',
'N', m, n, n, one, u, ldu, work( iu ),
820 $ ldwrku, zero, a, lda )
824 CALL
dlacpy(
'F', m, n, a, lda, u, ldu )
843 CALL
dgebrd( m, n, a, lda, s, work( ie ), work( itauq ),
844 $ work( itaup ), work( nwork ), lwork-nwork+1,
851 CALL
dbdsdc(
'U',
'N', n, s, work( ie ), dum, 1, dum, 1,
852 $ dum, idum, work( nwork ), iwork, info )
853 ELSE IF( wntqo )
THEN
855 IF( lwork.GE.m*n+3*n+bdspac )
THEN
860 nwork = iu + ldwrku*n
861 CALL
dlaset(
'F', m, n, zero, zero, work( iu ),
868 nwork = iu + ldwrku*n
873 ldwrkr = ( lwork-n*n-3*n ) / n
875 nwork = iu + ldwrku*n
882 CALL
dbdsdc(
'U',
'I', n, s, work( ie ), work( iu ),
883 $ ldwrku, vt, ldvt, dum, idum, work( nwork ),
889 CALL
dormbr(
'P',
'R',
'T', n, n, n, a, lda,
890 $ work( itaup ), vt, ldvt, work( nwork ),
891 $ lwork-nwork+1, ierr )
893 IF( lwork.GE.m*n+3*n+bdspac )
THEN
898 CALL
dormbr(
'Q',
'L',
'N', m, n, n, a, lda,
899 $ work( itauq ), work( iu ), ldwrku,
900 $ work( nwork ), lwork-nwork+1, ierr )
904 CALL
dlacpy(
'F', m, n, work( iu ), ldwrku, a, lda )
910 CALL
dorgbr(
'Q', m, n, n, a, lda, work( itauq ),
911 $ work( nwork ), lwork-nwork+1, ierr )
918 DO 20 i = 1, m, ldwrkr
919 chunk = min( m-i+1, ldwrkr )
920 CALL
dgemm(
'N',
'N', chunk, n, n, one, a( i, 1 ),
921 $ lda, work( iu ), ldwrku, zero,
922 $ work( ir ), ldwrkr )
923 CALL
dlacpy(
'F', chunk, n, work( ir ), ldwrkr,
928 ELSE IF( wntqs )
THEN
935 CALL
dlaset(
'F', m, n, zero, zero, u, ldu )
936 CALL
dbdsdc(
'U',
'I', n, s, work( ie ), u, ldu, vt,
937 $ ldvt, dum, idum, work( nwork ), iwork,
944 CALL
dormbr(
'Q',
'L',
'N', m, n, n, a, lda,
945 $ work( itauq ), u, ldu, work( nwork ),
946 $ lwork-nwork+1, ierr )
947 CALL
dormbr(
'P',
'R',
'T', n, n, n, a, lda,
948 $ work( itaup ), vt, ldvt, work( nwork ),
949 $ lwork-nwork+1, ierr )
950 ELSE IF( wntqa )
THEN
957 CALL
dlaset(
'F', m, m, zero, zero, u, ldu )
958 CALL
dbdsdc(
'U',
'I', n, s, work( ie ), u, ldu, vt,
959 $ ldvt, dum, idum, work( nwork ), iwork,
965 CALL
dlaset(
'F', m-n, m-n, zero, one, u( n+1, n+1 ),
973 CALL
dormbr(
'Q',
'L',
'N', m, m, n, a, lda,
974 $ work( itauq ), u, ldu, work( nwork ),
975 $ lwork-nwork+1, ierr )
976 CALL
dormbr(
'P',
'R',
'T', n, n, m, a, lda,
977 $ work( itaup ), vt, ldvt, work( nwork ),
978 $ lwork-nwork+1, ierr )
989 IF( n.GE.mnthr )
THEN
1002 CALL
dgelqf( m, n, a, lda, work( itau ), work( nwork ),
1003 $ lwork-nwork+1, ierr )
1007 CALL
dlaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ), lda )
1016 CALL
dgebrd( m, m, a, lda, s, work( ie ), work( itauq ),
1017 $ work( itaup ), work( nwork ), lwork-nwork+1,
1024 CALL
dbdsdc(
'U',
'N', m, s, work( ie ), dum, 1, dum, 1,
1025 $ dum, idum, work( nwork ), iwork, info )
1027 ELSE IF( wntqo )
THEN
1038 IF( lwork.GE.m*n+m*m+3*m+bdspac )
THEN
1046 chunk = ( lwork-m*m ) / m
1048 itau = il + ldwrkl*m
1054 CALL
dgelqf( m, n, a, lda, work( itau ), work( nwork ),
1055 $ lwork-nwork+1, ierr )
1059 CALL
dlacpy(
'L', m, m, a, lda, work( il ), ldwrkl )
1060 CALL
dlaset(
'U', m-1, m-1, zero, zero,
1061 $ work( il+ldwrkl ), ldwrkl )
1066 CALL
dorglq( m, n, m, a, lda, work( itau ),
1067 $ work( nwork ), lwork-nwork+1, ierr )
1076 CALL
dgebrd( m, m, work( il ), ldwrkl, s, work( ie ),
1077 $ work( itauq ), work( itaup ), work( nwork ),
1078 $ lwork-nwork+1, ierr )
1085 CALL
dbdsdc(
'U',
'I', m, s, work( ie ), u, ldu,
1086 $ work( ivt ), m, dum, idum, work( nwork ),
1093 CALL
dormbr(
'Q',
'L',
'N', m, m, m, work( il ), ldwrkl,
1094 $ work( itauq ), u, ldu, work( nwork ),
1095 $ lwork-nwork+1, ierr )
1096 CALL
dormbr(
'P',
'R',
'T', m, m, m, work( il ), ldwrkl,
1097 $ work( itaup ), work( ivt ), m,
1098 $ work( nwork ), lwork-nwork+1, ierr )
1104 DO 30 i = 1, n, chunk
1105 blk = min( n-i+1, chunk )
1106 CALL
dgemm(
'N',
'N', m, blk, m, one, work( ivt ), m,
1107 $ a( 1, i ), lda, zero, work( il ), ldwrkl )
1108 CALL
dlacpy(
'F', m, blk, work( il ), ldwrkl,
1112 ELSE IF( wntqs )
THEN
1123 itau = il + ldwrkl*m
1129 CALL
dgelqf( m, n, a, lda, work( itau ), work( nwork ),
1130 $ lwork-nwork+1, ierr )
1134 CALL
dlacpy(
'L', m, m, a, lda, work( il ), ldwrkl )
1135 CALL
dlaset(
'U', m-1, m-1, zero, zero,
1136 $ work( il+ldwrkl ), ldwrkl )
1141 CALL
dorglq( m, n, m, a, lda, work( itau ),
1142 $ work( nwork ), lwork-nwork+1, ierr )
1151 CALL
dgebrd( m, m, work( il ), ldwrkl, s, work( ie ),
1152 $ work( itauq ), work( itaup ), work( nwork ),
1153 $ lwork-nwork+1, ierr )
1160 CALL
dbdsdc(
'U',
'I', m, s, work( ie ), u, ldu, vt,
1161 $ ldvt, dum, idum, work( nwork ), iwork,
1168 CALL
dormbr(
'Q',
'L',
'N', m, m, m, work( il ), ldwrkl,
1169 $ work( itauq ), u, ldu, work( nwork ),
1170 $ lwork-nwork+1, ierr )
1171 CALL
dormbr(
'P',
'R',
'T', m, m, m, work( il ), ldwrkl,
1172 $ work( itaup ), vt, ldvt, work( nwork ),
1173 $ lwork-nwork+1, ierr )
1179 CALL
dlacpy(
'F', m, m, vt, ldvt, work( il ), ldwrkl )
1180 CALL
dgemm(
'N',
'N', m, n, m, one, work( il ), ldwrkl,
1181 $ a, lda, zero, vt, ldvt )
1183 ELSE IF( wntqa )
THEN
1194 itau = ivt + ldwkvt*m
1200 CALL
dgelqf( m, n, a, lda, work( itau ), work( nwork ),
1201 $ lwork-nwork+1, ierr )
1202 CALL
dlacpy(
'U', m, n, a, lda, vt, ldvt )
1207 CALL
dorglq( n, n, m, vt, ldvt, work( itau ),
1208 $ work( nwork ), lwork-nwork+1, ierr )
1212 CALL
dlaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ), lda )
1221 CALL
dgebrd( m, m, a, lda, s, work( ie ), work( itauq ),
1222 $ work( itaup ), work( nwork ), lwork-nwork+1,
1230 CALL
dbdsdc(
'U',
'I', m, s, work( ie ), u, ldu,
1231 $ work( ivt ), ldwkvt, dum, idum,
1232 $ work( nwork ), iwork, info )
1238 CALL
dormbr(
'Q',
'L',
'N', m, m, m, a, lda,
1239 $ work( itauq ), u, ldu, work( nwork ),
1240 $ lwork-nwork+1, ierr )
1241 CALL
dormbr(
'P',
'R',
'T', m, m, m, a, lda,
1242 $ work( itaup ), work( ivt ), ldwkvt,
1243 $ work( nwork ), lwork-nwork+1, ierr )
1249 CALL
dgemm(
'N',
'N', m, n, m, one, work( ivt ), ldwkvt,
1250 $ vt, ldvt, zero, a, lda )
1254 CALL
dlacpy(
'F', m, n, a, lda, vt, ldvt )
1273 CALL
dgebrd( m, n, a, lda, s, work( ie ), work( itauq ),
1274 $ work( itaup ), work( nwork ), lwork-nwork+1,
1281 CALL
dbdsdc(
'L',
'N', m, s, work( ie ), dum, 1, dum, 1,
1282 $ dum, idum, work( nwork ), iwork, info )
1283 ELSE IF( wntqo )
THEN
1286 IF( lwork.GE.m*n+3*m+bdspac )
THEN
1290 CALL
dlaset(
'F', m, n, zero, zero, work( ivt ),
1292 nwork = ivt + ldwkvt*n
1297 nwork = ivt + ldwkvt*m
1302 chunk = ( lwork-m*m-3*m ) / m
1310 CALL
dbdsdc(
'L',
'I', m, s, work( ie ), u, ldu,
1311 $ work( ivt ), ldwkvt, dum, idum,
1312 $ work( nwork ), iwork, info )
1317 CALL
dormbr(
'Q',
'L',
'N', m, m, n, a, lda,
1318 $ work( itauq ), u, ldu, work( nwork ),
1319 $ lwork-nwork+1, ierr )
1321 IF( lwork.GE.m*n+3*m+bdspac )
THEN
1326 CALL
dormbr(
'P',
'R',
'T', m, n, m, a, lda,
1327 $ work( itaup ), work( ivt ), ldwkvt,
1328 $ work( nwork ), lwork-nwork+1, ierr )
1332 CALL
dlacpy(
'F', m, n, work( ivt ), ldwkvt, a, lda )
1338 CALL
dorgbr(
'P', m, n, m, a, lda, work( itaup ),
1339 $ work( nwork ), lwork-nwork+1, ierr )
1346 DO 40 i = 1, n, chunk
1347 blk = min( n-i+1, chunk )
1348 CALL
dgemm(
'N',
'N', m, blk, m, one, work( ivt ),
1349 $ ldwkvt, a( 1, i ), lda, zero,
1351 CALL
dlacpy(
'F', m, blk, work( il ), m, a( 1, i ),
1355 ELSE IF( wntqs )
THEN
1362 CALL
dlaset(
'F', m, n, zero, zero, vt, ldvt )
1363 CALL
dbdsdc(
'L',
'I', m, s, work( ie ), u, ldu, vt,
1364 $ ldvt, dum, idum, work( nwork ), iwork,
1371 CALL
dormbr(
'Q',
'L',
'N', m, m, n, a, lda,
1372 $ work( itauq ), u, ldu, work( nwork ),
1373 $ lwork-nwork+1, ierr )
1374 CALL
dormbr(
'P',
'R',
'T', m, n, m, a, lda,
1375 $ work( itaup ), vt, ldvt, work( nwork ),
1376 $ lwork-nwork+1, ierr )
1377 ELSE IF( wntqa )
THEN
1384 CALL
dlaset(
'F', n, n, zero, zero, vt, ldvt )
1385 CALL
dbdsdc(
'L',
'I', m, s, work( ie ), u, ldu, vt,
1386 $ ldvt, dum, idum, work( nwork ), iwork,
1392 CALL
dlaset(
'F', n-m, n-m, zero, one, vt( m+1, m+1 ),
1400 CALL
dormbr(
'Q',
'L',
'N', m, m, n, a, lda,
1401 $ work( itauq ), u, ldu, work( nwork ),
1402 $ lwork-nwork+1, ierr )
1403 CALL
dormbr(
'P',
'R',
'T', n, n, m, a, lda,
1404 $ work( itaup ), vt, ldvt, work( nwork ),
1405 $ lwork-nwork+1, ierr )
1414 IF( iscl.EQ.1 )
THEN
1415 IF( anrm.GT.bignum )
1416 $ CALL
dlascl(
'G', 0, 0, bignum, anrm, minmn, 1, s, minmn,
1418 IF( anrm.LT.smlnum )
1419 $ CALL
dlascl(
'G', 0, 0, smlnum, anrm, minmn, 1, s, minmn,