209 SUBROUTINE dgesvd( JOBU, JOBVT, M, N, A, LDA, S, U, LDU,
210 $ VT, LDVT, WORK, LWORK, INFO )
217 CHARACTER JOBU, JOBVT
218 INTEGER INFO, LDA, LDU, LDVT, LWORK, M, N
221 DOUBLE PRECISION A( LDA, * ), S( * ), U( LDU, * ),
222 $ vt( ldvt, * ), work( * )
228 DOUBLE PRECISION ZERO, ONE
229 parameter( zero = 0.0d0, one = 1.0d0 )
232 LOGICAL LQUERY, WNTUA, WNTUAS, WNTUN, WNTUO, WNTUS,
233 $ wntva, wntvas, wntvn, wntvo, wntvs
234 INTEGER BDSPAC, BLK, CHUNK, I, IE, IERR, IR, ISCL,
235 $ itau, itaup, itauq, iu, iwork, ldwrkr, ldwrku,
236 $ maxwrk, minmn, minwrk, mnthr, ncu, ncvt, nru,
238 INTEGER LWORK_DGEQRF, LWORK_DORGQR_N, LWORK_DORGQR_M,
239 $ lwork_dgebrd, lwork_dorgbr_p, lwork_dorgbr_q,
240 $ lwork_dgelqf, lwork_dorglq_n, lwork_dorglq_m
241 DOUBLE PRECISION ANRM, BIGNUM, EPS, SMLNUM
244 DOUBLE PRECISION DUM( 1 )
254 DOUBLE PRECISION DLAMCH, DLANGE
255 EXTERNAL lsame, ilaenv, dlamch, dlange
258 INTRINSIC max, min, sqrt
266 wntua = lsame( jobu,
'A' )
267 wntus = lsame( jobu,
'S' )
268 wntuas = wntua .OR. wntus
269 wntuo = lsame( jobu,
'O' )
270 wntun = lsame( jobu,
'N' )
271 wntva = lsame( jobvt,
'A' )
272 wntvs = lsame( jobvt,
'S' )
273 wntvas = wntva .OR. wntvs
274 wntvo = lsame( jobvt,
'O' )
275 wntvn = lsame( jobvt,
'N' )
276 lquery = ( lwork.EQ.-1 )
278 IF( .NOT.( wntua .OR. wntus .OR. wntuo .OR. wntun ) )
THEN
280 ELSE IF( .NOT.( wntva .OR. wntvs .OR. wntvo .OR. wntvn ) .OR.
281 $ ( wntvo .AND. wntuo ) )
THEN
283 ELSE IF( m.LT.0 )
THEN
285 ELSE IF( n.LT.0 )
THEN
287 ELSE IF( lda.LT.max( 1, m ) )
THEN
289 ELSE IF( ldu.LT.1 .OR. ( wntuas .AND. ldu.LT.m ) )
THEN
291 ELSE IF( ldvt.LT.1 .OR. ( wntva .AND. ldvt.LT.n ) .OR.
292 $ ( wntvs .AND. ldvt.LT.minmn ) )
THEN
306 IF( m.GE.n .AND. minmn.GT.0 )
THEN
310 mnthr = ilaenv( 6,
'DGESVD', jobu // jobvt, m, n, 0, 0 )
313 CALL dgeqrf( m, n, a, lda, dum(1), dum(1), -1, ierr )
314 lwork_dgeqrf = int( dum(1) )
316 CALL dorgqr( m, n, n, a, lda, dum(1), dum(1), -1, ierr )
317 lwork_dorgqr_n = int( dum(1) )
318 CALL dorgqr( m, m, n, a, lda, dum(1), dum(1), -1, ierr )
319 lwork_dorgqr_m = int( dum(1) )
321 CALL dgebrd( n, n, a, lda, s, dum(1), dum(1),
322 $ dum(1), dum(1), -1, ierr )
323 lwork_dgebrd = int( dum(1) )
325 CALL dorgbr(
'P', n, n, n, a, lda, dum(1),
327 lwork_dorgbr_p = int( dum(1) )
329 CALL dorgbr(
'Q', n, n, n, a, lda, dum(1),
331 lwork_dorgbr_q = int( dum(1) )
333 IF( m.GE.mnthr )
THEN
338 maxwrk = n + lwork_dgeqrf
339 maxwrk = max( maxwrk, 3*n + lwork_dgebrd )
340 IF( wntvo .OR. wntvas )
341 $ maxwrk = max( maxwrk, 3*n + lwork_dorgbr_p )
342 maxwrk = max( maxwrk, bdspac )
343 minwrk = max( 4*n, bdspac )
344 ELSE IF( wntuo .AND. wntvn )
THEN
348 wrkbl = n + lwork_dgeqrf
349 wrkbl = max( wrkbl, n + lwork_dorgqr_n )
350 wrkbl = max( wrkbl, 3*n + lwork_dgebrd )
351 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_q )
352 wrkbl = max( wrkbl, bdspac )
353 maxwrk = max( n*n + wrkbl, n*n + m*n + n )
354 minwrk = max( 3*n + m, bdspac )
355 ELSE IF( wntuo .AND. wntvas )
THEN
360 wrkbl = n + lwork_dgeqrf
361 wrkbl = max( wrkbl, n + lwork_dorgqr_n )
362 wrkbl = max( wrkbl, 3*n + lwork_dgebrd )
363 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_q )
364 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_p )
365 wrkbl = max( wrkbl, bdspac )
366 maxwrk = max( n*n + wrkbl, n*n + m*n + n )
367 minwrk = max( 3*n + m, bdspac )
368 ELSE IF( wntus .AND. wntvn )
THEN
372 wrkbl = n + lwork_dgeqrf
373 wrkbl = max( wrkbl, n + lwork_dorgqr_n )
374 wrkbl = max( wrkbl, 3*n + lwork_dgebrd )
375 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_q )
376 wrkbl = max( wrkbl, bdspac )
378 minwrk = max( 3*n + m, bdspac )
379 ELSE IF( wntus .AND. wntvo )
THEN
383 wrkbl = n + lwork_dgeqrf
384 wrkbl = max( wrkbl, n + lwork_dorgqr_n )
385 wrkbl = max( wrkbl, 3*n + lwork_dgebrd )
386 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_q )
387 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_p )
388 wrkbl = max( wrkbl, bdspac )
389 maxwrk = 2*n*n + wrkbl
390 minwrk = max( 3*n + m, bdspac )
391 ELSE IF( wntus .AND. wntvas )
THEN
396 wrkbl = n + lwork_dgeqrf
397 wrkbl = max( wrkbl, n + lwork_dorgqr_n )
398 wrkbl = max( wrkbl, 3*n + lwork_dgebrd )
399 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_q )
400 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_p )
401 wrkbl = max( wrkbl, bdspac )
403 minwrk = max( 3*n + m, bdspac )
404 ELSE IF( wntua .AND. wntvn )
THEN
408 wrkbl = n + lwork_dgeqrf
409 wrkbl = max( wrkbl, n + lwork_dorgqr_m )
410 wrkbl = max( wrkbl, 3*n + lwork_dgebrd )
411 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_q )
412 wrkbl = max( wrkbl, bdspac )
414 minwrk = max( 3*n + m, bdspac )
415 ELSE IF( wntua .AND. wntvo )
THEN
419 wrkbl = n + lwork_dgeqrf
420 wrkbl = max( wrkbl, n + lwork_dorgqr_m )
421 wrkbl = max( wrkbl, 3*n + lwork_dgebrd )
422 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_q )
423 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_p )
424 wrkbl = max( wrkbl, bdspac )
425 maxwrk = 2*n*n + wrkbl
426 minwrk = max( 3*n + m, bdspac )
427 ELSE IF( wntua .AND. wntvas )
THEN
432 wrkbl = n + lwork_dgeqrf
433 wrkbl = max( wrkbl, n + lwork_dorgqr_m )
434 wrkbl = max( wrkbl, 3*n + lwork_dgebrd )
435 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_q )
436 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_p )
437 wrkbl = max( wrkbl, bdspac )
439 minwrk = max( 3*n + m, bdspac )
445 CALL dgebrd( m, n, a, lda, s, dum(1), dum(1),
446 $ dum(1), dum(1), -1, ierr )
447 lwork_dgebrd = int( dum(1) )
448 maxwrk = 3*n + lwork_dgebrd
449 IF( wntus .OR. wntuo )
THEN
450 CALL dorgbr(
'Q', m, n, n, a, lda, dum(1),
452 lwork_dorgbr_q = int( dum(1) )
453 maxwrk = max( maxwrk, 3*n + lwork_dorgbr_q )
456 CALL dorgbr(
'Q', m, m, n, a, lda, dum(1),
458 lwork_dorgbr_q = int( dum(1) )
459 maxwrk = max( maxwrk, 3*n + lwork_dorgbr_q )
461 IF( .NOT.wntvn )
THEN
462 maxwrk = max( maxwrk, 3*n + lwork_dorgbr_p )
464 maxwrk = max( maxwrk, bdspac )
465 minwrk = max( 3*n + m, bdspac )
467 ELSE IF( minmn.GT.0 )
THEN
471 mnthr = ilaenv( 6,
'DGESVD', jobu // jobvt, m, n, 0, 0 )
474 CALL dgelqf( m, n, a, lda, dum(1), dum(1), -1, ierr )
475 lwork_dgelqf = int( dum(1) )
477 CALL dorglq( n, n, m, dum(1), n, dum(1), dum(1), -1, ierr )
478 lwork_dorglq_n = int( dum(1) )
479 CALL dorglq( m, n, m, a, lda, dum(1), dum(1), -1, ierr )
480 lwork_dorglq_m = int( dum(1) )
482 CALL dgebrd( m, m, a, lda, s, dum(1), dum(1),
483 $ dum(1), dum(1), -1, ierr )
484 lwork_dgebrd = int( dum(1) )
486 CALL dorgbr(
'P', m, m, m, a, n, dum(1),
488 lwork_dorgbr_p = int( dum(1) )
490 CALL dorgbr(
'Q', m, m, m, a, n, dum(1),
492 lwork_dorgbr_q = int( dum(1) )
493 IF( n.GE.mnthr )
THEN
498 maxwrk = m + lwork_dgelqf
499 maxwrk = max( maxwrk, 3*m + lwork_dgebrd )
500 IF( wntuo .OR. wntuas )
501 $ maxwrk = max( maxwrk, 3*m + lwork_dorgbr_q )
502 maxwrk = max( maxwrk, bdspac )
503 minwrk = max( 4*m, bdspac )
504 ELSE IF( wntvo .AND. wntun )
THEN
508 wrkbl = m + lwork_dgelqf
509 wrkbl = max( wrkbl, m + lwork_dorglq_m )
510 wrkbl = max( wrkbl, 3*m + lwork_dgebrd )
511 wrkbl = max( wrkbl, 3*m + lwork_dorgbr_p )
512 wrkbl = max( wrkbl, bdspac )
513 maxwrk = max( m*m + wrkbl, m*m + m*n + m )
514 minwrk = max( 3*m + n, bdspac )
515 ELSE IF( wntvo .AND. wntuas )
THEN
520 wrkbl = m + lwork_dgelqf
521 wrkbl = max( wrkbl, m + lwork_dorglq_m )
522 wrkbl = max( wrkbl, 3*m + lwork_dgebrd )
523 wrkbl = max( wrkbl, 3*m + lwork_dorgbr_p )
524 wrkbl = max( wrkbl, 3*m + lwork_dorgbr_q )
525 wrkbl = max( wrkbl, bdspac )
526 maxwrk = max( m*m + wrkbl, m*m + m*n + m )
527 minwrk = max( 3*m + n, bdspac )
528 ELSE IF( wntvs .AND. wntun )
THEN
532 wrkbl = m + lwork_dgelqf
533 wrkbl = max( wrkbl, m + lwork_dorglq_m )
534 wrkbl = max( wrkbl, 3*m + lwork_dgebrd )
535 wrkbl = max( wrkbl, 3*m + lwork_dorgbr_p )
536 wrkbl = max( wrkbl, bdspac )
538 minwrk = max( 3*m + n, bdspac )
539 ELSE IF( wntvs .AND. wntuo )
THEN
543 wrkbl = m + lwork_dgelqf
544 wrkbl = max( wrkbl, m + lwork_dorglq_m )
545 wrkbl = max( wrkbl, 3*m + lwork_dgebrd )
546 wrkbl = max( wrkbl, 3*m + lwork_dorgbr_p )
547 wrkbl = max( wrkbl, 3*m + lwork_dorgbr_q )
548 wrkbl = max( wrkbl, bdspac )
549 maxwrk = 2*m*m + wrkbl
550 minwrk = max( 3*m + n, bdspac )
551 ELSE IF( wntvs .AND. wntuas )
THEN
556 wrkbl = m + lwork_dgelqf
557 wrkbl = max( wrkbl, m + lwork_dorglq_m )
558 wrkbl = max( wrkbl, 3*m + lwork_dgebrd )
559 wrkbl = max( wrkbl, 3*m + lwork_dorgbr_p )
560 wrkbl = max( wrkbl, 3*m + lwork_dorgbr_q )
561 wrkbl = max( wrkbl, bdspac )
563 minwrk = max( 3*m + n, bdspac )
564 ELSE IF( wntva .AND. wntun )
THEN
568 wrkbl = m + lwork_dgelqf
569 wrkbl = max( wrkbl, m + lwork_dorglq_n )
570 wrkbl = max( wrkbl, 3*m + lwork_dgebrd )
571 wrkbl = max( wrkbl, 3*m + lwork_dorgbr_p )
572 wrkbl = max( wrkbl, bdspac )
574 minwrk = max( 3*m + n, bdspac )
575 ELSE IF( wntva .AND. wntuo )
THEN
579 wrkbl = m + lwork_dgelqf
580 wrkbl = max( wrkbl, m + lwork_dorglq_n )
581 wrkbl = max( wrkbl, 3*m + lwork_dgebrd )
582 wrkbl = max( wrkbl, 3*m + lwork_dorgbr_p )
583 wrkbl = max( wrkbl, 3*m + lwork_dorgbr_q )
584 wrkbl = max( wrkbl, bdspac )
585 maxwrk = 2*m*m + wrkbl
586 minwrk = max( 3*m + n, bdspac )
587 ELSE IF( wntva .AND. wntuas )
THEN
592 wrkbl = m + lwork_dgelqf
593 wrkbl = max( wrkbl, m + lwork_dorglq_n )
594 wrkbl = max( wrkbl, 3*m + lwork_dgebrd )
595 wrkbl = max( wrkbl, 3*m + lwork_dorgbr_p )
596 wrkbl = max( wrkbl, 3*m + lwork_dorgbr_q )
597 wrkbl = max( wrkbl, bdspac )
599 minwrk = max( 3*m + n, bdspac )
605 CALL dgebrd( m, n, a, lda, s, dum(1), dum(1),
606 $ dum(1), dum(1), -1, ierr )
607 lwork_dgebrd = int( dum(1) )
608 maxwrk = 3*m + lwork_dgebrd
609 IF( wntvs .OR. wntvo )
THEN
611 CALL dorgbr(
'P', m, n, m, a, n, dum(1),
613 lwork_dorgbr_p = int( dum(1) )
614 maxwrk = max( maxwrk, 3*m + lwork_dorgbr_p )
617 CALL dorgbr(
'P', n, n, m, a, n, dum(1),
619 lwork_dorgbr_p = int( dum(1) )
620 maxwrk = max( maxwrk, 3*m + lwork_dorgbr_p )
622 IF( .NOT.wntun )
THEN
623 maxwrk = max( maxwrk, 3*m + lwork_dorgbr_q )
625 maxwrk = max( maxwrk, bdspac )
626 minwrk = max( 3*m + n, bdspac )
629 maxwrk = max( maxwrk, minwrk )
632 IF( lwork.LT.minwrk .AND. .NOT.lquery )
THEN
638 CALL xerbla(
'DGESVD', -info )
640 ELSE IF( lquery )
THEN
646 IF( m.EQ.0 .OR. n.EQ.0 )
THEN
653 smlnum = sqrt( dlamch(
'S' ) ) / eps
654 bignum = one / smlnum
658 anrm = dlange(
'M', m, n, a, lda, dum )
660 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
662 CALL dlascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, ierr )
663 ELSE IF( anrm.GT.bignum )
THEN
665 CALL dlascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, ierr )
674 IF( m.GE.mnthr )
THEN
687 CALL dgeqrf( m, n, a, lda, work( itau ), work( iwork ),
688 $ lwork-iwork+1, ierr )
693 CALL dlaset(
'L', n-1, n-1, zero, zero, a( 2, 1 ),
704 CALL dgebrd( n, n, a, lda, s, work( ie ), work( itauq ),
705 $ work( itaup ), work( iwork ), lwork-iwork+1,
708 IF( wntvo .OR. wntvas )
THEN
713 CALL dorgbr(
'P', n, n, n, a, lda, work( itaup ),
714 $ work( iwork ), lwork-iwork+1, ierr )
723 CALL dbdsqr(
'U', n, ncvt, 0, 0, s, work( ie ), a, lda,
724 $ dum, 1, dum, 1, work( iwork ), info )
729 $
CALL dlacpy(
'F', n, n, a, lda, vt, ldvt )
731 ELSE IF( wntuo .AND. wntvn )
THEN
737 IF( lwork.GE.n*n+max( 4*n, bdspac ) )
THEN
742 IF( lwork.GE.max( wrkbl, lda*n + n ) + lda*n )
THEN
748 ELSE IF( lwork.GE.max( wrkbl, lda*n + n ) + n*n )
THEN
758 ldwrku = ( lwork-n*n-n ) / n
767 CALL dgeqrf( m, n, a, lda, work( itau ),
768 $ work( iwork ), lwork-iwork+1, ierr )
772 CALL dlacpy(
'U', n, n, a, lda, work( ir ), ldwrkr )
773 CALL dlaset(
'L', n-1, n-1, zero, zero, work( ir+1 ),
779 CALL dorgqr( m, n, n, a, lda, work( itau ),
780 $ work( iwork ), lwork-iwork+1, ierr )
789 CALL dgebrd( n, n, work( ir ), ldwrkr, s, work( ie ),
790 $ work( itauq ), work( itaup ),
791 $ work( iwork ), lwork-iwork+1, ierr )
796 CALL dorgbr(
'Q', n, n, n, work( ir ), ldwrkr,
797 $ work( itauq ), work( iwork ),
798 $ lwork-iwork+1, ierr )
805 CALL dbdsqr(
'U', n, 0, n, 0, s, work( ie ), dum, 1,
806 $ work( ir ), ldwrkr, dum, 1,
807 $ work( iwork ), info )
814 DO 10 i = 1, m, ldwrku
815 chunk = min( m-i+1, ldwrku )
816 CALL dgemm(
'N',
'N', chunk, n, n, one, a( i, 1 ),
817 $ lda, work( ir ), ldwrkr, zero,
818 $ work( iu ), ldwrku )
819 CALL dlacpy(
'F', chunk, n, work( iu ), ldwrku,
835 CALL dgebrd( m, n, a, lda, s, work( ie ),
836 $ work( itauq ), work( itaup ),
837 $ work( iwork ), lwork-iwork+1, ierr )
842 CALL dorgbr(
'Q', m, n, n, a, lda, work( itauq ),
843 $ work( iwork ), lwork-iwork+1, ierr )
850 CALL dbdsqr(
'U', n, 0, m, 0, s, work( ie ), dum, 1,
851 $ a, lda, dum, 1, work( iwork ), info )
855 ELSE IF( wntuo .AND. wntvas )
THEN
861 IF( lwork.GE.n*n+max( 4*n, bdspac ) )
THEN
866 IF( lwork.GE.max( wrkbl, lda*n + n ) + lda*n )
THEN
872 ELSE IF( lwork.GE.max( wrkbl, lda*n + n ) + n*n )
THEN
882 ldwrku = ( lwork-n*n-n ) / n
891 CALL dgeqrf( m, n, a, lda, work( itau ),
892 $ work( iwork ), lwork-iwork+1, ierr )
896 CALL dlacpy(
'U', n, n, a, lda, vt, ldvt )
898 $
CALL dlaset(
'L', n-1, n-1, zero, zero,
904 CALL dorgqr( m, n, n, a, lda, work( itau ),
905 $ work( iwork ), lwork-iwork+1, ierr )
914 CALL dgebrd( n, n, vt, ldvt, s, work( ie ),
915 $ work( itauq ), work( itaup ),
916 $ work( iwork ), lwork-iwork+1, ierr )
917 CALL dlacpy(
'L', n, n, vt, ldvt, work( ir ), ldwrkr )
922 CALL dorgbr(
'Q', n, n, n, work( ir ), ldwrkr,
923 $ work( itauq ), work( iwork ),
924 $ lwork-iwork+1, ierr )
929 CALL dorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
930 $ work( iwork ), lwork-iwork+1, ierr )
938 CALL dbdsqr(
'U', n, n, n, 0, s, work( ie ), vt, ldvt,
939 $ work( ir ), ldwrkr, dum, 1,
940 $ work( iwork ), info )
947 DO 20 i = 1, m, ldwrku
948 chunk = min( m-i+1, ldwrku )
949 CALL dgemm(
'N',
'N', chunk, n, n, one, a( i, 1 ),
950 $ lda, work( ir ), ldwrkr, zero,
951 $ work( iu ), ldwrku )
952 CALL dlacpy(
'F', chunk, n, work( iu ), ldwrku,
966 CALL dgeqrf( m, n, a, lda, work( itau ),
967 $ work( iwork ), lwork-iwork+1, ierr )
971 CALL dlacpy(
'U', n, n, a, lda, vt, ldvt )
973 $
CALL dlaset(
'L', n-1, n-1, zero, zero,
979 CALL dorgqr( m, n, n, a, lda, work( itau ),
980 $ work( iwork ), lwork-iwork+1, ierr )
989 CALL dgebrd( n, n, vt, ldvt, s, work( ie ),
990 $ work( itauq ), work( itaup ),
991 $ work( iwork ), lwork-iwork+1, ierr )
996 CALL dormbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
997 $ work( itauq ), a, lda, work( iwork ),
998 $ lwork-iwork+1, ierr )
1003 CALL dorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1004 $ work( iwork ), lwork-iwork+1, ierr )
1012 CALL dbdsqr(
'U', n, n, m, 0, s, work( ie ), vt, ldvt,
1013 $ a, lda, dum, 1, work( iwork ), info )
1017 ELSE IF( wntus )
THEN
1025 IF( lwork.GE.n*n+max( 4*n, bdspac ) )
THEN
1030 IF( lwork.GE.wrkbl+lda*n )
THEN
1041 itau = ir + ldwrkr*n
1047 CALL dgeqrf( m, n, a, lda, work( itau ),
1048 $ work( iwork ), lwork-iwork+1, ierr )
1052 CALL dlacpy(
'U', n, n, a, lda, work( ir ),
1054 CALL dlaset(
'L', n-1, n-1, zero, zero,
1055 $ work( ir+1 ), ldwrkr )
1060 CALL dorgqr( m, n, n, a, lda, work( itau ),
1061 $ work( iwork ), lwork-iwork+1, ierr )
1070 CALL dgebrd( n, n, work( ir ), ldwrkr, s,
1071 $ work( ie ), work( itauq ),
1072 $ work( itaup ), work( iwork ),
1073 $ lwork-iwork+1, ierr )
1078 CALL dorgbr(
'Q', n, n, n, work( ir ), ldwrkr,
1079 $ work( itauq ), work( iwork ),
1080 $ lwork-iwork+1, ierr )
1087 CALL dbdsqr(
'U', n, 0, n, 0, s, work( ie ), dum,
1088 $ 1, work( ir ), ldwrkr, dum, 1,
1089 $ work( iwork ), info )
1095 CALL dgemm(
'N',
'N', m, n, n, one, a, lda,
1096 $ work( ir ), ldwrkr, zero, u, ldu )
1108 CALL dgeqrf( m, n, a, lda, work( itau ),
1109 $ work( iwork ), lwork-iwork+1, ierr )
1110 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1115 CALL dorgqr( m, n, n, u, ldu, work( itau ),
1116 $ work( iwork ), lwork-iwork+1, ierr )
1125 CALL dlaset(
'L', n-1, n-1, zero, zero,
1132 CALL dgebrd( n, n, a, lda, s, work( ie ),
1133 $ work( itauq ), work( itaup ),
1134 $ work( iwork ), lwork-iwork+1, ierr )
1139 CALL dormbr(
'Q',
'R',
'N', m, n, n, a, lda,
1140 $ work( itauq ), u, ldu, work( iwork ),
1141 $ lwork-iwork+1, ierr )
1148 CALL dbdsqr(
'U', n, 0, m, 0, s, work( ie ), dum,
1149 $ 1, u, ldu, dum, 1, work( iwork ),
1154 ELSE IF( wntvo )
THEN
1160 IF( lwork.GE.2*n*n+max( 4*n, bdspac ) )
THEN
1165 IF( lwork.GE.wrkbl+2*lda*n )
THEN
1172 ELSE IF( lwork.GE.wrkbl+( lda + n )*n )
THEN
1187 itau = ir + ldwrkr*n
1193 CALL dgeqrf( m, n, a, lda, work( itau ),
1194 $ work( iwork ), lwork-iwork+1, ierr )
1198 CALL dlacpy(
'U', n, n, a, lda, work( iu ),
1200 CALL dlaset(
'L', n-1, n-1, zero, zero,
1201 $ work( iu+1 ), ldwrku )
1206 CALL dorgqr( m, n, n, a, lda, work( itau ),
1207 $ work( iwork ), lwork-iwork+1, ierr )
1218 CALL dgebrd( n, n, work( iu ), ldwrku, s,
1219 $ work( ie ), work( itauq ),
1220 $ work( itaup ), work( iwork ),
1221 $ lwork-iwork+1, ierr )
1222 CALL dlacpy(
'U', n, n, work( iu ), ldwrku,
1223 $ work( ir ), ldwrkr )
1228 CALL dorgbr(
'Q', n, n, n, work( iu ), ldwrku,
1229 $ work( itauq ), work( iwork ),
1230 $ lwork-iwork+1, ierr )
1236 CALL dorgbr(
'P', n, n, n, work( ir ), ldwrkr,
1237 $ work( itaup ), work( iwork ),
1238 $ lwork-iwork+1, ierr )
1246 CALL dbdsqr(
'U', n, n, n, 0, s, work( ie ),
1247 $ work( ir ), ldwrkr, work( iu ),
1248 $ ldwrku, dum, 1, work( iwork ), info )
1254 CALL dgemm(
'N',
'N', m, n, n, one, a, lda,
1255 $ work( iu ), ldwrku, zero, u, ldu )
1260 CALL dlacpy(
'F', n, n, work( ir ), ldwrkr, a,
1273 CALL dgeqrf( m, n, a, lda, work( itau ),
1274 $ work( iwork ), lwork-iwork+1, ierr )
1275 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1280 CALL dorgqr( m, n, n, u, ldu, work( itau ),
1281 $ work( iwork ), lwork-iwork+1, ierr )
1290 CALL dlaset(
'L', n-1, n-1, zero, zero,
1297 CALL dgebrd( n, n, a, lda, s, work( ie ),
1298 $ work( itauq ), work( itaup ),
1299 $ work( iwork ), lwork-iwork+1, ierr )
1304 CALL dormbr(
'Q',
'R',
'N', m, n, n, a, lda,
1305 $ work( itauq ), u, ldu, work( iwork ),
1306 $ lwork-iwork+1, ierr )
1311 CALL dorgbr(
'P', n, n, n, a, lda, work( itaup ),
1312 $ work( iwork ), lwork-iwork+1, ierr )
1320 CALL dbdsqr(
'U', n, n, m, 0, s, work( ie ), a,
1321 $ lda, u, ldu, dum, 1, work( iwork ),
1326 ELSE IF( wntvas )
THEN
1333 IF( lwork.GE.n*n+max( 4*n, bdspac ) )
THEN
1338 IF( lwork.GE.wrkbl+lda*n )
THEN
1349 itau = iu + ldwrku*n
1355 CALL dgeqrf( m, n, a, lda, work( itau ),
1356 $ work( iwork ), lwork-iwork+1, ierr )
1360 CALL dlacpy(
'U', n, n, a, lda, work( iu ),
1362 CALL dlaset(
'L', n-1, n-1, zero, zero,
1363 $ work( iu+1 ), ldwrku )
1368 CALL dorgqr( m, n, n, a, lda, work( itau ),
1369 $ work( iwork ), lwork-iwork+1, ierr )
1378 CALL dgebrd( n, n, work( iu ), ldwrku, s,
1379 $ work( ie ), work( itauq ),
1380 $ work( itaup ), work( iwork ),
1381 $ lwork-iwork+1, ierr )
1382 CALL dlacpy(
'U', n, n, work( iu ), ldwrku, vt,
1388 CALL dorgbr(
'Q', n, n, n, work( iu ), ldwrku,
1389 $ work( itauq ), work( iwork ),
1390 $ lwork-iwork+1, ierr )
1396 CALL dorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1397 $ work( iwork ), lwork-iwork+1, ierr )
1405 CALL dbdsqr(
'U', n, n, n, 0, s, work( ie ), vt,
1406 $ ldvt, work( iu ), ldwrku, dum, 1,
1407 $ work( iwork ), info )
1413 CALL dgemm(
'N',
'N', m, n, n, one, a, lda,
1414 $ work( iu ), ldwrku, zero, u, ldu )
1426 CALL dgeqrf( m, n, a, lda, work( itau ),
1427 $ work( iwork ), lwork-iwork+1, ierr )
1428 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1433 CALL dorgqr( m, n, n, u, ldu, work( itau ),
1434 $ work( iwork ), lwork-iwork+1, ierr )
1438 CALL dlacpy(
'U', n, n, a, lda, vt, ldvt )
1440 $
CALL dlaset(
'L', n-1, n-1, zero, zero,
1441 $ vt( 2, 1 ), ldvt )
1450 CALL dgebrd( n, n, vt, ldvt, s, work( ie ),
1451 $ work( itauq ), work( itaup ),
1452 $ work( iwork ), lwork-iwork+1, ierr )
1458 CALL dormbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1459 $ work( itauq ), u, ldu, work( iwork ),
1460 $ lwork-iwork+1, ierr )
1465 CALL dorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1466 $ work( iwork ), lwork-iwork+1, ierr )
1474 CALL dbdsqr(
'U', n, n, m, 0, s, work( ie ), vt,
1475 $ ldvt, u, ldu, dum, 1, work( iwork ),
1482 ELSE IF( wntua )
THEN
1490 IF( lwork.GE.n*n+max( n+m, 4*n, bdspac ) )
THEN
1495 IF( lwork.GE.wrkbl+lda*n )
THEN
1506 itau = ir + ldwrkr*n
1512 CALL dgeqrf( m, n, a, lda, work( itau ),
1513 $ work( iwork ), lwork-iwork+1, ierr )
1514 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1518 CALL dlacpy(
'U', n, n, a, lda, work( ir ),
1520 CALL dlaset(
'L', n-1, n-1, zero, zero,
1521 $ work( ir+1 ), ldwrkr )
1526 CALL dorgqr( m, m, n, u, ldu, work( itau ),
1527 $ work( iwork ), lwork-iwork+1, ierr )
1536 CALL dgebrd( n, n, work( ir ), ldwrkr, s,
1537 $ work( ie ), work( itauq ),
1538 $ work( itaup ), work( iwork ),
1539 $ lwork-iwork+1, ierr )
1544 CALL dorgbr(
'Q', n, n, n, work( ir ), ldwrkr,
1545 $ work( itauq ), work( iwork ),
1546 $ lwork-iwork+1, ierr )
1553 CALL dbdsqr(
'U', n, 0, n, 0, s, work( ie ), dum,
1554 $ 1, work( ir ), ldwrkr, dum, 1,
1555 $ work( iwork ), info )
1561 CALL dgemm(
'N',
'N', m, n, n, one, u, ldu,
1562 $ work( ir ), ldwrkr, zero, a, lda )
1566 CALL dlacpy(
'F', m, n, a, lda, u, ldu )
1578 CALL dgeqrf( m, n, a, lda, work( itau ),
1579 $ work( iwork ), lwork-iwork+1, ierr )
1580 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1585 CALL dorgqr( m, m, n, u, ldu, work( itau ),
1586 $ work( iwork ), lwork-iwork+1, ierr )
1595 CALL dlaset(
'L', n-1, n-1, zero, zero,
1602 CALL dgebrd( n, n, a, lda, s, work( ie ),
1603 $ work( itauq ), work( itaup ),
1604 $ work( iwork ), lwork-iwork+1, ierr )
1610 CALL dormbr(
'Q',
'R',
'N', m, n, n, a, lda,
1611 $ work( itauq ), u, ldu, work( iwork ),
1612 $ lwork-iwork+1, ierr )
1619 CALL dbdsqr(
'U', n, 0, m, 0, s, work( ie ), dum,
1620 $ 1, u, ldu, dum, 1, work( iwork ),
1625 ELSE IF( wntvo )
THEN
1631 IF( lwork.GE.2*n*n+max( n+m, 4*n, bdspac ) )
THEN
1636 IF( lwork.GE.wrkbl+2*lda*n )
THEN
1643 ELSE IF( lwork.GE.wrkbl+( lda + n )*n )
THEN
1658 itau = ir + ldwrkr*n
1664 CALL dgeqrf( m, n, a, lda, work( itau ),
1665 $ work( iwork ), lwork-iwork+1, ierr )
1666 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1671 CALL dorgqr( m, m, n, u, ldu, work( itau ),
1672 $ work( iwork ), lwork-iwork+1, ierr )
1676 CALL dlacpy(
'U', n, n, a, lda, work( iu ),
1678 CALL dlaset(
'L', n-1, n-1, zero, zero,
1679 $ work( iu+1 ), ldwrku )
1690 CALL dgebrd( n, n, work( iu ), ldwrku, s,
1691 $ work( ie ), work( itauq ),
1692 $ work( itaup ), work( iwork ),
1693 $ lwork-iwork+1, ierr )
1694 CALL dlacpy(
'U', n, n, work( iu ), ldwrku,
1695 $ work( ir ), ldwrkr )
1700 CALL dorgbr(
'Q', n, n, n, work( iu ), ldwrku,
1701 $ work( itauq ), work( iwork ),
1702 $ lwork-iwork+1, ierr )
1708 CALL dorgbr(
'P', n, n, n, work( ir ), ldwrkr,
1709 $ work( itaup ), work( iwork ),
1710 $ lwork-iwork+1, ierr )
1718 CALL dbdsqr(
'U', n, n, n, 0, s, work( ie ),
1719 $ work( ir ), ldwrkr, work( iu ),
1720 $ ldwrku, dum, 1, work( iwork ), info )
1726 CALL dgemm(
'N',
'N', m, n, n, one, u, ldu,
1727 $ work( iu ), ldwrku, zero, a, lda )
1731 CALL dlacpy(
'F', m, n, a, lda, u, ldu )
1735 CALL dlacpy(
'F', n, n, work( ir ), ldwrkr, a,
1748 CALL dgeqrf( m, n, a, lda, work( itau ),
1749 $ work( iwork ), lwork-iwork+1, ierr )
1750 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1755 CALL dorgqr( m, m, n, u, ldu, work( itau ),
1756 $ work( iwork ), lwork-iwork+1, ierr )
1765 CALL dlaset(
'L', n-1, n-1, zero, zero,
1772 CALL dgebrd( n, n, a, lda, s, work( ie ),
1773 $ work( itauq ), work( itaup ),
1774 $ work( iwork ), lwork-iwork+1, ierr )
1780 CALL dormbr(
'Q',
'R',
'N', m, n, n, a, lda,
1781 $ work( itauq ), u, ldu, work( iwork ),
1782 $ lwork-iwork+1, ierr )
1787 CALL dorgbr(
'P', n, n, n, a, lda, work( itaup ),
1788 $ work( iwork ), lwork-iwork+1, ierr )
1796 CALL dbdsqr(
'U', n, n, m, 0, s, work( ie ), a,
1797 $ lda, u, ldu, dum, 1, work( iwork ),
1802 ELSE IF( wntvas )
THEN
1809 IF( lwork.GE.n*n+max( n+m, 4*n, bdspac ) )
THEN
1814 IF( lwork.GE.wrkbl+lda*n )
THEN
1825 itau = iu + ldwrku*n
1831 CALL dgeqrf( m, n, a, lda, work( itau ),
1832 $ work( iwork ), lwork-iwork+1, ierr )
1833 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1838 CALL dorgqr( m, m, n, u, ldu, work( itau ),
1839 $ work( iwork ), lwork-iwork+1, ierr )
1843 CALL dlacpy(
'U', n, n, a, lda, work( iu ),
1845 CALL dlaset(
'L', n-1, n-1, zero, zero,
1846 $ work( iu+1 ), ldwrku )
1855 CALL dgebrd( n, n, work( iu ), ldwrku, s,
1856 $ work( ie ), work( itauq ),
1857 $ work( itaup ), work( iwork ),
1858 $ lwork-iwork+1, ierr )
1859 CALL dlacpy(
'U', n, n, work( iu ), ldwrku, vt,
1865 CALL dorgbr(
'Q', n, n, n, work( iu ), ldwrku,
1866 $ work( itauq ), work( iwork ),
1867 $ lwork-iwork+1, ierr )
1873 CALL dorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1874 $ work( iwork ), lwork-iwork+1, ierr )
1882 CALL dbdsqr(
'U', n, n, n, 0, s, work( ie ), vt,
1883 $ ldvt, work( iu ), ldwrku, dum, 1,
1884 $ work( iwork ), info )
1890 CALL dgemm(
'N',
'N', m, n, n, one, u, ldu,
1891 $ work( iu ), ldwrku, zero, a, lda )
1895 CALL dlacpy(
'F', m, n, a, lda, u, ldu )
1907 CALL dgeqrf( m, n, a, lda, work( itau ),
1908 $ work( iwork ), lwork-iwork+1, ierr )
1909 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1914 CALL dorgqr( m, m, n, u, ldu, work( itau ),
1915 $ work( iwork ), lwork-iwork+1, ierr )
1919 CALL dlacpy(
'U', n, n, a, lda, vt, ldvt )
1921 $
CALL dlaset(
'L', n-1, n-1, zero, zero,
1922 $ vt( 2, 1 ), ldvt )
1931 CALL dgebrd( n, n, vt, ldvt, s, work( ie ),
1932 $ work( itauq ), work( itaup ),
1933 $ work( iwork ), lwork-iwork+1, ierr )
1939 CALL dormbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1940 $ work( itauq ), u, ldu, work( iwork ),
1941 $ lwork-iwork+1, ierr )
1946 CALL dorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1947 $ work( iwork ), lwork-iwork+1, ierr )
1955 CALL dbdsqr(
'U', n, n, m, 0, s, work( ie ), vt,
1956 $ ldvt, u, ldu, dum, 1, work( iwork ),
1980 CALL dgebrd( m, n, a, lda, s, work( ie ), work( itauq ),
1981 $ work( itaup ), work( iwork ), lwork-iwork+1,
1989 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1994 CALL dorgbr(
'Q', m, ncu, n, u, ldu, work( itauq ),
1995 $ work( iwork ), lwork-iwork+1, ierr )
2003 CALL dlacpy(
'U', n, n, a, lda, vt, ldvt )
2004 CALL dorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
2005 $ work( iwork ), lwork-iwork+1, ierr )
2013 CALL dorgbr(
'Q', m, n, n, a, lda, work( itauq ),
2014 $ work( iwork ), lwork-iwork+1, ierr )
2022 CALL dorgbr(
'P', n, n, n, a, lda, work( itaup ),
2023 $ work( iwork ), lwork-iwork+1, ierr )
2026 IF( wntuas .OR. wntuo )
2030 IF( wntvas .OR. wntvo )
2034 IF( ( .NOT.wntuo ) .AND. ( .NOT.wntvo ) )
THEN
2041 CALL dbdsqr(
'U', n, ncvt, nru, 0, s, work( ie ), vt,
2042 $ ldvt, u, ldu, dum, 1, work( iwork ), info )
2043 ELSE IF( ( .NOT.wntuo ) .AND. wntvo )
THEN
2050 CALL dbdsqr(
'U', n, ncvt, nru, 0, s, work( ie ), a, lda,
2051 $ u, ldu, dum, 1, work( iwork ), info )
2059 CALL dbdsqr(
'U', n, ncvt, nru, 0, s, work( ie ), vt,
2060 $ ldvt, a, lda, dum, 1, work( iwork ), info )
2071 IF( n.GE.mnthr )
THEN
2084 CALL dgelqf( m, n, a, lda, work( itau ), work( iwork ),
2085 $ lwork-iwork+1, ierr )
2089 CALL dlaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ), lda )
2098 CALL dgebrd( m, m, a, lda, s, work( ie ), work( itauq ),
2099 $ work( itaup ), work( iwork ), lwork-iwork+1,
2101 IF( wntuo .OR. wntuas )
THEN
2106 CALL dorgbr(
'Q', m, m, m, a, lda, work( itauq ),
2107 $ work( iwork ), lwork-iwork+1, ierr )
2111 IF( wntuo .OR. wntuas )
2118 CALL dbdsqr(
'U', m, 0, nru, 0, s, work( ie ), dum, 1, a,
2119 $ lda, dum, 1, work( iwork ), info )
2124 $
CALL dlacpy(
'F', m, m, a, lda, u, ldu )
2126 ELSE IF( wntvo .AND. wntun )
THEN
2132 IF( lwork.GE.m*m+max( 4*m, bdspac ) )
THEN
2137 IF( lwork.GE.max( wrkbl, lda*n + m ) + lda*m )
THEN
2144 ELSE IF( lwork.GE.max( wrkbl, lda*n + m ) + m*m )
THEN
2156 chunk = ( lwork-m*m-m ) / m
2159 itau = ir + ldwrkr*m
2165 CALL dgelqf( m, n, a, lda, work( itau ),
2166 $ work( iwork ), lwork-iwork+1, ierr )
2170 CALL dlacpy(
'L', m, m, a, lda, work( ir ), ldwrkr )
2171 CALL dlaset(
'U', m-1, m-1, zero, zero,
2172 $ work( ir+ldwrkr ), ldwrkr )
2177 CALL dorglq( m, n, m, a, lda, work( itau ),
2178 $ work( iwork ), lwork-iwork+1, ierr )
2187 CALL dgebrd( m, m, work( ir ), ldwrkr, s, work( ie ),
2188 $ work( itauq ), work( itaup ),
2189 $ work( iwork ), lwork-iwork+1, ierr )
2194 CALL dorgbr(
'P', m, m, m, work( ir ), ldwrkr,
2195 $ work( itaup ), work( iwork ),
2196 $ lwork-iwork+1, ierr )
2203 CALL dbdsqr(
'U', m, m, 0, 0, s, work( ie ),
2204 $ work( ir ), ldwrkr, dum, 1, dum, 1,
2205 $ work( iwork ), info )
2212 DO 30 i = 1, n, chunk
2213 blk = min( n-i+1, chunk )
2214 CALL dgemm(
'N',
'N', m, blk, m, one, work( ir ),
2215 $ ldwrkr, a( 1, i ), lda, zero,
2216 $ work( iu ), ldwrku )
2217 CALL dlacpy(
'F', m, blk, work( iu ), ldwrku,
2233 CALL dgebrd( m, n, a, lda, s, work( ie ),
2234 $ work( itauq ), work( itaup ),
2235 $ work( iwork ), lwork-iwork+1, ierr )
2240 CALL dorgbr(
'P', m, n, m, a, lda, work( itaup ),
2241 $ work( iwork ), lwork-iwork+1, ierr )
2248 CALL dbdsqr(
'L', m, n, 0, 0, s, work( ie ), a, lda,
2249 $ dum, 1, dum, 1, work( iwork ), info )
2253 ELSE IF( wntvo .AND. wntuas )
THEN
2259 IF( lwork.GE.m*m+max( 4*m, bdspac ) )
THEN
2264 IF( lwork.GE.max( wrkbl, lda*n + m ) + lda*m )
THEN
2271 ELSE IF( lwork.GE.max( wrkbl, lda*n + m ) + m*m )
THEN
2283 chunk = ( lwork-m*m-m ) / m
2286 itau = ir + ldwrkr*m
2292 CALL dgelqf( m, n, a, lda, work( itau ),
2293 $ work( iwork ), lwork-iwork+1, ierr )
2297 CALL dlacpy(
'L', m, m, a, lda, u, ldu )
2298 CALL dlaset(
'U', m-1, m-1, zero, zero, u( 1, 2 ),
2304 CALL dorglq( m, n, m, a, lda, work( itau ),
2305 $ work( iwork ), lwork-iwork+1, ierr )
2314 CALL dgebrd( m, m, u, ldu, s, work( ie ),
2315 $ work( itauq ), work( itaup ),
2316 $ work( iwork ), lwork-iwork+1, ierr )
2317 CALL dlacpy(
'U', m, m, u, ldu, work( ir ), ldwrkr )
2322 CALL dorgbr(
'P', m, m, m, work( ir ), ldwrkr,
2323 $ work( itaup ), work( iwork ),
2324 $ lwork-iwork+1, ierr )
2329 CALL dorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
2330 $ work( iwork ), lwork-iwork+1, ierr )
2338 CALL dbdsqr(
'U', m, m, m, 0, s, work( ie ),
2339 $ work( ir ), ldwrkr, u, ldu, dum, 1,
2340 $ work( iwork ), info )
2347 DO 40 i = 1, n, chunk
2348 blk = min( n-i+1, chunk )
2349 CALL dgemm(
'N',
'N', m, blk, m, one, work( ir ),
2350 $ ldwrkr, a( 1, i ), lda, zero,
2351 $ work( iu ), ldwrku )
2352 CALL dlacpy(
'F', m, blk, work( iu ), ldwrku,
2366 CALL dgelqf( m, n, a, lda, work( itau ),
2367 $ work( iwork ), lwork-iwork+1, ierr )
2371 CALL dlacpy(
'L', m, m, a, lda, u, ldu )
2372 CALL dlaset(
'U', m-1, m-1, zero, zero, u( 1, 2 ),
2378 CALL dorglq( m, n, m, a, lda, work( itau ),
2379 $ work( iwork ), lwork-iwork+1, ierr )
2388 CALL dgebrd( m, m, u, ldu, s, work( ie ),
2389 $ work( itauq ), work( itaup ),
2390 $ work( iwork ), lwork-iwork+1, ierr )
2395 CALL dormbr(
'P',
'L',
'T', m, n, m, u, ldu,
2396 $ work( itaup ), a, lda, work( iwork ),
2397 $ lwork-iwork+1, ierr )
2402 CALL dorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
2403 $ work( iwork ), lwork-iwork+1, ierr )
2411 CALL dbdsqr(
'U', m, n, m, 0, s, work( ie ), a, lda,
2412 $ u, ldu, dum, 1, work( iwork ), info )
2416 ELSE IF( wntvs )
THEN
2424 IF( lwork.GE.m*m+max( 4*m, bdspac ) )
THEN
2429 IF( lwork.GE.wrkbl+lda*m )
THEN
2440 itau = ir + ldwrkr*m
2446 CALL dgelqf( m, n, a, lda, work( itau ),
2447 $ work( iwork ), lwork-iwork+1, ierr )
2451 CALL dlacpy(
'L', m, m, a, lda, work( ir ),
2453 CALL dlaset(
'U', m-1, m-1, zero, zero,
2454 $ work( ir+ldwrkr ), ldwrkr )
2459 CALL dorglq( m, n, m, a, lda, work( itau ),
2460 $ work( iwork ), lwork-iwork+1, ierr )
2469 CALL dgebrd( m, m, work( ir ), ldwrkr, s,
2470 $ work( ie ), work( itauq ),
2471 $ work( itaup ), work( iwork ),
2472 $ lwork-iwork+1, ierr )
2478 CALL dorgbr(
'P', m, m, m, work( ir ), ldwrkr,
2479 $ work( itaup ), work( iwork ),
2480 $ lwork-iwork+1, ierr )
2487 CALL dbdsqr(
'U', m, m, 0, 0, s, work( ie ),
2488 $ work( ir ), ldwrkr, dum, 1, dum, 1,
2489 $ work( iwork ), info )
2495 CALL dgemm(
'N',
'N', m, n, m, one, work( ir ),
2496 $ ldwrkr, a, lda, zero, vt, ldvt )
2508 CALL dgelqf( m, n, a, lda, work( itau ),
2509 $ work( iwork ), lwork-iwork+1, ierr )
2513 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
2518 CALL dorglq( m, n, m, vt, ldvt, work( itau ),
2519 $ work( iwork ), lwork-iwork+1, ierr )
2527 CALL dlaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ),
2533 CALL dgebrd( m, m, a, lda, s, work( ie ),
2534 $ work( itauq ), work( itaup ),
2535 $ work( iwork ), lwork-iwork+1, ierr )
2540 CALL dormbr(
'P',
'L',
'T', m, n, m, a, lda,
2541 $ work( itaup ), vt, ldvt,
2542 $ work( iwork ), lwork-iwork+1, ierr )
2549 CALL dbdsqr(
'U', m, n, 0, 0, s, work( ie ), vt,
2550 $ ldvt, dum, 1, dum, 1, work( iwork ),
2555 ELSE IF( wntuo )
THEN
2561 IF( lwork.GE.2*m*m+max( 4*m, bdspac ) )
THEN
2566 IF( lwork.GE.wrkbl+2*lda*m )
THEN
2573 ELSE IF( lwork.GE.wrkbl+( lda + m )*m )
THEN
2588 itau = ir + ldwrkr*m
2594 CALL dgelqf( m, n, a, lda, work( itau ),
2595 $ work( iwork ), lwork-iwork+1, ierr )
2599 CALL dlacpy(
'L', m, m, a, lda, work( iu ),
2601 CALL dlaset(
'U', m-1, m-1, zero, zero,
2602 $ work( iu+ldwrku ), ldwrku )
2607 CALL dorglq( m, n, m, a, lda, work( itau ),
2608 $ work( iwork ), lwork-iwork+1, ierr )
2619 CALL dgebrd( m, m, work( iu ), ldwrku, s,
2620 $ work( ie ), work( itauq ),
2621 $ work( itaup ), work( iwork ),
2622 $ lwork-iwork+1, ierr )
2623 CALL dlacpy(
'L', m, m, work( iu ), ldwrku,
2624 $ work( ir ), ldwrkr )
2630 CALL dorgbr(
'P', m, m, m, work( iu ), ldwrku,
2631 $ work( itaup ), work( iwork ),
2632 $ lwork-iwork+1, ierr )
2637 CALL dorgbr(
'Q', m, m, m, work( ir ), ldwrkr,
2638 $ work( itauq ), work( iwork ),
2639 $ lwork-iwork+1, ierr )
2647 CALL dbdsqr(
'U', m, m, m, 0, s, work( ie ),
2648 $ work( iu ), ldwrku, work( ir ),
2649 $ ldwrkr, dum, 1, work( iwork ), info )
2655 CALL dgemm(
'N',
'N', m, n, m, one, work( iu ),
2656 $ ldwrku, a, lda, zero, vt, ldvt )
2661 CALL dlacpy(
'F', m, m, work( ir ), ldwrkr, a,
2674 CALL dgelqf( m, n, a, lda, work( itau ),
2675 $ work( iwork ), lwork-iwork+1, ierr )
2676 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
2681 CALL dorglq( m, n, m, vt, ldvt, work( itau ),
2682 $ work( iwork ), lwork-iwork+1, ierr )
2690 CALL dlaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ),
2696 CALL dgebrd( m, m, a, lda, s, work( ie ),
2697 $ work( itauq ), work( itaup ),
2698 $ work( iwork ), lwork-iwork+1, ierr )
2703 CALL dormbr(
'P',
'L',
'T', m, n, m, a, lda,
2704 $ work( itaup ), vt, ldvt,
2705 $ work( iwork ), lwork-iwork+1, ierr )
2710 CALL dorgbr(
'Q', m, m, m, a, lda, work( itauq ),
2711 $ work( iwork ), lwork-iwork+1, ierr )
2719 CALL dbdsqr(
'U', m, n, m, 0, s, work( ie ), vt,
2720 $ ldvt, a, lda, dum, 1, work( iwork ),
2725 ELSE IF( wntuas )
THEN
2732 IF( lwork.GE.m*m+max( 4*m, bdspac ) )
THEN
2737 IF( lwork.GE.wrkbl+lda*m )
THEN
2748 itau = iu + ldwrku*m
2754 CALL dgelqf( m, n, a, lda, work( itau ),
2755 $ work( iwork ), lwork-iwork+1, ierr )
2759 CALL dlacpy(
'L', m, m, a, lda, work( iu ),
2761 CALL dlaset(
'U', m-1, m-1, zero, zero,
2762 $ work( iu+ldwrku ), ldwrku )
2767 CALL dorglq( m, n, m, a, lda, work( itau ),
2768 $ work( iwork ), lwork-iwork+1, ierr )
2777 CALL dgebrd( m, m, work( iu ), ldwrku, s,
2778 $ work( ie ), work( itauq ),
2779 $ work( itaup ), work( iwork ),
2780 $ lwork-iwork+1, ierr )
2781 CALL dlacpy(
'L', m, m, work( iu ), ldwrku, u,
2788 CALL dorgbr(
'P', m, m, m, work( iu ), ldwrku,
2789 $ work( itaup ), work( iwork ),
2790 $ lwork-iwork+1, ierr )
2795 CALL dorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
2796 $ work( iwork ), lwork-iwork+1, ierr )
2804 CALL dbdsqr(
'U', m, m, m, 0, s, work( ie ),
2805 $ work( iu ), ldwrku, u, ldu, dum, 1,
2806 $ work( iwork ), info )
2812 CALL dgemm(
'N',
'N', m, n, m, one, work( iu ),
2813 $ ldwrku, a, lda, zero, vt, ldvt )
2825 CALL dgelqf( m, n, a, lda, work( itau ),
2826 $ work( iwork ), lwork-iwork+1, ierr )
2827 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
2832 CALL dorglq( m, n, m, vt, ldvt, work( itau ),
2833 $ work( iwork ), lwork-iwork+1, ierr )
2837 CALL dlacpy(
'L', m, m, a, lda, u, ldu )
2838 CALL dlaset(
'U', m-1, m-1, zero, zero, u( 1, 2 ),
2848 CALL dgebrd( m, m, u, ldu, s, work( ie ),
2849 $ work( itauq ), work( itaup ),
2850 $ work( iwork ), lwork-iwork+1, ierr )
2856 CALL dormbr(
'P',
'L',
'T', m, n, m, u, ldu,
2857 $ work( itaup ), vt, ldvt,
2858 $ work( iwork ), lwork-iwork+1, ierr )
2863 CALL dorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
2864 $ work( iwork ), lwork-iwork+1, ierr )
2872 CALL dbdsqr(
'U', m, n, m, 0, s, work( ie ), vt,
2873 $ ldvt, u, ldu, dum, 1, work( iwork ),
2880 ELSE IF( wntva )
THEN
2888 IF( lwork.GE.m*m+max( n + m, 4*m, bdspac ) )
THEN
2893 IF( lwork.GE.wrkbl+lda*m )
THEN
2904 itau = ir + ldwrkr*m
2910 CALL dgelqf( m, n, a, lda, work( itau ),
2911 $ work( iwork ), lwork-iwork+1, ierr )
2912 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
2916 CALL dlacpy(
'L', m, m, a, lda, work( ir ),
2918 CALL dlaset(
'U', m-1, m-1, zero, zero,
2919 $ work( ir+ldwrkr ), ldwrkr )
2924 CALL dorglq( n, n, m, vt, ldvt, work( itau ),
2925 $ work( iwork ), lwork-iwork+1, ierr )
2934 CALL dgebrd( m, m, work( ir ), ldwrkr, s,
2935 $ work( ie ), work( itauq ),
2936 $ work( itaup ), work( iwork ),
2937 $ lwork-iwork+1, ierr )
2943 CALL dorgbr(
'P', m, m, m, work( ir ), ldwrkr,
2944 $ work( itaup ), work( iwork ),
2945 $ lwork-iwork+1, ierr )
2952 CALL dbdsqr(
'U', m, m, 0, 0, s, work( ie ),
2953 $ work( ir ), ldwrkr, dum, 1, dum, 1,
2954 $ work( iwork ), info )
2960 CALL dgemm(
'N',
'N', m, n, m, one, work( ir ),
2961 $ ldwrkr, vt, ldvt, zero, a, lda )
2965 CALL dlacpy(
'F', m, n, a, lda, vt, ldvt )
2977 CALL dgelqf( m, n, a, lda, work( itau ),
2978 $ work( iwork ), lwork-iwork+1, ierr )
2979 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
2984 CALL dorglq( n, n, m, vt, ldvt, work( itau ),
2985 $ work( iwork ), lwork-iwork+1, ierr )
2993 CALL dlaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ),
2999 CALL dgebrd( m, m, a, lda, s, work( ie ),
3000 $ work( itauq ), work( itaup ),
3001 $ work( iwork ), lwork-iwork+1, ierr )
3007 CALL dormbr(
'P',
'L',
'T', m, n, m, a, lda,
3008 $ work( itaup ), vt, ldvt,
3009 $ work( iwork ), lwork-iwork+1, ierr )
3016 CALL dbdsqr(
'U', m, n, 0, 0, s, work( ie ), vt,
3017 $ ldvt, dum, 1, dum, 1, work( iwork ),
3022 ELSE IF( wntuo )
THEN
3028 IF( lwork.GE.2*m*m+max( n + m, 4*m, bdspac ) )
THEN
3033 IF( lwork.GE.wrkbl+2*lda*m )
THEN
3040 ELSE IF( lwork.GE.wrkbl+( lda + m )*m )
THEN
3055 itau = ir + ldwrkr*m
3061 CALL dgelqf( m, n, a, lda, work( itau ),
3062 $ work( iwork ), lwork-iwork+1, ierr )
3063 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
3068 CALL dorglq( n, n, m, vt, ldvt, work( itau ),
3069 $ work( iwork ), lwork-iwork+1, ierr )
3073 CALL dlacpy(
'L', m, m, a, lda, work( iu ),
3075 CALL dlaset(
'U', m-1, m-1, zero, zero,
3076 $ work( iu+ldwrku ), ldwrku )
3087 CALL dgebrd( m, m, work( iu ), ldwrku, s,
3088 $ work( ie ), work( itauq ),
3089 $ work( itaup ), work( iwork ),
3090 $ lwork-iwork+1, ierr )
3091 CALL dlacpy(
'L', m, m, work( iu ), ldwrku,
3092 $ work( ir ), ldwrkr )
3098 CALL dorgbr(
'P', m, m, m, work( iu ), ldwrku,
3099 $ work( itaup ), work( iwork ),
3100 $ lwork-iwork+1, ierr )
3105 CALL dorgbr(
'Q', m, m, m, work( ir ), ldwrkr,
3106 $ work( itauq ), work( iwork ),
3107 $ lwork-iwork+1, ierr )
3115 CALL dbdsqr(
'U', m, m, m, 0, s, work( ie ),
3116 $ work( iu ), ldwrku, work( ir ),
3117 $ ldwrkr, dum, 1, work( iwork ), info )
3123 CALL dgemm(
'N',
'N', m, n, m, one, work( iu ),
3124 $ ldwrku, vt, ldvt, zero, a, lda )
3128 CALL dlacpy(
'F', m, n, a, lda, vt, ldvt )
3132 CALL dlacpy(
'F', m, m, work( ir ), ldwrkr, a,
3145 CALL dgelqf( m, n, a, lda, work( itau ),
3146 $ work( iwork ), lwork-iwork+1, ierr )
3147 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
3152 CALL dorglq( n, n, m, vt, ldvt, work( itau ),
3153 $ work( iwork ), lwork-iwork+1, ierr )
3161 CALL dlaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ),
3167 CALL dgebrd( m, m, a, lda, s, work( ie ),
3168 $ work( itauq ), work( itaup ),
3169 $ work( iwork ), lwork-iwork+1, ierr )
3175 CALL dormbr(
'P',
'L',
'T', m, n, m, a, lda,
3176 $ work( itaup ), vt, ldvt,
3177 $ work( iwork ), lwork-iwork+1, ierr )
3182 CALL dorgbr(
'Q', m, m, m, a, lda, work( itauq ),
3183 $ work( iwork ), lwork-iwork+1, ierr )
3191 CALL dbdsqr(
'U', m, n, m, 0, s, work( ie ), vt,
3192 $ ldvt, a, lda, dum, 1, work( iwork ),
3197 ELSE IF( wntuas )
THEN
3204 IF( lwork.GE.m*m+max( n + m, 4*m, bdspac ) )
THEN
3209 IF( lwork.GE.wrkbl+lda*m )
THEN
3220 itau = iu + ldwrku*m
3226 CALL dgelqf( m, n, a, lda, work( itau ),
3227 $ work( iwork ), lwork-iwork+1, ierr )
3228 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
3233 CALL dorglq( n, n, m, vt, ldvt, work( itau ),
3234 $ work( iwork ), lwork-iwork+1, ierr )
3238 CALL dlacpy(
'L', m, m, a, lda, work( iu ),
3240 CALL dlaset(
'U', m-1, m-1, zero, zero,
3241 $ work( iu+ldwrku ), ldwrku )
3250 CALL dgebrd( m, m, work( iu ), ldwrku, s,
3251 $ work( ie ), work( itauq ),
3252 $ work( itaup ), work( iwork ),
3253 $ lwork-iwork+1, ierr )
3254 CALL dlacpy(
'L', m, m, work( iu ), ldwrku, u,
3260 CALL dorgbr(
'P', m, m, m, work( iu ), ldwrku,
3261 $ work( itaup ), work( iwork ),
3262 $ lwork-iwork+1, ierr )
3267 CALL dorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
3268 $ work( iwork ), lwork-iwork+1, ierr )
3276 CALL dbdsqr(
'U', m, m, m, 0, s, work( ie ),
3277 $ work( iu ), ldwrku, u, ldu, dum, 1,
3278 $ work( iwork ), info )
3284 CALL dgemm(
'N',
'N', m, n, m, one, work( iu ),
3285 $ ldwrku, vt, ldvt, zero, a, lda )
3289 CALL dlacpy(
'F', m, n, a, lda, vt, ldvt )
3301 CALL dgelqf( m, n, a, lda, work( itau ),
3302 $ work( iwork ), lwork-iwork+1, ierr )
3303 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
3308 CALL dorglq( n, n, m, vt, ldvt, work( itau ),
3309 $ work( iwork ), lwork-iwork+1, ierr )
3313 CALL dlacpy(
'L', m, m, a, lda, u, ldu )
3314 CALL dlaset(
'U', m-1, m-1, zero, zero, u( 1, 2 ),
3324 CALL dgebrd( m, m, u, ldu, s, work( ie ),
3325 $ work( itauq ), work( itaup ),
3326 $ work( iwork ), lwork-iwork+1, ierr )
3332 CALL dormbr(
'P',
'L',
'T', m, n, m, u, ldu,
3333 $ work( itaup ), vt, ldvt,
3334 $ work( iwork ), lwork-iwork+1, ierr )
3339 CALL dorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
3340 $ work( iwork ), lwork-iwork+1, ierr )
3348 CALL dbdsqr(
'U', m, n, m, 0, s, work( ie ), vt,
3349 $ ldvt, u, ldu, dum, 1, work( iwork ),
3373 CALL dgebrd( m, n, a, lda, s, work( ie ), work( itauq ),
3374 $ work( itaup ), work( iwork ), lwork-iwork+1,
3382 CALL dlacpy(
'L', m, m, a, lda, u, ldu )
3383 CALL dorgbr(
'Q', m, m, n, u, ldu, work( itauq ),
3384 $ work( iwork ), lwork-iwork+1, ierr )
3392 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
3397 CALL dorgbr(
'P', nrvt, n, m, vt, ldvt, work( itaup ),
3398 $ work( iwork ), lwork-iwork+1, ierr )
3406 CALL dorgbr(
'Q', m, m, n, a, lda, work( itauq ),
3407 $ work( iwork ), lwork-iwork+1, ierr )
3415 CALL dorgbr(
'P', m, n, m, a, lda, work( itaup ),
3416 $ work( iwork ), lwork-iwork+1, ierr )
3419 IF( wntuas .OR. wntuo )
3423 IF( wntvas .OR. wntvo )
3427 IF( ( .NOT.wntuo ) .AND. ( .NOT.wntvo ) )
THEN
3434 CALL dbdsqr(
'L', m, ncvt, nru, 0, s, work( ie ), vt,
3435 $ ldvt, u, ldu, dum, 1, work( iwork ), info )
3436 ELSE IF( ( .NOT.wntuo ) .AND. wntvo )
THEN
3443 CALL dbdsqr(
'L', m, ncvt, nru, 0, s, work( ie ), a, lda,
3444 $ u, ldu, dum, 1, work( iwork ), info )
3452 CALL dbdsqr(
'L', m, ncvt, nru, 0, s, work( ie ), vt,
3453 $ ldvt, a, lda, dum, 1, work( iwork ), info )
3463 IF( info.NE.0 )
THEN
3465 DO 50 i = 1, minmn - 1
3466 work( i+1 ) = work( i+ie-1 )
3470 DO 60 i = minmn - 1, 1, -1
3471 work( i+1 ) = work( i+ie-1 )
3478 IF( iscl.EQ.1 )
THEN
3479 IF( anrm.GT.bignum )
3480 $
CALL dlascl(
'G', 0, 0, bignum, anrm, minmn, 1, s, minmn,
3482 IF( info.NE.0 .AND. anrm.GT.bignum )
3483 $
CALL dlascl(
'G', 0, 0, bignum, anrm, minmn-1, 1, work( 2 ),
3485 IF( anrm.LT.smlnum )
3486 $
CALL dlascl(
'G', 0, 0, smlnum, anrm, minmn, 1, s, minmn,
3488 IF( info.NE.0 .AND. anrm.LT.smlnum )
3489 $
CALL dlascl(
'G', 0, 0, smlnum, anrm, minmn-1, 1, work( 2 ),
subroutine xerbla(srname, info)
subroutine dbdsqr(uplo, n, ncvt, nru, ncc, d, e, vt, ldvt, u, ldu, c, ldc, work, info)
DBDSQR
subroutine dgebrd(m, n, a, lda, d, e, tauq, taup, work, lwork, info)
DGEBRD
subroutine dgelqf(m, n, a, lda, tau, work, lwork, info)
DGELQF
subroutine dgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
DGEMM
subroutine dgeqrf(m, n, a, lda, tau, work, lwork, info)
DGEQRF
subroutine dgesvd(jobu, jobvt, m, n, a, lda, s, u, ldu, vt, ldvt, work, lwork, info)
DGESVD computes the singular value decomposition (SVD) for GE matrices
subroutine dlacpy(uplo, m, n, a, lda, b, ldb)
DLACPY copies all or part of one two-dimensional array to another.
subroutine dlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
DLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine dlaset(uplo, m, n, alpha, beta, a, lda)
DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine dorgbr(vect, m, n, k, a, lda, tau, work, lwork, info)
DORGBR
subroutine dorglq(m, n, k, a, lda, tau, work, lwork, info)
DORGLQ
subroutine dorgqr(m, n, k, a, lda, tau, work, lwork, info)
DORGQR
subroutine dormbr(vect, side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
DORMBR