212 SUBROUTINE zgesvd( JOBU, JOBVT, M, N, A, LDA, S, U, LDU,
213 $ VT, LDVT, WORK, LWORK, RWORK, INFO )
220 CHARACTER JOBU, JOBVT
221 INTEGER INFO, LDA, LDU, LDVT, LWORK, M, N
224 DOUBLE PRECISION RWORK( * ), S( * )
225 COMPLEX*16 A( LDA, * ), U( LDU, * ), VT( LDVT, * ),
232 COMPLEX*16 CZERO, CONE
233 parameter( czero = ( 0.0d0, 0.0d0 ),
234 $ cone = ( 1.0d0, 0.0d0 ) )
235 DOUBLE PRECISION ZERO, ONE
236 parameter( zero = 0.0d0, one = 1.0d0 )
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_ZGEQRF, LWORK_ZUNGQR_N, LWORK_ZUNGQR_M,
246 $ lwork_zgebrd, lwork_zungbr_p, lwork_zungbr_q,
247 $ lwork_zgelqf, lwork_zunglq_n, lwork_zunglq_m
248 DOUBLE PRECISION ANRM, BIGNUM, EPS, SMLNUM
251 DOUBLE PRECISION DUM( 1 )
262 DOUBLE PRECISION DLAMCH, ZLANGE
263 EXTERNAL lsame, ilaenv, dlamch, zlange
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,
'ZGESVD', jobu // jobvt, m, n, 0, 0 )
321 CALL zgeqrf( m, n, a, lda, cdum(1), cdum(1), -1, ierr )
322 lwork_zgeqrf = int( cdum(1) )
324 CALL zungqr( m, n, n, a, lda, cdum(1), cdum(1), -1, ierr )
325 lwork_zungqr_n = int( cdum(1) )
326 CALL zungqr( m, m, n, a, lda, cdum(1), cdum(1), -1, ierr )
327 lwork_zungqr_m = int( cdum(1) )
329 CALL zgebrd( n, n, a, lda, s, dum(1), cdum(1),
330 $ cdum(1), cdum(1), -1, ierr )
331 lwork_zgebrd = int( cdum(1) )
333 CALL zungbr(
'P', n, n, n, a, lda, cdum(1),
334 $ cdum(1), -1, ierr )
335 lwork_zungbr_p = int( cdum(1) )
336 CALL zungbr(
'Q', n, n, n, a, lda, cdum(1),
337 $ cdum(1), -1, ierr )
338 lwork_zungbr_q = int( cdum(1) )
340 IF( m.GE.mnthr )
THEN
345 maxwrk = n + lwork_zgeqrf
346 maxwrk = max( maxwrk, 2*n+lwork_zgebrd )
347 IF( wntvo .OR. wntvas )
348 $ maxwrk = max( maxwrk, 2*n+lwork_zungbr_p )
350 ELSE IF( wntuo .AND. wntvn )
THEN
354 wrkbl = n + lwork_zgeqrf
355 wrkbl = max( wrkbl, n+lwork_zungqr_n )
356 wrkbl = max( wrkbl, 2*n+lwork_zgebrd )
357 wrkbl = max( wrkbl, 2*n+lwork_zungbr_q )
358 maxwrk = max( n*n+wrkbl, n*n+m*n )
360 ELSE IF( wntuo .AND. wntvas )
THEN
365 wrkbl = n + lwork_zgeqrf
366 wrkbl = max( wrkbl, n+lwork_zungqr_n )
367 wrkbl = max( wrkbl, 2*n+lwork_zgebrd )
368 wrkbl = max( wrkbl, 2*n+lwork_zungbr_q )
369 wrkbl = max( wrkbl, 2*n+lwork_zungbr_p )
370 maxwrk = max( n*n+wrkbl, n*n+m*n )
372 ELSE IF( wntus .AND. wntvn )
THEN
376 wrkbl = n + lwork_zgeqrf
377 wrkbl = max( wrkbl, n+lwork_zungqr_n )
378 wrkbl = max( wrkbl, 2*n+lwork_zgebrd )
379 wrkbl = max( wrkbl, 2*n+lwork_zungbr_q )
382 ELSE IF( wntus .AND. wntvo )
THEN
386 wrkbl = n + lwork_zgeqrf
387 wrkbl = max( wrkbl, n+lwork_zungqr_n )
388 wrkbl = max( wrkbl, 2*n+lwork_zgebrd )
389 wrkbl = max( wrkbl, 2*n+lwork_zungbr_q )
390 wrkbl = max( wrkbl, 2*n+lwork_zungbr_p )
391 maxwrk = 2*n*n + wrkbl
393 ELSE IF( wntus .AND. wntvas )
THEN
398 wrkbl = n + lwork_zgeqrf
399 wrkbl = max( wrkbl, n+lwork_zungqr_n )
400 wrkbl = max( wrkbl, 2*n+lwork_zgebrd )
401 wrkbl = max( wrkbl, 2*n+lwork_zungbr_q )
402 wrkbl = max( wrkbl, 2*n+lwork_zungbr_p )
405 ELSE IF( wntua .AND. wntvn )
THEN
409 wrkbl = n + lwork_zgeqrf
410 wrkbl = max( wrkbl, n+lwork_zungqr_m )
411 wrkbl = max( wrkbl, 2*n+lwork_zgebrd )
412 wrkbl = max( wrkbl, 2*n+lwork_zungbr_q )
415 ELSE IF( wntua .AND. wntvo )
THEN
419 wrkbl = n + lwork_zgeqrf
420 wrkbl = max( wrkbl, n+lwork_zungqr_m )
421 wrkbl = max( wrkbl, 2*n+lwork_zgebrd )
422 wrkbl = max( wrkbl, 2*n+lwork_zungbr_q )
423 wrkbl = max( wrkbl, 2*n+lwork_zungbr_p )
424 maxwrk = 2*n*n + wrkbl
426 ELSE IF( wntua .AND. wntvas )
THEN
431 wrkbl = n + lwork_zgeqrf
432 wrkbl = max( wrkbl, n+lwork_zungqr_m )
433 wrkbl = max( wrkbl, 2*n+lwork_zgebrd )
434 wrkbl = max( wrkbl, 2*n+lwork_zungbr_q )
435 wrkbl = max( wrkbl, 2*n+lwork_zungbr_p )
443 CALL zgebrd( m, n, a, lda, s, dum(1), cdum(1),
444 $ cdum(1), cdum(1), -1, ierr )
445 lwork_zgebrd = int( cdum(1) )
446 maxwrk = 2*n + lwork_zgebrd
447 IF( wntus .OR. wntuo )
THEN
448 CALL zungbr(
'Q', m, n, n, a, lda, cdum(1),
449 $ cdum(1), -1, ierr )
450 lwork_zungbr_q = int( cdum(1) )
451 maxwrk = max( maxwrk, 2*n+lwork_zungbr_q )
454 CALL zungbr(
'Q', m, m, n, a, lda, cdum(1),
455 $ cdum(1), -1, ierr )
456 lwork_zungbr_q = int( cdum(1) )
457 maxwrk = max( maxwrk, 2*n+lwork_zungbr_q )
459 IF( .NOT.wntvn )
THEN
460 maxwrk = max( maxwrk, 2*n+lwork_zungbr_p )
464 ELSE IF( minmn.GT.0 )
THEN
468 mnthr = ilaenv( 6,
'ZGESVD', jobu // jobvt, m, n, 0, 0 )
470 CALL zgelqf( m, n, a, lda, cdum(1), cdum(1), -1, ierr )
471 lwork_zgelqf = int( cdum(1) )
473 CALL zunglq( n, n, m, cdum(1), n, cdum(1), cdum(1), -1,
475 lwork_zunglq_n = int( cdum(1) )
476 CALL zunglq( m, n, m, a, lda, cdum(1), cdum(1), -1, ierr )
477 lwork_zunglq_m = int( cdum(1) )
479 CALL zgebrd( m, m, a, lda, s, dum(1), cdum(1),
480 $ cdum(1), cdum(1), -1, ierr )
481 lwork_zgebrd = int( cdum(1) )
483 CALL zungbr(
'P', m, m, m, a, n, cdum(1),
484 $ cdum(1), -1, ierr )
485 lwork_zungbr_p = int( cdum(1) )
487 CALL zungbr(
'Q', m, m, m, a, n, cdum(1),
488 $ cdum(1), -1, ierr )
489 lwork_zungbr_q = int( cdum(1) )
490 IF( n.GE.mnthr )
THEN
495 maxwrk = m + lwork_zgelqf
496 maxwrk = max( maxwrk, 2*m+lwork_zgebrd )
497 IF( wntuo .OR. wntuas )
498 $ maxwrk = max( maxwrk, 2*m+lwork_zungbr_q )
500 ELSE IF( wntvo .AND. wntun )
THEN
504 wrkbl = m + lwork_zgelqf
505 wrkbl = max( wrkbl, m+lwork_zunglq_m )
506 wrkbl = max( wrkbl, 2*m+lwork_zgebrd )
507 wrkbl = max( wrkbl, 2*m+lwork_zungbr_p )
508 maxwrk = max( m*m+wrkbl, m*m+m*n )
510 ELSE IF( wntvo .AND. wntuas )
THEN
515 wrkbl = m + lwork_zgelqf
516 wrkbl = max( wrkbl, m+lwork_zunglq_m )
517 wrkbl = max( wrkbl, 2*m+lwork_zgebrd )
518 wrkbl = max( wrkbl, 2*m+lwork_zungbr_p )
519 wrkbl = max( wrkbl, 2*m+lwork_zungbr_q )
520 maxwrk = max( m*m+wrkbl, m*m+m*n )
522 ELSE IF( wntvs .AND. wntun )
THEN
526 wrkbl = m + lwork_zgelqf
527 wrkbl = max( wrkbl, m+lwork_zunglq_m )
528 wrkbl = max( wrkbl, 2*m+lwork_zgebrd )
529 wrkbl = max( wrkbl, 2*m+lwork_zungbr_p )
532 ELSE IF( wntvs .AND. wntuo )
THEN
536 wrkbl = m + lwork_zgelqf
537 wrkbl = max( wrkbl, m+lwork_zunglq_m )
538 wrkbl = max( wrkbl, 2*m+lwork_zgebrd )
539 wrkbl = max( wrkbl, 2*m+lwork_zungbr_p )
540 wrkbl = max( wrkbl, 2*m+lwork_zungbr_q )
541 maxwrk = 2*m*m + wrkbl
543 ELSE IF( wntvs .AND. wntuas )
THEN
548 wrkbl = m + lwork_zgelqf
549 wrkbl = max( wrkbl, m+lwork_zunglq_m )
550 wrkbl = max( wrkbl, 2*m+lwork_zgebrd )
551 wrkbl = max( wrkbl, 2*m+lwork_zungbr_p )
552 wrkbl = max( wrkbl, 2*m+lwork_zungbr_q )
555 ELSE IF( wntva .AND. wntun )
THEN
559 wrkbl = m + lwork_zgelqf
560 wrkbl = max( wrkbl, m+lwork_zunglq_n )
561 wrkbl = max( wrkbl, 2*m+lwork_zgebrd )
562 wrkbl = max( wrkbl, 2*m+lwork_zungbr_p )
565 ELSE IF( wntva .AND. wntuo )
THEN
569 wrkbl = m + lwork_zgelqf
570 wrkbl = max( wrkbl, m+lwork_zunglq_n )
571 wrkbl = max( wrkbl, 2*m+lwork_zgebrd )
572 wrkbl = max( wrkbl, 2*m+lwork_zungbr_p )
573 wrkbl = max( wrkbl, 2*m+lwork_zungbr_q )
574 maxwrk = 2*m*m + wrkbl
576 ELSE IF( wntva .AND. wntuas )
THEN
581 wrkbl = m + lwork_zgelqf
582 wrkbl = max( wrkbl, m+lwork_zunglq_n )
583 wrkbl = max( wrkbl, 2*m+lwork_zgebrd )
584 wrkbl = max( wrkbl, 2*m+lwork_zungbr_p )
585 wrkbl = max( wrkbl, 2*m+lwork_zungbr_q )
593 CALL zgebrd( m, n, a, lda, s, dum(1), cdum(1),
594 $ cdum(1), cdum(1), -1, ierr )
595 lwork_zgebrd = int( cdum(1) )
596 maxwrk = 2*m + lwork_zgebrd
597 IF( wntvs .OR. wntvo )
THEN
599 CALL zungbr(
'P', m, n, m, a, n, cdum(1),
600 $ cdum(1), -1, ierr )
601 lwork_zungbr_p = int( cdum(1) )
602 maxwrk = max( maxwrk, 2*m+lwork_zungbr_p )
605 CALL zungbr(
'P', n, n, m, a, n, cdum(1),
606 $ cdum(1), -1, ierr )
607 lwork_zungbr_p = int( cdum(1) )
608 maxwrk = max( maxwrk, 2*m+lwork_zungbr_p )
610 IF( .NOT.wntun )
THEN
611 maxwrk = max( maxwrk, 2*m+lwork_zungbr_q )
616 maxwrk = max( maxwrk, minwrk )
619 IF( lwork.LT.minwrk .AND. .NOT.lquery )
THEN
625 CALL xerbla(
'ZGESVD', -info )
627 ELSE IF( lquery )
THEN
633 IF( m.EQ.0 .OR. n.EQ.0 )
THEN
640 smlnum = sqrt( dlamch(
'S' ) ) / eps
641 bignum = one / smlnum
645 anrm = zlange(
'M', m, n, a, lda, dum )
647 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
649 CALL zlascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, ierr )
650 ELSE IF( anrm.GT.bignum )
THEN
652 CALL zlascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, ierr )
661 IF( m.GE.mnthr )
THEN
675 CALL zgeqrf( m, n, a, lda, work( itau ), work( iwork ),
676 $ lwork-iwork+1, ierr )
681 CALL zlaset(
'L', n-1, n-1, czero, czero, a( 2, 1 ),
693 CALL zgebrd( n, n, a, lda, s, rwork( ie ), work( itauq ),
694 $ work( itaup ), work( iwork ), lwork-iwork+1,
697 IF( wntvo .OR. wntvas )
THEN
703 CALL zungbr(
'P', n, n, n, a, lda, work( itaup ),
704 $ work( iwork ), lwork-iwork+1, ierr )
714 CALL zbdsqr(
'U', n, ncvt, 0, 0, s, rwork( ie ), a, lda,
715 $ cdum, 1, cdum, 1, rwork( irwork ), info )
720 $
CALL zlacpy(
'F', n, n, a, lda, vt, ldvt )
722 ELSE IF( wntuo .AND. wntvn )
THEN
728 IF( lwork.GE.n*n+3*n )
THEN
733 IF( lwork.GE.max( wrkbl, lda*n )+lda*n )
THEN
739 ELSE IF( lwork.GE.max( wrkbl, lda*n )+n*n )
THEN
749 ldwrku = ( lwork-n*n ) / n
759 CALL zgeqrf( m, n, a, lda, work( itau ),
760 $ work( iwork ), lwork-iwork+1, ierr )
764 CALL zlacpy(
'U', n, n, a, lda, work( ir ), ldwrkr )
765 CALL zlaset(
'L', n-1, n-1, czero, czero,
766 $ work( ir+1 ), ldwrkr )
772 CALL zungqr( m, n, n, a, lda, work( itau ),
773 $ work( iwork ), lwork-iwork+1, ierr )
783 CALL zgebrd( n, n, work( ir ), ldwrkr, s, rwork( ie ),
784 $ work( itauq ), work( itaup ),
785 $ work( iwork ), lwork-iwork+1, ierr )
791 CALL zungbr(
'Q', n, n, n, work( ir ), ldwrkr,
792 $ work( itauq ), work( iwork ),
793 $ lwork-iwork+1, ierr )
801 CALL zbdsqr(
'U', n, 0, n, 0, s, rwork( ie ), cdum, 1,
802 $ work( ir ), ldwrkr, cdum, 1,
803 $ rwork( irwork ), info )
811 DO 10 i = 1, m, ldwrku
812 chunk = min( m-i+1, ldwrku )
813 CALL zgemm(
'N',
'N', chunk, n, n, cone, a( i, 1 ),
814 $ lda, work( ir ), ldwrkr, czero,
815 $ work( iu ), ldwrku )
816 CALL zlacpy(
'F', chunk, n, work( iu ), ldwrku,
833 CALL zgebrd( m, n, a, lda, s, rwork( ie ),
834 $ work( itauq ), work( itaup ),
835 $ work( iwork ), lwork-iwork+1, ierr )
841 CALL zungbr(
'Q', m, n, n, a, lda, work( itauq ),
842 $ work( iwork ), lwork-iwork+1, ierr )
850 CALL zbdsqr(
'U', n, 0, m, 0, s, rwork( ie ), cdum, 1,
851 $ a, lda, cdum, 1, rwork( irwork ), info )
855 ELSE IF( wntuo .AND. wntvas )
THEN
861 IF( lwork.GE.n*n+3*n )
THEN
866 IF( lwork.GE.max( wrkbl, lda*n )+lda*n )
THEN
872 ELSE IF( lwork.GE.max( wrkbl, lda*n )+n*n )
THEN
882 ldwrku = ( lwork-n*n ) / n
892 CALL zgeqrf( m, n, a, lda, work( itau ),
893 $ work( iwork ), lwork-iwork+1, ierr )
897 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
899 $
CALL zlaset(
'L', n-1, n-1, czero, czero,
906 CALL zungqr( m, n, n, a, lda, work( itau ),
907 $ work( iwork ), lwork-iwork+1, ierr )
917 CALL zgebrd( n, n, vt, ldvt, s, rwork( ie ),
918 $ work( itauq ), work( itaup ),
919 $ work( iwork ), lwork-iwork+1, ierr )
920 CALL zlacpy(
'L', n, n, vt, ldvt, work( ir ), ldwrkr )
926 CALL zungbr(
'Q', n, n, n, work( ir ), ldwrkr,
927 $ work( itauq ), work( iwork ),
928 $ lwork-iwork+1, ierr )
934 CALL zungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
935 $ work( iwork ), lwork-iwork+1, ierr )
944 CALL zbdsqr(
'U', n, n, n, 0, s, rwork( ie ), vt,
945 $ ldvt, work( ir ), ldwrkr, cdum, 1,
946 $ rwork( irwork ), info )
954 DO 20 i = 1, m, ldwrku
955 chunk = min( m-i+1, ldwrku )
956 CALL zgemm(
'N',
'N', chunk, n, n, cone, a( i, 1 ),
957 $ lda, work( ir ), ldwrkr, czero,
958 $ work( iu ), ldwrku )
959 CALL zlacpy(
'F', chunk, n, work( iu ), ldwrku,
974 CALL zgeqrf( m, n, a, lda, work( itau ),
975 $ work( iwork ), lwork-iwork+1, ierr )
979 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
981 $
CALL zlaset(
'L', n-1, n-1, czero, czero,
988 CALL zungqr( m, n, n, a, lda, work( itau ),
989 $ work( iwork ), lwork-iwork+1, ierr )
999 CALL zgebrd( n, n, vt, ldvt, s, rwork( ie ),
1000 $ work( itauq ), work( itaup ),
1001 $ work( iwork ), lwork-iwork+1, ierr )
1007 CALL zunmbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1008 $ work( itauq ), a, lda, work( iwork ),
1009 $ lwork-iwork+1, ierr )
1015 CALL zungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1016 $ work( iwork ), lwork-iwork+1, ierr )
1025 CALL zbdsqr(
'U', n, n, m, 0, s, rwork( ie ), vt,
1026 $ ldvt, a, lda, cdum, 1, rwork( irwork ),
1031 ELSE IF( wntus )
THEN
1039 IF( lwork.GE.n*n+3*n )
THEN
1044 IF( lwork.GE.wrkbl+lda*n )
THEN
1055 itau = ir + ldwrkr*n
1062 CALL zgeqrf( m, n, a, lda, work( itau ),
1063 $ work( iwork ), lwork-iwork+1, ierr )
1067 CALL zlacpy(
'U', n, n, a, lda, work( ir ),
1069 CALL zlaset(
'L', n-1, n-1, czero, czero,
1070 $ work( ir+1 ), ldwrkr )
1076 CALL zungqr( m, n, n, a, lda, work( itau ),
1077 $ work( iwork ), lwork-iwork+1, ierr )
1087 CALL zgebrd( n, n, work( ir ), ldwrkr, s,
1088 $ rwork( ie ), work( itauq ),
1089 $ work( itaup ), work( iwork ),
1090 $ lwork-iwork+1, ierr )
1096 CALL zungbr(
'Q', n, n, n, work( ir ), ldwrkr,
1097 $ work( itauq ), work( iwork ),
1098 $ lwork-iwork+1, ierr )
1106 CALL zbdsqr(
'U', n, 0, n, 0, s, rwork( ie ), cdum,
1107 $ 1, work( ir ), ldwrkr, cdum, 1,
1108 $ rwork( irwork ), info )
1115 CALL zgemm(
'N',
'N', m, n, n, cone, a, lda,
1116 $ work( ir ), ldwrkr, czero, u, ldu )
1129 CALL zgeqrf( m, n, a, lda, work( itau ),
1130 $ work( iwork ), lwork-iwork+1, ierr )
1131 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1137 CALL zungqr( m, n, n, u, ldu, work( itau ),
1138 $ work( iwork ), lwork-iwork+1, ierr )
1147 CALL zlaset(
'L', n-1, n-1, czero, czero,
1155 CALL zgebrd( n, n, a, lda, s, rwork( ie ),
1156 $ work( itauq ), work( itaup ),
1157 $ work( iwork ), lwork-iwork+1, ierr )
1163 CALL zunmbr(
'Q',
'R',
'N', m, n, n, a, lda,
1164 $ work( itauq ), u, ldu, work( iwork ),
1165 $ lwork-iwork+1, ierr )
1173 CALL zbdsqr(
'U', n, 0, m, 0, s, rwork( ie ), cdum,
1174 $ 1, u, ldu, cdum, 1, rwork( irwork ),
1179 ELSE IF( wntvo )
THEN
1185 IF( lwork.GE.2*n*n+3*n )
THEN
1190 IF( lwork.GE.wrkbl+2*lda*n )
THEN
1197 ELSE IF( lwork.GE.wrkbl+( lda+n )*n )
THEN
1212 itau = ir + ldwrkr*n
1219 CALL zgeqrf( m, n, a, lda, work( itau ),
1220 $ work( iwork ), lwork-iwork+1, ierr )
1224 CALL zlacpy(
'U', n, n, a, lda, work( iu ),
1226 CALL zlaset(
'L', n-1, n-1, czero, czero,
1227 $ work( iu+1 ), ldwrku )
1233 CALL zungqr( m, n, n, a, lda, work( itau ),
1234 $ work( iwork ), lwork-iwork+1, ierr )
1246 CALL zgebrd( n, n, work( iu ), ldwrku, s,
1247 $ rwork( ie ), work( itauq ),
1248 $ work( itaup ), work( iwork ),
1249 $ lwork-iwork+1, ierr )
1250 CALL zlacpy(
'U', n, n, work( iu ), ldwrku,
1251 $ work( ir ), ldwrkr )
1257 CALL zungbr(
'Q', n, n, n, work( iu ), ldwrku,
1258 $ work( itauq ), work( iwork ),
1259 $ lwork-iwork+1, ierr )
1266 CALL zungbr(
'P', n, n, n, work( ir ), ldwrkr,
1267 $ work( itaup ), work( iwork ),
1268 $ lwork-iwork+1, ierr )
1277 CALL zbdsqr(
'U', n, n, n, 0, s, rwork( ie ),
1278 $ work( ir ), ldwrkr, work( iu ),
1279 $ ldwrku, cdum, 1, rwork( irwork ),
1287 CALL zgemm(
'N',
'N', m, n, n, cone, a, lda,
1288 $ work( iu ), ldwrku, czero, u, ldu )
1294 CALL zlacpy(
'F', n, n, work( ir ), ldwrkr, a,
1308 CALL zgeqrf( m, n, a, lda, work( itau ),
1309 $ work( iwork ), lwork-iwork+1, ierr )
1310 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1316 CALL zungqr( m, n, n, u, ldu, work( itau ),
1317 $ work( iwork ), lwork-iwork+1, ierr )
1326 CALL zlaset(
'L', n-1, n-1, czero, czero,
1334 CALL zgebrd( n, n, a, lda, s, rwork( ie ),
1335 $ work( itauq ), work( itaup ),
1336 $ work( iwork ), lwork-iwork+1, ierr )
1342 CALL zunmbr(
'Q',
'R',
'N', m, n, n, a, lda,
1343 $ work( itauq ), u, ldu, work( iwork ),
1344 $ lwork-iwork+1, ierr )
1350 CALL zungbr(
'P', n, n, n, a, lda, work( itaup ),
1351 $ work( iwork ), lwork-iwork+1, ierr )
1360 CALL zbdsqr(
'U', n, n, m, 0, s, rwork( ie ), a,
1361 $ lda, u, ldu, cdum, 1, rwork( irwork ),
1366 ELSE IF( wntvas )
THEN
1373 IF( lwork.GE.n*n+3*n )
THEN
1378 IF( lwork.GE.wrkbl+lda*n )
THEN
1389 itau = iu + ldwrku*n
1396 CALL zgeqrf( m, n, a, lda, work( itau ),
1397 $ work( iwork ), lwork-iwork+1, ierr )
1401 CALL zlacpy(
'U', n, n, a, lda, work( iu ),
1403 CALL zlaset(
'L', n-1, n-1, czero, czero,
1404 $ work( iu+1 ), ldwrku )
1410 CALL zungqr( m, n, n, a, lda, work( itau ),
1411 $ work( iwork ), lwork-iwork+1, ierr )
1421 CALL zgebrd( n, n, work( iu ), ldwrku, s,
1422 $ rwork( ie ), work( itauq ),
1423 $ work( itaup ), work( iwork ),
1424 $ lwork-iwork+1, ierr )
1425 CALL zlacpy(
'U', n, n, work( iu ), ldwrku, vt,
1432 CALL zungbr(
'Q', n, n, n, work( iu ), ldwrku,
1433 $ work( itauq ), work( iwork ),
1434 $ lwork-iwork+1, ierr )
1441 CALL zungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1442 $ work( iwork ), lwork-iwork+1, ierr )
1451 CALL zbdsqr(
'U', n, n, n, 0, s, rwork( ie ), vt,
1452 $ ldvt, work( iu ), ldwrku, cdum, 1,
1453 $ rwork( irwork ), info )
1460 CALL zgemm(
'N',
'N', m, n, n, cone, a, lda,
1461 $ work( iu ), ldwrku, czero, u, ldu )
1474 CALL zgeqrf( m, n, a, lda, work( itau ),
1475 $ work( iwork ), lwork-iwork+1, ierr )
1476 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1482 CALL zungqr( m, n, n, u, ldu, work( itau ),
1483 $ work( iwork ), lwork-iwork+1, ierr )
1487 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
1489 $
CALL zlaset(
'L', n-1, n-1, czero, czero,
1490 $ vt( 2, 1 ), ldvt )
1500 CALL zgebrd( n, n, vt, ldvt, s, rwork( ie ),
1501 $ work( itauq ), work( itaup ),
1502 $ work( iwork ), lwork-iwork+1, ierr )
1509 CALL zunmbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1510 $ work( itauq ), u, ldu, work( iwork ),
1511 $ lwork-iwork+1, ierr )
1517 CALL zungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1518 $ work( iwork ), lwork-iwork+1, ierr )
1527 CALL zbdsqr(
'U', n, n, m, 0, s, rwork( ie ), vt,
1528 $ ldvt, u, ldu, cdum, 1,
1529 $ rwork( irwork ), info )
1535 ELSE IF( wntua )
THEN
1543 IF( lwork.GE.n*n+max( n+m, 3*n ) )
THEN
1548 IF( lwork.GE.wrkbl+lda*n )
THEN
1559 itau = ir + ldwrkr*n
1566 CALL zgeqrf( m, n, a, lda, work( itau ),
1567 $ work( iwork ), lwork-iwork+1, ierr )
1568 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1572 CALL zlacpy(
'U', n, n, a, lda, work( ir ),
1574 CALL zlaset(
'L', n-1, n-1, czero, czero,
1575 $ work( ir+1 ), ldwrkr )
1581 CALL zungqr( m, m, n, u, ldu, work( itau ),
1582 $ work( iwork ), lwork-iwork+1, ierr )
1592 CALL zgebrd( n, n, work( ir ), ldwrkr, s,
1593 $ rwork( ie ), work( itauq ),
1594 $ work( itaup ), work( iwork ),
1595 $ lwork-iwork+1, ierr )
1601 CALL zungbr(
'Q', n, n, n, work( ir ), ldwrkr,
1602 $ work( itauq ), work( iwork ),
1603 $ lwork-iwork+1, ierr )
1611 CALL zbdsqr(
'U', n, 0, n, 0, s, rwork( ie ), cdum,
1612 $ 1, work( ir ), ldwrkr, cdum, 1,
1613 $ rwork( irwork ), info )
1620 CALL zgemm(
'N',
'N', m, n, n, cone, u, ldu,
1621 $ work( ir ), ldwrkr, czero, a, lda )
1625 CALL zlacpy(
'F', m, n, a, lda, u, ldu )
1638 CALL zgeqrf( m, n, a, lda, work( itau ),
1639 $ work( iwork ), lwork-iwork+1, ierr )
1640 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1646 CALL zungqr( m, m, n, u, ldu, work( itau ),
1647 $ work( iwork ), lwork-iwork+1, ierr )
1656 CALL zlaset(
'L', n-1, n-1, czero, czero,
1664 CALL zgebrd( n, n, a, lda, s, rwork( ie ),
1665 $ work( itauq ), work( itaup ),
1666 $ work( iwork ), lwork-iwork+1, ierr )
1673 CALL zunmbr(
'Q',
'R',
'N', m, n, n, a, lda,
1674 $ work( itauq ), u, ldu, work( iwork ),
1675 $ lwork-iwork+1, ierr )
1683 CALL zbdsqr(
'U', n, 0, m, 0, s, rwork( ie ), cdum,
1684 $ 1, u, ldu, cdum, 1, rwork( irwork ),
1689 ELSE IF( wntvo )
THEN
1695 IF( lwork.GE.2*n*n+max( n+m, 3*n ) )
THEN
1700 IF( lwork.GE.wrkbl+2*lda*n )
THEN
1707 ELSE IF( lwork.GE.wrkbl+( lda+n )*n )
THEN
1722 itau = ir + ldwrkr*n
1729 CALL zgeqrf( m, n, a, lda, work( itau ),
1730 $ work( iwork ), lwork-iwork+1, ierr )
1731 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1737 CALL zungqr( m, m, n, u, ldu, work( itau ),
1738 $ work( iwork ), lwork-iwork+1, ierr )
1742 CALL zlacpy(
'U', n, n, a, lda, work( iu ),
1744 CALL zlaset(
'L', n-1, n-1, czero, czero,
1745 $ work( iu+1 ), ldwrku )
1757 CALL zgebrd( n, n, work( iu ), ldwrku, s,
1758 $ rwork( ie ), work( itauq ),
1759 $ work( itaup ), work( iwork ),
1760 $ lwork-iwork+1, ierr )
1761 CALL zlacpy(
'U', n, n, work( iu ), ldwrku,
1762 $ work( ir ), ldwrkr )
1768 CALL zungbr(
'Q', n, n, n, work( iu ), ldwrku,
1769 $ work( itauq ), work( iwork ),
1770 $ lwork-iwork+1, ierr )
1777 CALL zungbr(
'P', n, n, n, work( ir ), ldwrkr,
1778 $ work( itaup ), work( iwork ),
1779 $ lwork-iwork+1, ierr )
1788 CALL zbdsqr(
'U', n, n, n, 0, s, rwork( ie ),
1789 $ work( ir ), ldwrkr, work( iu ),
1790 $ ldwrku, cdum, 1, rwork( irwork ),
1798 CALL zgemm(
'N',
'N', m, n, n, cone, u, ldu,
1799 $ work( iu ), ldwrku, czero, a, lda )
1803 CALL zlacpy(
'F', m, n, a, lda, u, ldu )
1807 CALL zlacpy(
'F', n, n, work( ir ), ldwrkr, a,
1821 CALL zgeqrf( m, n, a, lda, work( itau ),
1822 $ work( iwork ), lwork-iwork+1, ierr )
1823 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1829 CALL zungqr( m, m, n, u, ldu, work( itau ),
1830 $ work( iwork ), lwork-iwork+1, ierr )
1839 CALL zlaset(
'L', n-1, n-1, czero, czero,
1847 CALL zgebrd( n, n, a, lda, s, rwork( ie ),
1848 $ work( itauq ), work( itaup ),
1849 $ work( iwork ), lwork-iwork+1, ierr )
1856 CALL zunmbr(
'Q',
'R',
'N', m, n, n, a, lda,
1857 $ work( itauq ), u, ldu, work( iwork ),
1858 $ lwork-iwork+1, ierr )
1864 CALL zungbr(
'P', n, n, n, a, lda, work( itaup ),
1865 $ work( iwork ), lwork-iwork+1, ierr )
1874 CALL zbdsqr(
'U', n, n, m, 0, s, rwork( ie ), a,
1875 $ lda, u, ldu, cdum, 1, rwork( irwork ),
1880 ELSE IF( wntvas )
THEN
1887 IF( lwork.GE.n*n+max( n+m, 3*n ) )
THEN
1892 IF( lwork.GE.wrkbl+lda*n )
THEN
1903 itau = iu + ldwrku*n
1910 CALL zgeqrf( m, n, a, lda, work( itau ),
1911 $ work( iwork ), lwork-iwork+1, ierr )
1912 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
1918 CALL zungqr( m, m, n, u, ldu, work( itau ),
1919 $ work( iwork ), lwork-iwork+1, ierr )
1923 CALL zlacpy(
'U', n, n, a, lda, work( iu ),
1925 CALL zlaset(
'L', n-1, n-1, czero, czero,
1926 $ work( iu+1 ), ldwrku )
1936 CALL zgebrd( n, n, work( iu ), ldwrku, s,
1937 $ rwork( ie ), work( itauq ),
1938 $ work( itaup ), work( iwork ),
1939 $ lwork-iwork+1, ierr )
1940 CALL zlacpy(
'U', n, n, work( iu ), ldwrku, vt,
1947 CALL zungbr(
'Q', n, n, n, work( iu ), ldwrku,
1948 $ work( itauq ), work( iwork ),
1949 $ lwork-iwork+1, ierr )
1956 CALL zungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1957 $ work( iwork ), lwork-iwork+1, ierr )
1966 CALL zbdsqr(
'U', n, n, n, 0, s, rwork( ie ), vt,
1967 $ ldvt, work( iu ), ldwrku, cdum, 1,
1968 $ rwork( irwork ), info )
1975 CALL zgemm(
'N',
'N', m, n, n, cone, u, ldu,
1976 $ work( iu ), ldwrku, czero, a, lda )
1980 CALL zlacpy(
'F', m, n, a, lda, u, ldu )
1993 CALL zgeqrf( m, n, a, lda, work( itau ),
1994 $ work( iwork ), lwork-iwork+1, ierr )
1995 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
2001 CALL zungqr( m, m, n, u, ldu, work( itau ),
2002 $ work( iwork ), lwork-iwork+1, ierr )
2006 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
2008 $
CALL zlaset(
'L', n-1, n-1, czero, czero,
2009 $ vt( 2, 1 ), ldvt )
2019 CALL zgebrd( n, n, vt, ldvt, s, rwork( ie ),
2020 $ work( itauq ), work( itaup ),
2021 $ work( iwork ), lwork-iwork+1, ierr )
2028 CALL zunmbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
2029 $ work( itauq ), u, ldu, work( iwork ),
2030 $ lwork-iwork+1, ierr )
2036 CALL zungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
2037 $ work( iwork ), lwork-iwork+1, ierr )
2046 CALL zbdsqr(
'U', n, n, m, 0, s, rwork( ie ), vt,
2047 $ ldvt, u, ldu, cdum, 1,
2048 $ rwork( irwork ), info )
2072 CALL zgebrd( m, n, a, lda, s, rwork( ie ), work( itauq ),
2073 $ work( itaup ), work( iwork ), lwork-iwork+1,
2082 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
2087 CALL zungbr(
'Q', m, ncu, n, u, ldu, work( itauq ),
2088 $ work( iwork ), lwork-iwork+1, ierr )
2097 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
2098 CALL zungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
2099 $ work( iwork ), lwork-iwork+1, ierr )
2108 CALL zungbr(
'Q', m, n, n, a, lda, work( itauq ),
2109 $ work( iwork ), lwork-iwork+1, ierr )
2118 CALL zungbr(
'P', n, n, n, a, lda, work( itaup ),
2119 $ work( iwork ), lwork-iwork+1, ierr )
2122 IF( wntuas .OR. wntuo )
2126 IF( wntvas .OR. wntvo )
2130 IF( ( .NOT.wntuo ) .AND. ( .NOT.wntvo ) )
THEN
2138 CALL zbdsqr(
'U', n, ncvt, nru, 0, s, rwork( ie ), vt,
2139 $ ldvt, u, ldu, cdum, 1, rwork( irwork ),
2141 ELSE IF( ( .NOT.wntuo ) .AND. wntvo )
THEN
2149 CALL zbdsqr(
'U', n, ncvt, nru, 0, s, rwork( ie ), a,
2150 $ lda, u, ldu, cdum, 1, rwork( irwork ),
2160 CALL zbdsqr(
'U', n, ncvt, nru, 0, s, rwork( ie ), vt,
2161 $ ldvt, a, lda, cdum, 1, rwork( irwork ),
2173 IF( n.GE.mnthr )
THEN
2187 CALL zgelqf( m, n, a, lda, work( itau ), work( iwork ),
2188 $ lwork-iwork+1, ierr )
2192 CALL zlaset(
'U', m-1, m-1, czero, czero, a( 1, 2 ),
2203 CALL zgebrd( m, m, a, lda, s, rwork( ie ), work( itauq ),
2204 $ work( itaup ), work( iwork ), lwork-iwork+1,
2206 IF( wntuo .OR. wntuas )
THEN
2212 CALL zungbr(
'Q', m, m, m, a, lda, work( itauq ),
2213 $ work( iwork ), lwork-iwork+1, ierr )
2217 IF( wntuo .OR. wntuas )
2225 CALL zbdsqr(
'U', m, 0, nru, 0, s, rwork( ie ), cdum, 1,
2226 $ a, lda, cdum, 1, rwork( irwork ), info )
2231 $
CALL zlacpy(
'F', m, m, a, lda, u, ldu )
2233 ELSE IF( wntvo .AND. wntun )
THEN
2239 IF( lwork.GE.m*m+3*m )
THEN
2244 IF( lwork.GE.max( wrkbl, lda*n )+lda*m )
THEN
2251 ELSE IF( lwork.GE.max( wrkbl, lda*n )+m*m )
THEN
2263 chunk = ( lwork-m*m ) / m
2266 itau = ir + ldwrkr*m
2273 CALL zgelqf( m, n, a, lda, work( itau ),
2274 $ work( iwork ), lwork-iwork+1, ierr )
2278 CALL zlacpy(
'L', m, m, a, lda, work( ir ), ldwrkr )
2279 CALL zlaset(
'U', m-1, m-1, czero, czero,
2280 $ work( ir+ldwrkr ), ldwrkr )
2286 CALL zunglq( m, n, m, a, lda, work( itau ),
2287 $ work( iwork ), lwork-iwork+1, ierr )
2297 CALL zgebrd( m, m, work( ir ), ldwrkr, s, rwork( ie ),
2298 $ work( itauq ), work( itaup ),
2299 $ work( iwork ), lwork-iwork+1, ierr )
2305 CALL zungbr(
'P', m, m, m, work( ir ), ldwrkr,
2306 $ work( itaup ), work( iwork ),
2307 $ lwork-iwork+1, ierr )
2315 CALL zbdsqr(
'U', m, m, 0, 0, s, rwork( ie ),
2316 $ work( ir ), ldwrkr, cdum, 1, cdum, 1,
2317 $ rwork( irwork ), info )
2325 DO 30 i = 1, n, chunk
2326 blk = min( n-i+1, chunk )
2327 CALL zgemm(
'N',
'N', m, blk, m, cone, work( ir ),
2328 $ ldwrkr, a( 1, i ), lda, czero,
2329 $ work( iu ), ldwrku )
2330 CALL zlacpy(
'F', m, blk, work( iu ), ldwrku,
2347 CALL zgebrd( m, n, a, lda, s, rwork( ie ),
2348 $ work( itauq ), work( itaup ),
2349 $ work( iwork ), lwork-iwork+1, ierr )
2355 CALL zungbr(
'P', m, n, m, a, lda, work( itaup ),
2356 $ work( iwork ), lwork-iwork+1, ierr )
2364 CALL zbdsqr(
'L', m, n, 0, 0, s, rwork( ie ), a, lda,
2365 $ cdum, 1, cdum, 1, rwork( irwork ), info )
2369 ELSE IF( wntvo .AND. wntuas )
THEN
2375 IF( lwork.GE.m*m+3*m )
THEN
2380 IF( lwork.GE.max( wrkbl, lda*n )+lda*m )
THEN
2387 ELSE IF( lwork.GE.max( wrkbl, lda*n )+m*m )
THEN
2399 chunk = ( lwork-m*m ) / m
2402 itau = ir + ldwrkr*m
2409 CALL zgelqf( m, n, a, lda, work( itau ),
2410 $ work( iwork ), lwork-iwork+1, ierr )
2414 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
2415 CALL zlaset(
'U', m-1, m-1, czero, czero, u( 1, 2 ),
2422 CALL zunglq( m, n, m, a, lda, work( itau ),
2423 $ work( iwork ), lwork-iwork+1, ierr )
2433 CALL zgebrd( m, m, u, ldu, s, rwork( ie ),
2434 $ work( itauq ), work( itaup ),
2435 $ work( iwork ), lwork-iwork+1, ierr )
2436 CALL zlacpy(
'U', m, m, u, ldu, work( ir ), ldwrkr )
2442 CALL zungbr(
'P', m, m, m, work( ir ), ldwrkr,
2443 $ work( itaup ), work( iwork ),
2444 $ lwork-iwork+1, ierr )
2450 CALL zungbr(
'Q', m, m, m, u, ldu, work( itauq ),
2451 $ work( iwork ), lwork-iwork+1, ierr )
2460 CALL zbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
2461 $ work( ir ), ldwrkr, u, ldu, cdum, 1,
2462 $ rwork( irwork ), info )
2470 DO 40 i = 1, n, chunk
2471 blk = min( n-i+1, chunk )
2472 CALL zgemm(
'N',
'N', m, blk, m, cone, work( ir ),
2473 $ ldwrkr, a( 1, i ), lda, czero,
2474 $ work( iu ), ldwrku )
2475 CALL zlacpy(
'F', m, blk, work( iu ), ldwrku,
2490 CALL zgelqf( m, n, a, lda, work( itau ),
2491 $ work( iwork ), lwork-iwork+1, ierr )
2495 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
2496 CALL zlaset(
'U', m-1, m-1, czero, czero, u( 1, 2 ),
2503 CALL zunglq( m, n, m, a, lda, work( itau ),
2504 $ work( iwork ), lwork-iwork+1, ierr )
2514 CALL zgebrd( m, m, u, ldu, s, rwork( ie ),
2515 $ work( itauq ), work( itaup ),
2516 $ work( iwork ), lwork-iwork+1, ierr )
2522 CALL zunmbr(
'P',
'L',
'C', m, n, m, u, ldu,
2523 $ work( itaup ), a, lda, work( iwork ),
2524 $ lwork-iwork+1, ierr )
2530 CALL zungbr(
'Q', m, m, m, u, ldu, work( itauq ),
2531 $ work( iwork ), lwork-iwork+1, ierr )
2540 CALL zbdsqr(
'U', m, n, m, 0, s, rwork( ie ), a, lda,
2541 $ u, ldu, cdum, 1, rwork( irwork ), info )
2545 ELSE IF( wntvs )
THEN
2553 IF( lwork.GE.m*m+3*m )
THEN
2558 IF( lwork.GE.wrkbl+lda*m )
THEN
2569 itau = ir + ldwrkr*m
2576 CALL zgelqf( m, n, a, lda, work( itau ),
2577 $ work( iwork ), lwork-iwork+1, ierr )
2581 CALL zlacpy(
'L', m, m, a, lda, work( ir ),
2583 CALL zlaset(
'U', m-1, m-1, czero, czero,
2584 $ work( ir+ldwrkr ), ldwrkr )
2590 CALL zunglq( m, n, m, a, lda, work( itau ),
2591 $ work( iwork ), lwork-iwork+1, ierr )
2601 CALL zgebrd( m, m, work( ir ), ldwrkr, s,
2602 $ rwork( ie ), work( itauq ),
2603 $ work( itaup ), work( iwork ),
2604 $ lwork-iwork+1, ierr )
2611 CALL zungbr(
'P', m, m, m, work( ir ), ldwrkr,
2612 $ work( itaup ), work( iwork ),
2613 $ lwork-iwork+1, ierr )
2621 CALL zbdsqr(
'U', m, m, 0, 0, s, rwork( ie ),
2622 $ work( ir ), ldwrkr, cdum, 1, cdum, 1,
2623 $ rwork( irwork ), info )
2630 CALL zgemm(
'N',
'N', m, n, m, cone, work( ir ),
2631 $ ldwrkr, a, lda, czero, vt, ldvt )
2644 CALL zgelqf( m, n, a, lda, work( itau ),
2645 $ work( iwork ), lwork-iwork+1, ierr )
2649 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
2655 CALL zunglq( m, n, m, vt, ldvt, work( itau ),
2656 $ work( iwork ), lwork-iwork+1, ierr )
2664 CALL zlaset(
'U', m-1, m-1, czero, czero,
2671 CALL zgebrd( m, m, a, lda, s, rwork( ie ),
2672 $ work( itauq ), work( itaup ),
2673 $ work( iwork ), lwork-iwork+1, ierr )
2679 CALL zunmbr(
'P',
'L',
'C', m, n, m, a, lda,
2680 $ work( itaup ), vt, ldvt,
2681 $ work( iwork ), lwork-iwork+1, ierr )
2689 CALL zbdsqr(
'U', m, n, 0, 0, s, rwork( ie ), vt,
2690 $ ldvt, cdum, 1, cdum, 1,
2691 $ rwork( irwork ), info )
2695 ELSE IF( wntuo )
THEN
2701 IF( lwork.GE.2*m*m+3*m )
THEN
2706 IF( lwork.GE.wrkbl+2*lda*m )
THEN
2713 ELSE IF( lwork.GE.wrkbl+( lda+m )*m )
THEN
2728 itau = ir + ldwrkr*m
2735 CALL zgelqf( m, n, a, lda, work( itau ),
2736 $ work( iwork ), lwork-iwork+1, ierr )
2740 CALL zlacpy(
'L', m, m, a, lda, work( iu ),
2742 CALL zlaset(
'U', m-1, m-1, czero, czero,
2743 $ work( iu+ldwrku ), ldwrku )
2749 CALL zunglq( m, n, m, a, lda, work( itau ),
2750 $ work( iwork ), lwork-iwork+1, ierr )
2762 CALL zgebrd( m, m, work( iu ), ldwrku, s,
2763 $ rwork( ie ), work( itauq ),
2764 $ work( itaup ), work( iwork ),
2765 $ lwork-iwork+1, ierr )
2766 CALL zlacpy(
'L', m, m, work( iu ), ldwrku,
2767 $ work( ir ), ldwrkr )
2774 CALL zungbr(
'P', m, m, m, work( iu ), ldwrku,
2775 $ work( itaup ), work( iwork ),
2776 $ lwork-iwork+1, ierr )
2782 CALL zungbr(
'Q', m, m, m, work( ir ), ldwrkr,
2783 $ work( itauq ), work( iwork ),
2784 $ lwork-iwork+1, ierr )
2793 CALL zbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
2794 $ work( iu ), ldwrku, work( ir ),
2795 $ ldwrkr, cdum, 1, rwork( irwork ),
2803 CALL zgemm(
'N',
'N', m, n, m, cone, work( iu ),
2804 $ ldwrku, a, lda, czero, vt, ldvt )
2810 CALL zlacpy(
'F', m, m, work( ir ), ldwrkr, a,
2824 CALL zgelqf( m, n, a, lda, work( itau ),
2825 $ work( iwork ), lwork-iwork+1, ierr )
2826 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
2832 CALL zunglq( m, n, m, vt, ldvt, work( itau ),
2833 $ work( iwork ), lwork-iwork+1, ierr )
2841 CALL zlaset(
'U', m-1, m-1, czero, czero,
2848 CALL zgebrd( m, m, a, lda, s, rwork( ie ),
2849 $ work( itauq ), work( itaup ),
2850 $ work( iwork ), lwork-iwork+1, ierr )
2856 CALL zunmbr(
'P',
'L',
'C', m, n, m, a, lda,
2857 $ work( itaup ), vt, ldvt,
2858 $ work( iwork ), lwork-iwork+1, ierr )
2864 CALL zungbr(
'Q', m, m, m, a, lda, work( itauq ),
2865 $ work( iwork ), lwork-iwork+1, ierr )
2874 CALL zbdsqr(
'U', m, n, m, 0, s, rwork( ie ), vt,
2875 $ ldvt, a, lda, cdum, 1,
2876 $ rwork( irwork ), info )
2880 ELSE IF( wntuas )
THEN
2887 IF( lwork.GE.m*m+3*m )
THEN
2892 IF( lwork.GE.wrkbl+lda*m )
THEN
2903 itau = iu + ldwrku*m
2910 CALL zgelqf( m, n, a, lda, work( itau ),
2911 $ work( iwork ), lwork-iwork+1, ierr )
2915 CALL zlacpy(
'L', m, m, a, lda, work( iu ),
2917 CALL zlaset(
'U', m-1, m-1, czero, czero,
2918 $ work( iu+ldwrku ), ldwrku )
2924 CALL zunglq( m, n, m, a, lda, work( itau ),
2925 $ work( iwork ), lwork-iwork+1, ierr )
2935 CALL zgebrd( m, m, work( iu ), ldwrku, s,
2936 $ rwork( ie ), work( itauq ),
2937 $ work( itaup ), work( iwork ),
2938 $ lwork-iwork+1, ierr )
2939 CALL zlacpy(
'L', m, m, work( iu ), ldwrku, u,
2947 CALL zungbr(
'P', m, m, m, work( iu ), ldwrku,
2948 $ work( itaup ), work( iwork ),
2949 $ lwork-iwork+1, ierr )
2955 CALL zungbr(
'Q', m, m, m, u, ldu, work( itauq ),
2956 $ work( iwork ), lwork-iwork+1, ierr )
2965 CALL zbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
2966 $ work( iu ), ldwrku, u, ldu, cdum, 1,
2967 $ rwork( irwork ), info )
2974 CALL zgemm(
'N',
'N', m, n, m, cone, work( iu ),
2975 $ ldwrku, a, lda, czero, vt, ldvt )
2988 CALL zgelqf( m, n, a, lda, work( itau ),
2989 $ work( iwork ), lwork-iwork+1, ierr )
2990 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
2996 CALL zunglq( m, n, m, vt, ldvt, work( itau ),
2997 $ work( iwork ), lwork-iwork+1, ierr )
3001 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
3002 CALL zlaset(
'U', m-1, m-1, czero, czero,
3013 CALL zgebrd( m, m, u, ldu, s, rwork( ie ),
3014 $ work( itauq ), work( itaup ),
3015 $ work( iwork ), lwork-iwork+1, ierr )
3022 CALL zunmbr(
'P',
'L',
'C', m, n, m, u, ldu,
3023 $ work( itaup ), vt, ldvt,
3024 $ work( iwork ), lwork-iwork+1, ierr )
3030 CALL zungbr(
'Q', m, m, m, u, ldu, work( itauq ),
3031 $ work( iwork ), lwork-iwork+1, ierr )
3040 CALL zbdsqr(
'U', m, n, m, 0, s, rwork( ie ), vt,
3041 $ ldvt, u, ldu, cdum, 1,
3042 $ rwork( irwork ), info )
3048 ELSE IF( wntva )
THEN
3056 IF( lwork.GE.m*m+max( n+m, 3*m ) )
THEN
3061 IF( lwork.GE.wrkbl+lda*m )
THEN
3072 itau = ir + ldwrkr*m
3079 CALL zgelqf( m, n, a, lda, work( itau ),
3080 $ work( iwork ), lwork-iwork+1, ierr )
3081 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
3085 CALL zlacpy(
'L', m, m, a, lda, work( ir ),
3087 CALL zlaset(
'U', m-1, m-1, czero, czero,
3088 $ work( ir+ldwrkr ), ldwrkr )
3094 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3095 $ work( iwork ), lwork-iwork+1, ierr )
3105 CALL zgebrd( m, m, work( ir ), ldwrkr, s,
3106 $ rwork( ie ), work( itauq ),
3107 $ work( itaup ), work( iwork ),
3108 $ lwork-iwork+1, ierr )
3115 CALL zungbr(
'P', m, m, m, work( ir ), ldwrkr,
3116 $ work( itaup ), work( iwork ),
3117 $ lwork-iwork+1, ierr )
3125 CALL zbdsqr(
'U', m, m, 0, 0, s, rwork( ie ),
3126 $ work( ir ), ldwrkr, cdum, 1, cdum, 1,
3127 $ rwork( irwork ), info )
3134 CALL zgemm(
'N',
'N', m, n, m, cone, work( ir ),
3135 $ ldwrkr, vt, ldvt, czero, a, lda )
3139 CALL zlacpy(
'F', m, n, a, lda, vt, ldvt )
3152 CALL zgelqf( m, n, a, lda, work( itau ),
3153 $ work( iwork ), lwork-iwork+1, ierr )
3154 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
3160 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3161 $ work( iwork ), lwork-iwork+1, ierr )
3169 CALL zlaset(
'U', m-1, m-1, czero, czero,
3176 CALL zgebrd( m, m, a, lda, s, rwork( ie ),
3177 $ work( itauq ), work( itaup ),
3178 $ work( iwork ), lwork-iwork+1, ierr )
3185 CALL zunmbr(
'P',
'L',
'C', m, n, m, a, lda,
3186 $ work( itaup ), vt, ldvt,
3187 $ work( iwork ), lwork-iwork+1, ierr )
3195 CALL zbdsqr(
'U', m, n, 0, 0, s, rwork( ie ), vt,
3196 $ ldvt, cdum, 1, cdum, 1,
3197 $ rwork( irwork ), info )
3201 ELSE IF( wntuo )
THEN
3207 IF( lwork.GE.2*m*m+max( n+m, 3*m ) )
THEN
3212 IF( lwork.GE.wrkbl+2*lda*m )
THEN
3219 ELSE IF( lwork.GE.wrkbl+( lda+m )*m )
THEN
3234 itau = ir + ldwrkr*m
3241 CALL zgelqf( m, n, a, lda, work( itau ),
3242 $ work( iwork ), lwork-iwork+1, ierr )
3243 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
3249 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3250 $ work( iwork ), lwork-iwork+1, ierr )
3254 CALL zlacpy(
'L', m, m, a, lda, work( iu ),
3256 CALL zlaset(
'U', m-1, m-1, czero, czero,
3257 $ work( iu+ldwrku ), ldwrku )
3269 CALL zgebrd( m, m, work( iu ), ldwrku, s,
3270 $ rwork( ie ), work( itauq ),
3271 $ work( itaup ), work( iwork ),
3272 $ lwork-iwork+1, ierr )
3273 CALL zlacpy(
'L', m, m, work( iu ), ldwrku,
3274 $ work( ir ), ldwrkr )
3281 CALL zungbr(
'P', m, m, m, work( iu ), ldwrku,
3282 $ work( itaup ), work( iwork ),
3283 $ lwork-iwork+1, ierr )
3289 CALL zungbr(
'Q', m, m, m, work( ir ), ldwrkr,
3290 $ work( itauq ), work( iwork ),
3291 $ lwork-iwork+1, ierr )
3300 CALL zbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
3301 $ work( iu ), ldwrku, work( ir ),
3302 $ ldwrkr, cdum, 1, rwork( irwork ),
3310 CALL zgemm(
'N',
'N', m, n, m, cone, work( iu ),
3311 $ ldwrku, vt, ldvt, czero, a, lda )
3315 CALL zlacpy(
'F', m, n, a, lda, vt, ldvt )
3319 CALL zlacpy(
'F', m, m, work( ir ), ldwrkr, a,
3333 CALL zgelqf( m, n, a, lda, work( itau ),
3334 $ work( iwork ), lwork-iwork+1, ierr )
3335 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
3341 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3342 $ work( iwork ), lwork-iwork+1, ierr )
3350 CALL zlaset(
'U', m-1, m-1, czero, czero,
3357 CALL zgebrd( m, m, a, lda, s, rwork( ie ),
3358 $ work( itauq ), work( itaup ),
3359 $ work( iwork ), lwork-iwork+1, ierr )
3366 CALL zunmbr(
'P',
'L',
'C', m, n, m, a, lda,
3367 $ work( itaup ), vt, ldvt,
3368 $ work( iwork ), lwork-iwork+1, ierr )
3374 CALL zungbr(
'Q', m, m, m, a, lda, work( itauq ),
3375 $ work( iwork ), lwork-iwork+1, ierr )
3384 CALL zbdsqr(
'U', m, n, m, 0, s, rwork( ie ), vt,
3385 $ ldvt, a, lda, cdum, 1,
3386 $ rwork( irwork ), info )
3390 ELSE IF( wntuas )
THEN
3397 IF( lwork.GE.m*m+max( n+m, 3*m ) )
THEN
3402 IF( lwork.GE.wrkbl+lda*m )
THEN
3413 itau = iu + ldwrku*m
3420 CALL zgelqf( m, n, a, lda, work( itau ),
3421 $ work( iwork ), lwork-iwork+1, ierr )
3422 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
3428 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3429 $ work( iwork ), lwork-iwork+1, ierr )
3433 CALL zlacpy(
'L', m, m, a, lda, work( iu ),
3435 CALL zlaset(
'U', m-1, m-1, czero, czero,
3436 $ work( iu+ldwrku ), ldwrku )
3446 CALL zgebrd( m, m, work( iu ), ldwrku, s,
3447 $ rwork( ie ), work( itauq ),
3448 $ work( itaup ), work( iwork ),
3449 $ lwork-iwork+1, ierr )
3450 CALL zlacpy(
'L', m, m, work( iu ), ldwrku, u,
3457 CALL zungbr(
'P', m, m, m, work( iu ), ldwrku,
3458 $ work( itaup ), work( iwork ),
3459 $ lwork-iwork+1, ierr )
3465 CALL zungbr(
'Q', m, m, m, u, ldu, work( itauq ),
3466 $ work( iwork ), lwork-iwork+1, ierr )
3475 CALL zbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
3476 $ work( iu ), ldwrku, u, ldu, cdum, 1,
3477 $ rwork( irwork ), info )
3484 CALL zgemm(
'N',
'N', m, n, m, cone, work( iu ),
3485 $ ldwrku, vt, ldvt, czero, a, lda )
3489 CALL zlacpy(
'F', m, n, a, lda, vt, ldvt )
3502 CALL zgelqf( m, n, a, lda, work( itau ),
3503 $ work( iwork ), lwork-iwork+1, ierr )
3504 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
3510 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3511 $ work( iwork ), lwork-iwork+1, ierr )
3515 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
3516 CALL zlaset(
'U', m-1, m-1, czero, czero,
3527 CALL zgebrd( m, m, u, ldu, s, rwork( ie ),
3528 $ work( itauq ), work( itaup ),
3529 $ work( iwork ), lwork-iwork+1, ierr )
3536 CALL zunmbr(
'P',
'L',
'C', m, n, m, u, ldu,
3537 $ work( itaup ), vt, ldvt,
3538 $ work( iwork ), lwork-iwork+1, ierr )
3544 CALL zungbr(
'Q', m, m, m, u, ldu, work( itauq ),
3545 $ work( iwork ), lwork-iwork+1, ierr )
3554 CALL zbdsqr(
'U', m, n, m, 0, s, rwork( ie ), vt,
3555 $ ldvt, u, ldu, cdum, 1,
3556 $ rwork( irwork ), info )
3580 CALL zgebrd( m, n, a, lda, s, rwork( ie ), work( itauq ),
3581 $ work( itaup ), work( iwork ), lwork-iwork+1,
3590 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
3591 CALL zungbr(
'Q', m, m, n, u, ldu, work( itauq ),
3592 $ work( iwork ), lwork-iwork+1, ierr )
3601 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
3606 CALL zungbr(
'P', nrvt, n, m, vt, ldvt, work( itaup ),
3607 $ work( iwork ), lwork-iwork+1, ierr )
3616 CALL zungbr(
'Q', m, m, n, a, lda, work( itauq ),
3617 $ work( iwork ), lwork-iwork+1, ierr )
3626 CALL zungbr(
'P', m, n, m, a, lda, work( itaup ),
3627 $ work( iwork ), lwork-iwork+1, ierr )
3630 IF( wntuas .OR. wntuo )
3634 IF( wntvas .OR. wntvo )
3638 IF( ( .NOT.wntuo ) .AND. ( .NOT.wntvo ) )
THEN
3646 CALL zbdsqr(
'L', m, ncvt, nru, 0, s, rwork( ie ), vt,
3647 $ ldvt, u, ldu, cdum, 1, rwork( irwork ),
3649 ELSE IF( ( .NOT.wntuo ) .AND. wntvo )
THEN
3657 CALL zbdsqr(
'L', m, ncvt, nru, 0, s, rwork( ie ), a,
3658 $ lda, u, ldu, cdum, 1, rwork( irwork ),
3668 CALL zbdsqr(
'L', m, ncvt, nru, 0, s, rwork( ie ), vt,
3669 $ ldvt, a, lda, cdum, 1, rwork( irwork ),
3679 IF( iscl.EQ.1 )
THEN
3680 IF( anrm.GT.bignum )
3681 $
CALL dlascl(
'G', 0, 0, bignum, anrm, minmn, 1, s, minmn,
3683 IF( info.NE.0 .AND. anrm.GT.bignum )
3684 $
CALL dlascl(
'G', 0, 0, bignum, anrm, minmn-1, 1,
3685 $ rwork( ie ), minmn, ierr )
3686 IF( anrm.LT.smlnum )
3687 $
CALL dlascl(
'G', 0, 0, smlnum, anrm, minmn, 1, s, minmn,
3689 IF( info.NE.0 .AND. anrm.LT.smlnum )
3690 $
CALL dlascl(
'G', 0, 0, smlnum, anrm, minmn-1, 1,
3691 $ rwork( ie ), minmn, ierr )
subroutine xerbla(srname, info)
subroutine zbdsqr(uplo, n, ncvt, nru, ncc, d, e, vt, ldvt, u, ldu, c, ldc, rwork, info)
ZBDSQR
subroutine zgebrd(m, n, a, lda, d, e, tauq, taup, work, lwork, info)
ZGEBRD
subroutine zgelqf(m, n, a, lda, tau, work, lwork, info)
ZGELQF
subroutine zgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
ZGEMM
subroutine zgeqrf(m, n, a, lda, tau, work, lwork, info)
ZGEQRF
subroutine zgesvd(jobu, jobvt, m, n, a, lda, s, u, ldu, vt, ldvt, work, lwork, rwork, info)
ZGESVD computes the singular value decomposition (SVD) for GE matrices
subroutine zlacpy(uplo, m, n, a, lda, b, ldb)
ZLACPY copies all or part of one two-dimensional array to another.
subroutine zlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
ZLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine dlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
DLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine zlaset(uplo, m, n, alpha, beta, a, lda)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine zungbr(vect, m, n, k, a, lda, tau, work, lwork, info)
ZUNGBR
subroutine zunglq(m, n, k, a, lda, tau, work, lwork, info)
ZUNGLQ
subroutine zungqr(m, n, k, a, lda, tau, work, lwork, info)
ZUNGQR
subroutine zunmbr(vect, side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
ZUNMBR