210 SUBROUTINE zgesvd( JOBU, JOBVT, M, N, A, LDA, S, U, LDU,
211 $ VT, LDVT, WORK, LWORK, RWORK, INFO )
218 CHARACTER JOBU, JOBVT
219 INTEGER INFO, LDA, LDU, LDVT, LWORK, M, N
222 DOUBLE PRECISION RWORK( * ), S( * )
223 COMPLEX*16 A( LDA, * ), U( LDU, * ), VT( LDVT, * ),
230 COMPLEX*16 CZERO, CONE
231 parameter( czero = ( 0.0d0, 0.0d0 ),
232 $ cone = ( 1.0d0, 0.0d0 ) )
233 DOUBLE PRECISION ZERO, ONE
234 parameter( zero = 0.0d0, one = 1.0d0 )
237 LOGICAL LQUERY, WNTUA, WNTUAS, WNTUN, WNTUO, WNTUS,
238 $ wntva, wntvas, wntvn, wntvo, wntvs
239 INTEGER BLK, CHUNK, I, IE, IERR, IR, IRWORK, ISCL,
240 $ itau, itaup, itauq, iu, iwork, ldwrkr, ldwrku,
241 $ maxwrk, minmn, minwrk, mnthr, ncu, ncvt, nru,
243 INTEGER LWORK_ZGEQRF, LWORK_ZUNGQR_N, LWORK_ZUNGQR_M,
244 $ lwork_zgebrd, lwork_zungbr_p, lwork_zungbr_q,
245 $ lwork_zgelqf, lwork_zunglq_n, lwork_zunglq_m
246 DOUBLE PRECISION ANRM, BIGNUM, EPS, SMLNUM
249 DOUBLE PRECISION DUM( 1 )
261 DOUBLE PRECISION DLAMCH, ZLANGE
262 EXTERNAL lsame, ilaenv, dlamch, zlange
265 INTRINSIC max, min, sqrt
273 wntua = lsame( jobu,
'A' )
274 wntus = lsame( jobu,
'S' )
275 wntuas = wntua .OR. wntus
276 wntuo = lsame( jobu,
'O' )
277 wntun = lsame( jobu,
'N' )
278 wntva = lsame( jobvt,
'A' )
279 wntvs = lsame( jobvt,
'S' )
280 wntvas = wntva .OR. wntvs
281 wntvo = lsame( jobvt,
'O' )
282 wntvn = lsame( jobvt,
'N' )
283 lquery = ( lwork.EQ.-1 )
285 IF( .NOT.( wntua .OR. wntus .OR. wntuo .OR. wntun ) )
THEN
287 ELSE IF( .NOT.( wntva .OR. wntvs .OR. wntvo .OR. wntvn ) .OR.
288 $ ( wntvo .AND. wntuo ) )
THEN
290 ELSE IF( m.LT.0 )
THEN
292 ELSE IF( n.LT.0 )
THEN
294 ELSE IF( lda.LT.max( 1, m ) )
THEN
296 ELSE IF( ldu.LT.1 .OR. ( wntuas .AND. ldu.LT.m ) )
THEN
298 ELSE IF( ldvt.LT.1 .OR. ( wntva .AND. ldvt.LT.n ) .OR.
299 $ ( wntvs .AND. ldvt.LT.minmn ) )
THEN
314 IF( m.GE.n .AND. minmn.GT.0 )
THEN
318 mnthr = ilaenv( 6,
'ZGESVD', jobu // jobvt, m, n, 0, 0 )
320 CALL zgeqrf( m, n, a, lda, cdum(1), cdum(1), -1, ierr )
321 lwork_zgeqrf = int( cdum(1) )
323 CALL zungqr( m, n, n, a, lda, cdum(1), cdum(1), -1,
325 lwork_zungqr_n = int( cdum(1) )
326 CALL zungqr( m, m, n, a, lda, cdum(1), cdum(1), -1,
328 lwork_zungqr_m = int( cdum(1) )
330 CALL zgebrd( n, n, a, lda, s, dum(1), cdum(1),
331 $ cdum(1), cdum(1), -1, ierr )
332 lwork_zgebrd = int( cdum(1) )
334 CALL zungbr(
'P', n, n, n, a, lda, cdum(1),
335 $ cdum(1), -1, ierr )
336 lwork_zungbr_p = int( cdum(1) )
337 CALL zungbr(
'Q', n, n, n, a, lda, cdum(1),
338 $ cdum(1), -1, ierr )
339 lwork_zungbr_q = int( cdum(1) )
341 IF( m.GE.mnthr )
THEN
346 maxwrk = n + lwork_zgeqrf
347 maxwrk = max( maxwrk, 2*n+lwork_zgebrd )
348 IF( wntvo .OR. wntvas )
349 $ maxwrk = max( maxwrk, 2*n+lwork_zungbr_p )
351 ELSE IF( wntuo .AND. wntvn )
THEN
355 wrkbl = n + lwork_zgeqrf
356 wrkbl = max( wrkbl, n+lwork_zungqr_n )
357 wrkbl = max( wrkbl, 2*n+lwork_zgebrd )
358 wrkbl = max( wrkbl, 2*n+lwork_zungbr_q )
359 maxwrk = max( n*n+wrkbl, n*n+m*n )
361 ELSE IF( wntuo .AND. wntvas )
THEN
366 wrkbl = n + lwork_zgeqrf
367 wrkbl = max( wrkbl, n+lwork_zungqr_n )
368 wrkbl = max( wrkbl, 2*n+lwork_zgebrd )
369 wrkbl = max( wrkbl, 2*n+lwork_zungbr_q )
370 wrkbl = max( wrkbl, 2*n+lwork_zungbr_p )
371 maxwrk = max( n*n+wrkbl, n*n+m*n )
373 ELSE IF( wntus .AND. wntvn )
THEN
377 wrkbl = n + lwork_zgeqrf
378 wrkbl = max( wrkbl, n+lwork_zungqr_n )
379 wrkbl = max( wrkbl, 2*n+lwork_zgebrd )
380 wrkbl = max( wrkbl, 2*n+lwork_zungbr_q )
383 ELSE IF( wntus .AND. wntvo )
THEN
387 wrkbl = n + lwork_zgeqrf
388 wrkbl = max( wrkbl, n+lwork_zungqr_n )
389 wrkbl = max( wrkbl, 2*n+lwork_zgebrd )
390 wrkbl = max( wrkbl, 2*n+lwork_zungbr_q )
391 wrkbl = max( wrkbl, 2*n+lwork_zungbr_p )
392 maxwrk = 2*n*n + wrkbl
394 ELSE IF( wntus .AND. wntvas )
THEN
399 wrkbl = n + lwork_zgeqrf
400 wrkbl = max( wrkbl, n+lwork_zungqr_n )
401 wrkbl = max( wrkbl, 2*n+lwork_zgebrd )
402 wrkbl = max( wrkbl, 2*n+lwork_zungbr_q )
403 wrkbl = max( wrkbl, 2*n+lwork_zungbr_p )
406 ELSE IF( wntua .AND. wntvn )
THEN
410 wrkbl = n + lwork_zgeqrf
411 wrkbl = max( wrkbl, n+lwork_zungqr_m )
412 wrkbl = max( wrkbl, 2*n+lwork_zgebrd )
413 wrkbl = max( wrkbl, 2*n+lwork_zungbr_q )
416 ELSE IF( wntua .AND. wntvo )
THEN
420 wrkbl = n + lwork_zgeqrf
421 wrkbl = max( wrkbl, n+lwork_zungqr_m )
422 wrkbl = max( wrkbl, 2*n+lwork_zgebrd )
423 wrkbl = max( wrkbl, 2*n+lwork_zungbr_q )
424 wrkbl = max( wrkbl, 2*n+lwork_zungbr_p )
425 maxwrk = 2*n*n + wrkbl
427 ELSE IF( wntua .AND. wntvas )
THEN
432 wrkbl = n + lwork_zgeqrf
433 wrkbl = max( wrkbl, n+lwork_zungqr_m )
434 wrkbl = max( wrkbl, 2*n+lwork_zgebrd )
435 wrkbl = max( wrkbl, 2*n+lwork_zungbr_q )
436 wrkbl = max( wrkbl, 2*n+lwork_zungbr_p )
444 CALL zgebrd( m, n, a, lda, s, dum(1), cdum(1),
445 $ cdum(1), cdum(1), -1, ierr )
446 lwork_zgebrd = int( cdum(1) )
447 maxwrk = 2*n + lwork_zgebrd
448 IF( wntus .OR. wntuo )
THEN
449 CALL zungbr(
'Q', m, n, n, a, lda, cdum(1),
450 $ cdum(1), -1, ierr )
451 lwork_zungbr_q = int( cdum(1) )
452 maxwrk = max( maxwrk, 2*n+lwork_zungbr_q )
455 CALL zungbr(
'Q', m, m, n, a, lda, cdum(1),
456 $ cdum(1), -1, ierr )
457 lwork_zungbr_q = int( cdum(1) )
458 maxwrk = max( maxwrk, 2*n+lwork_zungbr_q )
460 IF( .NOT.wntvn )
THEN
461 maxwrk = max( maxwrk, 2*n+lwork_zungbr_p )
465 ELSE IF( minmn.GT.0 )
THEN
469 mnthr = ilaenv( 6,
'ZGESVD', jobu // jobvt, m, n, 0, 0 )
471 CALL zgelqf( m, n, a, lda, cdum(1), cdum(1), -1, ierr )
472 lwork_zgelqf = int( cdum(1) )
474 CALL zunglq( n, n, m, cdum(1), n, cdum(1), cdum(1), -1,
476 lwork_zunglq_n = int( cdum(1) )
477 CALL zunglq( m, n, m, a, lda, cdum(1), cdum(1), -1,
479 lwork_zunglq_m = int( cdum(1) )
481 CALL zgebrd( m, m, a, lda, s, dum(1), cdum(1),
482 $ cdum(1), cdum(1), -1, ierr )
483 lwork_zgebrd = int( cdum(1) )
485 CALL zungbr(
'P', m, m, m, a, n, cdum(1),
486 $ cdum(1), -1, ierr )
487 lwork_zungbr_p = int( cdum(1) )
489 CALL zungbr(
'Q', m, m, m, a, n, cdum(1),
490 $ cdum(1), -1, ierr )
491 lwork_zungbr_q = int( cdum(1) )
492 IF( n.GE.mnthr )
THEN
497 maxwrk = m + lwork_zgelqf
498 maxwrk = max( maxwrk, 2*m+lwork_zgebrd )
499 IF( wntuo .OR. wntuas )
500 $ maxwrk = max( maxwrk, 2*m+lwork_zungbr_q )
502 ELSE IF( wntvo .AND. wntun )
THEN
506 wrkbl = m + lwork_zgelqf
507 wrkbl = max( wrkbl, m+lwork_zunglq_m )
508 wrkbl = max( wrkbl, 2*m+lwork_zgebrd )
509 wrkbl = max( wrkbl, 2*m+lwork_zungbr_p )
510 maxwrk = max( m*m+wrkbl, m*m+m*n )
512 ELSE IF( wntvo .AND. wntuas )
THEN
517 wrkbl = m + lwork_zgelqf
518 wrkbl = max( wrkbl, m+lwork_zunglq_m )
519 wrkbl = max( wrkbl, 2*m+lwork_zgebrd )
520 wrkbl = max( wrkbl, 2*m+lwork_zungbr_p )
521 wrkbl = max( wrkbl, 2*m+lwork_zungbr_q )
522 maxwrk = max( m*m+wrkbl, m*m+m*n )
524 ELSE IF( wntvs .AND. wntun )
THEN
528 wrkbl = m + lwork_zgelqf
529 wrkbl = max( wrkbl, m+lwork_zunglq_m )
530 wrkbl = max( wrkbl, 2*m+lwork_zgebrd )
531 wrkbl = max( wrkbl, 2*m+lwork_zungbr_p )
534 ELSE IF( wntvs .AND. wntuo )
THEN
538 wrkbl = m + lwork_zgelqf
539 wrkbl = max( wrkbl, m+lwork_zunglq_m )
540 wrkbl = max( wrkbl, 2*m+lwork_zgebrd )
541 wrkbl = max( wrkbl, 2*m+lwork_zungbr_p )
542 wrkbl = max( wrkbl, 2*m+lwork_zungbr_q )
543 maxwrk = 2*m*m + wrkbl
545 ELSE IF( wntvs .AND. wntuas )
THEN
550 wrkbl = m + lwork_zgelqf
551 wrkbl = max( wrkbl, m+lwork_zunglq_m )
552 wrkbl = max( wrkbl, 2*m+lwork_zgebrd )
553 wrkbl = max( wrkbl, 2*m+lwork_zungbr_p )
554 wrkbl = max( wrkbl, 2*m+lwork_zungbr_q )
557 ELSE IF( wntva .AND. wntun )
THEN
561 wrkbl = m + lwork_zgelqf
562 wrkbl = max( wrkbl, m+lwork_zunglq_n )
563 wrkbl = max( wrkbl, 2*m+lwork_zgebrd )
564 wrkbl = max( wrkbl, 2*m+lwork_zungbr_p )
567 ELSE IF( wntva .AND. wntuo )
THEN
571 wrkbl = m + lwork_zgelqf
572 wrkbl = max( wrkbl, m+lwork_zunglq_n )
573 wrkbl = max( wrkbl, 2*m+lwork_zgebrd )
574 wrkbl = max( wrkbl, 2*m+lwork_zungbr_p )
575 wrkbl = max( wrkbl, 2*m+lwork_zungbr_q )
576 maxwrk = 2*m*m + wrkbl
578 ELSE IF( wntva .AND. wntuas )
THEN
583 wrkbl = m + lwork_zgelqf
584 wrkbl = max( wrkbl, m+lwork_zunglq_n )
585 wrkbl = max( wrkbl, 2*m+lwork_zgebrd )
586 wrkbl = max( wrkbl, 2*m+lwork_zungbr_p )
587 wrkbl = max( wrkbl, 2*m+lwork_zungbr_q )
595 CALL zgebrd( m, n, a, lda, s, dum(1), cdum(1),
596 $ cdum(1), cdum(1), -1, ierr )
597 lwork_zgebrd = int( cdum(1) )
598 maxwrk = 2*m + lwork_zgebrd
599 IF( wntvs .OR. wntvo )
THEN
601 CALL zungbr(
'P', m, n, m, a, n, cdum(1),
602 $ cdum(1), -1, ierr )
603 lwork_zungbr_p = int( cdum(1) )
604 maxwrk = max( maxwrk, 2*m+lwork_zungbr_p )
607 CALL zungbr(
'P', n, n, m, a, n, cdum(1),
608 $ cdum(1), -1, ierr )
609 lwork_zungbr_p = int( cdum(1) )
610 maxwrk = max( maxwrk, 2*m+lwork_zungbr_p )
612 IF( .NOT.wntun )
THEN
613 maxwrk = max( maxwrk, 2*m+lwork_zungbr_q )
618 maxwrk = max( maxwrk, minwrk )
621 IF( lwork.LT.minwrk .AND. .NOT.lquery )
THEN
627 CALL xerbla(
'ZGESVD', -info )
629 ELSE IF( lquery )
THEN
635 IF( m.EQ.0 .OR. n.EQ.0 )
THEN
642 smlnum = sqrt( dlamch(
'S' ) ) / eps
643 bignum = one / smlnum
647 anrm = zlange(
'M', m, n, a, lda, dum )
649 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
651 CALL zlascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, ierr )
652 ELSE IF( anrm.GT.bignum )
THEN
654 CALL zlascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, ierr )
663 IF( m.GE.mnthr )
THEN
677 CALL zgeqrf( m, n, a, lda, work( itau ),
679 $ lwork-iwork+1, ierr )
684 CALL zlaset(
'L', n-1, n-1, czero, czero, a( 2,
697 CALL zgebrd( n, n, a, lda, s, rwork( ie ),
699 $ work( itaup ), work( iwork ), lwork-iwork+1,
702 IF( wntvo .OR. wntvas )
THEN
708 CALL zungbr(
'P', n, n, n, a, lda, work( itaup ),
709 $ work( iwork ), lwork-iwork+1, ierr )
719 CALL zbdsqr(
'U', n, ncvt, 0, 0, s, rwork( ie ), a,
721 $ cdum, 1, cdum, 1, rwork( irwork ), info )
726 $
CALL zlacpy(
'F', n, n, a, lda, vt, ldvt )
728 ELSE IF( wntuo .AND. wntvn )
THEN
734 IF( lwork.GE.n*n+3*n )
THEN
739 IF( lwork.GE.max( wrkbl, lda*n )+lda*n )
THEN
745 ELSE IF( lwork.GE.max( wrkbl, lda*n )+n*n )
THEN
755 ldwrku = ( lwork-n*n ) / n
765 CALL zgeqrf( m, n, a, lda, work( itau ),
766 $ work( iwork ), lwork-iwork+1, ierr )
770 CALL zlacpy(
'U', n, n, a, lda, work( ir ),
772 CALL zlaset(
'L', n-1, n-1, czero, czero,
773 $ work( ir+1 ), ldwrkr )
779 CALL zungqr( m, n, n, a, lda, work( itau ),
780 $ work( iwork ), lwork-iwork+1, ierr )
790 CALL zgebrd( n, n, work( ir ), ldwrkr, s,
792 $ work( itauq ), work( itaup ),
793 $ work( iwork ), lwork-iwork+1, ierr )
799 CALL zungbr(
'Q', n, n, n, work( ir ), ldwrkr,
800 $ work( itauq ), work( iwork ),
801 $ lwork-iwork+1, ierr )
809 CALL zbdsqr(
'U', n, 0, n, 0, s, rwork( ie ), cdum,
811 $ work( ir ), ldwrkr, cdum, 1,
812 $ rwork( irwork ), info )
820 DO 10 i = 1, m, ldwrku
821 chunk = min( m-i+1, ldwrku )
822 CALL zgemm(
'N',
'N', chunk, n, n, cone, a( i,
824 $ lda, work( ir ), ldwrkr, czero,
825 $ work( iu ), ldwrku )
826 CALL zlacpy(
'F', chunk, n, work( iu ), ldwrku,
843 CALL zgebrd( m, n, a, lda, s, rwork( ie ),
844 $ work( itauq ), work( itaup ),
845 $ work( iwork ), lwork-iwork+1, ierr )
851 CALL zungbr(
'Q', m, n, n, a, lda, work( itauq ),
852 $ work( iwork ), lwork-iwork+1, ierr )
860 CALL zbdsqr(
'U', n, 0, m, 0, s, rwork( ie ), cdum,
862 $ a, lda, cdum, 1, rwork( irwork ), info )
866 ELSE IF( wntuo .AND. wntvas )
THEN
872 IF( lwork.GE.n*n+3*n )
THEN
877 IF( lwork.GE.max( wrkbl, lda*n )+lda*n )
THEN
883 ELSE IF( lwork.GE.max( wrkbl, lda*n )+n*n )
THEN
893 ldwrku = ( lwork-n*n ) / n
903 CALL zgeqrf( m, n, a, lda, work( itau ),
904 $ work( iwork ), lwork-iwork+1, ierr )
908 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
910 $
CALL zlaset(
'L', n-1, n-1, czero, czero,
917 CALL zungqr( m, n, n, a, lda, work( itau ),
918 $ work( iwork ), lwork-iwork+1, ierr )
928 CALL zgebrd( n, n, vt, ldvt, s, rwork( ie ),
929 $ work( itauq ), work( itaup ),
930 $ work( iwork ), lwork-iwork+1, ierr )
931 CALL zlacpy(
'L', n, n, vt, ldvt, work( ir ),
938 CALL zungbr(
'Q', n, n, n, work( ir ), ldwrkr,
939 $ work( itauq ), work( iwork ),
940 $ lwork-iwork+1, ierr )
946 CALL zungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
947 $ work( iwork ), lwork-iwork+1, ierr )
956 CALL zbdsqr(
'U', n, n, n, 0, s, rwork( ie ), vt,
957 $ ldvt, work( ir ), ldwrkr, cdum, 1,
958 $ rwork( irwork ), info )
966 DO 20 i = 1, m, ldwrku
967 chunk = min( m-i+1, ldwrku )
968 CALL zgemm(
'N',
'N', chunk, n, n, cone, a( i,
970 $ lda, work( ir ), ldwrkr, czero,
971 $ work( iu ), ldwrku )
972 CALL zlacpy(
'F', chunk, n, work( iu ), ldwrku,
987 CALL zgeqrf( m, n, a, lda, work( itau ),
988 $ work( iwork ), lwork-iwork+1, ierr )
992 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
994 $
CALL zlaset(
'L', n-1, n-1, czero, czero,
1001 CALL zungqr( m, n, n, a, lda, work( itau ),
1002 $ work( iwork ), lwork-iwork+1, ierr )
1012 CALL zgebrd( n, n, vt, ldvt, s, rwork( ie ),
1013 $ work( itauq ), work( itaup ),
1014 $ work( iwork ), lwork-iwork+1, ierr )
1020 CALL zunmbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1021 $ work( itauq ), a, lda, work( iwork ),
1022 $ lwork-iwork+1, ierr )
1028 CALL zungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1029 $ work( iwork ), lwork-iwork+1, ierr )
1038 CALL zbdsqr(
'U', n, n, m, 0, s, rwork( ie ), vt,
1039 $ ldvt, a, lda, cdum, 1, rwork( irwork ),
1044 ELSE IF( wntus )
THEN
1052 IF( lwork.GE.n*n+3*n )
THEN
1057 IF( lwork.GE.wrkbl+lda*n )
THEN
1068 itau = ir + ldwrkr*n
1075 CALL zgeqrf( m, n, a, lda, work( itau ),
1076 $ work( iwork ), lwork-iwork+1, ierr )
1080 CALL zlacpy(
'U', n, n, a, lda, work( ir ),
1082 CALL zlaset(
'L', n-1, n-1, czero, czero,
1083 $ work( ir+1 ), ldwrkr )
1089 CALL zungqr( m, n, n, a, lda, work( itau ),
1090 $ work( iwork ), lwork-iwork+1, ierr )
1100 CALL zgebrd( n, n, work( ir ), ldwrkr, s,
1101 $ rwork( ie ), work( itauq ),
1102 $ work( itaup ), work( iwork ),
1103 $ lwork-iwork+1, ierr )
1109 CALL zungbr(
'Q', n, n, n, work( ir ), ldwrkr,
1110 $ work( itauq ), work( iwork ),
1111 $ lwork-iwork+1, ierr )
1119 CALL zbdsqr(
'U', n, 0, n, 0, s, rwork( ie ),
1121 $ 1, work( ir ), ldwrkr, cdum, 1,
1122 $ rwork( irwork ), info )
1129 CALL zgemm(
'N',
'N', m, n, n, cone, a, lda,
1130 $ work( ir ), ldwrkr, czero, u, ldu )
1143 CALL zgeqrf( m, n, a, lda, work( itau ),
1144 $ work( iwork ), lwork-iwork+1, ierr )
1145 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1151 CALL zungqr( m, n, n, u, ldu, work( itau ),
1152 $ work( iwork ), lwork-iwork+1, ierr )
1161 CALL zlaset(
'L', n-1, n-1, czero, czero,
1169 CALL zgebrd( n, n, a, lda, s, rwork( ie ),
1170 $ work( itauq ), work( itaup ),
1171 $ work( iwork ), lwork-iwork+1, ierr )
1177 CALL zunmbr(
'Q',
'R',
'N', m, n, n, a, lda,
1178 $ work( itauq ), u, ldu, work( iwork ),
1179 $ lwork-iwork+1, ierr )
1187 CALL zbdsqr(
'U', n, 0, m, 0, s, rwork( ie ),
1189 $ 1, u, ldu, cdum, 1, rwork( irwork ),
1194 ELSE IF( wntvo )
THEN
1200 IF( lwork.GE.2*n*n+3*n )
THEN
1205 IF( lwork.GE.wrkbl+2*lda*n )
THEN
1212 ELSE IF( lwork.GE.wrkbl+( lda+n )*n )
THEN
1227 itau = ir + ldwrkr*n
1234 CALL zgeqrf( m, n, a, lda, work( itau ),
1235 $ work( iwork ), lwork-iwork+1, ierr )
1239 CALL zlacpy(
'U', n, n, a, lda, work( iu ),
1241 CALL zlaset(
'L', n-1, n-1, czero, czero,
1242 $ work( iu+1 ), ldwrku )
1248 CALL zungqr( m, n, n, a, lda, work( itau ),
1249 $ work( iwork ), lwork-iwork+1, ierr )
1261 CALL zgebrd( n, n, work( iu ), ldwrku, s,
1262 $ rwork( ie ), work( itauq ),
1263 $ work( itaup ), work( iwork ),
1264 $ lwork-iwork+1, ierr )
1265 CALL zlacpy(
'U', n, n, work( iu ), ldwrku,
1266 $ work( ir ), ldwrkr )
1272 CALL zungbr(
'Q', n, n, n, work( iu ), ldwrku,
1273 $ work( itauq ), work( iwork ),
1274 $ lwork-iwork+1, ierr )
1281 CALL zungbr(
'P', n, n, n, work( ir ), ldwrkr,
1282 $ work( itaup ), work( iwork ),
1283 $ lwork-iwork+1, ierr )
1292 CALL zbdsqr(
'U', n, n, n, 0, s, rwork( ie ),
1293 $ work( ir ), ldwrkr, work( iu ),
1294 $ ldwrku, cdum, 1, rwork( irwork ),
1302 CALL zgemm(
'N',
'N', m, n, n, cone, a, lda,
1303 $ work( iu ), ldwrku, czero, u, ldu )
1309 CALL zlacpy(
'F', n, n, work( ir ), ldwrkr, a,
1323 CALL zgeqrf( m, n, a, lda, work( itau ),
1324 $ work( iwork ), lwork-iwork+1, ierr )
1325 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1331 CALL zungqr( m, n, n, u, ldu, work( itau ),
1332 $ work( iwork ), lwork-iwork+1, ierr )
1341 CALL zlaset(
'L', n-1, n-1, czero, czero,
1349 CALL zgebrd( n, n, a, lda, s, rwork( ie ),
1350 $ work( itauq ), work( itaup ),
1351 $ work( iwork ), lwork-iwork+1, ierr )
1357 CALL zunmbr(
'Q',
'R',
'N', m, n, n, a, lda,
1358 $ work( itauq ), u, ldu, work( iwork ),
1359 $ lwork-iwork+1, ierr )
1365 CALL zungbr(
'P', n, n, n, a, lda,
1367 $ work( iwork ), lwork-iwork+1, ierr )
1376 CALL zbdsqr(
'U', n, n, m, 0, s, rwork( ie ), a,
1377 $ lda, u, ldu, cdum, 1, rwork( irwork ),
1382 ELSE IF( wntvas )
THEN
1389 IF( lwork.GE.n*n+3*n )
THEN
1394 IF( lwork.GE.wrkbl+lda*n )
THEN
1405 itau = iu + ldwrku*n
1412 CALL zgeqrf( m, n, a, lda, work( itau ),
1413 $ work( iwork ), lwork-iwork+1, ierr )
1417 CALL zlacpy(
'U', n, n, a, lda, work( iu ),
1419 CALL zlaset(
'L', n-1, n-1, czero, czero,
1420 $ work( iu+1 ), ldwrku )
1426 CALL zungqr( m, n, n, a, lda, work( itau ),
1427 $ work( iwork ), lwork-iwork+1, ierr )
1437 CALL zgebrd( n, n, work( iu ), ldwrku, s,
1438 $ rwork( ie ), work( itauq ),
1439 $ work( itaup ), work( iwork ),
1440 $ lwork-iwork+1, ierr )
1441 CALL zlacpy(
'U', n, n, work( iu ), ldwrku, vt,
1448 CALL zungbr(
'Q', n, n, n, work( iu ), ldwrku,
1449 $ work( itauq ), work( iwork ),
1450 $ lwork-iwork+1, ierr )
1457 CALL zungbr(
'P', n, n, n, vt, ldvt,
1459 $ work( iwork ), lwork-iwork+1, ierr )
1468 CALL zbdsqr(
'U', n, n, n, 0, s, rwork( ie ),
1470 $ ldvt, work( iu ), ldwrku, cdum, 1,
1471 $ rwork( irwork ), info )
1478 CALL zgemm(
'N',
'N', m, n, n, cone, a, lda,
1479 $ work( iu ), ldwrku, czero, u, ldu )
1492 CALL zgeqrf( m, n, a, lda, work( itau ),
1493 $ work( iwork ), lwork-iwork+1, ierr )
1494 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1500 CALL zungqr( m, n, n, u, ldu, work( itau ),
1501 $ work( iwork ), lwork-iwork+1, ierr )
1505 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
1507 $
CALL zlaset(
'L', n-1, n-1, czero, czero,
1508 $ vt( 2, 1 ), ldvt )
1518 CALL zgebrd( n, n, vt, ldvt, s, rwork( ie ),
1519 $ work( itauq ), work( itaup ),
1520 $ work( iwork ), lwork-iwork+1, ierr )
1527 CALL zunmbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1528 $ work( itauq ), u, ldu, work( iwork ),
1529 $ lwork-iwork+1, ierr )
1535 CALL zungbr(
'P', n, n, n, vt, ldvt,
1537 $ work( iwork ), lwork-iwork+1, ierr )
1546 CALL zbdsqr(
'U', n, n, m, 0, s, rwork( ie ),
1548 $ ldvt, u, ldu, cdum, 1,
1549 $ rwork( irwork ), info )
1555 ELSE IF( wntua )
THEN
1563 IF( lwork.GE.n*n+max( n+m, 3*n ) )
THEN
1568 IF( lwork.GE.wrkbl+lda*n )
THEN
1579 itau = ir + ldwrkr*n
1586 CALL zgeqrf( m, n, a, lda, work( itau ),
1587 $ work( iwork ), lwork-iwork+1, ierr )
1588 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1592 CALL zlacpy(
'U', n, n, a, lda, work( ir ),
1594 CALL zlaset(
'L', n-1, n-1, czero, czero,
1595 $ work( ir+1 ), ldwrkr )
1601 CALL zungqr( m, m, n, u, ldu, work( itau ),
1602 $ work( iwork ), lwork-iwork+1, ierr )
1612 CALL zgebrd( n, n, work( ir ), ldwrkr, s,
1613 $ rwork( ie ), work( itauq ),
1614 $ work( itaup ), work( iwork ),
1615 $ lwork-iwork+1, ierr )
1621 CALL zungbr(
'Q', n, n, n, work( ir ), ldwrkr,
1622 $ work( itauq ), work( iwork ),
1623 $ lwork-iwork+1, ierr )
1631 CALL zbdsqr(
'U', n, 0, n, 0, s, rwork( ie ),
1633 $ 1, work( ir ), ldwrkr, cdum, 1,
1634 $ rwork( irwork ), info )
1641 CALL zgemm(
'N',
'N', m, n, n, cone, u, ldu,
1642 $ work( ir ), ldwrkr, czero, a, lda )
1646 CALL zlacpy(
'F', m, n, a, lda, u, ldu )
1659 CALL zgeqrf( m, n, a, lda, work( itau ),
1660 $ work( iwork ), lwork-iwork+1, ierr )
1661 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1667 CALL zungqr( m, m, n, u, ldu, work( itau ),
1668 $ work( iwork ), lwork-iwork+1, ierr )
1677 CALL zlaset(
'L', n-1, n-1, czero, czero,
1685 CALL zgebrd( n, n, a, lda, s, rwork( ie ),
1686 $ work( itauq ), work( itaup ),
1687 $ work( iwork ), lwork-iwork+1, ierr )
1694 CALL zunmbr(
'Q',
'R',
'N', m, n, n, a, lda,
1695 $ work( itauq ), u, ldu, work( iwork ),
1696 $ lwork-iwork+1, ierr )
1704 CALL zbdsqr(
'U', n, 0, m, 0, s, rwork( ie ),
1706 $ 1, u, ldu, cdum, 1, rwork( irwork ),
1711 ELSE IF( wntvo )
THEN
1717 IF( lwork.GE.2*n*n+max( n+m, 3*n ) )
THEN
1722 IF( lwork.GE.wrkbl+2*lda*n )
THEN
1729 ELSE IF( lwork.GE.wrkbl+( lda+n )*n )
THEN
1744 itau = ir + ldwrkr*n
1751 CALL zgeqrf( m, n, a, lda, work( itau ),
1752 $ work( iwork ), lwork-iwork+1, ierr )
1753 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1759 CALL zungqr( m, m, n, u, ldu, work( itau ),
1760 $ work( iwork ), lwork-iwork+1, ierr )
1764 CALL zlacpy(
'U', n, n, a, lda, work( iu ),
1766 CALL zlaset(
'L', n-1, n-1, czero, czero,
1767 $ work( iu+1 ), ldwrku )
1779 CALL zgebrd( n, n, work( iu ), ldwrku, s,
1780 $ rwork( ie ), work( itauq ),
1781 $ work( itaup ), work( iwork ),
1782 $ lwork-iwork+1, ierr )
1783 CALL zlacpy(
'U', n, n, work( iu ), ldwrku,
1784 $ work( ir ), ldwrkr )
1790 CALL zungbr(
'Q', n, n, n, work( iu ), ldwrku,
1791 $ work( itauq ), work( iwork ),
1792 $ lwork-iwork+1, ierr )
1799 CALL zungbr(
'P', n, n, n, work( ir ), ldwrkr,
1800 $ work( itaup ), work( iwork ),
1801 $ lwork-iwork+1, ierr )
1810 CALL zbdsqr(
'U', n, n, n, 0, s, rwork( ie ),
1811 $ work( ir ), ldwrkr, work( iu ),
1812 $ ldwrku, cdum, 1, rwork( irwork ),
1820 CALL zgemm(
'N',
'N', m, n, n, cone, u, ldu,
1821 $ work( iu ), ldwrku, czero, a, lda )
1825 CALL zlacpy(
'F', m, n, a, lda, u, ldu )
1829 CALL zlacpy(
'F', n, n, work( ir ), ldwrkr, a,
1843 CALL zgeqrf( m, n, a, lda, work( itau ),
1844 $ work( iwork ), lwork-iwork+1, ierr )
1845 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1851 CALL zungqr( m, m, n, u, ldu, work( itau ),
1852 $ work( iwork ), lwork-iwork+1, ierr )
1861 CALL zlaset(
'L', n-1, n-1, czero, czero,
1869 CALL zgebrd( n, n, a, lda, s, rwork( ie ),
1870 $ work( itauq ), work( itaup ),
1871 $ work( iwork ), lwork-iwork+1, ierr )
1878 CALL zunmbr(
'Q',
'R',
'N', m, n, n, a, lda,
1879 $ work( itauq ), u, ldu, work( iwork ),
1880 $ lwork-iwork+1, ierr )
1886 CALL zungbr(
'P', n, n, n, a, lda,
1888 $ work( iwork ), lwork-iwork+1, ierr )
1897 CALL zbdsqr(
'U', n, n, m, 0, s, rwork( ie ), a,
1898 $ lda, u, ldu, cdum, 1, rwork( irwork ),
1903 ELSE IF( wntvas )
THEN
1910 IF( lwork.GE.n*n+max( n+m, 3*n ) )
THEN
1915 IF( lwork.GE.wrkbl+lda*n )
THEN
1926 itau = iu + ldwrku*n
1933 CALL zgeqrf( m, n, a, lda, work( itau ),
1934 $ work( iwork ), lwork-iwork+1, ierr )
1935 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1941 CALL zungqr( m, m, n, u, ldu, work( itau ),
1942 $ work( iwork ), lwork-iwork+1, ierr )
1946 CALL zlacpy(
'U', n, n, a, lda, work( iu ),
1948 CALL zlaset(
'L', n-1, n-1, czero, czero,
1949 $ work( iu+1 ), ldwrku )
1959 CALL zgebrd( n, n, work( iu ), ldwrku, s,
1960 $ rwork( ie ), work( itauq ),
1961 $ work( itaup ), work( iwork ),
1962 $ lwork-iwork+1, ierr )
1963 CALL zlacpy(
'U', n, n, work( iu ), ldwrku, vt,
1970 CALL zungbr(
'Q', n, n, n, work( iu ), ldwrku,
1971 $ work( itauq ), work( iwork ),
1972 $ lwork-iwork+1, ierr )
1979 CALL zungbr(
'P', n, n, n, vt, ldvt,
1981 $ work( iwork ), lwork-iwork+1, ierr )
1990 CALL zbdsqr(
'U', n, n, n, 0, s, rwork( ie ),
1992 $ ldvt, work( iu ), ldwrku, cdum, 1,
1993 $ rwork( irwork ), info )
2000 CALL zgemm(
'N',
'N', m, n, n, cone, u, ldu,
2001 $ work( iu ), ldwrku, czero, a, lda )
2005 CALL zlacpy(
'F', m, n, a, lda, u, ldu )
2018 CALL zgeqrf( m, n, a, lda, work( itau ),
2019 $ work( iwork ), lwork-iwork+1, ierr )
2020 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
2026 CALL zungqr( m, m, n, u, ldu, work( itau ),
2027 $ work( iwork ), lwork-iwork+1, ierr )
2031 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
2033 $
CALL zlaset(
'L', n-1, n-1, czero, czero,
2034 $ vt( 2, 1 ), ldvt )
2044 CALL zgebrd( n, n, vt, ldvt, s, rwork( ie ),
2045 $ work( itauq ), work( itaup ),
2046 $ work( iwork ), lwork-iwork+1, ierr )
2053 CALL zunmbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
2054 $ work( itauq ), u, ldu, work( iwork ),
2055 $ lwork-iwork+1, ierr )
2061 CALL zungbr(
'P', n, n, n, vt, ldvt,
2063 $ work( iwork ), lwork-iwork+1, ierr )
2072 CALL zbdsqr(
'U', n, n, m, 0, s, rwork( ie ),
2074 $ ldvt, u, ldu, cdum, 1,
2075 $ rwork( irwork ), info )
2099 CALL zgebrd( m, n, a, lda, s, rwork( ie ), work( itauq ),
2100 $ work( itaup ), work( iwork ), lwork-iwork+1,
2109 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
2114 CALL zungbr(
'Q', m, ncu, n, u, ldu, work( itauq ),
2115 $ work( iwork ), lwork-iwork+1, ierr )
2124 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
2125 CALL zungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
2126 $ work( iwork ), lwork-iwork+1, ierr )
2135 CALL zungbr(
'Q', m, n, n, a, lda, work( itauq ),
2136 $ work( iwork ), lwork-iwork+1, ierr )
2145 CALL zungbr(
'P', n, n, n, a, lda, work( itaup ),
2146 $ work( iwork ), lwork-iwork+1, ierr )
2149 IF( wntuas .OR. wntuo )
2153 IF( wntvas .OR. wntvo )
2157 IF( ( .NOT.wntuo ) .AND. ( .NOT.wntvo ) )
THEN
2165 CALL zbdsqr(
'U', n, ncvt, nru, 0, s, rwork( ie ), vt,
2166 $ ldvt, u, ldu, cdum, 1, rwork( irwork ),
2168 ELSE IF( ( .NOT.wntuo ) .AND. wntvo )
THEN
2176 CALL zbdsqr(
'U', n, ncvt, nru, 0, s, rwork( ie ), a,
2177 $ lda, u, ldu, cdum, 1, rwork( irwork ),
2187 CALL zbdsqr(
'U', n, ncvt, nru, 0, s, rwork( ie ), vt,
2188 $ ldvt, a, lda, cdum, 1, rwork( irwork ),
2200 IF( n.GE.mnthr )
THEN
2214 CALL zgelqf( m, n, a, lda, work( itau ),
2216 $ lwork-iwork+1, ierr )
2220 CALL zlaset(
'U', m-1, m-1, czero, czero, a( 1, 2 ),
2231 CALL zgebrd( m, m, a, lda, s, rwork( ie ),
2233 $ work( itaup ), work( iwork ), lwork-iwork+1,
2235 IF( wntuo .OR. wntuas )
THEN
2241 CALL zungbr(
'Q', m, m, m, a, lda, work( itauq ),
2242 $ work( iwork ), lwork-iwork+1, ierr )
2246 IF( wntuo .OR. wntuas )
2254 CALL zbdsqr(
'U', m, 0, nru, 0, s, rwork( ie ), cdum,
2256 $ a, lda, cdum, 1, rwork( irwork ), info )
2261 $
CALL zlacpy(
'F', m, m, a, lda, u, ldu )
2263 ELSE IF( wntvo .AND. wntun )
THEN
2269 IF( lwork.GE.m*m+3*m )
THEN
2274 IF( lwork.GE.max( wrkbl, lda*n )+lda*m )
THEN
2281 ELSE IF( lwork.GE.max( wrkbl, lda*n )+m*m )
THEN
2293 chunk = ( lwork-m*m ) / m
2296 itau = ir + ldwrkr*m
2303 CALL zgelqf( m, n, a, lda, work( itau ),
2304 $ work( iwork ), lwork-iwork+1, ierr )
2308 CALL zlacpy(
'L', m, m, a, lda, work( ir ),
2310 CALL zlaset(
'U', m-1, m-1, czero, czero,
2311 $ work( ir+ldwrkr ), ldwrkr )
2317 CALL zunglq( m, n, m, a, lda, work( itau ),
2318 $ work( iwork ), lwork-iwork+1, ierr )
2328 CALL zgebrd( m, m, work( ir ), ldwrkr, s,
2330 $ work( itauq ), work( itaup ),
2331 $ work( iwork ), lwork-iwork+1, ierr )
2337 CALL zungbr(
'P', m, m, m, work( ir ), ldwrkr,
2338 $ work( itaup ), work( iwork ),
2339 $ lwork-iwork+1, ierr )
2347 CALL zbdsqr(
'U', m, m, 0, 0, s, rwork( ie ),
2348 $ work( ir ), ldwrkr, cdum, 1, cdum, 1,
2349 $ rwork( irwork ), info )
2357 DO 30 i = 1, n, chunk
2358 blk = min( n-i+1, chunk )
2359 CALL zgemm(
'N',
'N', m, blk, m, cone,
2361 $ ldwrkr, a( 1, i ), lda, czero,
2362 $ work( iu ), ldwrku )
2363 CALL zlacpy(
'F', m, blk, work( iu ), ldwrku,
2380 CALL zgebrd( m, n, a, lda, s, rwork( ie ),
2381 $ work( itauq ), work( itaup ),
2382 $ work( iwork ), lwork-iwork+1, ierr )
2388 CALL zungbr(
'P', m, n, m, a, lda, work( itaup ),
2389 $ work( iwork ), lwork-iwork+1, ierr )
2397 CALL zbdsqr(
'L', m, n, 0, 0, s, rwork( ie ), a,
2399 $ cdum, 1, cdum, 1, rwork( irwork ), info )
2403 ELSE IF( wntvo .AND. wntuas )
THEN
2409 IF( lwork.GE.m*m+3*m )
THEN
2414 IF( lwork.GE.max( wrkbl, lda*n )+lda*m )
THEN
2421 ELSE IF( lwork.GE.max( wrkbl, lda*n )+m*m )
THEN
2433 chunk = ( lwork-m*m ) / m
2436 itau = ir + ldwrkr*m
2443 CALL zgelqf( m, n, a, lda, work( itau ),
2444 $ work( iwork ), lwork-iwork+1, ierr )
2448 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
2449 CALL zlaset(
'U', m-1, m-1, czero, czero, u( 1,
2457 CALL zunglq( m, n, m, a, lda, work( itau ),
2458 $ work( iwork ), lwork-iwork+1, ierr )
2468 CALL zgebrd( m, m, u, ldu, s, rwork( ie ),
2469 $ work( itauq ), work( itaup ),
2470 $ work( iwork ), lwork-iwork+1, ierr )
2471 CALL zlacpy(
'U', m, m, u, ldu, work( ir ),
2478 CALL zungbr(
'P', m, m, m, work( ir ), ldwrkr,
2479 $ work( itaup ), work( iwork ),
2480 $ lwork-iwork+1, ierr )
2486 CALL zungbr(
'Q', m, m, m, u, ldu, work( itauq ),
2487 $ work( iwork ), lwork-iwork+1, ierr )
2496 CALL zbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
2497 $ work( ir ), ldwrkr, u, ldu, cdum, 1,
2498 $ rwork( irwork ), info )
2506 DO 40 i = 1, n, chunk
2507 blk = min( n-i+1, chunk )
2508 CALL zgemm(
'N',
'N', m, blk, m, cone,
2510 $ ldwrkr, a( 1, i ), lda, czero,
2511 $ work( iu ), ldwrku )
2512 CALL zlacpy(
'F', m, blk, work( iu ), ldwrku,
2527 CALL zgelqf( m, n, a, lda, work( itau ),
2528 $ work( iwork ), lwork-iwork+1, ierr )
2532 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
2533 CALL zlaset(
'U', m-1, m-1, czero, czero, u( 1,
2541 CALL zunglq( m, n, m, a, lda, work( itau ),
2542 $ work( iwork ), lwork-iwork+1, ierr )
2552 CALL zgebrd( m, m, u, ldu, s, rwork( ie ),
2553 $ work( itauq ), work( itaup ),
2554 $ work( iwork ), lwork-iwork+1, ierr )
2560 CALL zunmbr(
'P',
'L',
'C', m, n, m, u, ldu,
2561 $ work( itaup ), a, lda, work( iwork ),
2562 $ lwork-iwork+1, ierr )
2568 CALL zungbr(
'Q', m, m, m, u, ldu, work( itauq ),
2569 $ work( iwork ), lwork-iwork+1, ierr )
2578 CALL zbdsqr(
'U', m, n, m, 0, s, rwork( ie ), a,
2580 $ u, ldu, cdum, 1, rwork( irwork ), info )
2584 ELSE IF( wntvs )
THEN
2592 IF( lwork.GE.m*m+3*m )
THEN
2597 IF( lwork.GE.wrkbl+lda*m )
THEN
2608 itau = ir + ldwrkr*m
2615 CALL zgelqf( m, n, a, lda, work( itau ),
2616 $ work( iwork ), lwork-iwork+1, ierr )
2620 CALL zlacpy(
'L', m, m, a, lda, work( ir ),
2622 CALL zlaset(
'U', m-1, m-1, czero, czero,
2623 $ work( ir+ldwrkr ), ldwrkr )
2629 CALL zunglq( m, n, m, a, lda, work( itau ),
2630 $ work( iwork ), lwork-iwork+1, ierr )
2640 CALL zgebrd( m, m, work( ir ), ldwrkr, s,
2641 $ rwork( ie ), work( itauq ),
2642 $ work( itaup ), work( iwork ),
2643 $ lwork-iwork+1, ierr )
2650 CALL zungbr(
'P', m, m, m, work( ir ), ldwrkr,
2651 $ work( itaup ), work( iwork ),
2652 $ lwork-iwork+1, ierr )
2660 CALL zbdsqr(
'U', m, m, 0, 0, s, rwork( ie ),
2661 $ work( ir ), ldwrkr, cdum, 1, cdum, 1,
2662 $ rwork( irwork ), info )
2669 CALL zgemm(
'N',
'N', m, n, m, cone, work( ir ),
2670 $ ldwrkr, a, lda, czero, vt, ldvt )
2683 CALL zgelqf( m, n, a, lda, work( itau ),
2684 $ work( iwork ), lwork-iwork+1, ierr )
2688 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
2694 CALL zunglq( m, n, m, vt, ldvt, work( itau ),
2695 $ work( iwork ), lwork-iwork+1, ierr )
2703 CALL zlaset(
'U', m-1, m-1, czero, czero,
2710 CALL zgebrd( m, m, a, lda, s, rwork( ie ),
2711 $ work( itauq ), work( itaup ),
2712 $ work( iwork ), lwork-iwork+1, ierr )
2718 CALL zunmbr(
'P',
'L',
'C', m, n, m, a, lda,
2719 $ work( itaup ), vt, ldvt,
2720 $ work( iwork ), lwork-iwork+1, ierr )
2728 CALL zbdsqr(
'U', m, n, 0, 0, s, rwork( ie ),
2730 $ ldvt, cdum, 1, cdum, 1,
2731 $ rwork( irwork ), info )
2735 ELSE IF( wntuo )
THEN
2741 IF( lwork.GE.2*m*m+3*m )
THEN
2746 IF( lwork.GE.wrkbl+2*lda*m )
THEN
2753 ELSE IF( lwork.GE.wrkbl+( lda+m )*m )
THEN
2768 itau = ir + ldwrkr*m
2775 CALL zgelqf( m, n, a, lda, work( itau ),
2776 $ work( iwork ), lwork-iwork+1, ierr )
2780 CALL zlacpy(
'L', m, m, a, lda, work( iu ),
2782 CALL zlaset(
'U', m-1, m-1, czero, czero,
2783 $ work( iu+ldwrku ), ldwrku )
2789 CALL zunglq( m, n, m, a, lda, work( itau ),
2790 $ work( iwork ), lwork-iwork+1, ierr )
2802 CALL zgebrd( m, m, work( iu ), ldwrku, s,
2803 $ rwork( ie ), work( itauq ),
2804 $ work( itaup ), work( iwork ),
2805 $ lwork-iwork+1, ierr )
2806 CALL zlacpy(
'L', m, m, work( iu ), ldwrku,
2807 $ work( ir ), ldwrkr )
2814 CALL zungbr(
'P', m, m, m, work( iu ), ldwrku,
2815 $ work( itaup ), work( iwork ),
2816 $ lwork-iwork+1, ierr )
2822 CALL zungbr(
'Q', m, m, m, work( ir ), ldwrkr,
2823 $ work( itauq ), work( iwork ),
2824 $ lwork-iwork+1, ierr )
2833 CALL zbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
2834 $ work( iu ), ldwrku, work( ir ),
2835 $ ldwrkr, cdum, 1, rwork( irwork ),
2843 CALL zgemm(
'N',
'N', m, n, m, cone, work( iu ),
2844 $ ldwrku, a, lda, czero, vt, ldvt )
2850 CALL zlacpy(
'F', m, m, work( ir ), ldwrkr, a,
2864 CALL zgelqf( m, n, a, lda, work( itau ),
2865 $ work( iwork ), lwork-iwork+1, ierr )
2866 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
2872 CALL zunglq( m, n, m, vt, ldvt, work( itau ),
2873 $ work( iwork ), lwork-iwork+1, ierr )
2881 CALL zlaset(
'U', m-1, m-1, czero, czero,
2888 CALL zgebrd( m, m, a, lda, s, rwork( ie ),
2889 $ work( itauq ), work( itaup ),
2890 $ work( iwork ), lwork-iwork+1, ierr )
2896 CALL zunmbr(
'P',
'L',
'C', m, n, m, a, lda,
2897 $ work( itaup ), vt, ldvt,
2898 $ work( iwork ), lwork-iwork+1, ierr )
2904 CALL zungbr(
'Q', m, m, m, a, lda,
2906 $ work( iwork ), lwork-iwork+1, ierr )
2915 CALL zbdsqr(
'U', m, n, m, 0, s, rwork( ie ),
2917 $ ldvt, a, lda, cdum, 1,
2918 $ rwork( irwork ), info )
2922 ELSE IF( wntuas )
THEN
2929 IF( lwork.GE.m*m+3*m )
THEN
2934 IF( lwork.GE.wrkbl+lda*m )
THEN
2945 itau = iu + ldwrku*m
2952 CALL zgelqf( m, n, a, lda, work( itau ),
2953 $ work( iwork ), lwork-iwork+1, ierr )
2957 CALL zlacpy(
'L', m, m, a, lda, work( iu ),
2959 CALL zlaset(
'U', m-1, m-1, czero, czero,
2960 $ work( iu+ldwrku ), ldwrku )
2966 CALL zunglq( m, n, m, a, lda, work( itau ),
2967 $ work( iwork ), lwork-iwork+1, ierr )
2977 CALL zgebrd( m, m, work( iu ), ldwrku, s,
2978 $ rwork( ie ), work( itauq ),
2979 $ work( itaup ), work( iwork ),
2980 $ lwork-iwork+1, ierr )
2981 CALL zlacpy(
'L', m, m, work( iu ), ldwrku, u,
2989 CALL zungbr(
'P', m, m, m, work( iu ), ldwrku,
2990 $ work( itaup ), work( iwork ),
2991 $ lwork-iwork+1, ierr )
2997 CALL zungbr(
'Q', m, m, m, u, ldu,
2999 $ work( iwork ), lwork-iwork+1, ierr )
3008 CALL zbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
3009 $ work( iu ), ldwrku, u, ldu, cdum, 1,
3010 $ rwork( irwork ), info )
3017 CALL zgemm(
'N',
'N', m, n, m, cone, work( iu ),
3018 $ ldwrku, a, lda, czero, vt, ldvt )
3031 CALL zgelqf( m, n, a, lda, work( itau ),
3032 $ work( iwork ), lwork-iwork+1, ierr )
3033 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
3039 CALL zunglq( m, n, m, vt, ldvt, work( itau ),
3040 $ work( iwork ), lwork-iwork+1, ierr )
3044 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
3045 CALL zlaset(
'U', m-1, m-1, czero, czero,
3056 CALL zgebrd( m, m, u, ldu, s, rwork( ie ),
3057 $ work( itauq ), work( itaup ),
3058 $ work( iwork ), lwork-iwork+1, ierr )
3065 CALL zunmbr(
'P',
'L',
'C', m, n, m, u, ldu,
3066 $ work( itaup ), vt, ldvt,
3067 $ work( iwork ), lwork-iwork+1, ierr )
3073 CALL zungbr(
'Q', m, m, m, u, ldu,
3075 $ work( iwork ), lwork-iwork+1, ierr )
3084 CALL zbdsqr(
'U', m, n, m, 0, s, rwork( ie ),
3086 $ ldvt, u, ldu, cdum, 1,
3087 $ rwork( irwork ), info )
3093 ELSE IF( wntva )
THEN
3101 IF( lwork.GE.m*m+max( n+m, 3*m ) )
THEN
3106 IF( lwork.GE.wrkbl+lda*m )
THEN
3117 itau = ir + ldwrkr*m
3124 CALL zgelqf( m, n, a, lda, work( itau ),
3125 $ work( iwork ), lwork-iwork+1, ierr )
3126 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
3130 CALL zlacpy(
'L', m, m, a, lda, work( ir ),
3132 CALL zlaset(
'U', m-1, m-1, czero, czero,
3133 $ work( ir+ldwrkr ), ldwrkr )
3139 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3140 $ work( iwork ), lwork-iwork+1, ierr )
3150 CALL zgebrd( m, m, work( ir ), ldwrkr, s,
3151 $ rwork( ie ), work( itauq ),
3152 $ work( itaup ), work( iwork ),
3153 $ lwork-iwork+1, ierr )
3160 CALL zungbr(
'P', m, m, m, work( ir ), ldwrkr,
3161 $ work( itaup ), work( iwork ),
3162 $ lwork-iwork+1, ierr )
3170 CALL zbdsqr(
'U', m, m, 0, 0, s, rwork( ie ),
3171 $ work( ir ), ldwrkr, cdum, 1, cdum, 1,
3172 $ rwork( irwork ), info )
3179 CALL zgemm(
'N',
'N', m, n, m, cone, work( ir ),
3180 $ ldwrkr, vt, ldvt, czero, a, lda )
3184 CALL zlacpy(
'F', m, n, a, lda, vt, ldvt )
3197 CALL zgelqf( m, n, a, lda, work( itau ),
3198 $ work( iwork ), lwork-iwork+1, ierr )
3199 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
3205 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3206 $ work( iwork ), lwork-iwork+1, ierr )
3214 CALL zlaset(
'U', m-1, m-1, czero, czero,
3221 CALL zgebrd( m, m, a, lda, s, rwork( ie ),
3222 $ work( itauq ), work( itaup ),
3223 $ work( iwork ), lwork-iwork+1, ierr )
3230 CALL zunmbr(
'P',
'L',
'C', m, n, m, a, lda,
3231 $ work( itaup ), vt, ldvt,
3232 $ work( iwork ), lwork-iwork+1, ierr )
3240 CALL zbdsqr(
'U', m, n, 0, 0, s, rwork( ie ),
3242 $ ldvt, cdum, 1, cdum, 1,
3243 $ rwork( irwork ), info )
3247 ELSE IF( wntuo )
THEN
3253 IF( lwork.GE.2*m*m+max( n+m, 3*m ) )
THEN
3258 IF( lwork.GE.wrkbl+2*lda*m )
THEN
3265 ELSE IF( lwork.GE.wrkbl+( lda+m )*m )
THEN
3280 itau = ir + ldwrkr*m
3287 CALL zgelqf( m, n, a, lda, work( itau ),
3288 $ work( iwork ), lwork-iwork+1, ierr )
3289 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
3295 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3296 $ work( iwork ), lwork-iwork+1, ierr )
3300 CALL zlacpy(
'L', m, m, a, lda, work( iu ),
3302 CALL zlaset(
'U', m-1, m-1, czero, czero,
3303 $ work( iu+ldwrku ), ldwrku )
3315 CALL zgebrd( m, m, work( iu ), ldwrku, s,
3316 $ rwork( ie ), work( itauq ),
3317 $ work( itaup ), work( iwork ),
3318 $ lwork-iwork+1, ierr )
3319 CALL zlacpy(
'L', m, m, work( iu ), ldwrku,
3320 $ work( ir ), ldwrkr )
3327 CALL zungbr(
'P', m, m, m, work( iu ), ldwrku,
3328 $ work( itaup ), work( iwork ),
3329 $ lwork-iwork+1, ierr )
3335 CALL zungbr(
'Q', m, m, m, work( ir ), ldwrkr,
3336 $ work( itauq ), work( iwork ),
3337 $ lwork-iwork+1, ierr )
3346 CALL zbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
3347 $ work( iu ), ldwrku, work( ir ),
3348 $ ldwrkr, cdum, 1, rwork( irwork ),
3356 CALL zgemm(
'N',
'N', m, n, m, cone, work( iu ),
3357 $ ldwrku, vt, ldvt, czero, a, lda )
3361 CALL zlacpy(
'F', m, n, a, lda, vt, ldvt )
3365 CALL zlacpy(
'F', m, m, work( ir ), ldwrkr, a,
3379 CALL zgelqf( m, n, a, lda, work( itau ),
3380 $ work( iwork ), lwork-iwork+1, ierr )
3381 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
3387 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3388 $ work( iwork ), lwork-iwork+1, ierr )
3396 CALL zlaset(
'U', m-1, m-1, czero, czero,
3403 CALL zgebrd( m, m, a, lda, s, rwork( ie ),
3404 $ work( itauq ), work( itaup ),
3405 $ work( iwork ), lwork-iwork+1, ierr )
3412 CALL zunmbr(
'P',
'L',
'C', m, n, m, a, lda,
3413 $ work( itaup ), vt, ldvt,
3414 $ work( iwork ), lwork-iwork+1, ierr )
3420 CALL zungbr(
'Q', m, m, m, a, lda,
3422 $ work( iwork ), lwork-iwork+1, ierr )
3431 CALL zbdsqr(
'U', m, n, m, 0, s, rwork( ie ),
3433 $ ldvt, a, lda, cdum, 1,
3434 $ rwork( irwork ), info )
3438 ELSE IF( wntuas )
THEN
3445 IF( lwork.GE.m*m+max( n+m, 3*m ) )
THEN
3450 IF( lwork.GE.wrkbl+lda*m )
THEN
3461 itau = iu + ldwrku*m
3468 CALL zgelqf( m, n, a, lda, work( itau ),
3469 $ work( iwork ), lwork-iwork+1, ierr )
3470 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
3476 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3477 $ work( iwork ), lwork-iwork+1, ierr )
3481 CALL zlacpy(
'L', m, m, a, lda, work( iu ),
3483 CALL zlaset(
'U', m-1, m-1, czero, czero,
3484 $ work( iu+ldwrku ), ldwrku )
3494 CALL zgebrd( m, m, work( iu ), ldwrku, s,
3495 $ rwork( ie ), work( itauq ),
3496 $ work( itaup ), work( iwork ),
3497 $ lwork-iwork+1, ierr )
3498 CALL zlacpy(
'L', m, m, work( iu ), ldwrku, u,
3505 CALL zungbr(
'P', m, m, m, work( iu ), ldwrku,
3506 $ work( itaup ), work( iwork ),
3507 $ lwork-iwork+1, ierr )
3513 CALL zungbr(
'Q', m, m, m, u, ldu,
3515 $ work( iwork ), lwork-iwork+1, ierr )
3524 CALL zbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
3525 $ work( iu ), ldwrku, u, ldu, cdum, 1,
3526 $ rwork( irwork ), info )
3533 CALL zgemm(
'N',
'N', m, n, m, cone, work( iu ),
3534 $ ldwrku, vt, ldvt, czero, a, lda )
3538 CALL zlacpy(
'F', m, n, a, lda, vt, ldvt )
3551 CALL zgelqf( m, n, a, lda, work( itau ),
3552 $ work( iwork ), lwork-iwork+1, ierr )
3553 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
3559 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3560 $ work( iwork ), lwork-iwork+1, ierr )
3564 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
3565 CALL zlaset(
'U', m-1, m-1, czero, czero,
3576 CALL zgebrd( m, m, u, ldu, s, rwork( ie ),
3577 $ work( itauq ), work( itaup ),
3578 $ work( iwork ), lwork-iwork+1, ierr )
3585 CALL zunmbr(
'P',
'L',
'C', m, n, m, u, ldu,
3586 $ work( itaup ), vt, ldvt,
3587 $ work( iwork ), lwork-iwork+1, ierr )
3593 CALL zungbr(
'Q', m, m, m, u, ldu,
3595 $ work( iwork ), lwork-iwork+1, ierr )
3604 CALL zbdsqr(
'U', m, n, m, 0, s, rwork( ie ),
3606 $ ldvt, u, ldu, cdum, 1,
3607 $ rwork( irwork ), info )
3631 CALL zgebrd( m, n, a, lda, s, rwork( ie ), work( itauq ),
3632 $ work( itaup ), work( iwork ), lwork-iwork+1,
3641 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
3642 CALL zungbr(
'Q', m, m, n, u, ldu, work( itauq ),
3643 $ work( iwork ), lwork-iwork+1, ierr )
3652 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
3657 CALL zungbr(
'P', nrvt, n, m, vt, ldvt, work( itaup ),
3658 $ work( iwork ), lwork-iwork+1, ierr )
3667 CALL zungbr(
'Q', m, m, n, a, lda, work( itauq ),
3668 $ work( iwork ), lwork-iwork+1, ierr )
3677 CALL zungbr(
'P', m, n, m, a, lda, work( itaup ),
3678 $ work( iwork ), lwork-iwork+1, ierr )
3681 IF( wntuas .OR. wntuo )
3685 IF( wntvas .OR. wntvo )
3689 IF( ( .NOT.wntuo ) .AND. ( .NOT.wntvo ) )
THEN
3697 CALL zbdsqr(
'L', m, ncvt, nru, 0, s, rwork( ie ), vt,
3698 $ ldvt, u, ldu, cdum, 1, rwork( irwork ),
3700 ELSE IF( ( .NOT.wntuo ) .AND. wntvo )
THEN
3708 CALL zbdsqr(
'L', m, ncvt, nru, 0, s, rwork( ie ), a,
3709 $ lda, u, ldu, cdum, 1, rwork( irwork ),
3719 CALL zbdsqr(
'L', m, ncvt, nru, 0, s, rwork( ie ), vt,
3720 $ ldvt, a, lda, cdum, 1, rwork( irwork ),
3730 IF( iscl.EQ.1 )
THEN
3731 IF( anrm.GT.bignum )
3732 $
CALL dlascl(
'G', 0, 0, bignum, anrm, minmn, 1, s, minmn,
3734 IF( info.NE.0 .AND. anrm.GT.bignum )
3735 $
CALL dlascl(
'G', 0, 0, bignum, anrm, minmn-1, 1,
3736 $ rwork( ie ), minmn, ierr )
3737 IF( anrm.LT.smlnum )
3738 $
CALL dlascl(
'G', 0, 0, smlnum, anrm, minmn, 1, s, minmn,
3740 IF( info.NE.0 .AND. anrm.LT.smlnum )
3741 $
CALL dlascl(
'G', 0, 0, smlnum, anrm, minmn-1, 1,
3742 $ rwork( ie ), minmn, ierr )