237 INTEGER info, lda, ldu, ldvt, lwork, m, n
241 REAL rwork( * ), s( * )
242 COMPLEX a( lda, * ), u( ldu, * ), vt( ldvt, * ),
250 parameter ( czero = ( 0.0e+0, 0.0e+0 ),
251 $ cone = ( 1.0e+0, 0.0e+0 ) )
253 parameter ( zero = 0.0e+0, one = 1.0e+0 )
256 LOGICAL lquery, wntqa, wntqas, wntqn, wntqo, wntqs
257 INTEGER blk, chunk, i, ie, ierr, il, ir, iru, irvt,
258 $ iscl, itau, itaup, itauq, iu, ivt, ldwkvt,
259 $ ldwrkl, ldwrkr, ldwrku, maxwrk, minmn, minwrk,
260 $ mnthr1, mnthr2, nrwork, nwork, wrkbl
261 INTEGER lwork_cgebrd_mn, lwork_cgebrd_mm,
262 $ lwork_cgebrd_nn, lwork_cgelqf_mn,
264 $ lwork_cungbr_p_mn, lwork_cungbr_p_nn,
265 $ lwork_cungbr_q_mn, lwork_cungbr_q_mm,
266 $ lwork_cunglq_mn, lwork_cunglq_nn,
267 $ lwork_cungqr_mm, lwork_cungqr_mn,
268 $ lwork_cunmbr_prc_mm, lwork_cunmbr_qln_mm,
269 $ lwork_cunmbr_prc_mn, lwork_cunmbr_qln_mn,
270 $ lwork_cunmbr_prc_nn, lwork_cunmbr_qln_nn
271 REAL anrm, bignum, eps, smlnum
289 INTRINSIC int, max, min, sqrt
297 mnthr1 = int( minmn*17.0e0 / 9.0e0 )
298 mnthr2 = int( minmn*5.0e0 / 3.0e0 )
299 wntqa =
lsame( jobz,
'A' )
300 wntqs =
lsame( jobz,
'S' )
301 wntqas = wntqa .OR. wntqs
302 wntqo =
lsame( jobz,
'O' )
303 wntqn =
lsame( jobz,
'N' )
304 lquery = ( lwork.EQ.-1 )
308 IF( .NOT.( wntqa .OR. wntqs .OR. wntqo .OR. wntqn ) )
THEN
310 ELSE IF( m.LT.0 )
THEN
312 ELSE IF( n.LT.0 )
THEN
314 ELSE IF( lda.LT.max( 1, m ) )
THEN
316 ELSE IF( ldu.LT.1 .OR. ( wntqas .AND. ldu.LT.m ) .OR.
317 $ ( wntqo .AND. m.LT.n .AND. ldu.LT.m ) )
THEN
319 ELSE IF( ldvt.LT.1 .OR. ( wntqa .AND. ldvt.LT.n ) .OR.
320 $ ( wntqs .AND. ldvt.LT.minmn ) .OR.
321 $ ( wntqo .AND. m.GE.n .AND. ldvt.LT.n ) )
THEN
333 IF( info.EQ.0 .AND. m.GT.0 .AND. n.GT.0 )
THEN
343 CALL cgebrd( m, n, cdum(1), m, dum(1), dum(1), cdum(1),
344 $ cdum(1), cdum(1), -1, ierr )
345 lwork_cgebrd_mn = int( cdum(1) )
347 CALL cgebrd( n, n, cdum(1), n, dum(1), dum(1), cdum(1),
348 $ cdum(1), cdum(1), -1, ierr )
349 lwork_cgebrd_nn = int( cdum(1) )
351 CALL cgeqrf( m, n, cdum(1), m, cdum(1), cdum(1), -1, ierr )
352 lwork_cgeqrf_mn = int( cdum(1) )
354 CALL cungbr(
'P', n, n, n, cdum(1), n, cdum(1), cdum(1),
356 lwork_cungbr_p_nn = int( cdum(1) )
358 CALL cungbr(
'Q', m, m, n, cdum(1), m, cdum(1), cdum(1),
360 lwork_cungbr_q_mm = int( cdum(1) )
362 CALL cungbr(
'Q', m, n, n, cdum(1), m, cdum(1), cdum(1),
364 lwork_cungbr_q_mn = int( cdum(1) )
366 CALL cungqr( m, m, n, cdum(1), m, cdum(1), cdum(1),
368 lwork_cungqr_mm = int( cdum(1) )
370 CALL cungqr( m, n, n, cdum(1), m, cdum(1), cdum(1),
372 lwork_cungqr_mn = int( cdum(1) )
374 CALL cunmbr(
'P',
'R',
'C', n, n, n, cdum(1), n, cdum(1),
375 $ cdum(1), n, cdum(1), -1, ierr )
376 lwork_cunmbr_prc_nn = int( cdum(1) )
378 CALL cunmbr(
'Q',
'L',
'N', m, m, n, cdum(1), m, cdum(1),
379 $ cdum(1), m, cdum(1), -1, ierr )
380 lwork_cunmbr_qln_mm = int( cdum(1) )
382 CALL cunmbr(
'Q',
'L',
'N', m, n, n, cdum(1), m, cdum(1),
383 $ cdum(1), m, cdum(1), -1, ierr )
384 lwork_cunmbr_qln_mn = int( cdum(1) )
386 CALL cunmbr(
'Q',
'L',
'N', n, n, n, cdum(1), n, cdum(1),
387 $ cdum(1), n, cdum(1), -1, ierr )
388 lwork_cunmbr_qln_nn = int( cdum(1) )
390 IF( m.GE.mnthr1 )
THEN
395 maxwrk = n + lwork_cgeqrf_mn
396 maxwrk = max( maxwrk, 2*n + lwork_cgebrd_nn )
398 ELSE IF( wntqo )
THEN
402 wrkbl = n + lwork_cgeqrf_mn
403 wrkbl = max( wrkbl, n + lwork_cungqr_mn )
404 wrkbl = max( wrkbl, 2*n + lwork_cgebrd_nn )
405 wrkbl = max( wrkbl, 2*n + lwork_cunmbr_qln_nn )
406 wrkbl = max( wrkbl, 2*n + lwork_cunmbr_prc_nn )
407 maxwrk = m*n + n*n + wrkbl
409 ELSE IF( wntqs )
THEN
413 wrkbl = n + lwork_cgeqrf_mn
414 wrkbl = max( wrkbl, n + lwork_cungqr_mn )
415 wrkbl = max( wrkbl, 2*n + lwork_cgebrd_nn )
416 wrkbl = max( wrkbl, 2*n + lwork_cunmbr_qln_nn )
417 wrkbl = max( wrkbl, 2*n + lwork_cunmbr_prc_nn )
420 ELSE IF( wntqa )
THEN
424 wrkbl = n + lwork_cgeqrf_mn
425 wrkbl = max( wrkbl, n + lwork_cungqr_mm )
426 wrkbl = max( wrkbl, 2*n + lwork_cgebrd_nn )
427 wrkbl = max( wrkbl, 2*n + lwork_cunmbr_qln_nn )
428 wrkbl = max( wrkbl, 2*n + lwork_cunmbr_prc_nn )
430 minwrk = n*n + max( 3*n, n + m )
432 ELSE IF( m.GE.mnthr2 )
THEN
436 maxwrk = 2*n + lwork_cgebrd_mn
440 maxwrk = max( maxwrk, 2*n + lwork_cungbr_p_nn )
441 maxwrk = max( maxwrk, 2*n + lwork_cungbr_q_mn )
442 maxwrk = maxwrk + m*n
443 minwrk = minwrk + n*n
444 ELSE IF( wntqs )
THEN
446 maxwrk = max( maxwrk, 2*n + lwork_cungbr_p_nn )
447 maxwrk = max( maxwrk, 2*n + lwork_cungbr_q_mn )
448 ELSE IF( wntqa )
THEN
450 maxwrk = max( maxwrk, 2*n + lwork_cungbr_p_nn )
451 maxwrk = max( maxwrk, 2*n + lwork_cungbr_q_mm )
457 maxwrk = 2*n + lwork_cgebrd_mn
461 maxwrk = max( maxwrk, 2*n + lwork_cunmbr_prc_nn )
462 maxwrk = max( maxwrk, 2*n + lwork_cunmbr_qln_mn )
463 maxwrk = maxwrk + m*n
464 minwrk = minwrk + n*n
465 ELSE IF( wntqs )
THEN
467 maxwrk = max( maxwrk, 2*n + lwork_cunmbr_qln_mn )
468 maxwrk = max( maxwrk, 2*n + lwork_cunmbr_prc_nn )
469 ELSE IF( wntqa )
THEN
471 maxwrk = max( maxwrk, 2*n + lwork_cunmbr_qln_mm )
472 maxwrk = max( maxwrk, 2*n + lwork_cunmbr_prc_nn )
484 CALL cgebrd( m, n, cdum(1), m, dum(1), dum(1), cdum(1),
485 $ cdum(1), cdum(1), -1, ierr )
486 lwork_cgebrd_mn = int( cdum(1) )
488 CALL cgebrd( m, m, cdum(1), m, dum(1), dum(1), cdum(1),
489 $ cdum(1), cdum(1), -1, ierr )
490 lwork_cgebrd_mm = int( cdum(1) )
492 CALL cgelqf( m, n, cdum(1), m, cdum(1), cdum(1), -1, ierr )
493 lwork_cgelqf_mn = int( cdum(1) )
495 CALL cungbr(
'P', m, n, m, cdum(1), m, cdum(1), cdum(1),
497 lwork_cungbr_p_mn = int( cdum(1) )
499 CALL cungbr(
'P', n, n, m, cdum(1), n, cdum(1), cdum(1),
501 lwork_cungbr_p_nn = int( cdum(1) )
503 CALL cungbr(
'Q', m, m, n, cdum(1), m, cdum(1), cdum(1),
505 lwork_cungbr_q_mm = int( cdum(1) )
507 CALL cunglq( m, n, m, cdum(1), m, cdum(1), cdum(1),
509 lwork_cunglq_mn = int( cdum(1) )
511 CALL cunglq( n, n, m, cdum(1), n, cdum(1), cdum(1),
513 lwork_cunglq_nn = int( cdum(1) )
515 CALL cunmbr(
'P',
'R',
'C', m, m, m, cdum(1), m, cdum(1),
516 $ cdum(1), m, cdum(1), -1, ierr )
517 lwork_cunmbr_prc_mm = int( cdum(1) )
519 CALL cunmbr(
'P',
'R',
'C', m, n, m, cdum(1), m, cdum(1),
520 $ cdum(1), m, cdum(1), -1, ierr )
521 lwork_cunmbr_prc_mn = int( cdum(1) )
523 CALL cunmbr(
'P',
'R',
'C', n, n, m, cdum(1), n, cdum(1),
524 $ cdum(1), n, cdum(1), -1, ierr )
525 lwork_cunmbr_prc_nn = int( cdum(1) )
527 CALL cunmbr(
'Q',
'L',
'N', m, m, m, cdum(1), m, cdum(1),
528 $ cdum(1), m, cdum(1), -1, ierr )
529 lwork_cunmbr_qln_mm = int( cdum(1) )
531 IF( n.GE.mnthr1 )
THEN
536 maxwrk = m + lwork_cgelqf_mn
537 maxwrk = max( maxwrk, 2*m + lwork_cgebrd_mm )
539 ELSE IF( wntqo )
THEN
543 wrkbl = m + lwork_cgelqf_mn
544 wrkbl = max( wrkbl, m + lwork_cunglq_mn )
545 wrkbl = max( wrkbl, 2*m + lwork_cgebrd_mm )
546 wrkbl = max( wrkbl, 2*m + lwork_cunmbr_qln_mm )
547 wrkbl = max( wrkbl, 2*m + lwork_cunmbr_prc_mm )
548 maxwrk = m*n + m*m + wrkbl
550 ELSE IF( wntqs )
THEN
554 wrkbl = m + lwork_cgelqf_mn
555 wrkbl = max( wrkbl, m + lwork_cunglq_mn )
556 wrkbl = max( wrkbl, 2*m + lwork_cgebrd_mm )
557 wrkbl = max( wrkbl, 2*m + lwork_cunmbr_qln_mm )
558 wrkbl = max( wrkbl, 2*m + lwork_cunmbr_prc_mm )
561 ELSE IF( wntqa )
THEN
565 wrkbl = m + lwork_cgelqf_mn
566 wrkbl = max( wrkbl, m + lwork_cunglq_nn )
567 wrkbl = max( wrkbl, 2*m + lwork_cgebrd_mm )
568 wrkbl = max( wrkbl, 2*m + lwork_cunmbr_qln_mm )
569 wrkbl = max( wrkbl, 2*m + lwork_cunmbr_prc_mm )
571 minwrk = m*m + max( 3*m, m + n )
573 ELSE IF( n.GE.mnthr2 )
THEN
577 maxwrk = 2*m + lwork_cgebrd_mn
581 maxwrk = max( maxwrk, 2*m + lwork_cungbr_q_mm )
582 maxwrk = max( maxwrk, 2*m + lwork_cungbr_p_mn )
583 maxwrk = maxwrk + m*n
584 minwrk = minwrk + m*m
585 ELSE IF( wntqs )
THEN
587 maxwrk = max( maxwrk, 2*m + lwork_cungbr_q_mm )
588 maxwrk = max( maxwrk, 2*m + lwork_cungbr_p_mn )
589 ELSE IF( wntqa )
THEN
591 maxwrk = max( maxwrk, 2*m + lwork_cungbr_q_mm )
592 maxwrk = max( maxwrk, 2*m + lwork_cungbr_p_nn )
598 maxwrk = 2*m + lwork_cgebrd_mn
602 maxwrk = max( maxwrk, 2*m + lwork_cunmbr_qln_mm )
603 maxwrk = max( maxwrk, 2*m + lwork_cunmbr_prc_mn )
604 maxwrk = maxwrk + m*n
605 minwrk = minwrk + m*m
606 ELSE IF( wntqs )
THEN
608 maxwrk = max( maxwrk, 2*m + lwork_cunmbr_qln_mm )
609 maxwrk = max( maxwrk, 2*m + lwork_cunmbr_prc_mn )
610 ELSE IF( wntqa )
THEN
612 maxwrk = max( maxwrk, 2*m + lwork_cunmbr_qln_mm )
613 maxwrk = max( maxwrk, 2*m + lwork_cunmbr_prc_nn )
617 maxwrk = max( maxwrk, minwrk )
621 IF( lwork.LT.minwrk .AND. .NOT. lquery )
THEN
627 CALL xerbla(
'CGESDD', -info )
629 ELSE IF( lquery )
THEN
635 IF( m.EQ.0 .OR. n.EQ.0 )
THEN
642 smlnum = sqrt(
slamch(
'S' ) ) / eps
643 bignum = one / smlnum
647 anrm =
clange(
'M', m, n, a, lda, dum )
649 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
651 CALL clascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, ierr )
652 ELSE IF( anrm.GT.bignum )
THEN
654 CALL clascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, ierr )
663 IF( m.GE.mnthr1 )
THEN
678 CALL cgeqrf( m, n, a, lda, work( itau ), work( nwork ),
679 $ lwork-nwork+1, ierr )
683 CALL claset(
'L', n-1, n-1, czero, czero, a( 2, 1 ),
695 CALL cgebrd( n, n, a, lda, s, rwork( ie ), work( itauq ),
696 $ work( itaup ), work( nwork ), lwork-nwork+1,
704 CALL sbdsdc(
'U',
'N', n, s, rwork( ie ), dum,1,dum,1,
705 $ dum, idum, rwork( nrwork ), iwork, info )
707 ELSE IF( wntqo )
THEN
719 IF( lwork .GE. m*n + n*n + 3*n )
THEN
725 ldwrkr = ( lwork - n*n - 3*n ) / n
735 CALL cgeqrf( m, n, a, lda, work( itau ), work( nwork ),
736 $ lwork-nwork+1, ierr )
740 CALL clacpy(
'U', n, n, a, lda, work( ir ), ldwrkr )
741 CALL claset(
'L', n-1, n-1, czero, czero, work( ir+1 ),
749 CALL cungqr( m, n, n, a, lda, work( itau ),
750 $ work( nwork ), lwork-nwork+1, ierr )
761 CALL cgebrd( n, n, work( ir ), ldwrkr, s, rwork( ie ),
762 $ work( itauq ), work( itaup ), work( nwork ),
763 $ lwork-nwork+1, ierr )
774 CALL sbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
775 $ n, rwork( irvt ), n, dum, idum,
776 $ rwork( nrwork ), iwork, info )
784 CALL clacp2(
'F', n, n, rwork( iru ), n, work( iu ),
786 CALL cunmbr(
'Q',
'L',
'N', n, n, n, work( ir ), ldwrkr,
787 $ work( itauq ), work( iu ), ldwrku,
788 $ work( nwork ), lwork-nwork+1, ierr )
796 CALL clacp2(
'F', n, n, rwork( irvt ), n, vt, ldvt )
797 CALL cunmbr(
'P',
'R',
'C', n, n, n, work( ir ), ldwrkr,
798 $ work( itaup ), vt, ldvt, work( nwork ),
799 $ lwork-nwork+1, ierr )
807 DO 10 i = 1, m, ldwrkr
808 chunk = min( m-i+1, ldwrkr )
809 CALL cgemm(
'N',
'N', chunk, n, n, cone, a( i, 1 ),
810 $ lda, work( iu ), ldwrku, czero,
811 $ work( ir ), ldwrkr )
812 CALL clacpy(
'F', chunk, n, work( ir ), ldwrkr,
816 ELSE IF( wntqs )
THEN
835 CALL cgeqrf( m, n, a, lda, work( itau ), work( nwork ),
836 $ lwork-nwork+1, ierr )
840 CALL clacpy(
'U', n, n, a, lda, work( ir ), ldwrkr )
841 CALL claset(
'L', n-1, n-1, czero, czero, work( ir+1 ),
849 CALL cungqr( m, n, n, a, lda, work( itau ),
850 $ work( nwork ), lwork-nwork+1, ierr )
861 CALL cgebrd( n, n, work( ir ), ldwrkr, s, rwork( ie ),
862 $ work( itauq ), work( itaup ), work( nwork ),
863 $ lwork-nwork+1, ierr )
874 CALL sbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
875 $ n, rwork( irvt ), n, dum, idum,
876 $ rwork( nrwork ), iwork, info )
884 CALL clacp2(
'F', n, n, rwork( iru ), n, u, ldu )
885 CALL cunmbr(
'Q',
'L',
'N', n, n, n, work( ir ), ldwrkr,
886 $ work( itauq ), u, ldu, work( nwork ),
887 $ lwork-nwork+1, ierr )
895 CALL clacp2(
'F', n, n, rwork( irvt ), n, vt, ldvt )
896 CALL cunmbr(
'P',
'R',
'C', n, n, n, work( ir ), ldwrkr,
897 $ work( itaup ), vt, ldvt, work( nwork ),
898 $ lwork-nwork+1, ierr )
905 CALL clacpy(
'F', n, n, u, ldu, work( ir ), ldwrkr )
906 CALL cgemm(
'N',
'N', m, n, n, cone, a, lda, work( ir ),
907 $ ldwrkr, czero, u, ldu )
909 ELSE IF( wntqa )
THEN
928 CALL cgeqrf( m, n, a, lda, work( itau ), work( nwork ),
929 $ lwork-nwork+1, ierr )
930 CALL clacpy(
'L', m, n, a, lda, u, ldu )
937 CALL cungqr( m, m, n, u, ldu, work( itau ),
938 $ work( nwork ), lwork-nwork+1, ierr )
942 CALL claset(
'L', n-1, n-1, czero, czero, a( 2, 1 ),
954 CALL cgebrd( n, n, a, lda, s, rwork( ie ), work( itauq ),
955 $ work( itaup ), work( nwork ), lwork-nwork+1,
967 CALL sbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
968 $ n, rwork( irvt ), n, dum, idum,
969 $ rwork( nrwork ), iwork, info )
977 CALL clacp2(
'F', n, n, rwork( iru ), n, work( iu ),
979 CALL cunmbr(
'Q',
'L',
'N', n, n, n, a, lda,
980 $ work( itauq ), work( iu ), ldwrku,
981 $ work( nwork ), lwork-nwork+1, ierr )
989 CALL clacp2(
'F', n, n, rwork( irvt ), n, vt, ldvt )
990 CALL cunmbr(
'P',
'R',
'C', n, n, n, a, lda,
991 $ work( itaup ), vt, ldvt, work( nwork ),
992 $ lwork-nwork+1, ierr )
999 CALL cgemm(
'N',
'N', m, n, n, cone, u, ldu, work( iu ),
1000 $ ldwrku, czero, a, lda )
1004 CALL clacpy(
'F', m, n, a, lda, u, ldu )
1008 ELSE IF( m.GE.mnthr2 )
THEN
1027 CALL cgebrd( m, n, a, lda, s, rwork( ie ), work( itauq ),
1028 $ work( itaup ), work( nwork ), lwork-nwork+1,
1037 CALL sbdsdc(
'U',
'N', n, s, rwork( ie ), dum, 1,dum,1,
1038 $ dum, idum, rwork( nrwork ), iwork, info )
1039 ELSE IF( wntqo )
THEN
1051 CALL clacpy(
'U', n, n, a, lda, vt, ldvt )
1052 CALL cungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1053 $ work( nwork ), lwork-nwork+1, ierr )
1060 CALL cungbr(
'Q', m, n, n, a, lda, work( itauq ),
1061 $ work( nwork ), lwork-nwork+1, ierr )
1063 IF( lwork .GE. m*n + 3*n )
THEN
1072 ldwrku = ( lwork - 3*n ) / n
1074 nwork = iu + ldwrku*n
1082 CALL sbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
1083 $ n, rwork( irvt ), n, dum, idum,
1084 $ rwork( nrwork ), iwork, info )
1091 CALL clarcm( n, n, rwork( irvt ), n, vt, ldvt,
1092 $ work( iu ), ldwrku, rwork( nrwork ) )
1093 CALL clacpy(
'F', n, n, work( iu ), ldwrku, vt, ldvt )
1103 DO 20 i = 1, m, ldwrku
1104 chunk = min( m-i+1, ldwrku )
1105 CALL clacrm( chunk, n, a( i, 1 ), lda, rwork( iru ),
1106 $ n, work( iu ), ldwrku, rwork( nrwork ) )
1107 CALL clacpy(
'F', chunk, n, work( iu ), ldwrku,
1111 ELSE IF( wntqs )
THEN
1119 CALL clacpy(
'U', n, n, a, lda, vt, ldvt )
1120 CALL cungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1121 $ work( nwork ), lwork-nwork+1, ierr )
1128 CALL clacpy(
'L', m, n, a, lda, u, ldu )
1129 CALL cungbr(
'Q', m, n, n, u, ldu, work( itauq ),
1130 $ work( nwork ), lwork-nwork+1, ierr )
1141 CALL sbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
1142 $ n, rwork( irvt ), n, dum, idum,
1143 $ rwork( nrwork ), iwork, info )
1150 CALL clarcm( n, n, rwork( irvt ), n, vt, ldvt, a, lda,
1152 CALL clacpy(
'F', n, n, a, lda, vt, ldvt )
1160 CALL clacrm( m, n, u, ldu, rwork( iru ), n, a, lda,
1162 CALL clacpy(
'F', m, n, a, lda, u, ldu )
1171 CALL clacpy(
'U', n, n, a, lda, vt, ldvt )
1172 CALL cungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1173 $ work( nwork ), lwork-nwork+1, ierr )
1180 CALL clacpy(
'L', m, n, a, lda, u, ldu )
1181 CALL cungbr(
'Q', m, m, n, u, ldu, work( itauq ),
1182 $ work( nwork ), lwork-nwork+1, ierr )
1193 CALL sbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
1194 $ n, rwork( irvt ), n, dum, idum,
1195 $ rwork( nrwork ), iwork, info )
1202 CALL clarcm( n, n, rwork( irvt ), n, vt, ldvt, a, lda,
1204 CALL clacpy(
'F', n, n, a, lda, vt, ldvt )
1212 CALL clacrm( m, n, u, ldu, rwork( iru ), n, a, lda,
1214 CALL clacpy(
'F', m, n, a, lda, u, ldu )
1236 CALL cgebrd( m, n, a, lda, s, rwork( ie ), work( itauq ),
1237 $ work( itaup ), work( nwork ), lwork-nwork+1,
1246 CALL sbdsdc(
'U',
'N', n, s, rwork( ie ), dum,1,dum,1,
1247 $ dum, idum, rwork( nrwork ), iwork, info )
1248 ELSE IF( wntqo )
THEN
1253 IF( lwork .GE. m*n + 3*n )
THEN
1262 ldwrku = ( lwork - 3*n ) / n
1264 nwork = iu + ldwrku*n
1273 CALL sbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
1274 $ n, rwork( irvt ), n, dum, idum,
1275 $ rwork( nrwork ), iwork, info )
1283 CALL clacp2(
'F', n, n, rwork( irvt ), n, vt, ldvt )
1284 CALL cunmbr(
'P',
'R',
'C', n, n, n, a, lda,
1285 $ work( itaup ), vt, ldvt, work( nwork ),
1286 $ lwork-nwork+1, ierr )
1288 IF( lwork .GE. m*n + 3*n )
THEN
1298 CALL claset(
'F', m, n, czero, czero, work( iu ),
1300 CALL clacp2(
'F', n, n, rwork( iru ), n, work( iu ),
1302 CALL cunmbr(
'Q',
'L',
'N', m, n, n, a, lda,
1303 $ work( itauq ), work( iu ), ldwrku,
1304 $ work( nwork ), lwork-nwork+1, ierr )
1305 CALL clacpy(
'F', m, n, work( iu ), ldwrku, a, lda )
1314 CALL cungbr(
'Q', m, n, n, a, lda, work( itauq ),
1315 $ work( nwork ), lwork-nwork+1, ierr )
1325 DO 30 i = 1, m, ldwrku
1326 chunk = min( m-i+1, ldwrku )
1327 CALL clacrm( chunk, n, a( i, 1 ), lda,
1328 $ rwork( iru ), n, work( iu ), ldwrku,
1330 CALL clacpy(
'F', chunk, n, work( iu ), ldwrku,
1335 ELSE IF( wntqs )
THEN
1347 CALL sbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
1348 $ n, rwork( irvt ), n, dum, idum,
1349 $ rwork( nrwork ), iwork, info )
1357 CALL claset(
'F', m, n, czero, czero, u, ldu )
1358 CALL clacp2(
'F', n, n, rwork( iru ), n, u, ldu )
1359 CALL cunmbr(
'Q',
'L',
'N', m, n, n, a, lda,
1360 $ work( itauq ), u, ldu, work( nwork ),
1361 $ lwork-nwork+1, ierr )
1369 CALL clacp2(
'F', n, n, rwork( irvt ), n, vt, ldvt )
1370 CALL cunmbr(
'P',
'R',
'C', n, n, n, a, lda,
1371 $ work( itaup ), vt, ldvt, work( nwork ),
1372 $ lwork-nwork+1, ierr )
1385 CALL sbdsdc(
'U',
'I', n, s, rwork( ie ), rwork( iru ),
1386 $ n, rwork( irvt ), n, dum, idum,
1387 $ rwork( nrwork ), iwork, info )
1391 CALL claset(
'F', m, m, czero, czero, u, ldu )
1393 CALL claset(
'F', m-n, m-n, czero, cone,
1394 $ u( n+1, n+1 ), ldu )
1403 CALL clacp2(
'F', n, n, rwork( iru ), n, u, ldu )
1404 CALL cunmbr(
'Q',
'L',
'N', m, m, n, a, lda,
1405 $ work( itauq ), u, ldu, work( nwork ),
1406 $ lwork-nwork+1, ierr )
1414 CALL clacp2(
'F', n, n, rwork( irvt ), n, vt, ldvt )
1415 CALL cunmbr(
'P',
'R',
'C', n, n, n, a, lda,
1416 $ work( itaup ), vt, ldvt, work( nwork ),
1417 $ lwork-nwork+1, ierr )
1428 IF( n.GE.mnthr1 )
THEN
1443 CALL cgelqf( m, n, a, lda, work( itau ), work( nwork ),
1444 $ lwork-nwork+1, ierr )
1448 CALL claset(
'U', m-1, m-1, czero, czero, a( 1, 2 ),
1460 CALL cgebrd( m, m, a, lda, s, rwork( ie ), work( itauq ),
1461 $ work( itaup ), work( nwork ), lwork-nwork+1,
1469 CALL sbdsdc(
'U',
'N', m, s, rwork( ie ), dum,1,dum,1,
1470 $ dum, idum, rwork( nrwork ), iwork, info )
1472 ELSE IF( wntqo )
THEN
1484 IF( lwork .GE. m*n + m*m + 3*m )
THEN
1495 chunk = ( lwork - m*m - 3*m ) / m
1497 itau = il + ldwrkl*chunk
1505 CALL cgelqf( m, n, a, lda, work( itau ), work( nwork ),
1506 $ lwork-nwork+1, ierr )
1510 CALL clacpy(
'L', m, m, a, lda, work( il ), ldwrkl )
1511 CALL claset(
'U', m-1, m-1, czero, czero,
1512 $ work( il+ldwrkl ), ldwrkl )
1519 CALL cunglq( m, n, m, a, lda, work( itau ),
1520 $ work( nwork ), lwork-nwork+1, ierr )
1531 CALL cgebrd( m, m, work( il ), ldwrkl, s, rwork( ie ),
1532 $ work( itauq ), work( itaup ), work( nwork ),
1533 $ lwork-nwork+1, ierr )
1544 CALL sbdsdc(
'U',
'I', m, s, rwork( ie ), rwork( iru ),
1545 $ m, rwork( irvt ), m, dum, idum,
1546 $ rwork( nrwork ), iwork, info )
1554 CALL clacp2(
'F', m, m, rwork( iru ), m, u, ldu )
1555 CALL cunmbr(
'Q',
'L',
'N', m, m, m, work( il ), ldwrkl,
1556 $ work( itauq ), u, ldu, work( nwork ),
1557 $ lwork-nwork+1, ierr )
1565 CALL clacp2(
'F', m, m, rwork( irvt ), m, work( ivt ),
1567 CALL cunmbr(
'P',
'R',
'C', m, m, m, work( il ), ldwrkl,
1568 $ work( itaup ), work( ivt ), ldwkvt,
1569 $ work( nwork ), lwork-nwork+1, ierr )
1577 DO 40 i = 1, n, chunk
1578 blk = min( n-i+1, chunk )
1579 CALL cgemm(
'N',
'N', m, blk, m, cone, work( ivt ), m,
1580 $ a( 1, i ), lda, czero, work( il ),
1582 CALL clacpy(
'F', m, blk, work( il ), ldwrkl,
1586 ELSE IF( wntqs )
THEN
1597 itau = il + ldwrkl*m
1605 CALL cgelqf( m, n, a, lda, work( itau ), work( nwork ),
1606 $ lwork-nwork+1, ierr )
1610 CALL clacpy(
'L', m, m, a, lda, work( il ), ldwrkl )
1611 CALL claset(
'U', m-1, m-1, czero, czero,
1612 $ work( il+ldwrkl ), ldwrkl )
1619 CALL cunglq( m, n, m, a, lda, work( itau ),
1620 $ work( nwork ), lwork-nwork+1, ierr )
1631 CALL cgebrd( m, m, work( il ), ldwrkl, s, rwork( ie ),
1632 $ work( itauq ), work( itaup ), work( nwork ),
1633 $ lwork-nwork+1, ierr )
1644 CALL sbdsdc(
'U',
'I', m, s, rwork( ie ), rwork( iru ),
1645 $ m, rwork( irvt ), m, dum, idum,
1646 $ rwork( nrwork ), iwork, info )
1654 CALL clacp2(
'F', m, m, rwork( iru ), m, u, ldu )
1655 CALL cunmbr(
'Q',
'L',
'N', m, m, m, work( il ), ldwrkl,
1656 $ work( itauq ), u, ldu, work( nwork ),
1657 $ lwork-nwork+1, ierr )
1665 CALL clacp2(
'F', m, m, rwork( irvt ), m, vt, ldvt )
1666 CALL cunmbr(
'P',
'R',
'C', m, m, m, work( il ), ldwrkl,
1667 $ work( itaup ), vt, ldvt, work( nwork ),
1668 $ lwork-nwork+1, ierr )
1675 CALL clacpy(
'F', m, m, vt, ldvt, work( il ), ldwrkl )
1676 CALL cgemm(
'N',
'N', m, n, m, cone, work( il ), ldwrkl,
1677 $ a, lda, czero, vt, ldvt )
1679 ELSE IF( wntqa )
THEN
1690 itau = ivt + ldwkvt*m
1698 CALL cgelqf( m, n, a, lda, work( itau ), work( nwork ),
1699 $ lwork-nwork+1, ierr )
1700 CALL clacpy(
'U', m, n, a, lda, vt, ldvt )
1707 CALL cunglq( n, n, m, vt, ldvt, work( itau ),
1708 $ work( nwork ), lwork-nwork+1, ierr )
1712 CALL claset(
'U', m-1, m-1, czero, czero, a( 1, 2 ),
1724 CALL cgebrd( m, m, a, lda, s, rwork( ie ), work( itauq ),
1725 $ work( itaup ), work( nwork ), lwork-nwork+1,
1737 CALL sbdsdc(
'U',
'I', m, s, rwork( ie ), rwork( iru ),
1738 $ m, rwork( irvt ), m, dum, idum,
1739 $ rwork( nrwork ), iwork, info )
1747 CALL clacp2(
'F', m, m, rwork( iru ), m, u, ldu )
1748 CALL cunmbr(
'Q',
'L',
'N', m, m, m, a, lda,
1749 $ work( itauq ), u, ldu, work( nwork ),
1750 $ lwork-nwork+1, ierr )
1758 CALL clacp2(
'F', m, m, rwork( irvt ), m, work( ivt ),
1760 CALL cunmbr(
'P',
'R',
'C', m, m, m, a, lda,
1761 $ work( itaup ), work( ivt ), ldwkvt,
1762 $ work( nwork ), lwork-nwork+1, ierr )
1769 CALL cgemm(
'N',
'N', m, n, m, cone, work( ivt ), ldwkvt,
1770 $ vt, ldvt, czero, a, lda )
1774 CALL clacpy(
'F', m, n, a, lda, vt, ldvt )
1778 ELSE IF( n.GE.mnthr2 )
THEN
1797 CALL cgebrd( m, n, a, lda, s, rwork( ie ), work( itauq ),
1798 $ work( itaup ), work( nwork ), lwork-nwork+1,
1808 CALL sbdsdc(
'L',
'N', m, s, rwork( ie ), dum,1,dum,1,
1809 $ dum, idum, rwork( nrwork ), iwork, info )
1810 ELSE IF( wntqo )
THEN
1822 CALL clacpy(
'L', m, m, a, lda, u, ldu )
1823 CALL cungbr(
'Q', m, m, n, u, ldu, work( itauq ),
1824 $ work( nwork ), lwork-nwork+1, ierr )
1831 CALL cungbr(
'P', m, n, m, a, lda, work( itaup ),
1832 $ work( nwork ), lwork-nwork+1, ierr )
1835 IF( lwork .GE. m*n + 3*m )
THEN
1839 nwork = ivt + ldwkvt*n
1845 chunk = ( lwork - 3*m ) / m
1846 nwork = ivt + ldwkvt*chunk
1855 CALL sbdsdc(
'L',
'I', m, s, rwork( ie ), rwork( iru ),
1856 $ m, rwork( irvt ), m, dum, idum,
1857 $ rwork( nrwork ), iwork, info )
1864 CALL clacrm( m, m, u, ldu, rwork( iru ), m, work( ivt ),
1865 $ ldwkvt, rwork( nrwork ) )
1866 CALL clacpy(
'F', m, m, work( ivt ), ldwkvt, u, ldu )
1876 DO 50 i = 1, n, chunk
1877 blk = min( n-i+1, chunk )
1878 CALL clarcm( m, blk, rwork( irvt ), m, a( 1, i ), lda,
1879 $ work( ivt ), ldwkvt, rwork( nrwork ) )
1880 CALL clacpy(
'F', m, blk, work( ivt ), ldwkvt,
1883 ELSE IF( wntqs )
THEN
1891 CALL clacpy(
'L', m, m, a, lda, u, ldu )
1892 CALL cungbr(
'Q', m, m, n, u, ldu, work( itauq ),
1893 $ work( nwork ), lwork-nwork+1, ierr )
1900 CALL clacpy(
'U', m, n, a, lda, vt, ldvt )
1901 CALL cungbr(
'P', m, n, m, vt, ldvt, work( itaup ),
1902 $ work( nwork ), lwork-nwork+1, ierr )
1913 CALL sbdsdc(
'L',
'I', m, s, rwork( ie ), rwork( iru ),
1914 $ m, rwork( irvt ), m, dum, idum,
1915 $ rwork( nrwork ), iwork, info )
1922 CALL clacrm( m, m, u, ldu, rwork( iru ), m, a, lda,
1924 CALL clacpy(
'F', m, m, a, lda, u, ldu )
1932 CALL clarcm( m, n, rwork( irvt ), m, vt, ldvt, a, lda,
1934 CALL clacpy(
'F', m, n, a, lda, vt, ldvt )
1943 CALL clacpy(
'L', m, m, a, lda, u, ldu )
1944 CALL cungbr(
'Q', m, m, n, u, ldu, work( itauq ),
1945 $ work( nwork ), lwork-nwork+1, ierr )
1952 CALL clacpy(
'U', m, n, a, lda, vt, ldvt )
1953 CALL cungbr(
'P', n, n, m, vt, ldvt, work( itaup ),
1954 $ work( nwork ), lwork-nwork+1, ierr )
1965 CALL sbdsdc(
'L',
'I', m, s, rwork( ie ), rwork( iru ),
1966 $ m, rwork( irvt ), m, dum, idum,
1967 $ rwork( nrwork ), iwork, info )
1974 CALL clacrm( m, m, u, ldu, rwork( iru ), m, a, lda,
1976 CALL clacpy(
'F', m, m, a, lda, u, ldu )
1984 CALL clarcm( m, n, rwork( irvt ), m, vt, ldvt, a, lda,
1986 CALL clacpy(
'F', m, n, a, lda, vt, ldvt )
2008 CALL cgebrd( m, n, a, lda, s, rwork( ie ), work( itauq ),
2009 $ work( itaup ), work( nwork ), lwork-nwork+1,
2018 CALL sbdsdc(
'L',
'N', m, s, rwork( ie ), dum,1,dum,1,
2019 $ dum, idum, rwork( nrwork ), iwork, info )
2020 ELSE IF( wntqo )
THEN
2024 IF( lwork .GE. m*n + 3*m )
THEN
2028 CALL claset(
'F', m, n, czero, czero, work( ivt ),
2030 nwork = ivt + ldwkvt*n
2035 chunk = ( lwork - 3*m ) / m
2036 nwork = ivt + ldwkvt*chunk
2048 CALL sbdsdc(
'L',
'I', m, s, rwork( ie ), rwork( iru ),
2049 $ m, rwork( irvt ), m, dum, idum,
2050 $ rwork( nrwork ), iwork, info )
2058 CALL clacp2(
'F', m, m, rwork( iru ), m, u, ldu )
2059 CALL cunmbr(
'Q',
'L',
'N', m, m, n, a, lda,
2060 $ work( itauq ), u, ldu, work( nwork ),
2061 $ lwork-nwork+1, ierr )
2063 IF( lwork .GE. m*n + 3*m )
THEN
2073 CALL clacp2(
'F', m, m, rwork( irvt ), m, work( ivt ),
2075 CALL cunmbr(
'P',
'R',
'C', m, n, m, a, lda,
2076 $ work( itaup ), work( ivt ), ldwkvt,
2077 $ work( nwork ), lwork-nwork+1, ierr )
2078 CALL clacpy(
'F', m, n, work( ivt ), ldwkvt, a, lda )
2087 CALL cungbr(
'P', m, n, m, a, lda, work( itaup ),
2088 $ work( nwork ), lwork-nwork+1, ierr )
2098 DO 60 i = 1, n, chunk
2099 blk = min( n-i+1, chunk )
2100 CALL clarcm( m, blk, rwork( irvt ), m, a( 1, i ),
2101 $ lda, work( ivt ), ldwkvt,
2103 CALL clacpy(
'F', m, blk, work( ivt ), ldwkvt,
2107 ELSE IF( wntqs )
THEN
2119 CALL sbdsdc(
'L',
'I', m, s, rwork( ie ), rwork( iru ),
2120 $ m, rwork( irvt ), m, dum, idum,
2121 $ rwork( nrwork ), iwork, info )
2129 CALL clacp2(
'F', m, m, rwork( iru ), m, u, ldu )
2130 CALL cunmbr(
'Q',
'L',
'N', m, m, n, a, lda,
2131 $ work( itauq ), u, ldu, work( nwork ),
2132 $ lwork-nwork+1, ierr )
2140 CALL claset(
'F', m, n, czero, czero, vt, ldvt )
2141 CALL clacp2(
'F', m, m, rwork( irvt ), m, vt, ldvt )
2142 CALL cunmbr(
'P',
'R',
'C', m, n, m, a, lda,
2143 $ work( itaup ), vt, ldvt, work( nwork ),
2144 $ lwork-nwork+1, ierr )
2158 CALL sbdsdc(
'L',
'I', m, s, rwork( ie ), rwork( iru ),
2159 $ m, rwork( irvt ), m, dum, idum,
2160 $ rwork( nrwork ), iwork, info )
2168 CALL clacp2(
'F', m, m, rwork( iru ), m, u, ldu )
2169 CALL cunmbr(
'Q',
'L',
'N', m, m, n, a, lda,
2170 $ work( itauq ), u, ldu, work( nwork ),
2171 $ lwork-nwork+1, ierr )
2175 CALL claset(
'F', n, n, czero, cone, vt, ldvt )
2183 CALL clacp2(
'F', m, m, rwork( irvt ), m, vt, ldvt )
2184 CALL cunmbr(
'P',
'R',
'C', n, n, m, a, lda,
2185 $ work( itaup ), vt, ldvt, work( nwork ),
2186 $ lwork-nwork+1, ierr )
2195 IF( iscl.EQ.1 )
THEN
2196 IF( anrm.GT.bignum )
2197 $
CALL slascl(
'G', 0, 0, bignum, anrm, minmn, 1, s, minmn,
2199 IF( info.NE.0 .AND. anrm.GT.bignum )
2200 $
CALL slascl(
'G', 0, 0, bignum, anrm, minmn-1, 1,
2201 $ rwork( ie ), minmn, ierr )
2202 IF( anrm.LT.smlnum )
2203 $
CALL slascl(
'G', 0, 0, smlnum, anrm, minmn, 1, s, minmn,
2205 IF( info.NE.0 .AND. anrm.LT.smlnum )
2206 $
CALL slascl(
'G', 0, 0, smlnum, anrm, minmn-1, 1,
2207 $ rwork( ie ), minmn, ierr )
subroutine cungbr(VECT, M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
CUNGBR
subroutine cunmbr(VECT, SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
CUNMBR
subroutine clascl(TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
CLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine slascl(TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
SLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine clarcm(M, N, A, LDA, B, LDB, C, LDC, RWORK)
CLARCM copies all or part of a real two-dimensional array to a complex array.
real function clange(NORM, M, N, A, LDA, WORK)
CLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value ...
subroutine xerbla(SRNAME, INFO)
XERBLA
subroutine cgelqf(M, N, A, LDA, TAU, WORK, LWORK, INFO)
CGELQF
subroutine clacp2(UPLO, M, N, A, LDA, B, LDB)
CLACP2 copies all or part of a real two-dimensional array to a complex array.
subroutine claset(UPLO, M, N, ALPHA, BETA, A, LDA)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values...
subroutine cunglq(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
CUNGLQ
subroutine cgeqrf(M, N, A, LDA, TAU, WORK, LWORK, INFO)
CGEQRF
subroutine cgebrd(M, N, A, LDA, D, E, TAUQ, TAUP, WORK, LWORK, INFO)
CGEBRD
subroutine sbdsdc(UPLO, COMPQ, N, D, E, U, LDU, VT, LDVT, Q, IQ, WORK, IWORK, INFO)
SBDSDC
subroutine clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
real function slamch(CMACH)
SLAMCH
subroutine clacrm(M, N, A, LDA, B, LDB, C, LDC, RWORK)
CLACRM multiplies a complex matrix by a square real matrix.
subroutine cungqr(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
CUNGQR
subroutine cgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
CGEMM
logical function lsame(CA, CB)
LSAME