207 SUBROUTINE dgesvd( JOBU, JOBVT, M, N, A, LDA, S, U, LDU,
208 $ VT, LDVT, WORK, LWORK, INFO )
215 CHARACTER JOBU, JOBVT
216 INTEGER INFO, LDA, LDU, LDVT, LWORK, M, N
219 DOUBLE PRECISION A( LDA, * ), S( * ), U( LDU, * ),
220 $ vt( ldvt, * ), work( * )
226 DOUBLE PRECISION ZERO, ONE
227 parameter( zero = 0.0d0, one = 1.0d0 )
230 LOGICAL LQUERY, WNTUA, WNTUAS, WNTUN, WNTUO, WNTUS,
231 $ wntva, wntvas, wntvn, wntvo, wntvs
232 INTEGER BDSPAC, BLK, CHUNK, I, IE, IERR, IR, ISCL,
233 $ itau, itaup, itauq, iu, iwork, ldwrkr, ldwrku,
234 $ maxwrk, minmn, minwrk, mnthr, ncu, ncvt, nru,
236 INTEGER LWORK_DGEQRF, LWORK_DORGQR_N, LWORK_DORGQR_M,
237 $ lwork_dgebrd, lwork_dorgbr_p, lwork_dorgbr_q,
238 $ lwork_dgelqf, lwork_dorglq_n, lwork_dorglq_m
239 DOUBLE PRECISION ANRM, BIGNUM, EPS, SMLNUM
242 DOUBLE PRECISION DUM( 1 )
253 DOUBLE PRECISION DLAMCH, DLANGE
254 EXTERNAL lsame, ilaenv, dlamch, dlange
257 INTRINSIC max, min, sqrt
265 wntua = lsame( jobu,
'A' )
266 wntus = lsame( jobu,
'S' )
267 wntuas = wntua .OR. wntus
268 wntuo = lsame( jobu,
'O' )
269 wntun = lsame( jobu,
'N' )
270 wntva = lsame( jobvt,
'A' )
271 wntvs = lsame( jobvt,
'S' )
272 wntvas = wntva .OR. wntvs
273 wntvo = lsame( jobvt,
'O' )
274 wntvn = lsame( jobvt,
'N' )
275 lquery = ( lwork.EQ.-1 )
277 IF( .NOT.( wntua .OR. wntus .OR. wntuo .OR. wntun ) )
THEN
279 ELSE IF( .NOT.( wntva .OR. wntvs .OR. wntvo .OR. wntvn ) .OR.
280 $ ( wntvo .AND. wntuo ) )
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. ( wntuas .AND. ldu.LT.m ) )
THEN
290 ELSE IF( ldvt.LT.1 .OR. ( wntva .AND. ldvt.LT.n ) .OR.
291 $ ( wntvs .AND. ldvt.LT.minmn ) )
THEN
305 IF( m.GE.n .AND. minmn.GT.0 )
THEN
309 mnthr = ilaenv( 6,
'DGESVD', jobu // jobvt, m, n, 0, 0 )
312 CALL dgeqrf( m, n, a, lda, dum(1), dum(1), -1, ierr )
313 lwork_dgeqrf = int( dum(1) )
315 CALL dorgqr( m, n, n, a, lda, dum(1), dum(1), -1, ierr )
316 lwork_dorgqr_n = int( dum(1) )
317 CALL dorgqr( m, m, n, a, lda, dum(1), dum(1), -1, ierr )
318 lwork_dorgqr_m = int( dum(1) )
320 CALL dgebrd( n, n, a, lda, s, dum(1), dum(1),
321 $ dum(1), dum(1), -1, ierr )
322 lwork_dgebrd = int( dum(1) )
324 CALL dorgbr(
'P', n, n, n, a, lda, dum(1),
326 lwork_dorgbr_p = int( dum(1) )
328 CALL dorgbr(
'Q', n, n, n, a, lda, dum(1),
330 lwork_dorgbr_q = int( dum(1) )
332 IF( m.GE.mnthr )
THEN
337 maxwrk = n + lwork_dgeqrf
338 maxwrk = max( maxwrk, 3*n + lwork_dgebrd )
339 IF( wntvo .OR. wntvas )
340 $ maxwrk = max( maxwrk, 3*n + lwork_dorgbr_p )
341 maxwrk = max( maxwrk, bdspac )
342 minwrk = max( 4*n, bdspac )
343 ELSE IF( wntuo .AND. wntvn )
THEN
347 wrkbl = n + lwork_dgeqrf
348 wrkbl = max( wrkbl, n + lwork_dorgqr_n )
349 wrkbl = max( wrkbl, 3*n + lwork_dgebrd )
350 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_q )
351 wrkbl = max( wrkbl, bdspac )
352 maxwrk = max( n*n + wrkbl, n*n + m*n + n )
353 minwrk = max( 3*n + m, bdspac )
354 ELSE IF( wntuo .AND. wntvas )
THEN
359 wrkbl = n + lwork_dgeqrf
360 wrkbl = max( wrkbl, n + lwork_dorgqr_n )
361 wrkbl = max( wrkbl, 3*n + lwork_dgebrd )
362 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_q )
363 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_p )
364 wrkbl = max( wrkbl, bdspac )
365 maxwrk = max( n*n + wrkbl, n*n + m*n + n )
366 minwrk = max( 3*n + m, bdspac )
367 ELSE IF( wntus .AND. wntvn )
THEN
371 wrkbl = n + lwork_dgeqrf
372 wrkbl = max( wrkbl, n + lwork_dorgqr_n )
373 wrkbl = max( wrkbl, 3*n + lwork_dgebrd )
374 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_q )
375 wrkbl = max( wrkbl, bdspac )
377 minwrk = max( 3*n + m, bdspac )
378 ELSE IF( wntus .AND. wntvo )
THEN
382 wrkbl = n + lwork_dgeqrf
383 wrkbl = max( wrkbl, n + lwork_dorgqr_n )
384 wrkbl = max( wrkbl, 3*n + lwork_dgebrd )
385 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_q )
386 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_p )
387 wrkbl = max( wrkbl, bdspac )
388 maxwrk = 2*n*n + wrkbl
389 minwrk = max( 3*n + m, bdspac )
390 ELSE IF( wntus .AND. wntvas )
THEN
395 wrkbl = n + lwork_dgeqrf
396 wrkbl = max( wrkbl, n + lwork_dorgqr_n )
397 wrkbl = max( wrkbl, 3*n + lwork_dgebrd )
398 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_q )
399 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_p )
400 wrkbl = max( wrkbl, bdspac )
402 minwrk = max( 3*n + m, bdspac )
403 ELSE IF( wntua .AND. wntvn )
THEN
407 wrkbl = n + lwork_dgeqrf
408 wrkbl = max( wrkbl, n + lwork_dorgqr_m )
409 wrkbl = max( wrkbl, 3*n + lwork_dgebrd )
410 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_q )
411 wrkbl = max( wrkbl, bdspac )
413 minwrk = max( 3*n + m, bdspac )
414 ELSE IF( wntua .AND. wntvo )
THEN
418 wrkbl = n + lwork_dgeqrf
419 wrkbl = max( wrkbl, n + lwork_dorgqr_m )
420 wrkbl = max( wrkbl, 3*n + lwork_dgebrd )
421 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_q )
422 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_p )
423 wrkbl = max( wrkbl, bdspac )
424 maxwrk = 2*n*n + wrkbl
425 minwrk = max( 3*n + m, bdspac )
426 ELSE IF( wntua .AND. wntvas )
THEN
431 wrkbl = n + lwork_dgeqrf
432 wrkbl = max( wrkbl, n + lwork_dorgqr_m )
433 wrkbl = max( wrkbl, 3*n + lwork_dgebrd )
434 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_q )
435 wrkbl = max( wrkbl, 3*n + lwork_dorgbr_p )
436 wrkbl = max( wrkbl, bdspac )
438 minwrk = max( 3*n + m, bdspac )
444 CALL dgebrd( m, n, a, lda, s, dum(1), dum(1),
445 $ dum(1), dum(1), -1, ierr )
446 lwork_dgebrd = int( dum(1) )
447 maxwrk = 3*n + lwork_dgebrd
448 IF( wntus .OR. wntuo )
THEN
449 CALL dorgbr(
'Q', m, n, n, a, lda, dum(1),
451 lwork_dorgbr_q = int( dum(1) )
452 maxwrk = max( maxwrk, 3*n + lwork_dorgbr_q )
455 CALL dorgbr(
'Q', m, m, n, a, lda, dum(1),
457 lwork_dorgbr_q = int( dum(1) )
458 maxwrk = max( maxwrk, 3*n + lwork_dorgbr_q )
460 IF( .NOT.wntvn )
THEN
461 maxwrk = max( maxwrk, 3*n + lwork_dorgbr_p )
463 maxwrk = max( maxwrk, bdspac )
464 minwrk = max( 3*n + m, bdspac )
466 ELSE IF( minmn.GT.0 )
THEN
470 mnthr = ilaenv( 6,
'DGESVD', jobu // jobvt, m, n, 0, 0 )
473 CALL dgelqf( m, n, a, lda, dum(1), dum(1), -1, ierr )
474 lwork_dgelqf = int( dum(1) )
476 CALL dorglq( n, n, m, dum(1), n, dum(1), dum(1), -1,
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 ),
689 $ lwork-iwork+1, ierr )
694 CALL dlaset(
'L', n-1, n-1, zero, zero, a( 2, 1 ),
705 CALL dgebrd( n, n, a, lda, s, work( ie ),
707 $ work( itaup ), work( iwork ), lwork-iwork+1,
710 IF( wntvo .OR. wntvas )
THEN
715 CALL dorgbr(
'P', n, n, n, a, lda, work( itaup ),
716 $ work( iwork ), lwork-iwork+1, ierr )
725 CALL dbdsqr(
'U', n, ncvt, 0, 0, s, work( ie ), a,
727 $ dum, 1, dum, 1, work( iwork ), info )
732 $
CALL dlacpy(
'F', n, n, a, lda, vt, ldvt )
734 ELSE IF( wntuo .AND. wntvn )
THEN
740 IF( lwork.GE.n*n+max( 4*n, bdspac ) )
THEN
745 IF( lwork.GE.max( wrkbl, lda*n + n ) + lda*n )
THEN
751 ELSE IF( lwork.GE.max( wrkbl, lda*n + n ) + n*n )
THEN
761 ldwrku = ( lwork-n*n-n ) / n
770 CALL dgeqrf( m, n, a, lda, work( itau ),
771 $ work( iwork ), lwork-iwork+1, ierr )
775 CALL dlacpy(
'U', n, n, a, lda, work( ir ),
777 CALL dlaset(
'L', n-1, n-1, zero, zero,
784 CALL dorgqr( m, n, n, a, lda, work( itau ),
785 $ work( iwork ), lwork-iwork+1, ierr )
794 CALL dgebrd( n, n, work( ir ), ldwrkr, s,
796 $ work( itauq ), work( itaup ),
797 $ work( iwork ), lwork-iwork+1, ierr )
802 CALL dorgbr(
'Q', n, n, n, work( ir ), ldwrkr,
803 $ work( itauq ), work( iwork ),
804 $ lwork-iwork+1, ierr )
811 CALL dbdsqr(
'U', n, 0, n, 0, s, work( ie ), dum,
813 $ work( ir ), ldwrkr, dum, 1,
814 $ work( iwork ), info )
821 DO 10 i = 1, m, ldwrku
822 chunk = min( m-i+1, ldwrku )
823 CALL dgemm(
'N',
'N', chunk, n, n, one, a( i,
825 $ lda, work( ir ), ldwrkr, zero,
826 $ work( iu ), ldwrku )
827 CALL dlacpy(
'F', chunk, n, work( iu ), ldwrku,
843 CALL dgebrd( m, n, a, lda, s, work( ie ),
844 $ work( itauq ), work( itaup ),
845 $ work( iwork ), lwork-iwork+1, ierr )
850 CALL dorgbr(
'Q', m, n, n, a, lda, work( itauq ),
851 $ work( iwork ), lwork-iwork+1, ierr )
858 CALL dbdsqr(
'U', n, 0, m, 0, s, work( ie ), dum,
860 $ a, lda, dum, 1, work( iwork ), info )
864 ELSE IF( wntuo .AND. wntvas )
THEN
870 IF( lwork.GE.n*n+max( 4*n, bdspac ) )
THEN
875 IF( lwork.GE.max( wrkbl, lda*n + n ) + lda*n )
THEN
881 ELSE IF( lwork.GE.max( wrkbl, lda*n + n ) + n*n )
THEN
891 ldwrku = ( lwork-n*n-n ) / n
900 CALL dgeqrf( m, n, a, lda, work( itau ),
901 $ work( iwork ), lwork-iwork+1, ierr )
905 CALL dlacpy(
'U', n, n, a, lda, vt, ldvt )
907 $
CALL dlaset(
'L', n-1, n-1, zero, zero,
913 CALL dorgqr( m, n, n, a, lda, work( itau ),
914 $ work( iwork ), lwork-iwork+1, ierr )
923 CALL dgebrd( n, n, vt, ldvt, s, work( ie ),
924 $ work( itauq ), work( itaup ),
925 $ work( iwork ), lwork-iwork+1, ierr )
926 CALL dlacpy(
'L', n, n, vt, ldvt, work( ir ),
932 CALL dorgbr(
'Q', n, n, n, work( ir ), ldwrkr,
933 $ work( itauq ), work( iwork ),
934 $ lwork-iwork+1, ierr )
939 CALL dorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
940 $ work( iwork ), lwork-iwork+1, ierr )
948 CALL dbdsqr(
'U', n, n, n, 0, s, work( ie ), vt,
950 $ work( ir ), ldwrkr, dum, 1,
951 $ work( iwork ), info )
958 DO 20 i = 1, m, ldwrku
959 chunk = min( m-i+1, ldwrku )
960 CALL dgemm(
'N',
'N', chunk, n, n, one, a( i,
962 $ lda, work( ir ), ldwrkr, zero,
963 $ work( iu ), ldwrku )
964 CALL dlacpy(
'F', chunk, n, work( iu ), ldwrku,
978 CALL dgeqrf( m, n, a, lda, work( itau ),
979 $ work( iwork ), lwork-iwork+1, ierr )
983 CALL dlacpy(
'U', n, n, a, lda, vt, ldvt )
985 $
CALL dlaset(
'L', n-1, n-1, zero, zero,
991 CALL dorgqr( m, n, n, a, lda, work( itau ),
992 $ work( iwork ), lwork-iwork+1, ierr )
1001 CALL dgebrd( n, n, vt, ldvt, s, work( ie ),
1002 $ work( itauq ), work( itaup ),
1003 $ work( iwork ), lwork-iwork+1, ierr )
1008 CALL dormbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1009 $ work( itauq ), a, lda, work( iwork ),
1010 $ lwork-iwork+1, ierr )
1015 CALL dorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1016 $ work( iwork ), lwork-iwork+1, ierr )
1024 CALL dbdsqr(
'U', n, n, m, 0, s, work( ie ), vt,
1026 $ a, lda, dum, 1, work( iwork ), info )
1030 ELSE IF( wntus )
THEN
1038 IF( lwork.GE.n*n+max( 4*n, bdspac ) )
THEN
1043 IF( lwork.GE.wrkbl+lda*n )
THEN
1054 itau = ir + ldwrkr*n
1060 CALL dgeqrf( m, n, a, lda, work( itau ),
1061 $ work( iwork ), lwork-iwork+1, ierr )
1065 CALL dlacpy(
'U', n, n, a, lda, work( ir ),
1067 CALL dlaset(
'L', n-1, n-1, zero, zero,
1068 $ work( ir+1 ), ldwrkr )
1073 CALL dorgqr( m, n, n, a, lda, work( itau ),
1074 $ work( iwork ), lwork-iwork+1, ierr )
1083 CALL dgebrd( n, n, work( ir ), ldwrkr, s,
1084 $ work( ie ), work( itauq ),
1085 $ work( itaup ), work( iwork ),
1086 $ lwork-iwork+1, ierr )
1091 CALL dorgbr(
'Q', n, n, n, work( ir ), ldwrkr,
1092 $ work( itauq ), work( iwork ),
1093 $ lwork-iwork+1, ierr )
1100 CALL dbdsqr(
'U', n, 0, n, 0, s, work( ie ),
1102 $ 1, work( ir ), ldwrkr, dum, 1,
1103 $ work( iwork ), info )
1109 CALL dgemm(
'N',
'N', m, n, n, one, a, lda,
1110 $ work( ir ), ldwrkr, zero, u, ldu )
1122 CALL dgeqrf( m, n, a, lda, work( itau ),
1123 $ work( iwork ), lwork-iwork+1, ierr )
1124 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1129 CALL dorgqr( m, n, n, u, ldu, work( itau ),
1130 $ work( iwork ), lwork-iwork+1, ierr )
1139 CALL dlaset(
'L', n-1, n-1, zero, zero,
1146 CALL dgebrd( n, n, a, lda, s, work( ie ),
1147 $ work( itauq ), work( itaup ),
1148 $ work( iwork ), lwork-iwork+1, ierr )
1153 CALL dormbr(
'Q',
'R',
'N', m, n, n, a, lda,
1154 $ work( itauq ), u, ldu, work( iwork ),
1155 $ lwork-iwork+1, ierr )
1162 CALL dbdsqr(
'U', n, 0, m, 0, s, work( ie ),
1164 $ 1, u, ldu, dum, 1, work( iwork ),
1169 ELSE IF( wntvo )
THEN
1175 IF( lwork.GE.2*n*n+max( 4*n, bdspac ) )
THEN
1180 IF( lwork.GE.wrkbl+2*lda*n )
THEN
1187 ELSE IF( lwork.GE.wrkbl+( lda + n )*n )
THEN
1202 itau = ir + ldwrkr*n
1208 CALL dgeqrf( m, n, a, lda, work( itau ),
1209 $ work( iwork ), lwork-iwork+1, ierr )
1213 CALL dlacpy(
'U', n, n, a, lda, work( iu ),
1215 CALL dlaset(
'L', n-1, n-1, zero, zero,
1216 $ work( iu+1 ), ldwrku )
1221 CALL dorgqr( m, n, n, a, lda, work( itau ),
1222 $ work( iwork ), lwork-iwork+1, ierr )
1233 CALL dgebrd( n, n, work( iu ), ldwrku, s,
1234 $ work( ie ), work( itauq ),
1235 $ work( itaup ), work( iwork ),
1236 $ lwork-iwork+1, ierr )
1237 CALL dlacpy(
'U', n, n, work( iu ), ldwrku,
1238 $ work( ir ), ldwrkr )
1243 CALL dorgbr(
'Q', n, n, n, work( iu ), ldwrku,
1244 $ work( itauq ), work( iwork ),
1245 $ lwork-iwork+1, ierr )
1251 CALL dorgbr(
'P', n, n, n, work( ir ), ldwrkr,
1252 $ work( itaup ), work( iwork ),
1253 $ lwork-iwork+1, ierr )
1261 CALL dbdsqr(
'U', n, n, n, 0, s, work( ie ),
1262 $ work( ir ), ldwrkr, work( iu ),
1263 $ ldwrku, dum, 1, work( iwork ), info )
1269 CALL dgemm(
'N',
'N', m, n, n, one, a, lda,
1270 $ work( iu ), ldwrku, zero, u, ldu )
1275 CALL dlacpy(
'F', n, n, work( ir ), ldwrkr, a,
1288 CALL dgeqrf( m, n, a, lda, work( itau ),
1289 $ work( iwork ), lwork-iwork+1, ierr )
1290 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1295 CALL dorgqr( m, n, n, u, ldu, work( itau ),
1296 $ work( iwork ), lwork-iwork+1, ierr )
1305 CALL dlaset(
'L', n-1, n-1, zero, zero,
1312 CALL dgebrd( n, n, a, lda, s, work( ie ),
1313 $ work( itauq ), work( itaup ),
1314 $ work( iwork ), lwork-iwork+1, ierr )
1319 CALL dormbr(
'Q',
'R',
'N', m, n, n, a, lda,
1320 $ work( itauq ), u, ldu, work( iwork ),
1321 $ lwork-iwork+1, ierr )
1326 CALL dorgbr(
'P', n, n, n, a, lda,
1328 $ work( iwork ), lwork-iwork+1, ierr )
1336 CALL dbdsqr(
'U', n, n, m, 0, s, work( ie ), a,
1337 $ lda, u, ldu, dum, 1, work( iwork ),
1342 ELSE IF( wntvas )
THEN
1349 IF( lwork.GE.n*n+max( 4*n, bdspac ) )
THEN
1354 IF( lwork.GE.wrkbl+lda*n )
THEN
1365 itau = iu + ldwrku*n
1371 CALL dgeqrf( m, n, a, lda, work( itau ),
1372 $ work( iwork ), lwork-iwork+1, ierr )
1376 CALL dlacpy(
'U', n, n, a, lda, work( iu ),
1378 CALL dlaset(
'L', n-1, n-1, zero, zero,
1379 $ work( iu+1 ), ldwrku )
1384 CALL dorgqr( m, n, n, a, lda, work( itau ),
1385 $ work( iwork ), lwork-iwork+1, ierr )
1394 CALL dgebrd( n, n, work( iu ), ldwrku, s,
1395 $ work( ie ), work( itauq ),
1396 $ work( itaup ), work( iwork ),
1397 $ lwork-iwork+1, ierr )
1398 CALL dlacpy(
'U', n, n, work( iu ), ldwrku, vt,
1404 CALL dorgbr(
'Q', n, n, n, work( iu ), ldwrku,
1405 $ work( itauq ), work( iwork ),
1406 $ lwork-iwork+1, ierr )
1412 CALL dorgbr(
'P', n, n, n, vt, ldvt,
1414 $ work( iwork ), lwork-iwork+1, ierr )
1422 CALL dbdsqr(
'U', n, n, n, 0, s, work( ie ), vt,
1423 $ ldvt, work( iu ), ldwrku, dum, 1,
1424 $ work( iwork ), info )
1430 CALL dgemm(
'N',
'N', m, n, n, one, a, lda,
1431 $ work( iu ), ldwrku, zero, u, ldu )
1443 CALL dgeqrf( m, n, a, lda, work( itau ),
1444 $ work( iwork ), lwork-iwork+1, ierr )
1445 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1450 CALL dorgqr( m, n, n, u, ldu, work( itau ),
1451 $ work( iwork ), lwork-iwork+1, ierr )
1455 CALL dlacpy(
'U', n, n, a, lda, vt, ldvt )
1457 $
CALL dlaset(
'L', n-1, n-1, zero, zero,
1458 $ vt( 2, 1 ), ldvt )
1467 CALL dgebrd( n, n, vt, ldvt, s, work( ie ),
1468 $ work( itauq ), work( itaup ),
1469 $ work( iwork ), lwork-iwork+1, ierr )
1475 CALL dormbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1476 $ work( itauq ), u, ldu, work( iwork ),
1477 $ lwork-iwork+1, ierr )
1482 CALL dorgbr(
'P', n, n, n, vt, ldvt,
1484 $ work( iwork ), lwork-iwork+1, ierr )
1492 CALL dbdsqr(
'U', n, n, m, 0, s, work( ie ), vt,
1493 $ ldvt, u, ldu, dum, 1, work( iwork ),
1500 ELSE IF( wntua )
THEN
1508 IF( lwork.GE.n*n+max( n+m, 4*n, bdspac ) )
THEN
1513 IF( lwork.GE.wrkbl+lda*n )
THEN
1524 itau = ir + ldwrkr*n
1530 CALL dgeqrf( m, n, a, lda, work( itau ),
1531 $ work( iwork ), lwork-iwork+1, ierr )
1532 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1536 CALL dlacpy(
'U', n, n, a, lda, work( ir ),
1538 CALL dlaset(
'L', n-1, n-1, zero, zero,
1539 $ work( ir+1 ), ldwrkr )
1544 CALL dorgqr( m, m, n, u, ldu, work( itau ),
1545 $ work( iwork ), lwork-iwork+1, ierr )
1554 CALL dgebrd( n, n, work( ir ), ldwrkr, s,
1555 $ work( ie ), work( itauq ),
1556 $ work( itaup ), work( iwork ),
1557 $ lwork-iwork+1, ierr )
1562 CALL dorgbr(
'Q', n, n, n, work( ir ), ldwrkr,
1563 $ work( itauq ), work( iwork ),
1564 $ lwork-iwork+1, ierr )
1571 CALL dbdsqr(
'U', n, 0, n, 0, s, work( ie ),
1573 $ 1, work( ir ), ldwrkr, dum, 1,
1574 $ work( iwork ), info )
1580 CALL dgemm(
'N',
'N', m, n, n, one, u, ldu,
1581 $ work( ir ), ldwrkr, zero, a, lda )
1585 CALL dlacpy(
'F', m, n, a, lda, u, ldu )
1597 CALL dgeqrf( m, n, a, lda, work( itau ),
1598 $ work( iwork ), lwork-iwork+1, ierr )
1599 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1604 CALL dorgqr( m, m, n, u, ldu, work( itau ),
1605 $ work( iwork ), lwork-iwork+1, ierr )
1614 CALL dlaset(
'L', n-1, n-1, zero, zero,
1621 CALL dgebrd( n, n, a, lda, s, work( ie ),
1622 $ work( itauq ), work( itaup ),
1623 $ work( iwork ), lwork-iwork+1, ierr )
1629 CALL dormbr(
'Q',
'R',
'N', m, n, n, a, lda,
1630 $ work( itauq ), u, ldu, work( iwork ),
1631 $ lwork-iwork+1, ierr )
1638 CALL dbdsqr(
'U', n, 0, m, 0, s, work( ie ),
1640 $ 1, u, ldu, dum, 1, work( iwork ),
1645 ELSE IF( wntvo )
THEN
1651 IF( lwork.GE.2*n*n+max( n+m, 4*n, bdspac ) )
THEN
1656 IF( lwork.GE.wrkbl+2*lda*n )
THEN
1663 ELSE IF( lwork.GE.wrkbl+( lda + n )*n )
THEN
1678 itau = ir + ldwrkr*n
1684 CALL dgeqrf( m, n, a, lda, work( itau ),
1685 $ work( iwork ), lwork-iwork+1, ierr )
1686 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1691 CALL dorgqr( m, m, n, u, ldu, work( itau ),
1692 $ work( iwork ), lwork-iwork+1, ierr )
1696 CALL dlacpy(
'U', n, n, a, lda, work( iu ),
1698 CALL dlaset(
'L', n-1, n-1, zero, zero,
1699 $ work( iu+1 ), ldwrku )
1710 CALL dgebrd( n, n, work( iu ), ldwrku, s,
1711 $ work( ie ), work( itauq ),
1712 $ work( itaup ), work( iwork ),
1713 $ lwork-iwork+1, ierr )
1714 CALL dlacpy(
'U', n, n, work( iu ), ldwrku,
1715 $ work( ir ), ldwrkr )
1720 CALL dorgbr(
'Q', n, n, n, work( iu ), ldwrku,
1721 $ work( itauq ), work( iwork ),
1722 $ lwork-iwork+1, ierr )
1728 CALL dorgbr(
'P', n, n, n, work( ir ), ldwrkr,
1729 $ work( itaup ), work( iwork ),
1730 $ lwork-iwork+1, ierr )
1738 CALL dbdsqr(
'U', n, n, n, 0, s, work( ie ),
1739 $ work( ir ), ldwrkr, work( iu ),
1740 $ ldwrku, dum, 1, work( iwork ), info )
1746 CALL dgemm(
'N',
'N', m, n, n, one, u, ldu,
1747 $ work( iu ), ldwrku, zero, a, lda )
1751 CALL dlacpy(
'F', m, n, a, lda, u, ldu )
1755 CALL dlacpy(
'F', n, n, work( ir ), ldwrkr, a,
1768 CALL dgeqrf( m, n, a, lda, work( itau ),
1769 $ work( iwork ), lwork-iwork+1, ierr )
1770 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1775 CALL dorgqr( m, m, n, u, ldu, work( itau ),
1776 $ work( iwork ), lwork-iwork+1, ierr )
1785 CALL dlaset(
'L', n-1, n-1, zero, zero,
1792 CALL dgebrd( n, n, a, lda, s, work( ie ),
1793 $ work( itauq ), work( itaup ),
1794 $ work( iwork ), lwork-iwork+1, ierr )
1800 CALL dormbr(
'Q',
'R',
'N', m, n, n, a, lda,
1801 $ work( itauq ), u, ldu, work( iwork ),
1802 $ lwork-iwork+1, ierr )
1807 CALL dorgbr(
'P', n, n, n, a, lda,
1809 $ work( iwork ), lwork-iwork+1, ierr )
1817 CALL dbdsqr(
'U', n, n, m, 0, s, work( ie ), a,
1818 $ lda, u, ldu, dum, 1, work( iwork ),
1823 ELSE IF( wntvas )
THEN
1830 IF( lwork.GE.n*n+max( n+m, 4*n, bdspac ) )
THEN
1835 IF( lwork.GE.wrkbl+lda*n )
THEN
1846 itau = iu + ldwrku*n
1852 CALL dgeqrf( m, n, a, lda, work( itau ),
1853 $ work( iwork ), lwork-iwork+1, ierr )
1854 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1859 CALL dorgqr( m, m, n, u, ldu, work( itau ),
1860 $ work( iwork ), lwork-iwork+1, ierr )
1864 CALL dlacpy(
'U', n, n, a, lda, work( iu ),
1866 CALL dlaset(
'L', n-1, n-1, zero, zero,
1867 $ work( iu+1 ), ldwrku )
1876 CALL dgebrd( n, n, work( iu ), ldwrku, s,
1877 $ work( ie ), work( itauq ),
1878 $ work( itaup ), work( iwork ),
1879 $ lwork-iwork+1, ierr )
1880 CALL dlacpy(
'U', n, n, work( iu ), ldwrku, vt,
1886 CALL dorgbr(
'Q', n, n, n, work( iu ), ldwrku,
1887 $ work( itauq ), work( iwork ),
1888 $ lwork-iwork+1, ierr )
1894 CALL dorgbr(
'P', n, n, n, vt, ldvt,
1896 $ work( iwork ), lwork-iwork+1, ierr )
1904 CALL dbdsqr(
'U', n, n, n, 0, s, work( ie ), vt,
1905 $ ldvt, work( iu ), ldwrku, dum, 1,
1906 $ work( iwork ), info )
1912 CALL dgemm(
'N',
'N', m, n, n, one, u, ldu,
1913 $ work( iu ), ldwrku, zero, a, lda )
1917 CALL dlacpy(
'F', m, n, a, lda, u, ldu )
1929 CALL dgeqrf( m, n, a, lda, work( itau ),
1930 $ work( iwork ), lwork-iwork+1, ierr )
1931 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
1936 CALL dorgqr( m, m, n, u, ldu, work( itau ),
1937 $ work( iwork ), lwork-iwork+1, ierr )
1941 CALL dlacpy(
'U', n, n, a, lda, vt, ldvt )
1943 $
CALL dlaset(
'L', n-1, n-1, zero, zero,
1944 $ vt( 2, 1 ), ldvt )
1953 CALL dgebrd( n, n, vt, ldvt, s, work( ie ),
1954 $ work( itauq ), work( itaup ),
1955 $ work( iwork ), lwork-iwork+1, ierr )
1961 CALL dormbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1962 $ work( itauq ), u, ldu, work( iwork ),
1963 $ lwork-iwork+1, ierr )
1968 CALL dorgbr(
'P', n, n, n, vt, ldvt,
1970 $ work( iwork ), lwork-iwork+1, ierr )
1978 CALL dbdsqr(
'U', n, n, m, 0, s, work( ie ), vt,
1979 $ ldvt, u, ldu, dum, 1, work( iwork ),
2003 CALL dgebrd( m, n, a, lda, s, work( ie ), work( itauq ),
2004 $ work( itaup ), work( iwork ), lwork-iwork+1,
2012 CALL dlacpy(
'L', m, n, a, lda, u, ldu )
2017 CALL dorgbr(
'Q', m, ncu, n, u, ldu, work( itauq ),
2018 $ work( iwork ), lwork-iwork+1, ierr )
2026 CALL dlacpy(
'U', n, n, a, lda, vt, ldvt )
2027 CALL dorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
2028 $ work( iwork ), lwork-iwork+1, ierr )
2036 CALL dorgbr(
'Q', m, n, n, a, lda, work( itauq ),
2037 $ work( iwork ), lwork-iwork+1, ierr )
2045 CALL dorgbr(
'P', n, n, n, a, lda, work( itaup ),
2046 $ work( iwork ), lwork-iwork+1, ierr )
2049 IF( wntuas .OR. wntuo )
2053 IF( wntvas .OR. wntvo )
2057 IF( ( .NOT.wntuo ) .AND. ( .NOT.wntvo ) )
THEN
2064 CALL dbdsqr(
'U', n, ncvt, nru, 0, s, work( ie ), vt,
2065 $ ldvt, u, ldu, dum, 1, work( iwork ), info )
2066 ELSE IF( ( .NOT.wntuo ) .AND. wntvo )
THEN
2073 CALL dbdsqr(
'U', n, ncvt, nru, 0, s, work( ie ), a,
2075 $ u, ldu, dum, 1, work( iwork ), info )
2083 CALL dbdsqr(
'U', n, ncvt, nru, 0, s, work( ie ), vt,
2084 $ ldvt, a, lda, dum, 1, work( iwork ), info )
2095 IF( n.GE.mnthr )
THEN
2108 CALL dgelqf( m, n, a, lda, work( itau ),
2110 $ lwork-iwork+1, ierr )
2114 CALL dlaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ),
2124 CALL dgebrd( m, m, a, lda, s, work( ie ),
2126 $ work( itaup ), work( iwork ), lwork-iwork+1,
2128 IF( wntuo .OR. wntuas )
THEN
2133 CALL dorgbr(
'Q', m, m, m, a, lda, work( itauq ),
2134 $ work( iwork ), lwork-iwork+1, ierr )
2138 IF( wntuo .OR. wntuas )
2145 CALL dbdsqr(
'U', m, 0, nru, 0, s, work( ie ), dum, 1,
2147 $ lda, dum, 1, work( iwork ), info )
2152 $
CALL dlacpy(
'F', m, m, a, lda, u, ldu )
2154 ELSE IF( wntvo .AND. wntun )
THEN
2160 IF( lwork.GE.m*m+max( 4*m, bdspac ) )
THEN
2165 IF( lwork.GE.max( wrkbl, lda*n + m ) + lda*m )
THEN
2172 ELSE IF( lwork.GE.max( wrkbl, lda*n + m ) + m*m )
THEN
2184 chunk = ( lwork-m*m-m ) / m
2187 itau = ir + ldwrkr*m
2193 CALL dgelqf( m, n, a, lda, work( itau ),
2194 $ work( iwork ), lwork-iwork+1, ierr )
2198 CALL dlacpy(
'L', m, m, a, lda, work( ir ),
2200 CALL dlaset(
'U', m-1, m-1, zero, zero,
2201 $ work( ir+ldwrkr ), ldwrkr )
2206 CALL dorglq( m, n, m, a, lda, work( itau ),
2207 $ work( iwork ), lwork-iwork+1, ierr )
2216 CALL dgebrd( m, m, work( ir ), ldwrkr, s,
2218 $ work( itauq ), work( itaup ),
2219 $ work( iwork ), lwork-iwork+1, ierr )
2224 CALL dorgbr(
'P', m, m, m, work( ir ), ldwrkr,
2225 $ work( itaup ), work( iwork ),
2226 $ lwork-iwork+1, ierr )
2233 CALL dbdsqr(
'U', m, m, 0, 0, s, work( ie ),
2234 $ work( ir ), ldwrkr, dum, 1, dum, 1,
2235 $ work( iwork ), info )
2242 DO 30 i = 1, n, chunk
2243 blk = min( n-i+1, chunk )
2244 CALL dgemm(
'N',
'N', m, blk, m, one,
2246 $ ldwrkr, a( 1, i ), lda, zero,
2247 $ work( iu ), ldwrku )
2248 CALL dlacpy(
'F', m, blk, work( iu ), ldwrku,
2264 CALL dgebrd( m, n, a, lda, s, work( ie ),
2265 $ work( itauq ), work( itaup ),
2266 $ work( iwork ), lwork-iwork+1, ierr )
2271 CALL dorgbr(
'P', m, n, m, a, lda, work( itaup ),
2272 $ work( iwork ), lwork-iwork+1, ierr )
2279 CALL dbdsqr(
'L', m, n, 0, 0, s, work( ie ), a,
2281 $ dum, 1, dum, 1, work( iwork ), info )
2285 ELSE IF( wntvo .AND. wntuas )
THEN
2291 IF( lwork.GE.m*m+max( 4*m, bdspac ) )
THEN
2296 IF( lwork.GE.max( wrkbl, lda*n + m ) + lda*m )
THEN
2303 ELSE IF( lwork.GE.max( wrkbl, lda*n + m ) + m*m )
THEN
2315 chunk = ( lwork-m*m-m ) / m
2318 itau = ir + ldwrkr*m
2324 CALL dgelqf( m, n, a, lda, work( itau ),
2325 $ work( iwork ), lwork-iwork+1, ierr )
2329 CALL dlacpy(
'L', m, m, a, lda, u, ldu )
2330 CALL dlaset(
'U', m-1, m-1, zero, zero, u( 1, 2 ),
2336 CALL dorglq( m, n, m, a, lda, work( itau ),
2337 $ work( iwork ), lwork-iwork+1, ierr )
2346 CALL dgebrd( m, m, u, ldu, s, work( ie ),
2347 $ work( itauq ), work( itaup ),
2348 $ work( iwork ), lwork-iwork+1, ierr )
2349 CALL dlacpy(
'U', m, m, u, ldu, work( ir ),
2355 CALL dorgbr(
'P', m, m, m, work( ir ), ldwrkr,
2356 $ work( itaup ), work( iwork ),
2357 $ lwork-iwork+1, ierr )
2362 CALL dorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
2363 $ work( iwork ), lwork-iwork+1, ierr )
2371 CALL dbdsqr(
'U', m, m, m, 0, s, work( ie ),
2372 $ work( ir ), ldwrkr, u, ldu, dum, 1,
2373 $ work( iwork ), info )
2380 DO 40 i = 1, n, chunk
2381 blk = min( n-i+1, chunk )
2382 CALL dgemm(
'N',
'N', m, blk, m, one,
2384 $ ldwrkr, a( 1, i ), lda, zero,
2385 $ work( iu ), ldwrku )
2386 CALL dlacpy(
'F', m, blk, work( iu ), ldwrku,
2400 CALL dgelqf( m, n, a, lda, work( itau ),
2401 $ work( iwork ), lwork-iwork+1, ierr )
2405 CALL dlacpy(
'L', m, m, a, lda, u, ldu )
2406 CALL dlaset(
'U', m-1, m-1, zero, zero, u( 1, 2 ),
2412 CALL dorglq( m, n, m, a, lda, work( itau ),
2413 $ work( iwork ), lwork-iwork+1, ierr )
2422 CALL dgebrd( m, m, u, ldu, s, work( ie ),
2423 $ work( itauq ), work( itaup ),
2424 $ work( iwork ), lwork-iwork+1, ierr )
2429 CALL dormbr(
'P',
'L',
'T', m, n, m, u, ldu,
2430 $ work( itaup ), a, lda, work( iwork ),
2431 $ lwork-iwork+1, ierr )
2436 CALL dorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
2437 $ work( iwork ), lwork-iwork+1, ierr )
2445 CALL dbdsqr(
'U', m, n, m, 0, s, work( ie ), a,
2447 $ u, ldu, dum, 1, work( iwork ), info )
2451 ELSE IF( wntvs )
THEN
2459 IF( lwork.GE.m*m+max( 4*m, bdspac ) )
THEN
2464 IF( lwork.GE.wrkbl+lda*m )
THEN
2475 itau = ir + ldwrkr*m
2481 CALL dgelqf( m, n, a, lda, work( itau ),
2482 $ work( iwork ), lwork-iwork+1, ierr )
2486 CALL dlacpy(
'L', m, m, a, lda, work( ir ),
2488 CALL dlaset(
'U', m-1, m-1, zero, zero,
2489 $ work( ir+ldwrkr ), ldwrkr )
2494 CALL dorglq( m, n, m, a, lda, work( itau ),
2495 $ work( iwork ), lwork-iwork+1, ierr )
2504 CALL dgebrd( m, m, work( ir ), ldwrkr, s,
2505 $ work( ie ), work( itauq ),
2506 $ work( itaup ), work( iwork ),
2507 $ lwork-iwork+1, ierr )
2513 CALL dorgbr(
'P', m, m, m, work( ir ), ldwrkr,
2514 $ work( itaup ), work( iwork ),
2515 $ lwork-iwork+1, ierr )
2522 CALL dbdsqr(
'U', m, m, 0, 0, s, work( ie ),
2523 $ work( ir ), ldwrkr, dum, 1, dum, 1,
2524 $ work( iwork ), info )
2530 CALL dgemm(
'N',
'N', m, n, m, one, work( ir ),
2531 $ ldwrkr, a, lda, zero, vt, ldvt )
2543 CALL dgelqf( m, n, a, lda, work( itau ),
2544 $ work( iwork ), lwork-iwork+1, ierr )
2548 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
2553 CALL dorglq( m, n, m, vt, ldvt, work( itau ),
2554 $ work( iwork ), lwork-iwork+1, ierr )
2562 CALL dlaset(
'U', m-1, m-1, zero, zero, a( 1,
2569 CALL dgebrd( m, m, a, lda, s, work( ie ),
2570 $ work( itauq ), work( itaup ),
2571 $ work( iwork ), lwork-iwork+1, ierr )
2576 CALL dormbr(
'P',
'L',
'T', m, n, m, a, lda,
2577 $ work( itaup ), vt, ldvt,
2578 $ work( iwork ), lwork-iwork+1, ierr )
2585 CALL dbdsqr(
'U', m, n, 0, 0, s, work( ie ), vt,
2586 $ ldvt, dum, 1, dum, 1, work( iwork ),
2591 ELSE IF( wntuo )
THEN
2597 IF( lwork.GE.2*m*m+max( 4*m, bdspac ) )
THEN
2602 IF( lwork.GE.wrkbl+2*lda*m )
THEN
2609 ELSE IF( lwork.GE.wrkbl+( lda + m )*m )
THEN
2624 itau = ir + ldwrkr*m
2630 CALL dgelqf( m, n, a, lda, work( itau ),
2631 $ work( iwork ), lwork-iwork+1, ierr )
2635 CALL dlacpy(
'L', m, m, a, lda, work( iu ),
2637 CALL dlaset(
'U', m-1, m-1, zero, zero,
2638 $ work( iu+ldwrku ), ldwrku )
2643 CALL dorglq( m, n, m, a, lda, work( itau ),
2644 $ work( iwork ), lwork-iwork+1, ierr )
2655 CALL dgebrd( m, m, work( iu ), ldwrku, s,
2656 $ work( ie ), work( itauq ),
2657 $ work( itaup ), work( iwork ),
2658 $ lwork-iwork+1, ierr )
2659 CALL dlacpy(
'L', m, m, work( iu ), ldwrku,
2660 $ work( ir ), ldwrkr )
2666 CALL dorgbr(
'P', m, m, m, work( iu ), ldwrku,
2667 $ work( itaup ), work( iwork ),
2668 $ lwork-iwork+1, ierr )
2673 CALL dorgbr(
'Q', m, m, m, work( ir ), ldwrkr,
2674 $ work( itauq ), work( iwork ),
2675 $ lwork-iwork+1, ierr )
2683 CALL dbdsqr(
'U', m, m, m, 0, s, work( ie ),
2684 $ work( iu ), ldwrku, work( ir ),
2685 $ ldwrkr, dum, 1, work( iwork ), info )
2691 CALL dgemm(
'N',
'N', m, n, m, one, work( iu ),
2692 $ ldwrku, a, lda, zero, vt, ldvt )
2697 CALL dlacpy(
'F', m, m, work( ir ), ldwrkr, a,
2710 CALL dgelqf( m, n, a, lda, work( itau ),
2711 $ work( iwork ), lwork-iwork+1, ierr )
2712 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
2717 CALL dorglq( m, n, m, vt, ldvt, work( itau ),
2718 $ work( iwork ), lwork-iwork+1, ierr )
2726 CALL dlaset(
'U', m-1, m-1, zero, zero, a( 1,
2733 CALL dgebrd( m, m, a, lda, s, work( ie ),
2734 $ work( itauq ), work( itaup ),
2735 $ work( iwork ), lwork-iwork+1, ierr )
2740 CALL dormbr(
'P',
'L',
'T', m, n, m, a, lda,
2741 $ work( itaup ), vt, ldvt,
2742 $ work( iwork ), lwork-iwork+1, ierr )
2747 CALL dorgbr(
'Q', m, m, m, a, lda,
2749 $ work( iwork ), lwork-iwork+1, ierr )
2757 CALL dbdsqr(
'U', m, n, m, 0, s, work( ie ), vt,
2758 $ ldvt, a, lda, dum, 1, work( iwork ),
2763 ELSE IF( wntuas )
THEN
2770 IF( lwork.GE.m*m+max( 4*m, bdspac ) )
THEN
2775 IF( lwork.GE.wrkbl+lda*m )
THEN
2786 itau = iu + ldwrku*m
2792 CALL dgelqf( m, n, a, lda, work( itau ),
2793 $ work( iwork ), lwork-iwork+1, ierr )
2797 CALL dlacpy(
'L', m, m, a, lda, work( iu ),
2799 CALL dlaset(
'U', m-1, m-1, zero, zero,
2800 $ work( iu+ldwrku ), ldwrku )
2805 CALL dorglq( m, n, m, a, lda, work( itau ),
2806 $ work( iwork ), lwork-iwork+1, ierr )
2815 CALL dgebrd( m, m, work( iu ), ldwrku, s,
2816 $ work( ie ), work( itauq ),
2817 $ work( itaup ), work( iwork ),
2818 $ lwork-iwork+1, ierr )
2819 CALL dlacpy(
'L', m, m, work( iu ), ldwrku, u,
2826 CALL dorgbr(
'P', m, m, m, work( iu ), ldwrku,
2827 $ work( itaup ), work( iwork ),
2828 $ lwork-iwork+1, ierr )
2833 CALL dorgbr(
'Q', m, m, m, u, ldu,
2835 $ work( iwork ), lwork-iwork+1, ierr )
2843 CALL dbdsqr(
'U', m, m, m, 0, s, work( ie ),
2844 $ work( iu ), ldwrku, u, ldu, dum, 1,
2845 $ work( iwork ), info )
2851 CALL dgemm(
'N',
'N', m, n, m, one, work( iu ),
2852 $ ldwrku, a, lda, zero, vt, ldvt )
2864 CALL dgelqf( m, n, a, lda, work( itau ),
2865 $ work( iwork ), lwork-iwork+1, ierr )
2866 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
2871 CALL dorglq( m, n, m, vt, ldvt, work( itau ),
2872 $ work( iwork ), lwork-iwork+1, ierr )
2876 CALL dlacpy(
'L', m, m, a, lda, u, ldu )
2877 CALL dlaset(
'U', m-1, m-1, zero, zero, u( 1,
2888 CALL dgebrd( m, m, u, ldu, s, work( ie ),
2889 $ work( itauq ), work( itaup ),
2890 $ work( iwork ), lwork-iwork+1, ierr )
2896 CALL dormbr(
'P',
'L',
'T', m, n, m, u, ldu,
2897 $ work( itaup ), vt, ldvt,
2898 $ work( iwork ), lwork-iwork+1, ierr )
2903 CALL dorgbr(
'Q', m, m, m, u, ldu,
2905 $ work( iwork ), lwork-iwork+1, ierr )
2913 CALL dbdsqr(
'U', m, n, m, 0, s, work( ie ), vt,
2914 $ ldvt, u, ldu, dum, 1, work( iwork ),
2921 ELSE IF( wntva )
THEN
2929 IF( lwork.GE.m*m+max( n + m, 4*m, bdspac ) )
THEN
2934 IF( lwork.GE.wrkbl+lda*m )
THEN
2945 itau = ir + ldwrkr*m
2951 CALL dgelqf( m, n, a, lda, work( itau ),
2952 $ work( iwork ), lwork-iwork+1, ierr )
2953 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
2957 CALL dlacpy(
'L', m, m, a, lda, work( ir ),
2959 CALL dlaset(
'U', m-1, m-1, zero, zero,
2960 $ work( ir+ldwrkr ), ldwrkr )
2965 CALL dorglq( n, n, m, vt, ldvt, work( itau ),
2966 $ work( iwork ), lwork-iwork+1, ierr )
2975 CALL dgebrd( m, m, work( ir ), ldwrkr, s,
2976 $ work( ie ), work( itauq ),
2977 $ work( itaup ), work( iwork ),
2978 $ lwork-iwork+1, ierr )
2984 CALL dorgbr(
'P', m, m, m, work( ir ), ldwrkr,
2985 $ work( itaup ), work( iwork ),
2986 $ lwork-iwork+1, ierr )
2993 CALL dbdsqr(
'U', m, m, 0, 0, s, work( ie ),
2994 $ work( ir ), ldwrkr, dum, 1, dum, 1,
2995 $ work( iwork ), info )
3001 CALL dgemm(
'N',
'N', m, n, m, one, work( ir ),
3002 $ ldwrkr, vt, ldvt, zero, a, lda )
3006 CALL dlacpy(
'F', m, n, a, lda, vt, ldvt )
3018 CALL dgelqf( m, n, a, lda, work( itau ),
3019 $ work( iwork ), lwork-iwork+1, ierr )
3020 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
3025 CALL dorglq( n, n, m, vt, ldvt, work( itau ),
3026 $ work( iwork ), lwork-iwork+1, ierr )
3034 CALL dlaset(
'U', m-1, m-1, zero, zero, a( 1,
3041 CALL dgebrd( m, m, a, lda, s, work( ie ),
3042 $ work( itauq ), work( itaup ),
3043 $ work( iwork ), lwork-iwork+1, ierr )
3049 CALL dormbr(
'P',
'L',
'T', m, n, m, a, lda,
3050 $ work( itaup ), vt, ldvt,
3051 $ work( iwork ), lwork-iwork+1, ierr )
3058 CALL dbdsqr(
'U', m, n, 0, 0, s, work( ie ), vt,
3059 $ ldvt, dum, 1, dum, 1, work( iwork ),
3064 ELSE IF( wntuo )
THEN
3070 IF( lwork.GE.2*m*m+max( n + m, 4*m, bdspac ) )
THEN
3075 IF( lwork.GE.wrkbl+2*lda*m )
THEN
3082 ELSE IF( lwork.GE.wrkbl+( lda + m )*m )
THEN
3097 itau = ir + ldwrkr*m
3103 CALL dgelqf( m, n, a, lda, work( itau ),
3104 $ work( iwork ), lwork-iwork+1, ierr )
3105 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
3110 CALL dorglq( n, n, m, vt, ldvt, work( itau ),
3111 $ work( iwork ), lwork-iwork+1, ierr )
3115 CALL dlacpy(
'L', m, m, a, lda, work( iu ),
3117 CALL dlaset(
'U', m-1, m-1, zero, zero,
3118 $ work( iu+ldwrku ), ldwrku )
3129 CALL dgebrd( m, m, work( iu ), ldwrku, s,
3130 $ work( ie ), work( itauq ),
3131 $ work( itaup ), work( iwork ),
3132 $ lwork-iwork+1, ierr )
3133 CALL dlacpy(
'L', m, m, work( iu ), ldwrku,
3134 $ work( ir ), ldwrkr )
3140 CALL dorgbr(
'P', m, m, m, work( iu ), ldwrku,
3141 $ work( itaup ), work( iwork ),
3142 $ lwork-iwork+1, ierr )
3147 CALL dorgbr(
'Q', m, m, m, work( ir ), ldwrkr,
3148 $ work( itauq ), work( iwork ),
3149 $ lwork-iwork+1, ierr )
3157 CALL dbdsqr(
'U', m, m, m, 0, s, work( ie ),
3158 $ work( iu ), ldwrku, work( ir ),
3159 $ ldwrkr, dum, 1, work( iwork ), info )
3165 CALL dgemm(
'N',
'N', m, n, m, one, work( iu ),
3166 $ ldwrku, vt, ldvt, zero, a, lda )
3170 CALL dlacpy(
'F', m, n, a, lda, vt, ldvt )
3174 CALL dlacpy(
'F', m, m, work( ir ), ldwrkr, a,
3187 CALL dgelqf( m, n, a, lda, work( itau ),
3188 $ work( iwork ), lwork-iwork+1, ierr )
3189 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
3194 CALL dorglq( n, n, m, vt, ldvt, work( itau ),
3195 $ work( iwork ), lwork-iwork+1, ierr )
3203 CALL dlaset(
'U', m-1, m-1, zero, zero, a( 1,
3210 CALL dgebrd( m, m, a, lda, s, work( ie ),
3211 $ work( itauq ), work( itaup ),
3212 $ work( iwork ), lwork-iwork+1, ierr )
3218 CALL dormbr(
'P',
'L',
'T', m, n, m, a, lda,
3219 $ work( itaup ), vt, ldvt,
3220 $ work( iwork ), lwork-iwork+1, ierr )
3225 CALL dorgbr(
'Q', m, m, m, a, lda,
3227 $ work( iwork ), lwork-iwork+1, ierr )
3235 CALL dbdsqr(
'U', m, n, m, 0, s, work( ie ), vt,
3236 $ ldvt, a, lda, dum, 1, work( iwork ),
3241 ELSE IF( wntuas )
THEN
3248 IF( lwork.GE.m*m+max( n + m, 4*m, bdspac ) )
THEN
3253 IF( lwork.GE.wrkbl+lda*m )
THEN
3264 itau = iu + ldwrku*m
3270 CALL dgelqf( m, n, a, lda, work( itau ),
3271 $ work( iwork ), lwork-iwork+1, ierr )
3272 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
3277 CALL dorglq( n, n, m, vt, ldvt, work( itau ),
3278 $ work( iwork ), lwork-iwork+1, ierr )
3282 CALL dlacpy(
'L', m, m, a, lda, work( iu ),
3284 CALL dlaset(
'U', m-1, m-1, zero, zero,
3285 $ work( iu+ldwrku ), ldwrku )
3294 CALL dgebrd( m, m, work( iu ), ldwrku, s,
3295 $ work( ie ), work( itauq ),
3296 $ work( itaup ), work( iwork ),
3297 $ lwork-iwork+1, ierr )
3298 CALL dlacpy(
'L', m, m, work( iu ), ldwrku, u,
3304 CALL dorgbr(
'P', m, m, m, work( iu ), ldwrku,
3305 $ work( itaup ), work( iwork ),
3306 $ lwork-iwork+1, ierr )
3311 CALL dorgbr(
'Q', m, m, m, u, ldu,
3313 $ work( iwork ), lwork-iwork+1, ierr )
3321 CALL dbdsqr(
'U', m, m, m, 0, s, work( ie ),
3322 $ work( iu ), ldwrku, u, ldu, dum, 1,
3323 $ work( iwork ), info )
3329 CALL dgemm(
'N',
'N', m, n, m, one, work( iu ),
3330 $ ldwrku, vt, ldvt, zero, a, lda )
3334 CALL dlacpy(
'F', m, n, a, lda, vt, ldvt )
3346 CALL dgelqf( m, n, a, lda, work( itau ),
3347 $ work( iwork ), lwork-iwork+1, ierr )
3348 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
3353 CALL dorglq( n, n, m, vt, ldvt, work( itau ),
3354 $ work( iwork ), lwork-iwork+1, ierr )
3358 CALL dlacpy(
'L', m, m, a, lda, u, ldu )
3359 CALL dlaset(
'U', m-1, m-1, zero, zero, u( 1,
3370 CALL dgebrd( m, m, u, ldu, s, work( ie ),
3371 $ work( itauq ), work( itaup ),
3372 $ work( iwork ), lwork-iwork+1, ierr )
3378 CALL dormbr(
'P',
'L',
'T', m, n, m, u, ldu,
3379 $ work( itaup ), vt, ldvt,
3380 $ work( iwork ), lwork-iwork+1, ierr )
3385 CALL dorgbr(
'Q', m, m, m, u, ldu,
3387 $ work( iwork ), lwork-iwork+1, ierr )
3395 CALL dbdsqr(
'U', m, n, m, 0, s, work( ie ), vt,
3396 $ ldvt, u, ldu, dum, 1, work( iwork ),
3420 CALL dgebrd( m, n, a, lda, s, work( ie ), work( itauq ),
3421 $ work( itaup ), work( iwork ), lwork-iwork+1,
3429 CALL dlacpy(
'L', m, m, a, lda, u, ldu )
3430 CALL dorgbr(
'Q', m, m, n, u, ldu, work( itauq ),
3431 $ work( iwork ), lwork-iwork+1, ierr )
3439 CALL dlacpy(
'U', m, n, a, lda, vt, ldvt )
3444 CALL dorgbr(
'P', nrvt, n, m, vt, ldvt, work( itaup ),
3445 $ work( iwork ), lwork-iwork+1, ierr )
3453 CALL dorgbr(
'Q', m, m, n, a, lda, work( itauq ),
3454 $ work( iwork ), lwork-iwork+1, ierr )
3462 CALL dorgbr(
'P', m, n, m, a, lda, work( itaup ),
3463 $ work( iwork ), lwork-iwork+1, ierr )
3466 IF( wntuas .OR. wntuo )
3470 IF( wntvas .OR. wntvo )
3474 IF( ( .NOT.wntuo ) .AND. ( .NOT.wntvo ) )
THEN
3481 CALL dbdsqr(
'L', m, ncvt, nru, 0, s, work( ie ), vt,
3482 $ ldvt, u, ldu, dum, 1, work( iwork ), info )
3483 ELSE IF( ( .NOT.wntuo ) .AND. wntvo )
THEN
3490 CALL dbdsqr(
'L', m, ncvt, nru, 0, s, work( ie ), a,
3492 $ u, ldu, dum, 1, work( iwork ), info )
3500 CALL dbdsqr(
'L', m, ncvt, nru, 0, s, work( ie ), vt,
3501 $ ldvt, a, lda, dum, 1, work( iwork ), info )
3511 IF( info.NE.0 )
THEN
3513 DO 50 i = 1, minmn - 1
3514 work( i+1 ) = work( i+ie-1 )
3518 DO 60 i = minmn - 1, 1, -1
3519 work( i+1 ) = work( i+ie-1 )
3526 IF( iscl.EQ.1 )
THEN
3527 IF( anrm.GT.bignum )
3528 $
CALL dlascl(
'G', 0, 0, bignum, anrm, minmn, 1, s, minmn,
3530 IF( info.NE.0 .AND. anrm.GT.bignum )
3531 $
CALL dlascl(
'G', 0, 0, bignum, anrm, minmn-1, 1,
3534 IF( anrm.LT.smlnum )
3535 $
CALL dlascl(
'G', 0, 0, smlnum, anrm, minmn, 1, s, minmn,
3537 IF( info.NE.0 .AND. anrm.LT.smlnum )
3538 $
CALL dlascl(
'G', 0, 0, smlnum, anrm, minmn-1, 1,