212 SUBROUTINE cgesvd( JOBU, JOBVT, M, N, A, LDA, S, U, LDU, VT, LDVT,
213 $ WORK, LWORK, RWORK, INFO )
220 CHARACTER JOBU, JOBVT
221 INTEGER INFO, LDA, LDU, LDVT, LWORK, M, N
224 REAL RWORK( * ), S( * )
225 COMPLEX A( LDA, * ), U( LDU, * ), VT( LDVT, * ),
233 parameter( czero = ( 0.0e0, 0.0e0 ),
234 $ cone = ( 1.0e0, 0.0e0 ) )
236 parameter( zero = 0.0e0, one = 1.0e0 )
239 LOGICAL LQUERY, WNTUA, WNTUAS, WNTUN, WNTUO, WNTUS,
240 $ wntva, wntvas, wntvn, wntvo, wntvs
241 INTEGER BLK, CHUNK, I, IE, IERR, IR, IRWORK, ISCL,
242 $ itau, itaup, itauq, iu, iwork, ldwrkr, ldwrku,
243 $ maxwrk, minmn, minwrk, mnthr, ncu, ncvt, nru,
245 INTEGER LWORK_CGEQRF, LWORK_CUNGQR_N, LWORK_CUNGQR_M,
246 $ lwork_cgebrd, lwork_cungbr_p, lwork_cungbr_q,
247 $ lwork_cgelqf, lwork_cunglq_n, lwork_cunglq_m
248 REAL ANRM, BIGNUM, EPS, SMLNUM
262 REAL CLANGE, SLAMCH, SROUNDUP_LWORK
263 EXTERNAL lsame, ilaenv, clange, slamch, sroundup_lwork
266 INTRINSIC max, min, sqrt
274 wntua = lsame( jobu,
'A' )
275 wntus = lsame( jobu,
'S' )
276 wntuas = wntua .OR. wntus
277 wntuo = lsame( jobu,
'O' )
278 wntun = lsame( jobu,
'N' )
279 wntva = lsame( jobvt,
'A' )
280 wntvs = lsame( jobvt,
'S' )
281 wntvas = wntva .OR. wntvs
282 wntvo = lsame( jobvt,
'O' )
283 wntvn = lsame( jobvt,
'N' )
284 lquery = ( lwork.EQ.-1 )
286 IF( .NOT.( wntua .OR. wntus .OR. wntuo .OR. wntun ) )
THEN
288 ELSE IF( .NOT.( wntva .OR. wntvs .OR. wntvo .OR. wntvn ) .OR.
289 $ ( wntvo .AND. wntuo ) )
THEN
291 ELSE IF( m.LT.0 )
THEN
293 ELSE IF( n.LT.0 )
THEN
295 ELSE IF( lda.LT.max( 1, m ) )
THEN
297 ELSE IF( ldu.LT.1 .OR. ( wntuas .AND. ldu.LT.m ) )
THEN
299 ELSE IF( ldvt.LT.1 .OR. ( wntva .AND. ldvt.LT.n ) .OR.
300 $ ( wntvs .AND. ldvt.LT.minmn ) )
THEN
315 IF( m.GE.n .AND. minmn.GT.0 )
THEN
319 mnthr = ilaenv( 6,
'CGESVD', jobu // jobvt, m, n, 0, 0 )
321 CALL cgeqrf( m, n, a, lda, cdum(1), cdum(1), -1, ierr )
322 lwork_cgeqrf = int( cdum(1) )
324 CALL cungqr( m, n, n, a, lda, cdum(1), cdum(1), -1, ierr )
325 lwork_cungqr_n = int( cdum(1) )
326 CALL cungqr( m, m, n, a, lda, cdum(1), cdum(1), -1, ierr )
327 lwork_cungqr_m = int( cdum(1) )
329 CALL cgebrd( n, n, a, lda, s, dum(1), cdum(1),
330 $ cdum(1), cdum(1), -1, ierr )
331 lwork_cgebrd = int( cdum(1) )
333 CALL cungbr(
'P', n, n, n, a, lda, cdum(1),
334 $ cdum(1), -1, ierr )
335 lwork_cungbr_p = int( cdum(1) )
336 CALL cungbr(
'Q', n, n, n, a, lda, cdum(1),
337 $ cdum(1), -1, ierr )
338 lwork_cungbr_q = int( cdum(1) )
340 mnthr = ilaenv( 6,
'CGESVD', jobu // jobvt, m, n, 0, 0 )
341 IF( m.GE.mnthr )
THEN
346 maxwrk = n + lwork_cgeqrf
347 maxwrk = max( maxwrk, 2*n+lwork_cgebrd )
348 IF( wntvo .OR. wntvas )
349 $ maxwrk = max( maxwrk, 2*n+lwork_cungbr_p )
351 ELSE IF( wntuo .AND. wntvn )
THEN
355 wrkbl = n + lwork_cgeqrf
356 wrkbl = max( wrkbl, n+lwork_cungqr_n )
357 wrkbl = max( wrkbl, 2*n+lwork_cgebrd )
358 wrkbl = max( wrkbl, 2*n+lwork_cungbr_q )
359 maxwrk = max( n*n+wrkbl, n*n+m*n )
361 ELSE IF( wntuo .AND. wntvas )
THEN
366 wrkbl = n + lwork_cgeqrf
367 wrkbl = max( wrkbl, n+lwork_cungqr_n )
368 wrkbl = max( wrkbl, 2*n+lwork_cgebrd )
369 wrkbl = max( wrkbl, 2*n+lwork_cungbr_q )
370 wrkbl = max( wrkbl, 2*n+lwork_cungbr_p )
371 maxwrk = max( n*n+wrkbl, n*n+m*n )
373 ELSE IF( wntus .AND. wntvn )
THEN
377 wrkbl = n + lwork_cgeqrf
378 wrkbl = max( wrkbl, n+lwork_cungqr_n )
379 wrkbl = max( wrkbl, 2*n+lwork_cgebrd )
380 wrkbl = max( wrkbl, 2*n+lwork_cungbr_q )
383 ELSE IF( wntus .AND. wntvo )
THEN
387 wrkbl = n + lwork_cgeqrf
388 wrkbl = max( wrkbl, n+lwork_cungqr_n )
389 wrkbl = max( wrkbl, 2*n+lwork_cgebrd )
390 wrkbl = max( wrkbl, 2*n+lwork_cungbr_q )
391 wrkbl = max( wrkbl, 2*n+lwork_cungbr_p )
392 maxwrk = 2*n*n + wrkbl
394 ELSE IF( wntus .AND. wntvas )
THEN
399 wrkbl = n + lwork_cgeqrf
400 wrkbl = max( wrkbl, n+lwork_cungqr_n )
401 wrkbl = max( wrkbl, 2*n+lwork_cgebrd )
402 wrkbl = max( wrkbl, 2*n+lwork_cungbr_q )
403 wrkbl = max( wrkbl, 2*n+lwork_cungbr_p )
406 ELSE IF( wntua .AND. wntvn )
THEN
410 wrkbl = n + lwork_cgeqrf
411 wrkbl = max( wrkbl, n+lwork_cungqr_m )
412 wrkbl = max( wrkbl, 2*n+lwork_cgebrd )
413 wrkbl = max( wrkbl, 2*n+lwork_cungbr_q )
416 ELSE IF( wntua .AND. wntvo )
THEN
420 wrkbl = n + lwork_cgeqrf
421 wrkbl = max( wrkbl, n+lwork_cungqr_m )
422 wrkbl = max( wrkbl, 2*n+lwork_cgebrd )
423 wrkbl = max( wrkbl, 2*n+lwork_cungbr_q )
424 wrkbl = max( wrkbl, 2*n+lwork_cungbr_p )
425 maxwrk = 2*n*n + wrkbl
427 ELSE IF( wntua .AND. wntvas )
THEN
432 wrkbl = n + lwork_cgeqrf
433 wrkbl = max( wrkbl, n+lwork_cungqr_m )
434 wrkbl = max( wrkbl, 2*n+lwork_cgebrd )
435 wrkbl = max( wrkbl, 2*n+lwork_cungbr_q )
436 wrkbl = max( wrkbl, 2*n+lwork_cungbr_p )
444 CALL cgebrd( m, n, a, lda, s, dum(1), cdum(1),
445 $ cdum(1), cdum(1), -1, ierr )
446 lwork_cgebrd = int( cdum(1) )
447 maxwrk = 2*n + lwork_cgebrd
448 IF( wntus .OR. wntuo )
THEN
449 CALL cungbr(
'Q', m, n, n, a, lda, cdum(1),
450 $ cdum(1), -1, ierr )
451 lwork_cungbr_q = int( cdum(1) )
452 maxwrk = max( maxwrk, 2*n+lwork_cungbr_q )
455 CALL cungbr(
'Q', m, m, n, a, lda, cdum(1),
456 $ cdum(1), -1, ierr )
457 lwork_cungbr_q = int( cdum(1) )
458 maxwrk = max( maxwrk, 2*n+lwork_cungbr_q )
460 IF( .NOT.wntvn )
THEN
461 maxwrk = max( maxwrk, 2*n+lwork_cungbr_p )
465 ELSE IF( minmn.GT.0 )
THEN
469 mnthr = ilaenv( 6,
'CGESVD', jobu // jobvt, m, n, 0, 0 )
471 CALL cgelqf( m, n, a, lda, cdum(1), cdum(1), -1, ierr )
472 lwork_cgelqf = int( cdum(1) )
474 CALL cunglq( n, n, m, cdum(1), n, cdum(1), cdum(1), -1,
476 lwork_cunglq_n = int( cdum(1) )
477 CALL cunglq( m, n, m, a, lda, cdum(1), cdum(1), -1, ierr )
478 lwork_cunglq_m = int( cdum(1) )
480 CALL cgebrd( m, m, a, lda, s, dum(1), cdum(1),
481 $ cdum(1), cdum(1), -1, ierr )
482 lwork_cgebrd = int( cdum(1) )
484 CALL cungbr(
'P', m, m, m, a, n, cdum(1),
485 $ cdum(1), -1, ierr )
486 lwork_cungbr_p = int( cdum(1) )
488 CALL cungbr(
'Q', m, m, m, a, n, cdum(1),
489 $ cdum(1), -1, ierr )
490 lwork_cungbr_q = int( cdum(1) )
491 IF( n.GE.mnthr )
THEN
496 maxwrk = m + lwork_cgelqf
497 maxwrk = max( maxwrk, 2*m+lwork_cgebrd )
498 IF( wntuo .OR. wntuas )
499 $ maxwrk = max( maxwrk, 2*m+lwork_cungbr_q )
501 ELSE IF( wntvo .AND. wntun )
THEN
505 wrkbl = m + lwork_cgelqf
506 wrkbl = max( wrkbl, m+lwork_cunglq_m )
507 wrkbl = max( wrkbl, 2*m+lwork_cgebrd )
508 wrkbl = max( wrkbl, 2*m+lwork_cungbr_p )
509 maxwrk = max( m*m+wrkbl, m*m+m*n )
511 ELSE IF( wntvo .AND. wntuas )
THEN
516 wrkbl = m + lwork_cgelqf
517 wrkbl = max( wrkbl, m+lwork_cunglq_m )
518 wrkbl = max( wrkbl, 2*m+lwork_cgebrd )
519 wrkbl = max( wrkbl, 2*m+lwork_cungbr_p )
520 wrkbl = max( wrkbl, 2*m+lwork_cungbr_q )
521 maxwrk = max( m*m+wrkbl, m*m+m*n )
523 ELSE IF( wntvs .AND. wntun )
THEN
527 wrkbl = m + lwork_cgelqf
528 wrkbl = max( wrkbl, m+lwork_cunglq_m )
529 wrkbl = max( wrkbl, 2*m+lwork_cgebrd )
530 wrkbl = max( wrkbl, 2*m+lwork_cungbr_p )
533 ELSE IF( wntvs .AND. wntuo )
THEN
537 wrkbl = m + lwork_cgelqf
538 wrkbl = max( wrkbl, m+lwork_cunglq_m )
539 wrkbl = max( wrkbl, 2*m+lwork_cgebrd )
540 wrkbl = max( wrkbl, 2*m+lwork_cungbr_p )
541 wrkbl = max( wrkbl, 2*m+lwork_cungbr_q )
542 maxwrk = 2*m*m + wrkbl
544 ELSE IF( wntvs .AND. wntuas )
THEN
549 wrkbl = m + lwork_cgelqf
550 wrkbl = max( wrkbl, m+lwork_cunglq_m )
551 wrkbl = max( wrkbl, 2*m+lwork_cgebrd )
552 wrkbl = max( wrkbl, 2*m+lwork_cungbr_p )
553 wrkbl = max( wrkbl, 2*m+lwork_cungbr_q )
556 ELSE IF( wntva .AND. wntun )
THEN
560 wrkbl = m + lwork_cgelqf
561 wrkbl = max( wrkbl, m+lwork_cunglq_n )
562 wrkbl = max( wrkbl, 2*m+lwork_cgebrd )
563 wrkbl = max( wrkbl, 2*m+lwork_cungbr_p )
566 ELSE IF( wntva .AND. wntuo )
THEN
570 wrkbl = m + lwork_cgelqf
571 wrkbl = max( wrkbl, m+lwork_cunglq_n )
572 wrkbl = max( wrkbl, 2*m+lwork_cgebrd )
573 wrkbl = max( wrkbl, 2*m+lwork_cungbr_p )
574 wrkbl = max( wrkbl, 2*m+lwork_cungbr_q )
575 maxwrk = 2*m*m + wrkbl
577 ELSE IF( wntva .AND. wntuas )
THEN
582 wrkbl = m + lwork_cgelqf
583 wrkbl = max( wrkbl, m+lwork_cunglq_n )
584 wrkbl = max( wrkbl, 2*m+lwork_cgebrd )
585 wrkbl = max( wrkbl, 2*m+lwork_cungbr_p )
586 wrkbl = max( wrkbl, 2*m+lwork_cungbr_q )
594 CALL cgebrd( m, n, a, lda, s, dum(1), cdum(1),
595 $ cdum(1), cdum(1), -1, ierr )
596 lwork_cgebrd = int( cdum(1) )
597 maxwrk = 2*m + lwork_cgebrd
598 IF( wntvs .OR. wntvo )
THEN
600 CALL cungbr(
'P', m, n, m, a, n, cdum(1),
601 $ cdum(1), -1, ierr )
602 lwork_cungbr_p = int( cdum(1) )
603 maxwrk = max( maxwrk, 2*m+lwork_cungbr_p )
606 CALL cungbr(
'P', n, n, m, a, n, cdum(1),
607 $ cdum(1), -1, ierr )
608 lwork_cungbr_p = int( cdum(1) )
609 maxwrk = max( maxwrk, 2*m+lwork_cungbr_p )
611 IF( .NOT.wntun )
THEN
612 maxwrk = max( maxwrk, 2*m+lwork_cungbr_q )
617 maxwrk = max( minwrk, maxwrk )
618 work( 1 ) = sroundup_lwork(maxwrk)
620 IF( lwork.LT.minwrk .AND. .NOT.lquery )
THEN
626 CALL xerbla(
'CGESVD', -info )
628 ELSE IF( lquery )
THEN
634 IF( m.EQ.0 .OR. n.EQ.0 )
THEN
641 smlnum = sqrt( slamch(
'S' ) ) / eps
642 bignum = one / smlnum
646 anrm = clange(
'M', m, n, a, lda, dum )
648 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
650 CALL clascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, ierr )
651 ELSE IF( anrm.GT.bignum )
THEN
653 CALL clascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, ierr )
662 IF( m.GE.mnthr )
THEN
676 CALL cgeqrf( m, n, a, lda, work( itau ), work( iwork ),
677 $ lwork-iwork+1, ierr )
682 CALL claset(
'L', n-1, n-1, czero, czero, a( 2, 1 ),
694 CALL cgebrd( n, n, a, lda, s, rwork( ie ), work( itauq ),
695 $ work( itaup ), work( iwork ), lwork-iwork+1,
698 IF( wntvo .OR. wntvas )
THEN
704 CALL cungbr(
'P', n, n, n, a, lda, work( itaup ),
705 $ work( iwork ), lwork-iwork+1, ierr )
715 CALL cbdsqr(
'U', n, ncvt, 0, 0, s, rwork( ie ), a, lda,
716 $ cdum, 1, cdum, 1, rwork( irwork ), info )
721 $
CALL clacpy(
'F', n, n, a, lda, vt, ldvt )
723 ELSE IF( wntuo .AND. wntvn )
THEN
729 IF( lwork.GE.n*n+3*n )
THEN
734 IF( lwork.GE.max( wrkbl, lda*n )+lda*n )
THEN
740 ELSE IF( lwork.GE.max( wrkbl, lda*n )+n*n )
THEN
750 ldwrku = ( lwork-n*n ) / n
760 CALL cgeqrf( m, n, a, lda, work( itau ),
761 $ work( iwork ), lwork-iwork+1, ierr )
765 CALL clacpy(
'U', n, n, a, lda, work( ir ), ldwrkr )
766 CALL claset(
'L', n-1, n-1, czero, czero,
767 $ work( ir+1 ), ldwrkr )
773 CALL cungqr( m, n, n, a, lda, work( itau ),
774 $ work( iwork ), lwork-iwork+1, ierr )
784 CALL cgebrd( n, n, work( ir ), ldwrkr, s, rwork( ie ),
785 $ work( itauq ), work( itaup ),
786 $ work( iwork ), lwork-iwork+1, ierr )
792 CALL cungbr(
'Q', n, n, n, work( ir ), ldwrkr,
793 $ work( itauq ), work( iwork ),
794 $ lwork-iwork+1, ierr )
802 CALL cbdsqr(
'U', n, 0, n, 0, s, rwork( ie ), cdum, 1,
803 $ work( ir ), ldwrkr, cdum, 1,
804 $ rwork( irwork ), info )
812 DO 10 i = 1, m, ldwrku
813 chunk = min( m-i+1, ldwrku )
814 CALL cgemm(
'N',
'N', chunk, n, n, cone, a( i, 1 ),
815 $ lda, work( ir ), ldwrkr, czero,
816 $ work( iu ), ldwrku )
817 CALL clacpy(
'F', chunk, n, work( iu ), ldwrku,
834 CALL cgebrd( m, n, a, lda, s, rwork( ie ),
835 $ work( itauq ), work( itaup ),
836 $ work( iwork ), lwork-iwork+1, ierr )
842 CALL cungbr(
'Q', m, n, n, a, lda, work( itauq ),
843 $ work( iwork ), lwork-iwork+1, ierr )
851 CALL cbdsqr(
'U', n, 0, m, 0, s, rwork( ie ), cdum, 1,
852 $ a, lda, cdum, 1, rwork( irwork ), info )
856 ELSE IF( wntuo .AND. wntvas )
THEN
862 IF( lwork.GE.n*n+3*n )
THEN
867 IF( lwork.GE.max( wrkbl, lda*n )+lda*n )
THEN
873 ELSE IF( lwork.GE.max( wrkbl, lda*n )+n*n )
THEN
883 ldwrku = ( lwork-n*n ) / n
893 CALL cgeqrf( m, n, a, lda, work( itau ),
894 $ work( iwork ), lwork-iwork+1, ierr )
898 CALL clacpy(
'U', n, n, a, lda, vt, ldvt )
900 $
CALL claset(
'L', n-1, n-1, czero, czero,
907 CALL cungqr( m, n, n, a, lda, work( itau ),
908 $ work( iwork ), lwork-iwork+1, ierr )
918 CALL cgebrd( n, n, vt, ldvt, s, rwork( ie ),
919 $ work( itauq ), work( itaup ),
920 $ work( iwork ), lwork-iwork+1, ierr )
921 CALL clacpy(
'L', n, n, vt, ldvt, work( ir ), ldwrkr )
927 CALL cungbr(
'Q', n, n, n, work( ir ), ldwrkr,
928 $ work( itauq ), work( iwork ),
929 $ lwork-iwork+1, ierr )
935 CALL cungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
936 $ work( iwork ), lwork-iwork+1, ierr )
945 CALL cbdsqr(
'U', n, n, n, 0, s, rwork( ie ), vt,
946 $ ldvt, work( ir ), ldwrkr, cdum, 1,
947 $ rwork( irwork ), info )
955 DO 20 i = 1, m, ldwrku
956 chunk = min( m-i+1, ldwrku )
957 CALL cgemm(
'N',
'N', chunk, n, n, cone, a( i, 1 ),
958 $ lda, work( ir ), ldwrkr, czero,
959 $ work( iu ), ldwrku )
960 CALL clacpy(
'F', chunk, n, work( iu ), ldwrku,
975 CALL cgeqrf( m, n, a, lda, work( itau ),
976 $ work( iwork ), lwork-iwork+1, ierr )
980 CALL clacpy(
'U', n, n, a, lda, vt, ldvt )
982 $
CALL claset(
'L', n-1, n-1, czero, czero,
989 CALL cungqr( m, n, n, a, lda, work( itau ),
990 $ work( iwork ), lwork-iwork+1, ierr )
1000 CALL cgebrd( n, n, vt, ldvt, s, rwork( ie ),
1001 $ work( itauq ), work( itaup ),
1002 $ work( iwork ), lwork-iwork+1, ierr )
1008 CALL cunmbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1009 $ work( itauq ), a, lda, work( iwork ),
1010 $ lwork-iwork+1, ierr )
1016 CALL cungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1017 $ work( iwork ), lwork-iwork+1, ierr )
1026 CALL cbdsqr(
'U', n, n, m, 0, s, rwork( ie ), vt,
1027 $ ldvt, a, lda, cdum, 1, rwork( irwork ),
1032 ELSE IF( wntus )
THEN
1040 IF( lwork.GE.n*n+3*n )
THEN
1045 IF( lwork.GE.wrkbl+lda*n )
THEN
1056 itau = ir + ldwrkr*n
1063 CALL cgeqrf( m, n, a, lda, work( itau ),
1064 $ work( iwork ), lwork-iwork+1, ierr )
1068 CALL clacpy(
'U', n, n, a, lda, work( ir ),
1070 CALL claset(
'L', n-1, n-1, czero, czero,
1071 $ work( ir+1 ), ldwrkr )
1077 CALL cungqr( m, n, n, a, lda, work( itau ),
1078 $ work( iwork ), lwork-iwork+1, ierr )
1088 CALL cgebrd( n, n, work( ir ), ldwrkr, s,
1089 $ rwork( ie ), work( itauq ),
1090 $ work( itaup ), work( iwork ),
1091 $ lwork-iwork+1, ierr )
1097 CALL cungbr(
'Q', n, n, n, work( ir ), ldwrkr,
1098 $ work( itauq ), work( iwork ),
1099 $ lwork-iwork+1, ierr )
1107 CALL cbdsqr(
'U', n, 0, n, 0, s, rwork( ie ), cdum,
1108 $ 1, work( ir ), ldwrkr, cdum, 1,
1109 $ rwork( irwork ), info )
1116 CALL cgemm(
'N',
'N', m, n, n, cone, a, lda,
1117 $ work( ir ), ldwrkr, czero, u, ldu )
1130 CALL cgeqrf( m, n, a, lda, work( itau ),
1131 $ work( iwork ), lwork-iwork+1, ierr )
1132 CALL clacpy(
'L', m, n, a, lda, u, ldu )
1138 CALL cungqr( m, n, n, u, ldu, work( itau ),
1139 $ work( iwork ), lwork-iwork+1, ierr )
1148 CALL claset(
'L', n-1, n-1, czero, czero,
1156 CALL cgebrd( n, n, a, lda, s, rwork( ie ),
1157 $ work( itauq ), work( itaup ),
1158 $ work( iwork ), lwork-iwork+1, ierr )
1164 CALL cunmbr(
'Q',
'R',
'N', m, n, n, a, lda,
1165 $ work( itauq ), u, ldu, work( iwork ),
1166 $ lwork-iwork+1, ierr )
1174 CALL cbdsqr(
'U', n, 0, m, 0, s, rwork( ie ), cdum,
1175 $ 1, u, ldu, cdum, 1, rwork( irwork ),
1180 ELSE IF( wntvo )
THEN
1186 IF( lwork.GE.2*n*n+3*n )
THEN
1191 IF( lwork.GE.wrkbl+2*lda*n )
THEN
1198 ELSE IF( lwork.GE.wrkbl+( lda+n )*n )
THEN
1213 itau = ir + ldwrkr*n
1220 CALL cgeqrf( m, n, a, lda, work( itau ),
1221 $ work( iwork ), lwork-iwork+1, ierr )
1225 CALL clacpy(
'U', n, n, a, lda, work( iu ),
1227 CALL claset(
'L', n-1, n-1, czero, czero,
1228 $ work( iu+1 ), ldwrku )
1234 CALL cungqr( m, n, n, a, lda, work( itau ),
1235 $ work( iwork ), lwork-iwork+1, ierr )
1247 CALL cgebrd( n, n, work( iu ), ldwrku, s,
1248 $ rwork( ie ), work( itauq ),
1249 $ work( itaup ), work( iwork ),
1250 $ lwork-iwork+1, ierr )
1251 CALL clacpy(
'U', n, n, work( iu ), ldwrku,
1252 $ work( ir ), ldwrkr )
1258 CALL cungbr(
'Q', n, n, n, work( iu ), ldwrku,
1259 $ work( itauq ), work( iwork ),
1260 $ lwork-iwork+1, ierr )
1267 CALL cungbr(
'P', n, n, n, work( ir ), ldwrkr,
1268 $ work( itaup ), work( iwork ),
1269 $ lwork-iwork+1, ierr )
1278 CALL cbdsqr(
'U', n, n, n, 0, s, rwork( ie ),
1279 $ work( ir ), ldwrkr, work( iu ),
1280 $ ldwrku, cdum, 1, rwork( irwork ),
1288 CALL cgemm(
'N',
'N', m, n, n, cone, a, lda,
1289 $ work( iu ), ldwrku, czero, u, ldu )
1295 CALL clacpy(
'F', n, n, work( ir ), ldwrkr, a,
1309 CALL cgeqrf( m, n, a, lda, work( itau ),
1310 $ work( iwork ), lwork-iwork+1, ierr )
1311 CALL clacpy(
'L', m, n, a, lda, u, ldu )
1317 CALL cungqr( m, n, n, u, ldu, work( itau ),
1318 $ work( iwork ), lwork-iwork+1, ierr )
1327 CALL claset(
'L', n-1, n-1, czero, czero,
1335 CALL cgebrd( n, n, a, lda, s, rwork( ie ),
1336 $ work( itauq ), work( itaup ),
1337 $ work( iwork ), lwork-iwork+1, ierr )
1343 CALL cunmbr(
'Q',
'R',
'N', m, n, n, a, lda,
1344 $ work( itauq ), u, ldu, work( iwork ),
1345 $ lwork-iwork+1, ierr )
1351 CALL cungbr(
'P', n, n, n, a, lda, work( itaup ),
1352 $ work( iwork ), lwork-iwork+1, ierr )
1361 CALL cbdsqr(
'U', n, n, m, 0, s, rwork( ie ), a,
1362 $ lda, u, ldu, cdum, 1, rwork( irwork ),
1367 ELSE IF( wntvas )
THEN
1374 IF( lwork.GE.n*n+3*n )
THEN
1379 IF( lwork.GE.wrkbl+lda*n )
THEN
1390 itau = iu + ldwrku*n
1397 CALL cgeqrf( m, n, a, lda, work( itau ),
1398 $ work( iwork ), lwork-iwork+1, ierr )
1402 CALL clacpy(
'U', n, n, a, lda, work( iu ),
1404 CALL claset(
'L', n-1, n-1, czero, czero,
1405 $ work( iu+1 ), ldwrku )
1411 CALL cungqr( m, n, n, a, lda, work( itau ),
1412 $ work( iwork ), lwork-iwork+1, ierr )
1422 CALL cgebrd( n, n, work( iu ), ldwrku, s,
1423 $ rwork( ie ), work( itauq ),
1424 $ work( itaup ), work( iwork ),
1425 $ lwork-iwork+1, ierr )
1426 CALL clacpy(
'U', n, n, work( iu ), ldwrku, vt,
1433 CALL cungbr(
'Q', n, n, n, work( iu ), ldwrku,
1434 $ work( itauq ), work( iwork ),
1435 $ lwork-iwork+1, ierr )
1442 CALL cungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1443 $ work( iwork ), lwork-iwork+1, ierr )
1452 CALL cbdsqr(
'U', n, n, n, 0, s, rwork( ie ), vt,
1453 $ ldvt, work( iu ), ldwrku, cdum, 1,
1454 $ rwork( irwork ), info )
1461 CALL cgemm(
'N',
'N', m, n, n, cone, a, lda,
1462 $ work( iu ), ldwrku, czero, u, ldu )
1475 CALL cgeqrf( m, n, a, lda, work( itau ),
1476 $ work( iwork ), lwork-iwork+1, ierr )
1477 CALL clacpy(
'L', m, n, a, lda, u, ldu )
1483 CALL cungqr( m, n, n, u, ldu, work( itau ),
1484 $ work( iwork ), lwork-iwork+1, ierr )
1488 CALL clacpy(
'U', n, n, a, lda, vt, ldvt )
1490 $
CALL claset(
'L', n-1, n-1, czero, czero,
1491 $ vt( 2, 1 ), ldvt )
1501 CALL cgebrd( n, n, vt, ldvt, s, rwork( ie ),
1502 $ work( itauq ), work( itaup ),
1503 $ work( iwork ), lwork-iwork+1, ierr )
1510 CALL cunmbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1511 $ work( itauq ), u, ldu, work( iwork ),
1512 $ lwork-iwork+1, ierr )
1518 CALL cungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1519 $ work( iwork ), lwork-iwork+1, ierr )
1528 CALL cbdsqr(
'U', n, n, m, 0, s, rwork( ie ), vt,
1529 $ ldvt, u, ldu, cdum, 1,
1530 $ rwork( irwork ), info )
1536 ELSE IF( wntua )
THEN
1544 IF( lwork.GE.n*n+max( n+m, 3*n ) )
THEN
1549 IF( lwork.GE.wrkbl+lda*n )
THEN
1560 itau = ir + ldwrkr*n
1567 CALL cgeqrf( m, n, a, lda, work( itau ),
1568 $ work( iwork ), lwork-iwork+1, ierr )
1569 CALL clacpy(
'L', m, n, a, lda, u, ldu )
1573 CALL clacpy(
'U', n, n, a, lda, work( ir ),
1575 CALL claset(
'L', n-1, n-1, czero, czero,
1576 $ work( ir+1 ), ldwrkr )
1582 CALL cungqr( m, m, n, u, ldu, work( itau ),
1583 $ work( iwork ), lwork-iwork+1, ierr )
1593 CALL cgebrd( n, n, work( ir ), ldwrkr, s,
1594 $ rwork( ie ), work( itauq ),
1595 $ work( itaup ), work( iwork ),
1596 $ lwork-iwork+1, ierr )
1602 CALL cungbr(
'Q', n, n, n, work( ir ), ldwrkr,
1603 $ work( itauq ), work( iwork ),
1604 $ lwork-iwork+1, ierr )
1612 CALL cbdsqr(
'U', n, 0, n, 0, s, rwork( ie ), cdum,
1613 $ 1, work( ir ), ldwrkr, cdum, 1,
1614 $ rwork( irwork ), info )
1621 CALL cgemm(
'N',
'N', m, n, n, cone, u, ldu,
1622 $ work( ir ), ldwrkr, czero, a, lda )
1626 CALL clacpy(
'F', m, n, a, lda, u, ldu )
1639 CALL cgeqrf( m, n, a, lda, work( itau ),
1640 $ work( iwork ), lwork-iwork+1, ierr )
1641 CALL clacpy(
'L', m, n, a, lda, u, ldu )
1647 CALL cungqr( m, m, n, u, ldu, work( itau ),
1648 $ work( iwork ), lwork-iwork+1, ierr )
1657 CALL claset(
'L', n-1, n-1, czero, czero,
1665 CALL cgebrd( n, n, a, lda, s, rwork( ie ),
1666 $ work( itauq ), work( itaup ),
1667 $ work( iwork ), lwork-iwork+1, ierr )
1674 CALL cunmbr(
'Q',
'R',
'N', m, n, n, a, lda,
1675 $ work( itauq ), u, ldu, work( iwork ),
1676 $ lwork-iwork+1, ierr )
1684 CALL cbdsqr(
'U', n, 0, m, 0, s, rwork( ie ), cdum,
1685 $ 1, u, ldu, cdum, 1, rwork( irwork ),
1690 ELSE IF( wntvo )
THEN
1696 IF( lwork.GE.2*n*n+max( n+m, 3*n ) )
THEN
1701 IF( lwork.GE.wrkbl+2*lda*n )
THEN
1708 ELSE IF( lwork.GE.wrkbl+( lda+n )*n )
THEN
1723 itau = ir + ldwrkr*n
1730 CALL cgeqrf( m, n, a, lda, work( itau ),
1731 $ work( iwork ), lwork-iwork+1, ierr )
1732 CALL clacpy(
'L', m, n, a, lda, u, ldu )
1738 CALL cungqr( m, m, n, u, ldu, work( itau ),
1739 $ work( iwork ), lwork-iwork+1, ierr )
1743 CALL clacpy(
'U', n, n, a, lda, work( iu ),
1745 CALL claset(
'L', n-1, n-1, czero, czero,
1746 $ work( iu+1 ), ldwrku )
1758 CALL cgebrd( n, n, work( iu ), ldwrku, s,
1759 $ rwork( ie ), work( itauq ),
1760 $ work( itaup ), work( iwork ),
1761 $ lwork-iwork+1, ierr )
1762 CALL clacpy(
'U', n, n, work( iu ), ldwrku,
1763 $ work( ir ), ldwrkr )
1769 CALL cungbr(
'Q', n, n, n, work( iu ), ldwrku,
1770 $ work( itauq ), work( iwork ),
1771 $ lwork-iwork+1, ierr )
1778 CALL cungbr(
'P', n, n, n, work( ir ), ldwrkr,
1779 $ work( itaup ), work( iwork ),
1780 $ lwork-iwork+1, ierr )
1789 CALL cbdsqr(
'U', n, n, n, 0, s, rwork( ie ),
1790 $ work( ir ), ldwrkr, work( iu ),
1791 $ ldwrku, cdum, 1, rwork( irwork ),
1799 CALL cgemm(
'N',
'N', m, n, n, cone, u, ldu,
1800 $ work( iu ), ldwrku, czero, a, lda )
1804 CALL clacpy(
'F', m, n, a, lda, u, ldu )
1808 CALL clacpy(
'F', n, n, work( ir ), ldwrkr, a,
1822 CALL cgeqrf( m, n, a, lda, work( itau ),
1823 $ work( iwork ), lwork-iwork+1, ierr )
1824 CALL clacpy(
'L', m, n, a, lda, u, ldu )
1830 CALL cungqr( m, m, n, u, ldu, work( itau ),
1831 $ work( iwork ), lwork-iwork+1, ierr )
1840 CALL claset(
'L', n-1, n-1, czero, czero,
1848 CALL cgebrd( n, n, a, lda, s, rwork( ie ),
1849 $ work( itauq ), work( itaup ),
1850 $ work( iwork ), lwork-iwork+1, ierr )
1857 CALL cunmbr(
'Q',
'R',
'N', m, n, n, a, lda,
1858 $ work( itauq ), u, ldu, work( iwork ),
1859 $ lwork-iwork+1, ierr )
1865 CALL cungbr(
'P', n, n, n, a, lda, work( itaup ),
1866 $ work( iwork ), lwork-iwork+1, ierr )
1875 CALL cbdsqr(
'U', n, n, m, 0, s, rwork( ie ), a,
1876 $ lda, u, ldu, cdum, 1, rwork( irwork ),
1881 ELSE IF( wntvas )
THEN
1888 IF( lwork.GE.n*n+max( n+m, 3*n ) )
THEN
1893 IF( lwork.GE.wrkbl+lda*n )
THEN
1904 itau = iu + ldwrku*n
1911 CALL cgeqrf( m, n, a, lda, work( itau ),
1912 $ work( iwork ), lwork-iwork+1, ierr )
1913 CALL clacpy(
'L', m, n, a, lda, u, ldu )
1919 CALL cungqr( m, m, n, u, ldu, work( itau ),
1920 $ work( iwork ), lwork-iwork+1, ierr )
1924 CALL clacpy(
'U', n, n, a, lda, work( iu ),
1926 CALL claset(
'L', n-1, n-1, czero, czero,
1927 $ work( iu+1 ), ldwrku )
1937 CALL cgebrd( n, n, work( iu ), ldwrku, s,
1938 $ rwork( ie ), work( itauq ),
1939 $ work( itaup ), work( iwork ),
1940 $ lwork-iwork+1, ierr )
1941 CALL clacpy(
'U', n, n, work( iu ), ldwrku, vt,
1948 CALL cungbr(
'Q', n, n, n, work( iu ), ldwrku,
1949 $ work( itauq ), work( iwork ),
1950 $ lwork-iwork+1, ierr )
1957 CALL cungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1958 $ work( iwork ), lwork-iwork+1, ierr )
1967 CALL cbdsqr(
'U', n, n, n, 0, s, rwork( ie ), vt,
1968 $ ldvt, work( iu ), ldwrku, cdum, 1,
1969 $ rwork( irwork ), info )
1976 CALL cgemm(
'N',
'N', m, n, n, cone, u, ldu,
1977 $ work( iu ), ldwrku, czero, a, lda )
1981 CALL clacpy(
'F', m, n, a, lda, u, ldu )
1994 CALL cgeqrf( m, n, a, lda, work( itau ),
1995 $ work( iwork ), lwork-iwork+1, ierr )
1996 CALL clacpy(
'L', m, n, a, lda, u, ldu )
2002 CALL cungqr( m, m, n, u, ldu, work( itau ),
2003 $ work( iwork ), lwork-iwork+1, ierr )
2007 CALL clacpy(
'U', n, n, a, lda, vt, ldvt )
2009 $
CALL claset(
'L', n-1, n-1, czero, czero,
2010 $ vt( 2, 1 ), ldvt )
2020 CALL cgebrd( n, n, vt, ldvt, s, rwork( ie ),
2021 $ work( itauq ), work( itaup ),
2022 $ work( iwork ), lwork-iwork+1, ierr )
2029 CALL cunmbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
2030 $ work( itauq ), u, ldu, work( iwork ),
2031 $ lwork-iwork+1, ierr )
2037 CALL cungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
2038 $ work( iwork ), lwork-iwork+1, ierr )
2047 CALL cbdsqr(
'U', n, n, m, 0, s, rwork( ie ), vt,
2048 $ ldvt, u, ldu, cdum, 1,
2049 $ rwork( irwork ), info )
2073 CALL cgebrd( m, n, a, lda, s, rwork( ie ), work( itauq ),
2074 $ work( itaup ), work( iwork ), lwork-iwork+1,
2083 CALL clacpy(
'L', m, n, a, lda, u, ldu )
2088 CALL cungbr(
'Q', m, ncu, n, u, ldu, work( itauq ),
2089 $ work( iwork ), lwork-iwork+1, ierr )
2098 CALL clacpy(
'U', n, n, a, lda, vt, ldvt )
2099 CALL cungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
2100 $ work( iwork ), lwork-iwork+1, ierr )
2109 CALL cungbr(
'Q', m, n, n, a, lda, work( itauq ),
2110 $ work( iwork ), lwork-iwork+1, ierr )
2119 CALL cungbr(
'P', n, n, n, a, lda, work( itaup ),
2120 $ work( iwork ), lwork-iwork+1, ierr )
2123 IF( wntuas .OR. wntuo )
2127 IF( wntvas .OR. wntvo )
2131 IF( ( .NOT.wntuo ) .AND. ( .NOT.wntvo ) )
THEN
2139 CALL cbdsqr(
'U', n, ncvt, nru, 0, s, rwork( ie ), vt,
2140 $ ldvt, u, ldu, cdum, 1, rwork( irwork ),
2142 ELSE IF( ( .NOT.wntuo ) .AND. wntvo )
THEN
2150 CALL cbdsqr(
'U', n, ncvt, nru, 0, s, rwork( ie ), a,
2151 $ lda, u, ldu, cdum, 1, rwork( irwork ),
2161 CALL cbdsqr(
'U', n, ncvt, nru, 0, s, rwork( ie ), vt,
2162 $ ldvt, a, lda, cdum, 1, rwork( irwork ),
2174 IF( n.GE.mnthr )
THEN
2188 CALL cgelqf( m, n, a, lda, work( itau ), work( iwork ),
2189 $ lwork-iwork+1, ierr )
2193 CALL claset(
'U', m-1, m-1, czero, czero, a( 1, 2 ),
2204 CALL cgebrd( m, m, a, lda, s, rwork( ie ), work( itauq ),
2205 $ work( itaup ), work( iwork ), lwork-iwork+1,
2207 IF( wntuo .OR. wntuas )
THEN
2213 CALL cungbr(
'Q', m, m, m, a, lda, work( itauq ),
2214 $ work( iwork ), lwork-iwork+1, ierr )
2218 IF( wntuo .OR. wntuas )
2226 CALL cbdsqr(
'U', m, 0, nru, 0, s, rwork( ie ), cdum, 1,
2227 $ a, lda, cdum, 1, rwork( irwork ), info )
2232 $
CALL clacpy(
'F', m, m, a, lda, u, ldu )
2234 ELSE IF( wntvo .AND. wntun )
THEN
2240 IF( lwork.GE.m*m+3*m )
THEN
2245 IF( lwork.GE.max( wrkbl, lda*n )+lda*m )
THEN
2252 ELSE IF( lwork.GE.max( wrkbl, lda*n )+m*m )
THEN
2264 chunk = ( lwork-m*m ) / m
2267 itau = ir + ldwrkr*m
2274 CALL cgelqf( m, n, a, lda, work( itau ),
2275 $ work( iwork ), lwork-iwork+1, ierr )
2279 CALL clacpy(
'L', m, m, a, lda, work( ir ), ldwrkr )
2280 CALL claset(
'U', m-1, m-1, czero, czero,
2281 $ work( ir+ldwrkr ), ldwrkr )
2287 CALL cunglq( m, n, m, a, lda, work( itau ),
2288 $ work( iwork ), lwork-iwork+1, ierr )
2298 CALL cgebrd( m, m, work( ir ), ldwrkr, s, rwork( ie ),
2299 $ work( itauq ), work( itaup ),
2300 $ work( iwork ), lwork-iwork+1, ierr )
2306 CALL cungbr(
'P', m, m, m, work( ir ), ldwrkr,
2307 $ work( itaup ), work( iwork ),
2308 $ lwork-iwork+1, ierr )
2316 CALL cbdsqr(
'U', m, m, 0, 0, s, rwork( ie ),
2317 $ work( ir ), ldwrkr, cdum, 1, cdum, 1,
2318 $ rwork( irwork ), info )
2326 DO 30 i = 1, n, chunk
2327 blk = min( n-i+1, chunk )
2328 CALL cgemm(
'N',
'N', m, blk, m, cone, work( ir ),
2329 $ ldwrkr, a( 1, i ), lda, czero,
2330 $ work( iu ), ldwrku )
2331 CALL clacpy(
'F', m, blk, work( iu ), ldwrku,
2348 CALL cgebrd( m, n, a, lda, s, rwork( ie ),
2349 $ work( itauq ), work( itaup ),
2350 $ work( iwork ), lwork-iwork+1, ierr )
2356 CALL cungbr(
'P', m, n, m, a, lda, work( itaup ),
2357 $ work( iwork ), lwork-iwork+1, ierr )
2365 CALL cbdsqr(
'L', m, n, 0, 0, s, rwork( ie ), a, lda,
2366 $ cdum, 1, cdum, 1, rwork( irwork ), info )
2370 ELSE IF( wntvo .AND. wntuas )
THEN
2376 IF( lwork.GE.m*m+3*m )
THEN
2381 IF( lwork.GE.max( wrkbl, lda*n )+lda*m )
THEN
2388 ELSE IF( lwork.GE.max( wrkbl, lda*n )+m*m )
THEN
2400 chunk = ( lwork-m*m ) / m
2403 itau = ir + ldwrkr*m
2410 CALL cgelqf( m, n, a, lda, work( itau ),
2411 $ work( iwork ), lwork-iwork+1, ierr )
2415 CALL clacpy(
'L', m, m, a, lda, u, ldu )
2416 CALL claset(
'U', m-1, m-1, czero, czero, u( 1, 2 ),
2423 CALL cunglq( m, n, m, a, lda, work( itau ),
2424 $ work( iwork ), lwork-iwork+1, ierr )
2434 CALL cgebrd( m, m, u, ldu, s, rwork( ie ),
2435 $ work( itauq ), work( itaup ),
2436 $ work( iwork ), lwork-iwork+1, ierr )
2437 CALL clacpy(
'U', m, m, u, ldu, work( ir ), ldwrkr )
2443 CALL cungbr(
'P', m, m, m, work( ir ), ldwrkr,
2444 $ work( itaup ), work( iwork ),
2445 $ lwork-iwork+1, ierr )
2451 CALL cungbr(
'Q', m, m, m, u, ldu, work( itauq ),
2452 $ work( iwork ), lwork-iwork+1, ierr )
2461 CALL cbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
2462 $ work( ir ), ldwrkr, u, ldu, cdum, 1,
2463 $ rwork( irwork ), info )
2471 DO 40 i = 1, n, chunk
2472 blk = min( n-i+1, chunk )
2473 CALL cgemm(
'N',
'N', m, blk, m, cone, work( ir ),
2474 $ ldwrkr, a( 1, i ), lda, czero,
2475 $ work( iu ), ldwrku )
2476 CALL clacpy(
'F', m, blk, work( iu ), ldwrku,
2491 CALL cgelqf( m, n, a, lda, work( itau ),
2492 $ work( iwork ), lwork-iwork+1, ierr )
2496 CALL clacpy(
'L', m, m, a, lda, u, ldu )
2497 CALL claset(
'U', m-1, m-1, czero, czero, u( 1, 2 ),
2504 CALL cunglq( m, n, m, a, lda, work( itau ),
2505 $ work( iwork ), lwork-iwork+1, ierr )
2515 CALL cgebrd( m, m, u, ldu, s, rwork( ie ),
2516 $ work( itauq ), work( itaup ),
2517 $ work( iwork ), lwork-iwork+1, ierr )
2523 CALL cunmbr(
'P',
'L',
'C', m, n, m, u, ldu,
2524 $ work( itaup ), a, lda, work( iwork ),
2525 $ lwork-iwork+1, ierr )
2531 CALL cungbr(
'Q', m, m, m, u, ldu, work( itauq ),
2532 $ work( iwork ), lwork-iwork+1, ierr )
2541 CALL cbdsqr(
'U', m, n, m, 0, s, rwork( ie ), a, lda,
2542 $ u, ldu, cdum, 1, rwork( irwork ), info )
2546 ELSE IF( wntvs )
THEN
2554 IF( lwork.GE.m*m+3*m )
THEN
2559 IF( lwork.GE.wrkbl+lda*m )
THEN
2570 itau = ir + ldwrkr*m
2577 CALL cgelqf( m, n, a, lda, work( itau ),
2578 $ work( iwork ), lwork-iwork+1, ierr )
2582 CALL clacpy(
'L', m, m, a, lda, work( ir ),
2584 CALL claset(
'U', m-1, m-1, czero, czero,
2585 $ work( ir+ldwrkr ), ldwrkr )
2591 CALL cunglq( m, n, m, a, lda, work( itau ),
2592 $ work( iwork ), lwork-iwork+1, ierr )
2602 CALL cgebrd( m, m, work( ir ), ldwrkr, s,
2603 $ rwork( ie ), work( itauq ),
2604 $ work( itaup ), work( iwork ),
2605 $ lwork-iwork+1, ierr )
2612 CALL cungbr(
'P', m, m, m, work( ir ), ldwrkr,
2613 $ work( itaup ), work( iwork ),
2614 $ lwork-iwork+1, ierr )
2622 CALL cbdsqr(
'U', m, m, 0, 0, s, rwork( ie ),
2623 $ work( ir ), ldwrkr, cdum, 1, cdum, 1,
2624 $ rwork( irwork ), info )
2631 CALL cgemm(
'N',
'N', m, n, m, cone, work( ir ),
2632 $ ldwrkr, a, lda, czero, vt, ldvt )
2645 CALL cgelqf( m, n, a, lda, work( itau ),
2646 $ work( iwork ), lwork-iwork+1, ierr )
2650 CALL clacpy(
'U', m, n, a, lda, vt, ldvt )
2656 CALL cunglq( m, n, m, vt, ldvt, work( itau ),
2657 $ work( iwork ), lwork-iwork+1, ierr )
2665 CALL claset(
'U', m-1, m-1, czero, czero,
2672 CALL cgebrd( m, m, a, lda, s, rwork( ie ),
2673 $ work( itauq ), work( itaup ),
2674 $ work( iwork ), lwork-iwork+1, ierr )
2680 CALL cunmbr(
'P',
'L',
'C', m, n, m, a, lda,
2681 $ work( itaup ), vt, ldvt,
2682 $ work( iwork ), lwork-iwork+1, ierr )
2690 CALL cbdsqr(
'U', m, n, 0, 0, s, rwork( ie ), vt,
2691 $ ldvt, cdum, 1, cdum, 1,
2692 $ rwork( irwork ), info )
2696 ELSE IF( wntuo )
THEN
2702 IF( lwork.GE.2*m*m+3*m )
THEN
2707 IF( lwork.GE.wrkbl+2*lda*m )
THEN
2714 ELSE IF( lwork.GE.wrkbl+( lda+m )*m )
THEN
2729 itau = ir + ldwrkr*m
2736 CALL cgelqf( m, n, a, lda, work( itau ),
2737 $ work( iwork ), lwork-iwork+1, ierr )
2741 CALL clacpy(
'L', m, m, a, lda, work( iu ),
2743 CALL claset(
'U', m-1, m-1, czero, czero,
2744 $ work( iu+ldwrku ), ldwrku )
2750 CALL cunglq( m, n, m, a, lda, work( itau ),
2751 $ work( iwork ), lwork-iwork+1, ierr )
2763 CALL cgebrd( m, m, work( iu ), ldwrku, s,
2764 $ rwork( ie ), work( itauq ),
2765 $ work( itaup ), work( iwork ),
2766 $ lwork-iwork+1, ierr )
2767 CALL clacpy(
'L', m, m, work( iu ), ldwrku,
2768 $ work( ir ), ldwrkr )
2775 CALL cungbr(
'P', m, m, m, work( iu ), ldwrku,
2776 $ work( itaup ), work( iwork ),
2777 $ lwork-iwork+1, ierr )
2783 CALL cungbr(
'Q', m, m, m, work( ir ), ldwrkr,
2784 $ work( itauq ), work( iwork ),
2785 $ lwork-iwork+1, ierr )
2794 CALL cbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
2795 $ work( iu ), ldwrku, work( ir ),
2796 $ ldwrkr, cdum, 1, rwork( irwork ),
2804 CALL cgemm(
'N',
'N', m, n, m, cone, work( iu ),
2805 $ ldwrku, a, lda, czero, vt, ldvt )
2811 CALL clacpy(
'F', m, m, work( ir ), ldwrkr, a,
2825 CALL cgelqf( m, n, a, lda, work( itau ),
2826 $ work( iwork ), lwork-iwork+1, ierr )
2827 CALL clacpy(
'U', m, n, a, lda, vt, ldvt )
2833 CALL cunglq( m, n, m, vt, ldvt, work( itau ),
2834 $ work( iwork ), lwork-iwork+1, ierr )
2842 CALL claset(
'U', m-1, m-1, czero, czero,
2849 CALL cgebrd( m, m, a, lda, s, rwork( ie ),
2850 $ work( itauq ), work( itaup ),
2851 $ work( iwork ), lwork-iwork+1, ierr )
2857 CALL cunmbr(
'P',
'L',
'C', m, n, m, a, lda,
2858 $ work( itaup ), vt, ldvt,
2859 $ work( iwork ), lwork-iwork+1, ierr )
2865 CALL cungbr(
'Q', m, m, m, a, lda, work( itauq ),
2866 $ work( iwork ), lwork-iwork+1, ierr )
2875 CALL cbdsqr(
'U', m, n, m, 0, s, rwork( ie ), vt,
2876 $ ldvt, a, lda, cdum, 1,
2877 $ rwork( irwork ), info )
2881 ELSE IF( wntuas )
THEN
2888 IF( lwork.GE.m*m+3*m )
THEN
2893 IF( lwork.GE.wrkbl+lda*m )
THEN
2904 itau = iu + ldwrku*m
2911 CALL cgelqf( m, n, a, lda, work( itau ),
2912 $ work( iwork ), lwork-iwork+1, ierr )
2916 CALL clacpy(
'L', m, m, a, lda, work( iu ),
2918 CALL claset(
'U', m-1, m-1, czero, czero,
2919 $ work( iu+ldwrku ), ldwrku )
2925 CALL cunglq( m, n, m, a, lda, work( itau ),
2926 $ work( iwork ), lwork-iwork+1, ierr )
2936 CALL cgebrd( m, m, work( iu ), ldwrku, s,
2937 $ rwork( ie ), work( itauq ),
2938 $ work( itaup ), work( iwork ),
2939 $ lwork-iwork+1, ierr )
2940 CALL clacpy(
'L', m, m, work( iu ), ldwrku, u,
2948 CALL cungbr(
'P', m, m, m, work( iu ), ldwrku,
2949 $ work( itaup ), work( iwork ),
2950 $ lwork-iwork+1, ierr )
2956 CALL cungbr(
'Q', m, m, m, u, ldu, work( itauq ),
2957 $ work( iwork ), lwork-iwork+1, ierr )
2966 CALL cbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
2967 $ work( iu ), ldwrku, u, ldu, cdum, 1,
2968 $ rwork( irwork ), info )
2975 CALL cgemm(
'N',
'N', m, n, m, cone, work( iu ),
2976 $ ldwrku, a, lda, czero, vt, ldvt )
2989 CALL cgelqf( m, n, a, lda, work( itau ),
2990 $ work( iwork ), lwork-iwork+1, ierr )
2991 CALL clacpy(
'U', m, n, a, lda, vt, ldvt )
2997 CALL cunglq( m, n, m, vt, ldvt, work( itau ),
2998 $ work( iwork ), lwork-iwork+1, ierr )
3002 CALL clacpy(
'L', m, m, a, lda, u, ldu )
3003 CALL claset(
'U', m-1, m-1, czero, czero,
3014 CALL cgebrd( m, m, u, ldu, s, rwork( ie ),
3015 $ work( itauq ), work( itaup ),
3016 $ work( iwork ), lwork-iwork+1, ierr )
3023 CALL cunmbr(
'P',
'L',
'C', m, n, m, u, ldu,
3024 $ work( itaup ), vt, ldvt,
3025 $ work( iwork ), lwork-iwork+1, ierr )
3031 CALL cungbr(
'Q', m, m, m, u, ldu, work( itauq ),
3032 $ work( iwork ), lwork-iwork+1, ierr )
3041 CALL cbdsqr(
'U', m, n, m, 0, s, rwork( ie ), vt,
3042 $ ldvt, u, ldu, cdum, 1,
3043 $ rwork( irwork ), info )
3049 ELSE IF( wntva )
THEN
3057 IF( lwork.GE.m*m+max( n+m, 3*m ) )
THEN
3062 IF( lwork.GE.wrkbl+lda*m )
THEN
3073 itau = ir + ldwrkr*m
3080 CALL cgelqf( m, n, a, lda, work( itau ),
3081 $ work( iwork ), lwork-iwork+1, ierr )
3082 CALL clacpy(
'U', m, n, a, lda, vt, ldvt )
3086 CALL clacpy(
'L', m, m, a, lda, work( ir ),
3088 CALL claset(
'U', m-1, m-1, czero, czero,
3089 $ work( ir+ldwrkr ), ldwrkr )
3095 CALL cunglq( n, n, m, vt, ldvt, work( itau ),
3096 $ work( iwork ), lwork-iwork+1, ierr )
3106 CALL cgebrd( m, m, work( ir ), ldwrkr, s,
3107 $ rwork( ie ), work( itauq ),
3108 $ work( itaup ), work( iwork ),
3109 $ lwork-iwork+1, ierr )
3116 CALL cungbr(
'P', m, m, m, work( ir ), ldwrkr,
3117 $ work( itaup ), work( iwork ),
3118 $ lwork-iwork+1, ierr )
3126 CALL cbdsqr(
'U', m, m, 0, 0, s, rwork( ie ),
3127 $ work( ir ), ldwrkr, cdum, 1, cdum, 1,
3128 $ rwork( irwork ), info )
3135 CALL cgemm(
'N',
'N', m, n, m, cone, work( ir ),
3136 $ ldwrkr, vt, ldvt, czero, a, lda )
3140 CALL clacpy(
'F', m, n, a, lda, vt, ldvt )
3153 CALL cgelqf( m, n, a, lda, work( itau ),
3154 $ work( iwork ), lwork-iwork+1, ierr )
3155 CALL clacpy(
'U', m, n, a, lda, vt, ldvt )
3161 CALL cunglq( n, n, m, vt, ldvt, work( itau ),
3162 $ work( iwork ), lwork-iwork+1, ierr )
3170 CALL claset(
'U', m-1, m-1, czero, czero,
3177 CALL cgebrd( m, m, a, lda, s, rwork( ie ),
3178 $ work( itauq ), work( itaup ),
3179 $ work( iwork ), lwork-iwork+1, ierr )
3186 CALL cunmbr(
'P',
'L',
'C', m, n, m, a, lda,
3187 $ work( itaup ), vt, ldvt,
3188 $ work( iwork ), lwork-iwork+1, ierr )
3196 CALL cbdsqr(
'U', m, n, 0, 0, s, rwork( ie ), vt,
3197 $ ldvt, cdum, 1, cdum, 1,
3198 $ rwork( irwork ), info )
3202 ELSE IF( wntuo )
THEN
3208 IF( lwork.GE.2*m*m+max( n+m, 3*m ) )
THEN
3213 IF( lwork.GE.wrkbl+2*lda*m )
THEN
3220 ELSE IF( lwork.GE.wrkbl+( lda+m )*m )
THEN
3235 itau = ir + ldwrkr*m
3242 CALL cgelqf( m, n, a, lda, work( itau ),
3243 $ work( iwork ), lwork-iwork+1, ierr )
3244 CALL clacpy(
'U', m, n, a, lda, vt, ldvt )
3250 CALL cunglq( n, n, m, vt, ldvt, work( itau ),
3251 $ work( iwork ), lwork-iwork+1, ierr )
3255 CALL clacpy(
'L', m, m, a, lda, work( iu ),
3257 CALL claset(
'U', m-1, m-1, czero, czero,
3258 $ work( iu+ldwrku ), ldwrku )
3270 CALL cgebrd( m, m, work( iu ), ldwrku, s,
3271 $ rwork( ie ), work( itauq ),
3272 $ work( itaup ), work( iwork ),
3273 $ lwork-iwork+1, ierr )
3274 CALL clacpy(
'L', m, m, work( iu ), ldwrku,
3275 $ work( ir ), ldwrkr )
3282 CALL cungbr(
'P', m, m, m, work( iu ), ldwrku,
3283 $ work( itaup ), work( iwork ),
3284 $ lwork-iwork+1, ierr )
3290 CALL cungbr(
'Q', m, m, m, work( ir ), ldwrkr,
3291 $ work( itauq ), work( iwork ),
3292 $ lwork-iwork+1, ierr )
3301 CALL cbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
3302 $ work( iu ), ldwrku, work( ir ),
3303 $ ldwrkr, cdum, 1, rwork( irwork ),
3311 CALL cgemm(
'N',
'N', m, n, m, cone, work( iu ),
3312 $ ldwrku, vt, ldvt, czero, a, lda )
3316 CALL clacpy(
'F', m, n, a, lda, vt, ldvt )
3320 CALL clacpy(
'F', m, m, work( ir ), ldwrkr, a,
3334 CALL cgelqf( m, n, a, lda, work( itau ),
3335 $ work( iwork ), lwork-iwork+1, ierr )
3336 CALL clacpy(
'U', m, n, a, lda, vt, ldvt )
3342 CALL cunglq( n, n, m, vt, ldvt, work( itau ),
3343 $ work( iwork ), lwork-iwork+1, ierr )
3351 CALL claset(
'U', m-1, m-1, czero, czero,
3358 CALL cgebrd( m, m, a, lda, s, rwork( ie ),
3359 $ work( itauq ), work( itaup ),
3360 $ work( iwork ), lwork-iwork+1, ierr )
3367 CALL cunmbr(
'P',
'L',
'C', m, n, m, a, lda,
3368 $ work( itaup ), vt, ldvt,
3369 $ work( iwork ), lwork-iwork+1, ierr )
3375 CALL cungbr(
'Q', m, m, m, a, lda, work( itauq ),
3376 $ work( iwork ), lwork-iwork+1, ierr )
3385 CALL cbdsqr(
'U', m, n, m, 0, s, rwork( ie ), vt,
3386 $ ldvt, a, lda, cdum, 1,
3387 $ rwork( irwork ), info )
3391 ELSE IF( wntuas )
THEN
3398 IF( lwork.GE.m*m+max( n+m, 3*m ) )
THEN
3403 IF( lwork.GE.wrkbl+lda*m )
THEN
3414 itau = iu + ldwrku*m
3421 CALL cgelqf( m, n, a, lda, work( itau ),
3422 $ work( iwork ), lwork-iwork+1, ierr )
3423 CALL clacpy(
'U', m, n, a, lda, vt, ldvt )
3429 CALL cunglq( n, n, m, vt, ldvt, work( itau ),
3430 $ work( iwork ), lwork-iwork+1, ierr )
3434 CALL clacpy(
'L', m, m, a, lda, work( iu ),
3436 CALL claset(
'U', m-1, m-1, czero, czero,
3437 $ work( iu+ldwrku ), ldwrku )
3447 CALL cgebrd( m, m, work( iu ), ldwrku, s,
3448 $ rwork( ie ), work( itauq ),
3449 $ work( itaup ), work( iwork ),
3450 $ lwork-iwork+1, ierr )
3451 CALL clacpy(
'L', m, m, work( iu ), ldwrku, u,
3458 CALL cungbr(
'P', m, m, m, work( iu ), ldwrku,
3459 $ work( itaup ), work( iwork ),
3460 $ lwork-iwork+1, ierr )
3466 CALL cungbr(
'Q', m, m, m, u, ldu, work( itauq ),
3467 $ work( iwork ), lwork-iwork+1, ierr )
3476 CALL cbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
3477 $ work( iu ), ldwrku, u, ldu, cdum, 1,
3478 $ rwork( irwork ), info )
3485 CALL cgemm(
'N',
'N', m, n, m, cone, work( iu ),
3486 $ ldwrku, vt, ldvt, czero, a, lda )
3490 CALL clacpy(
'F', m, n, a, lda, vt, ldvt )
3503 CALL cgelqf( m, n, a, lda, work( itau ),
3504 $ work( iwork ), lwork-iwork+1, ierr )
3505 CALL clacpy(
'U', m, n, a, lda, vt, ldvt )
3511 CALL cunglq( n, n, m, vt, ldvt, work( itau ),
3512 $ work( iwork ), lwork-iwork+1, ierr )
3516 CALL clacpy(
'L', m, m, a, lda, u, ldu )
3517 CALL claset(
'U', m-1, m-1, czero, czero,
3528 CALL cgebrd( m, m, u, ldu, s, rwork( ie ),
3529 $ work( itauq ), work( itaup ),
3530 $ work( iwork ), lwork-iwork+1, ierr )
3537 CALL cunmbr(
'P',
'L',
'C', m, n, m, u, ldu,
3538 $ work( itaup ), vt, ldvt,
3539 $ work( iwork ), lwork-iwork+1, ierr )
3545 CALL cungbr(
'Q', m, m, m, u, ldu, work( itauq ),
3546 $ work( iwork ), lwork-iwork+1, ierr )
3555 CALL cbdsqr(
'U', m, n, m, 0, s, rwork( ie ), vt,
3556 $ ldvt, u, ldu, cdum, 1,
3557 $ rwork( irwork ), info )
3581 CALL cgebrd( m, n, a, lda, s, rwork( ie ), work( itauq ),
3582 $ work( itaup ), work( iwork ), lwork-iwork+1,
3591 CALL clacpy(
'L', m, m, a, lda, u, ldu )
3592 CALL cungbr(
'Q', m, m, n, u, ldu, work( itauq ),
3593 $ work( iwork ), lwork-iwork+1, ierr )
3602 CALL clacpy(
'U', m, n, a, lda, vt, ldvt )
3607 CALL cungbr(
'P', nrvt, n, m, vt, ldvt, work( itaup ),
3608 $ work( iwork ), lwork-iwork+1, ierr )
3617 CALL cungbr(
'Q', m, m, n, a, lda, work( itauq ),
3618 $ work( iwork ), lwork-iwork+1, ierr )
3627 CALL cungbr(
'P', m, n, m, a, lda, work( itaup ),
3628 $ work( iwork ), lwork-iwork+1, ierr )
3631 IF( wntuas .OR. wntuo )
3635 IF( wntvas .OR. wntvo )
3639 IF( ( .NOT.wntuo ) .AND. ( .NOT.wntvo ) )
THEN
3647 CALL cbdsqr(
'L', m, ncvt, nru, 0, s, rwork( ie ), vt,
3648 $ ldvt, u, ldu, cdum, 1, rwork( irwork ),
3650 ELSE IF( ( .NOT.wntuo ) .AND. wntvo )
THEN
3658 CALL cbdsqr(
'L', m, ncvt, nru, 0, s, rwork( ie ), a,
3659 $ lda, u, ldu, cdum, 1, rwork( irwork ),
3669 CALL cbdsqr(
'L', m, ncvt, nru, 0, s, rwork( ie ), vt,
3670 $ ldvt, a, lda, cdum, 1, rwork( irwork ),
3680 IF( iscl.EQ.1 )
THEN
3681 IF( anrm.GT.bignum )
3682 $
CALL slascl(
'G', 0, 0, bignum, anrm, minmn, 1, s, minmn,
3684 IF( info.NE.0 .AND. anrm.GT.bignum )
3685 $
CALL slascl(
'G', 0, 0, bignum, anrm, minmn-1, 1,
3686 $ rwork( ie ), minmn, ierr )
3687 IF( anrm.LT.smlnum )
3688 $
CALL slascl(
'G', 0, 0, smlnum, anrm, minmn, 1, s, minmn,
3690 IF( info.NE.0 .AND. anrm.LT.smlnum )
3691 $
CALL slascl(
'G', 0, 0, smlnum, anrm, minmn-1, 1,
3692 $ rwork( ie ), minmn, ierr )
3697 work( 1 ) = sroundup_lwork(maxwrk)
subroutine xerbla(srname, info)
subroutine cbdsqr(uplo, n, ncvt, nru, ncc, d, e, vt, ldvt, u, ldu, c, ldc, rwork, info)
CBDSQR
subroutine cgebrd(m, n, a, lda, d, e, tauq, taup, work, lwork, info)
CGEBRD
subroutine cgelqf(m, n, a, lda, tau, work, lwork, info)
CGELQF
subroutine cgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
CGEMM
subroutine cgeqrf(m, n, a, lda, tau, work, lwork, info)
CGEQRF
subroutine cgesvd(jobu, jobvt, m, n, a, lda, s, u, ldu, vt, ldvt, work, lwork, rwork, info)
CGESVD computes the singular value decomposition (SVD) for GE matrices
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
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 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 cungbr(vect, m, n, k, a, lda, tau, work, lwork, info)
CUNGBR
subroutine cunglq(m, n, k, a, lda, tau, work, lwork, info)
CUNGLQ
subroutine cungqr(m, n, k, a, lda, tau, work, lwork, info)
CUNGQR
subroutine cunmbr(vect, side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
CUNMBR