227 SUBROUTINE zgesdd( JOBZ, M, N, A, LDA, S, U, LDU, VT, LDVT,
228 $ work, lwork, rwork, iwork, info )
238 INTEGER INFO, LDA, LDU, LDVT, LWORK, M, N
242 DOUBLE PRECISION RWORK( * ), S( * )
243 COMPLEX*16 A( lda, * ), U( ldu, * ), VT( ldvt, * ),
250 COMPLEX*16 CZERO, CONE
251 parameter ( czero = ( 0.0d+0, 0.0d+0 ),
252 $ cone = ( 1.0d+0, 0.0d+0 ) )
253 DOUBLE PRECISION ZERO, ONE
254 parameter ( zero = 0.0d+0, one = 1.0d+0 )
257 LOGICAL LQUERY, WNTQA, WNTQAS, WNTQN, WNTQO, WNTQS
258 INTEGER BLK, CHUNK, I, IE, IERR, IL, IR, IRU, IRVT,
259 $ iscl, itau, itaup, itauq, iu, ivt, ldwkvt,
260 $ ldwrkl, ldwrkr, ldwrku, maxwrk, minmn, minwrk,
261 $ mnthr1, mnthr2, nrwork, nwork, wrkbl
262 INTEGER LWORK_ZGEBRD_MN, LWORK_ZGEBRD_MM,
263 $ lwork_zgebrd_nn, lwork_zgelqf_mn,
265 $ lwork_zungbr_p_mn, lwork_zungbr_p_nn,
266 $ lwork_zungbr_q_mn, lwork_zungbr_q_mm,
267 $ lwork_zunglq_mn, lwork_zunglq_nn,
268 $ lwork_zungqr_mm, lwork_zungqr_mn,
269 $ lwork_zunmbr_prc_mm, lwork_zunmbr_qln_mm,
270 $ lwork_zunmbr_prc_mn, lwork_zunmbr_qln_mn,
271 $ lwork_zunmbr_prc_nn, lwork_zunmbr_qln_nn
272 DOUBLE PRECISION ANRM, BIGNUM, EPS, SMLNUM
276 DOUBLE PRECISION DUM( 1 )
286 DOUBLE PRECISION DLAMCH, ZLANGE
287 EXTERNAL lsame, dlamch, zlange
290 INTRINSIC int, max, min, sqrt
298 mnthr1 = int( minmn*17.0d0 / 9.0d0 )
299 mnthr2 = int( minmn*5.0d0 / 3.0d0 )
300 wntqa = lsame( jobz,
'A' )
301 wntqs = lsame( jobz,
'S' )
302 wntqas = wntqa .OR. wntqs
303 wntqo = lsame( jobz,
'O' )
304 wntqn = lsame( jobz,
'N' )
305 lquery = ( lwork.EQ.-1 )
309 IF( .NOT.( wntqa .OR. wntqs .OR. wntqo .OR. wntqn ) )
THEN
311 ELSE IF( m.LT.0 )
THEN
313 ELSE IF( n.LT.0 )
THEN
315 ELSE IF( lda.LT.max( 1, m ) )
THEN
317 ELSE IF( ldu.LT.1 .OR. ( wntqas .AND. ldu.LT.m ) .OR.
318 $ ( wntqo .AND. m.LT.n .AND. ldu.LT.m ) )
THEN
320 ELSE IF( ldvt.LT.1 .OR. ( wntqa .AND. ldvt.LT.n ) .OR.
321 $ ( wntqs .AND. ldvt.LT.minmn ) .OR.
322 $ ( wntqo .AND. m.GE.n .AND. ldvt.LT.n ) )
THEN
334 IF( info.EQ.0 .AND. m.GT.0 .AND. n.GT.0 )
THEN
344 CALL zgebrd( m, n, cdum(1), m, dum(1), dum(1), cdum(1),
345 $ cdum(1), cdum(1), -1, ierr )
346 lwork_zgebrd_mn = int( cdum(1) )
348 CALL zgebrd( n, n, cdum(1), n, dum(1), dum(1), cdum(1),
349 $ cdum(1), cdum(1), -1, ierr )
350 lwork_zgebrd_nn = int( cdum(1) )
352 CALL zgeqrf( m, n, cdum(1), m, cdum(1), cdum(1), -1, ierr )
353 lwork_zgeqrf_mn = int( cdum(1) )
355 CALL zungbr(
'P', n, n, n, cdum(1), n, cdum(1), cdum(1),
357 lwork_zungbr_p_nn = int( cdum(1) )
359 CALL zungbr(
'Q', m, m, n, cdum(1), m, cdum(1), cdum(1),
361 lwork_zungbr_q_mm = int( cdum(1) )
363 CALL zungbr(
'Q', m, n, n, cdum(1), m, cdum(1), cdum(1),
365 lwork_zungbr_q_mn = int( cdum(1) )
367 CALL zungqr( m, m, n, cdum(1), m, cdum(1), cdum(1),
369 lwork_zungqr_mm = int( cdum(1) )
371 CALL zungqr( m, n, n, cdum(1), m, cdum(1), cdum(1),
373 lwork_zungqr_mn = int( cdum(1) )
375 CALL zunmbr(
'P',
'R',
'C', n, n, n, cdum(1), n, cdum(1),
376 $ cdum(1), n, cdum(1), -1, ierr )
377 lwork_zunmbr_prc_nn = int( cdum(1) )
379 CALL zunmbr(
'Q',
'L',
'N', m, m, n, cdum(1), m, cdum(1),
380 $ cdum(1), m, cdum(1), -1, ierr )
381 lwork_zunmbr_qln_mm = int( cdum(1) )
383 CALL zunmbr(
'Q',
'L',
'N', m, n, n, cdum(1), m, cdum(1),
384 $ cdum(1), m, cdum(1), -1, ierr )
385 lwork_zunmbr_qln_mn = int( cdum(1) )
387 CALL zunmbr(
'Q',
'L',
'N', n, n, n, cdum(1), n, cdum(1),
388 $ cdum(1), n, cdum(1), -1, ierr )
389 lwork_zunmbr_qln_nn = int( cdum(1) )
391 IF( m.GE.mnthr1 )
THEN
396 maxwrk = n + lwork_zgeqrf_mn
397 maxwrk = max( maxwrk, 2*n + lwork_zgebrd_nn )
399 ELSE IF( wntqo )
THEN
403 wrkbl = n + lwork_zgeqrf_mn
404 wrkbl = max( wrkbl, n + lwork_zungqr_mn )
405 wrkbl = max( wrkbl, 2*n + lwork_zgebrd_nn )
406 wrkbl = max( wrkbl, 2*n + lwork_zunmbr_qln_nn )
407 wrkbl = max( wrkbl, 2*n + lwork_zunmbr_prc_nn )
408 maxwrk = m*n + n*n + wrkbl
410 ELSE IF( wntqs )
THEN
414 wrkbl = n + lwork_zgeqrf_mn
415 wrkbl = max( wrkbl, n + lwork_zungqr_mn )
416 wrkbl = max( wrkbl, 2*n + lwork_zgebrd_nn )
417 wrkbl = max( wrkbl, 2*n + lwork_zunmbr_qln_nn )
418 wrkbl = max( wrkbl, 2*n + lwork_zunmbr_prc_nn )
421 ELSE IF( wntqa )
THEN
425 wrkbl = n + lwork_zgeqrf_mn
426 wrkbl = max( wrkbl, n + lwork_zungqr_mm )
427 wrkbl = max( wrkbl, 2*n + lwork_zgebrd_nn )
428 wrkbl = max( wrkbl, 2*n + lwork_zunmbr_qln_nn )
429 wrkbl = max( wrkbl, 2*n + lwork_zunmbr_prc_nn )
431 minwrk = n*n + max( 3*n, n + m )
433 ELSE IF( m.GE.mnthr2 )
THEN
437 maxwrk = 2*n + lwork_zgebrd_mn
441 maxwrk = max( maxwrk, 2*n + lwork_zungbr_p_nn )
442 maxwrk = max( maxwrk, 2*n + lwork_zungbr_q_mn )
443 maxwrk = maxwrk + m*n
444 minwrk = minwrk + n*n
445 ELSE IF( wntqs )
THEN
447 maxwrk = max( maxwrk, 2*n + lwork_zungbr_p_nn )
448 maxwrk = max( maxwrk, 2*n + lwork_zungbr_q_mn )
449 ELSE IF( wntqa )
THEN
451 maxwrk = max( maxwrk, 2*n + lwork_zungbr_p_nn )
452 maxwrk = max( maxwrk, 2*n + lwork_zungbr_q_mm )
458 maxwrk = 2*n + lwork_zgebrd_mn
462 maxwrk = max( maxwrk, 2*n + lwork_zunmbr_prc_nn )
463 maxwrk = max( maxwrk, 2*n + lwork_zunmbr_qln_mn )
464 maxwrk = maxwrk + m*n
465 minwrk = minwrk + n*n
466 ELSE IF( wntqs )
THEN
468 maxwrk = max( maxwrk, 2*n + lwork_zunmbr_qln_mn )
469 maxwrk = max( maxwrk, 2*n + lwork_zunmbr_prc_nn )
470 ELSE IF( wntqa )
THEN
472 maxwrk = max( maxwrk, 2*n + lwork_zunmbr_qln_mm )
473 maxwrk = max( maxwrk, 2*n + lwork_zunmbr_prc_nn )
485 CALL zgebrd( m, n, cdum(1), m, dum(1), dum(1), cdum(1),
486 $ cdum(1), cdum(1), -1, ierr )
487 lwork_zgebrd_mn = int( cdum(1) )
489 CALL zgebrd( m, m, cdum(1), m, dum(1), dum(1), cdum(1),
490 $ cdum(1), cdum(1), -1, ierr )
491 lwork_zgebrd_mm = int( cdum(1) )
493 CALL zgelqf( m, n, cdum(1), m, cdum(1), cdum(1), -1, ierr )
494 lwork_zgelqf_mn = int( cdum(1) )
496 CALL zungbr(
'P', m, n, m, cdum(1), m, cdum(1), cdum(1),
498 lwork_zungbr_p_mn = int( cdum(1) )
500 CALL zungbr(
'P', n, n, m, cdum(1), n, cdum(1), cdum(1),
502 lwork_zungbr_p_nn = int( cdum(1) )
504 CALL zungbr(
'Q', m, m, n, cdum(1), m, cdum(1), cdum(1),
506 lwork_zungbr_q_mm = int( cdum(1) )
508 CALL zunglq( m, n, m, cdum(1), m, cdum(1), cdum(1),
510 lwork_zunglq_mn = int( cdum(1) )
512 CALL zunglq( n, n, m, cdum(1), n, cdum(1), cdum(1),
514 lwork_zunglq_nn = int( cdum(1) )
516 CALL zunmbr(
'P',
'R',
'C', m, m, m, cdum(1), m, cdum(1),
517 $ cdum(1), m, cdum(1), -1, ierr )
518 lwork_zunmbr_prc_mm = int( cdum(1) )
520 CALL zunmbr(
'P',
'R',
'C', m, n, m, cdum(1), m, cdum(1),
521 $ cdum(1), m, cdum(1), -1, ierr )
522 lwork_zunmbr_prc_mn = int( cdum(1) )
524 CALL zunmbr(
'P',
'R',
'C', n, n, m, cdum(1), n, cdum(1),
525 $ cdum(1), n, cdum(1), -1, ierr )
526 lwork_zunmbr_prc_nn = int( cdum(1) )
528 CALL zunmbr(
'Q',
'L',
'N', m, m, m, cdum(1), m, cdum(1),
529 $ cdum(1), m, cdum(1), -1, ierr )
530 lwork_zunmbr_qln_mm = int( cdum(1) )
532 IF( n.GE.mnthr1 )
THEN
537 maxwrk = m + lwork_zgelqf_mn
538 maxwrk = max( maxwrk, 2*m + lwork_zgebrd_mm )
540 ELSE IF( wntqo )
THEN
544 wrkbl = m + lwork_zgelqf_mn
545 wrkbl = max( wrkbl, m + lwork_zunglq_mn )
546 wrkbl = max( wrkbl, 2*m + lwork_zgebrd_mm )
547 wrkbl = max( wrkbl, 2*m + lwork_zunmbr_qln_mm )
548 wrkbl = max( wrkbl, 2*m + lwork_zunmbr_prc_mm )
549 maxwrk = m*n + m*m + wrkbl
551 ELSE IF( wntqs )
THEN
555 wrkbl = m + lwork_zgelqf_mn
556 wrkbl = max( wrkbl, m + lwork_zunglq_mn )
557 wrkbl = max( wrkbl, 2*m + lwork_zgebrd_mm )
558 wrkbl = max( wrkbl, 2*m + lwork_zunmbr_qln_mm )
559 wrkbl = max( wrkbl, 2*m + lwork_zunmbr_prc_mm )
562 ELSE IF( wntqa )
THEN
566 wrkbl = m + lwork_zgelqf_mn
567 wrkbl = max( wrkbl, m + lwork_zunglq_nn )
568 wrkbl = max( wrkbl, 2*m + lwork_zgebrd_mm )
569 wrkbl = max( wrkbl, 2*m + lwork_zunmbr_qln_mm )
570 wrkbl = max( wrkbl, 2*m + lwork_zunmbr_prc_mm )
572 minwrk = m*m + max( 3*m, m + n )
574 ELSE IF( n.GE.mnthr2 )
THEN
578 maxwrk = 2*m + lwork_zgebrd_mn
582 maxwrk = max( maxwrk, 2*m + lwork_zungbr_q_mm )
583 maxwrk = max( maxwrk, 2*m + lwork_zungbr_p_mn )
584 maxwrk = maxwrk + m*n
585 minwrk = minwrk + m*m
586 ELSE IF( wntqs )
THEN
588 maxwrk = max( maxwrk, 2*m + lwork_zungbr_q_mm )
589 maxwrk = max( maxwrk, 2*m + lwork_zungbr_p_mn )
590 ELSE IF( wntqa )
THEN
592 maxwrk = max( maxwrk, 2*m + lwork_zungbr_q_mm )
593 maxwrk = max( maxwrk, 2*m + lwork_zungbr_p_nn )
599 maxwrk = 2*m + lwork_zgebrd_mn
603 maxwrk = max( maxwrk, 2*m + lwork_zunmbr_qln_mm )
604 maxwrk = max( maxwrk, 2*m + lwork_zunmbr_prc_mn )
605 maxwrk = maxwrk + m*n
606 minwrk = minwrk + m*m
607 ELSE IF( wntqs )
THEN
609 maxwrk = max( maxwrk, 2*m + lwork_zunmbr_qln_mm )
610 maxwrk = max( maxwrk, 2*m + lwork_zunmbr_prc_mn )
611 ELSE IF( wntqa )
THEN
613 maxwrk = max( maxwrk, 2*m + lwork_zunmbr_qln_mm )
614 maxwrk = max( maxwrk, 2*m + lwork_zunmbr_prc_nn )
618 maxwrk = max( maxwrk, minwrk )
622 IF( lwork.LT.minwrk .AND. .NOT. lquery )
THEN
628 CALL xerbla(
'ZGESDD', -info )
630 ELSE IF( lquery )
THEN
636 IF( m.EQ.0 .OR. n.EQ.0 )
THEN
643 smlnum = sqrt( dlamch(
'S' ) ) / eps
644 bignum = one / smlnum
648 anrm = zlange(
'M', m, n, a, lda, dum )
650 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
652 CALL zlascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, ierr )
653 ELSE IF( anrm.GT.bignum )
THEN
655 CALL zlascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, ierr )
664 IF( m.GE.mnthr1 )
THEN
679 CALL zgeqrf( m, n, a, lda, work( itau ), work( nwork ),
680 $ lwork-nwork+1, ierr )
684 CALL zlaset(
'L', n-1, n-1, czero, czero, a( 2, 1 ),
696 CALL zgebrd( n, n, a, lda, s, rwork( ie ), work( itauq ),
697 $ work( itaup ), work( nwork ), lwork-nwork+1,
705 CALL dbdsdc(
'U',
'N', n, s, rwork( ie ), dum,1,dum,1,
706 $ dum, idum, rwork( nrwork ), iwork, info )
708 ELSE IF( wntqo )
THEN
720 IF( lwork .GE. m*n + n*n + 3*n )
THEN
726 ldwrkr = ( lwork - n*n - 3*n ) / n
736 CALL zgeqrf( m, n, a, lda, work( itau ), work( nwork ),
737 $ lwork-nwork+1, ierr )
741 CALL zlacpy(
'U', n, n, a, lda, work( ir ), ldwrkr )
742 CALL zlaset(
'L', n-1, n-1, czero, czero, work( ir+1 ),
750 CALL zungqr( m, n, n, a, lda, work( itau ),
751 $ work( nwork ), lwork-nwork+1, ierr )
762 CALL zgebrd( n, n, work( ir ), ldwrkr, s, rwork( ie ),
763 $ work( itauq ), work( itaup ), work( nwork ),
764 $ lwork-nwork+1, ierr )
775 CALL dbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
776 $ n, rwork( irvt ), n, dum, idum,
777 $ rwork( nrwork ), iwork, info )
785 CALL zlacp2(
'F', n, n, rwork( iru ), n, work( iu ),
787 CALL zunmbr(
'Q',
'L',
'N', n, n, n, work( ir ), ldwrkr,
788 $ work( itauq ), work( iu ), ldwrku,
789 $ work( nwork ), lwork-nwork+1, ierr )
797 CALL zlacp2(
'F', n, n, rwork( irvt ), n, vt, ldvt )
798 CALL zunmbr(
'P',
'R',
'C', n, n, n, work( ir ), ldwrkr,
799 $ work( itaup ), vt, ldvt, work( nwork ),
800 $ lwork-nwork+1, ierr )
808 DO 10 i = 1, m, ldwrkr
809 chunk = min( m-i+1, ldwrkr )
810 CALL zgemm(
'N',
'N', chunk, n, n, cone, a( i, 1 ),
811 $ lda, work( iu ), ldwrku, czero,
812 $ work( ir ), ldwrkr )
813 CALL zlacpy(
'F', chunk, n, work( ir ), ldwrkr,
817 ELSE IF( wntqs )
THEN
836 CALL zgeqrf( m, n, a, lda, work( itau ), work( nwork ),
837 $ lwork-nwork+1, ierr )
841 CALL zlacpy(
'U', n, n, a, lda, work( ir ), ldwrkr )
842 CALL zlaset(
'L', n-1, n-1, czero, czero, work( ir+1 ),
850 CALL zungqr( m, n, n, a, lda, work( itau ),
851 $ work( nwork ), lwork-nwork+1, ierr )
862 CALL zgebrd( n, n, work( ir ), ldwrkr, s, rwork( ie ),
863 $ work( itauq ), work( itaup ), work( nwork ),
864 $ lwork-nwork+1, ierr )
875 CALL dbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
876 $ n, rwork( irvt ), n, dum, idum,
877 $ rwork( nrwork ), iwork, info )
885 CALL zlacp2(
'F', n, n, rwork( iru ), n, u, ldu )
886 CALL zunmbr(
'Q',
'L',
'N', n, n, n, work( ir ), ldwrkr,
887 $ work( itauq ), u, ldu, work( nwork ),
888 $ lwork-nwork+1, ierr )
896 CALL zlacp2(
'F', n, n, rwork( irvt ), n, vt, ldvt )
897 CALL zunmbr(
'P',
'R',
'C', n, n, n, work( ir ), ldwrkr,
898 $ work( itaup ), vt, ldvt, work( nwork ),
899 $ lwork-nwork+1, ierr )
906 CALL zlacpy(
'F', n, n, u, ldu, work( ir ), ldwrkr )
907 CALL zgemm(
'N',
'N', m, n, n, cone, a, lda, work( ir ),
908 $ ldwrkr, czero, u, ldu )
910 ELSE IF( wntqa )
THEN
929 CALL zgeqrf( m, n, a, lda, work( itau ), work( nwork ),
930 $ lwork-nwork+1, ierr )
931 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
938 CALL zungqr( m, m, n, u, ldu, work( itau ),
939 $ work( nwork ), lwork-nwork+1, ierr )
943 CALL zlaset(
'L', n-1, n-1, czero, czero, a( 2, 1 ),
955 CALL zgebrd( n, n, a, lda, s, rwork( ie ), work( itauq ),
956 $ work( itaup ), work( nwork ), lwork-nwork+1,
968 CALL dbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
969 $ n, rwork( irvt ), n, dum, idum,
970 $ rwork( nrwork ), iwork, info )
978 CALL zlacp2(
'F', n, n, rwork( iru ), n, work( iu ),
980 CALL zunmbr(
'Q',
'L',
'N', n, n, n, a, lda,
981 $ work( itauq ), work( iu ), ldwrku,
982 $ work( nwork ), lwork-nwork+1, ierr )
990 CALL zlacp2(
'F', n, n, rwork( irvt ), n, vt, ldvt )
991 CALL zunmbr(
'P',
'R',
'C', n, n, n, a, lda,
992 $ work( itaup ), vt, ldvt, work( nwork ),
993 $ lwork-nwork+1, ierr )
1000 CALL zgemm(
'N',
'N', m, n, n, cone, u, ldu, work( iu ),
1001 $ ldwrku, czero, a, lda )
1005 CALL zlacpy(
'F', m, n, a, lda, u, ldu )
1009 ELSE IF( m.GE.mnthr2 )
THEN
1028 CALL zgebrd( m, n, a, lda, s, rwork( ie ), work( itauq ),
1029 $ work( itaup ), work( nwork ), lwork-nwork+1,
1038 CALL dbdsdc(
'U',
'N', n, s, rwork( ie ), dum, 1,dum,1,
1039 $ dum, idum, rwork( nrwork ), iwork, info )
1040 ELSE IF( wntqo )
THEN
1052 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
1053 CALL zungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1054 $ work( nwork ), lwork-nwork+1, ierr )
1061 CALL zungbr(
'Q', m, n, n, a, lda, work( itauq ),
1062 $ work( nwork ), lwork-nwork+1, ierr )
1064 IF( lwork .GE. m*n + 3*n )
THEN
1073 ldwrku = ( lwork - 3*n ) / n
1075 nwork = iu + ldwrku*n
1083 CALL dbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
1084 $ n, rwork( irvt ), n, dum, idum,
1085 $ rwork( nrwork ), iwork, info )
1092 CALL zlarcm( n, n, rwork( irvt ), n, vt, ldvt,
1093 $ work( iu ), ldwrku, rwork( nrwork ) )
1094 CALL zlacpy(
'F', n, n, work( iu ), ldwrku, vt, ldvt )
1104 DO 20 i = 1, m, ldwrku
1105 chunk = min( m-i+1, ldwrku )
1106 CALL zlacrm( chunk, n, a( i, 1 ), lda, rwork( iru ),
1107 $ n, work( iu ), ldwrku, rwork( nrwork ) )
1108 CALL zlacpy(
'F', chunk, n, work( iu ), ldwrku,
1112 ELSE IF( wntqs )
THEN
1120 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
1121 CALL zungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1122 $ work( nwork ), lwork-nwork+1, ierr )
1129 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1130 CALL zungbr(
'Q', m, n, n, u, ldu, work( itauq ),
1131 $ work( nwork ), lwork-nwork+1, ierr )
1142 CALL dbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
1143 $ n, rwork( irvt ), n, dum, idum,
1144 $ rwork( nrwork ), iwork, info )
1151 CALL zlarcm( n, n, rwork( irvt ), n, vt, ldvt, a, lda,
1153 CALL zlacpy(
'F', n, n, a, lda, vt, ldvt )
1161 CALL zlacrm( m, n, u, ldu, rwork( iru ), n, a, lda,
1163 CALL zlacpy(
'F', m, n, a, lda, u, ldu )
1172 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
1173 CALL zungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1174 $ work( nwork ), lwork-nwork+1, ierr )
1181 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1182 CALL zungbr(
'Q', m, m, n, u, ldu, work( itauq ),
1183 $ work( nwork ), lwork-nwork+1, ierr )
1194 CALL dbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
1195 $ n, rwork( irvt ), n, dum, idum,
1196 $ rwork( nrwork ), iwork, info )
1203 CALL zlarcm( n, n, rwork( irvt ), n, vt, ldvt, a, lda,
1205 CALL zlacpy(
'F', n, n, a, lda, vt, ldvt )
1213 CALL zlacrm( m, n, u, ldu, rwork( iru ), n, a, lda,
1215 CALL zlacpy(
'F', m, n, a, lda, u, ldu )
1237 CALL zgebrd( m, n, a, lda, s, rwork( ie ), work( itauq ),
1238 $ work( itaup ), work( nwork ), lwork-nwork+1,
1247 CALL dbdsdc(
'U',
'N', n, s, rwork( ie ), dum,1,dum,1,
1248 $ dum, idum, rwork( nrwork ), iwork, info )
1249 ELSE IF( wntqo )
THEN
1254 IF( lwork .GE. m*n + 3*n )
THEN
1263 ldwrku = ( lwork - 3*n ) / n
1265 nwork = iu + ldwrku*n
1274 CALL dbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
1275 $ n, rwork( irvt ), n, dum, idum,
1276 $ rwork( nrwork ), iwork, info )
1284 CALL zlacp2(
'F', n, n, rwork( irvt ), n, vt, ldvt )
1285 CALL zunmbr(
'P',
'R',
'C', n, n, n, a, lda,
1286 $ work( itaup ), vt, ldvt, work( nwork ),
1287 $ lwork-nwork+1, ierr )
1289 IF( lwork .GE. m*n + 3*n )
THEN
1299 CALL zlaset(
'F', m, n, czero, czero, work( iu ),
1301 CALL zlacp2(
'F', n, n, rwork( iru ), n, work( iu ),
1303 CALL zunmbr(
'Q',
'L',
'N', m, n, n, a, lda,
1304 $ work( itauq ), work( iu ), ldwrku,
1305 $ work( nwork ), lwork-nwork+1, ierr )
1306 CALL zlacpy(
'F', m, n, work( iu ), ldwrku, a, lda )
1315 CALL zungbr(
'Q', m, n, n, a, lda, work( itauq ),
1316 $ work( nwork ), lwork-nwork+1, ierr )
1326 DO 30 i = 1, m, ldwrku
1327 chunk = min( m-i+1, ldwrku )
1328 CALL zlacrm( chunk, n, a( i, 1 ), lda,
1329 $ rwork( iru ), n, work( iu ), ldwrku,
1331 CALL zlacpy(
'F', chunk, n, work( iu ), ldwrku,
1336 ELSE IF( wntqs )
THEN
1348 CALL dbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
1349 $ n, rwork( irvt ), n, dum, idum,
1350 $ rwork( nrwork ), iwork, info )
1358 CALL zlaset(
'F', m, n, czero, czero, u, ldu )
1359 CALL zlacp2(
'F', n, n, rwork( iru ), n, u, ldu )
1360 CALL zunmbr(
'Q',
'L',
'N', m, n, n, a, lda,
1361 $ work( itauq ), u, ldu, work( nwork ),
1362 $ lwork-nwork+1, ierr )
1370 CALL zlacp2(
'F', n, n, rwork( irvt ), n, vt, ldvt )
1371 CALL zunmbr(
'P',
'R',
'C', n, n, n, a, lda,
1372 $ work( itaup ), vt, ldvt, work( nwork ),
1373 $ lwork-nwork+1, ierr )
1386 CALL dbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
1387 $ n, rwork( irvt ), n, dum, idum,
1388 $ rwork( nrwork ), iwork, info )
1392 CALL zlaset(
'F', m, m, czero, czero, u, ldu )
1394 CALL zlaset(
'F', m-n, m-n, czero, cone,
1395 $ u( n+1, n+1 ), ldu )
1404 CALL zlacp2(
'F', n, n, rwork( iru ), n, u, ldu )
1405 CALL zunmbr(
'Q',
'L',
'N', m, m, n, a, lda,
1406 $ work( itauq ), u, ldu, work( nwork ),
1407 $ lwork-nwork+1, ierr )
1415 CALL zlacp2(
'F', n, n, rwork( irvt ), n, vt, ldvt )
1416 CALL zunmbr(
'P',
'R',
'C', n, n, n, a, lda,
1417 $ work( itaup ), vt, ldvt, work( nwork ),
1418 $ lwork-nwork+1, ierr )
1429 IF( n.GE.mnthr1 )
THEN
1444 CALL zgelqf( m, n, a, lda, work( itau ), work( nwork ),
1445 $ lwork-nwork+1, ierr )
1449 CALL zlaset(
'U', m-1, m-1, czero, czero, a( 1, 2 ),
1461 CALL zgebrd( m, m, a, lda, s, rwork( ie ), work( itauq ),
1462 $ work( itaup ), work( nwork ), lwork-nwork+1,
1470 CALL dbdsdc(
'U',
'N', m, s, rwork( ie ), dum,1,dum,1,
1471 $ dum, idum, rwork( nrwork ), iwork, info )
1473 ELSE IF( wntqo )
THEN
1485 IF( lwork .GE. m*n + m*m + 3*m )
THEN
1496 chunk = ( lwork - m*m - 3*m ) / m
1498 itau = il + ldwrkl*chunk
1506 CALL zgelqf( m, n, a, lda, work( itau ), work( nwork ),
1507 $ lwork-nwork+1, ierr )
1511 CALL zlacpy(
'L', m, m, a, lda, work( il ), ldwrkl )
1512 CALL zlaset(
'U', m-1, m-1, czero, czero,
1513 $ work( il+ldwrkl ), ldwrkl )
1520 CALL zunglq( m, n, m, a, lda, work( itau ),
1521 $ work( nwork ), lwork-nwork+1, ierr )
1532 CALL zgebrd( m, m, work( il ), ldwrkl, s, rwork( ie ),
1533 $ work( itauq ), work( itaup ), work( nwork ),
1534 $ lwork-nwork+1, ierr )
1545 CALL dbdsdc(
'U',
'I', m, s, rwork( ie ), rwork( iru ),
1546 $ m, rwork( irvt ), m, dum, idum,
1547 $ rwork( nrwork ), iwork, info )
1555 CALL zlacp2(
'F', m, m, rwork( iru ), m, u, ldu )
1556 CALL zunmbr(
'Q',
'L',
'N', m, m, m, work( il ), ldwrkl,
1557 $ work( itauq ), u, ldu, work( nwork ),
1558 $ lwork-nwork+1, ierr )
1566 CALL zlacp2(
'F', m, m, rwork( irvt ), m, work( ivt ),
1568 CALL zunmbr(
'P',
'R',
'C', m, m, m, work( il ), ldwrkl,
1569 $ work( itaup ), work( ivt ), ldwkvt,
1570 $ work( nwork ), lwork-nwork+1, ierr )
1578 DO 40 i = 1, n, chunk
1579 blk = min( n-i+1, chunk )
1580 CALL zgemm(
'N',
'N', m, blk, m, cone, work( ivt ), m,
1581 $ a( 1, i ), lda, czero, work( il ),
1583 CALL zlacpy(
'F', m, blk, work( il ), ldwrkl,
1587 ELSE IF( wntqs )
THEN
1598 itau = il + ldwrkl*m
1606 CALL zgelqf( m, n, a, lda, work( itau ), work( nwork ),
1607 $ lwork-nwork+1, ierr )
1611 CALL zlacpy(
'L', m, m, a, lda, work( il ), ldwrkl )
1612 CALL zlaset(
'U', m-1, m-1, czero, czero,
1613 $ work( il+ldwrkl ), ldwrkl )
1620 CALL zunglq( m, n, m, a, lda, work( itau ),
1621 $ work( nwork ), lwork-nwork+1, ierr )
1632 CALL zgebrd( m, m, work( il ), ldwrkl, s, rwork( ie ),
1633 $ work( itauq ), work( itaup ), work( nwork ),
1634 $ lwork-nwork+1, ierr )
1645 CALL dbdsdc(
'U',
'I', m, s, rwork( ie ), rwork( iru ),
1646 $ m, rwork( irvt ), m, dum, idum,
1647 $ rwork( nrwork ), iwork, info )
1655 CALL zlacp2(
'F', m, m, rwork( iru ), m, u, ldu )
1656 CALL zunmbr(
'Q',
'L',
'N', m, m, m, work( il ), ldwrkl,
1657 $ work( itauq ), u, ldu, work( nwork ),
1658 $ lwork-nwork+1, ierr )
1666 CALL zlacp2(
'F', m, m, rwork( irvt ), m, vt, ldvt )
1667 CALL zunmbr(
'P',
'R',
'C', m, m, m, work( il ), ldwrkl,
1668 $ work( itaup ), vt, ldvt, work( nwork ),
1669 $ lwork-nwork+1, ierr )
1676 CALL zlacpy(
'F', m, m, vt, ldvt, work( il ), ldwrkl )
1677 CALL zgemm(
'N',
'N', m, n, m, cone, work( il ), ldwrkl,
1678 $ a, lda, czero, vt, ldvt )
1680 ELSE IF( wntqa )
THEN
1691 itau = ivt + ldwkvt*m
1699 CALL zgelqf( m, n, a, lda, work( itau ), work( nwork ),
1700 $ lwork-nwork+1, ierr )
1701 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
1708 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
1709 $ work( nwork ), lwork-nwork+1, ierr )
1713 CALL zlaset(
'U', m-1, m-1, czero, czero, a( 1, 2 ),
1725 CALL zgebrd( m, m, a, lda, s, rwork( ie ), work( itauq ),
1726 $ work( itaup ), work( nwork ), lwork-nwork+1,
1738 CALL dbdsdc(
'U',
'I', m, s, rwork( ie ), rwork( iru ),
1739 $ m, rwork( irvt ), m, dum, idum,
1740 $ rwork( nrwork ), iwork, info )
1748 CALL zlacp2(
'F', m, m, rwork( iru ), m, u, ldu )
1749 CALL zunmbr(
'Q',
'L',
'N', m, m, m, a, lda,
1750 $ work( itauq ), u, ldu, work( nwork ),
1751 $ lwork-nwork+1, ierr )
1759 CALL zlacp2(
'F', m, m, rwork( irvt ), m, work( ivt ),
1761 CALL zunmbr(
'P',
'R',
'C', m, m, m, a, lda,
1762 $ work( itaup ), work( ivt ), ldwkvt,
1763 $ work( nwork ), lwork-nwork+1, ierr )
1770 CALL zgemm(
'N',
'N', m, n, m, cone, work( ivt ), ldwkvt,
1771 $ vt, ldvt, czero, a, lda )
1775 CALL zlacpy(
'F', m, n, a, lda, vt, ldvt )
1779 ELSE IF( n.GE.mnthr2 )
THEN
1798 CALL zgebrd( m, n, a, lda, s, rwork( ie ), work( itauq ),
1799 $ work( itaup ), work( nwork ), lwork-nwork+1,
1809 CALL dbdsdc(
'L',
'N', m, s, rwork( ie ), dum,1,dum,1,
1810 $ dum, idum, rwork( nrwork ), iwork, info )
1811 ELSE IF( wntqo )
THEN
1823 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
1824 CALL zungbr(
'Q', m, m, n, u, ldu, work( itauq ),
1825 $ work( nwork ), lwork-nwork+1, ierr )
1832 CALL zungbr(
'P', m, n, m, a, lda, work( itaup ),
1833 $ work( nwork ), lwork-nwork+1, ierr )
1836 IF( lwork .GE. m*n + 3*m )
THEN
1840 nwork = ivt + ldwkvt*n
1846 chunk = ( lwork - 3*m ) / m
1847 nwork = ivt + ldwkvt*chunk
1856 CALL dbdsdc(
'L',
'I', m, s, rwork( ie ), rwork( iru ),
1857 $ m, rwork( irvt ), m, dum, idum,
1858 $ rwork( nrwork ), iwork, info )
1865 CALL zlacrm( m, m, u, ldu, rwork( iru ), m, work( ivt ),
1866 $ ldwkvt, rwork( nrwork ) )
1867 CALL zlacpy(
'F', m, m, work( ivt ), ldwkvt, u, ldu )
1877 DO 50 i = 1, n, chunk
1878 blk = min( n-i+1, chunk )
1879 CALL zlarcm( m, blk, rwork( irvt ), m, a( 1, i ), lda,
1880 $ work( ivt ), ldwkvt, rwork( nrwork ) )
1881 CALL zlacpy(
'F', m, blk, work( ivt ), ldwkvt,
1884 ELSE IF( wntqs )
THEN
1892 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
1893 CALL zungbr(
'Q', m, m, n, u, ldu, work( itauq ),
1894 $ work( nwork ), lwork-nwork+1, ierr )
1901 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
1902 CALL zungbr(
'P', m, n, m, vt, ldvt, work( itaup ),
1903 $ work( nwork ), lwork-nwork+1, ierr )
1914 CALL dbdsdc(
'L',
'I', m, s, rwork( ie ), rwork( iru ),
1915 $ m, rwork( irvt ), m, dum, idum,
1916 $ rwork( nrwork ), iwork, info )
1923 CALL zlacrm( m, m, u, ldu, rwork( iru ), m, a, lda,
1925 CALL zlacpy(
'F', m, m, a, lda, u, ldu )
1933 CALL zlarcm( m, n, rwork( irvt ), m, vt, ldvt, a, lda,
1935 CALL zlacpy(
'F', m, n, a, lda, vt, ldvt )
1944 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
1945 CALL zungbr(
'Q', m, m, n, u, ldu, work( itauq ),
1946 $ work( nwork ), lwork-nwork+1, ierr )
1953 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
1954 CALL zungbr(
'P', n, n, m, vt, ldvt, work( itaup ),
1955 $ work( nwork ), lwork-nwork+1, ierr )
1966 CALL dbdsdc(
'L',
'I', m, s, rwork( ie ), rwork( iru ),
1967 $ m, rwork( irvt ), m, dum, idum,
1968 $ rwork( nrwork ), iwork, info )
1975 CALL zlacrm( m, m, u, ldu, rwork( iru ), m, a, lda,
1977 CALL zlacpy(
'F', m, m, a, lda, u, ldu )
1985 CALL zlarcm( m, n, rwork( irvt ), m, vt, ldvt, a, lda,
1987 CALL zlacpy(
'F', m, n, a, lda, vt, ldvt )
2009 CALL zgebrd( m, n, a, lda, s, rwork( ie ), work( itauq ),
2010 $ work( itaup ), work( nwork ), lwork-nwork+1,
2019 CALL dbdsdc(
'L',
'N', m, s, rwork( ie ), dum,1,dum,1,
2020 $ dum, idum, rwork( nrwork ), iwork, info )
2021 ELSE IF( wntqo )
THEN
2025 IF( lwork .GE. m*n + 3*m )
THEN
2029 CALL zlaset(
'F', m, n, czero, czero, work( ivt ),
2031 nwork = ivt + ldwkvt*n
2036 chunk = ( lwork - 3*m ) / m
2037 nwork = ivt + ldwkvt*chunk
2049 CALL dbdsdc(
'L',
'I', m, s, rwork( ie ), rwork( iru ),
2050 $ m, rwork( irvt ), m, dum, idum,
2051 $ rwork( nrwork ), iwork, info )
2059 CALL zlacp2(
'F', m, m, rwork( iru ), m, u, ldu )
2060 CALL zunmbr(
'Q',
'L',
'N', m, m, n, a, lda,
2061 $ work( itauq ), u, ldu, work( nwork ),
2062 $ lwork-nwork+1, ierr )
2064 IF( lwork .GE. m*n + 3*m )
THEN
2074 CALL zlacp2(
'F', m, m, rwork( irvt ), m, work( ivt ),
2076 CALL zunmbr(
'P',
'R',
'C', m, n, m, a, lda,
2077 $ work( itaup ), work( ivt ), ldwkvt,
2078 $ work( nwork ), lwork-nwork+1, ierr )
2079 CALL zlacpy(
'F', m, n, work( ivt ), ldwkvt, a, lda )
2088 CALL zungbr(
'P', m, n, m, a, lda, work( itaup ),
2089 $ work( nwork ), lwork-nwork+1, ierr )
2099 DO 60 i = 1, n, chunk
2100 blk = min( n-i+1, chunk )
2101 CALL zlarcm( m, blk, rwork( irvt ), m, a( 1, i ),
2102 $ lda, work( ivt ), ldwkvt,
2104 CALL zlacpy(
'F', m, blk, work( ivt ), ldwkvt,
2108 ELSE IF( wntqs )
THEN
2120 CALL dbdsdc(
'L',
'I', m, s, rwork( ie ), rwork( iru ),
2121 $ m, rwork( irvt ), m, dum, idum,
2122 $ rwork( nrwork ), iwork, info )
2130 CALL zlacp2(
'F', m, m, rwork( iru ), m, u, ldu )
2131 CALL zunmbr(
'Q',
'L',
'N', m, m, n, a, lda,
2132 $ work( itauq ), u, ldu, work( nwork ),
2133 $ lwork-nwork+1, ierr )
2141 CALL zlaset(
'F', m, n, czero, czero, vt, ldvt )
2142 CALL zlacp2(
'F', m, m, rwork( irvt ), m, vt, ldvt )
2143 CALL zunmbr(
'P',
'R',
'C', m, n, m, a, lda,
2144 $ work( itaup ), vt, ldvt, work( nwork ),
2145 $ lwork-nwork+1, ierr )
2159 CALL dbdsdc(
'L',
'I', m, s, rwork( ie ), rwork( iru ),
2160 $ m, rwork( irvt ), m, dum, idum,
2161 $ rwork( nrwork ), iwork, info )
2169 CALL zlacp2(
'F', m, m, rwork( iru ), m, u, ldu )
2170 CALL zunmbr(
'Q',
'L',
'N', m, m, n, a, lda,
2171 $ work( itauq ), u, ldu, work( nwork ),
2172 $ lwork-nwork+1, ierr )
2176 CALL zlaset(
'F', n, n, czero, cone, vt, ldvt )
2184 CALL zlacp2(
'F', m, m, rwork( irvt ), m, vt, ldvt )
2185 CALL zunmbr(
'P',
'R',
'C', n, n, m, a, lda,
2186 $ work( itaup ), vt, ldvt, work( nwork ),
2187 $ lwork-nwork+1, ierr )
2196 IF( iscl.EQ.1 )
THEN
2197 IF( anrm.GT.bignum )
2198 $
CALL dlascl(
'G', 0, 0, bignum, anrm, minmn, 1, s, minmn,
2200 IF( info.NE.0 .AND. anrm.GT.bignum )
2201 $
CALL dlascl(
'G', 0, 0, bignum, anrm, minmn-1, 1,
2202 $ rwork( ie ), minmn, ierr )
2203 IF( anrm.LT.smlnum )
2204 $
CALL dlascl(
'G', 0, 0, smlnum, anrm, minmn, 1, s, minmn,
2206 IF( info.NE.0 .AND. anrm.LT.smlnum )
2207 $
CALL dlascl(
'G', 0, 0, smlnum, anrm, minmn-1, 1,
2208 $ rwork( ie ), minmn, ierr )
subroutine zunglq(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
ZUNGLQ
subroutine zgesdd(JOBZ, M, N, A, LDA, S, U, LDU, VT, LDVT, WORK, LWORK, RWORK, IWORK, INFO)
ZGESDD
subroutine zlacpy(UPLO, M, N, A, LDA, B, LDB)
ZLACPY copies all or part of one two-dimensional array to another.
subroutine zungbr(VECT, M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
ZUNGBR
subroutine zlacp2(UPLO, M, N, A, LDA, B, LDB)
ZLACP2 copies all or part of a real two-dimensional array to a complex array.
subroutine zgeqrf(M, N, A, LDA, TAU, WORK, LWORK, INFO)
ZGEQRF VARIANT: left-looking Level 3 BLAS of the algorithm.
subroutine zunmbr(VECT, SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
ZUNMBR
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 zgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
ZGEMM
subroutine zlaset(UPLO, M, N, ALPHA, BETA, A, LDA)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values...
subroutine xerbla(SRNAME, INFO)
XERBLA
subroutine zgebrd(M, N, A, LDA, D, E, TAUQ, TAUP, WORK, LWORK, INFO)
ZGEBRD
subroutine zungqr(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
ZUNGQR
subroutine dbdsdc(UPLO, COMPQ, N, D, E, U, LDU, VT, LDVT, Q, IQ, WORK, IWORK, INFO)
DBDSDC
subroutine zlarcm(M, N, A, LDA, B, LDB, C, LDC, RWORK)
ZLARCM copies all or part of a real two-dimensional array to a complex array.
subroutine zgelqf(M, N, A, LDA, TAU, WORK, LWORK, INFO)
ZGELQF
subroutine zlascl(TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
ZLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine zlacrm(M, N, A, LDA, B, LDB, C, LDC, RWORK)
ZLACRM multiplies a complex matrix by a square real matrix.