212
213
214
215
216
217
218 CHARACTER JOBU, JOBVT
219 INTEGER INFO, LDA, LDU, LDVT, LWORK, M, N
220
221
222 DOUBLE PRECISION RWORK( * ), S( * )
223 COMPLEX*16 A( LDA, * ), U( LDU, * ), VT( LDVT, * ),
224 $ WORK( * )
225
226
227
228
229
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 )
235
236
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,
242 $ NRVT, WRKBL
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
247
248
249 DOUBLE PRECISION DUM( 1 )
250 COMPLEX*16 CDUM( 1 )
251
252
257
258
259 LOGICAL LSAME
260 INTEGER ILAENV
261 DOUBLE PRECISION DLAMCH, ZLANGE
263
264
265 INTRINSIC max, min, sqrt
266
267
268
269
270
271 info = 0
272 minmn = min( m, n )
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 )
284
285 IF( .NOT.( wntua .OR. wntus .OR. wntuo .OR. wntun ) ) THEN
286 info = -1
287 ELSE IF( .NOT.( wntva .OR. wntvs .OR. wntvo .OR. wntvn ) .OR.
288 $ ( wntvo .AND. wntuo ) ) THEN
289 info = -2
290 ELSE IF( m.LT.0 ) THEN
291 info = -3
292 ELSE IF( n.LT.0 ) THEN
293 info = -4
294 ELSE IF( lda.LT.max( 1, m ) ) THEN
295 info = -6
296 ELSE IF( ldu.LT.1 .OR. ( wntuas .AND. ldu.LT.m ) ) THEN
297 info = -9
298 ELSE IF( ldvt.LT.1 .OR. ( wntva .AND. ldvt.LT.n ) .OR.
299 $ ( wntvs .AND. ldvt.LT.minmn ) ) THEN
300 info = -11
301 END IF
302
303
304
305
306
307
308
309
310
311 IF( info.EQ.0 ) THEN
312 minwrk = 1
313 maxwrk = 1
314 IF( m.GE.n .AND. minmn.GT.0 ) THEN
315
316
317
318 mnthr =
ilaenv( 6,
'ZGESVD', jobu // jobvt, m, n, 0, 0 )
319
320 CALL zgeqrf( m, n, a, lda, cdum(1), cdum(1), -1, ierr )
321 lwork_zgeqrf = int( cdum(1) )
322
323 CALL zungqr( m, n, n, a, lda, cdum(1), cdum(1), -1,
324 $ ierr )
325 lwork_zungqr_n = int( cdum(1) )
326 CALL zungqr( m, m, n, a, lda, cdum(1), cdum(1), -1,
327 $ ierr )
328 lwork_zungqr_m = int( cdum(1) )
329
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) )
333
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) )
340
341 IF( m.GE.mnthr ) THEN
342 IF( wntun ) THEN
343
344
345
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 )
350 minwrk = 3*n
351 ELSE IF( wntuo .AND. wntvn ) THEN
352
353
354
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 )
360 minwrk = 2*n + m
361 ELSE IF( wntuo .AND. wntvas ) THEN
362
363
364
365
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 )
372 minwrk = 2*n + m
373 ELSE IF( wntus .AND. wntvn ) THEN
374
375
376
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 )
381 maxwrk = n*n + wrkbl
382 minwrk = 2*n + m
383 ELSE IF( wntus .AND. wntvo ) THEN
384
385
386
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
393 minwrk = 2*n + m
394 ELSE IF( wntus .AND. wntvas ) THEN
395
396
397
398
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 )
404 maxwrk = n*n + wrkbl
405 minwrk = 2*n + m
406 ELSE IF( wntua .AND. wntvn ) THEN
407
408
409
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 )
414 maxwrk = n*n + wrkbl
415 minwrk = 2*n + m
416 ELSE IF( wntua .AND. wntvo ) THEN
417
418
419
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
426 minwrk = 2*n + m
427 ELSE IF( wntua .AND. wntvas ) THEN
428
429
430
431
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 )
437 maxwrk = n*n + wrkbl
438 minwrk = 2*n + m
439 END IF
440 ELSE
441
442
443
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 )
453 END IF
454 IF( wntua ) THEN
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 )
459 END IF
460 IF( .NOT.wntvn ) THEN
461 maxwrk = max( maxwrk, 2*n+lwork_zungbr_p )
462 END IF
463 minwrk = 2*n + m
464 END IF
465 ELSE IF( minmn.GT.0 ) THEN
466
467
468
469 mnthr =
ilaenv( 6,
'ZGESVD', jobu // jobvt, m, n, 0, 0 )
470
471 CALL zgelqf( m, n, a, lda, cdum(1), cdum(1), -1, ierr )
472 lwork_zgelqf = int( cdum(1) )
473
474 CALL zunglq( n, n, m, cdum(1), n, cdum(1), cdum(1), -1,
475 $ ierr )
476 lwork_zunglq_n = int( cdum(1) )
477 CALL zunglq( m, n, m, a, lda, cdum(1), cdum(1), -1,
478 $ ierr )
479 lwork_zunglq_m = int( cdum(1) )
480
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) )
484
485 CALL zungbr(
'P', m, m, m, a, n, cdum(1),
486 $ cdum(1), -1, ierr )
487 lwork_zungbr_p = int( cdum(1) )
488
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
493 IF( wntvn ) THEN
494
495
496
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 )
501 minwrk = 3*m
502 ELSE IF( wntvo .AND. wntun ) THEN
503
504
505
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 )
511 minwrk = 2*m + n
512 ELSE IF( wntvo .AND. wntuas ) THEN
513
514
515
516
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 )
523 minwrk = 2*m + n
524 ELSE IF( wntvs .AND. wntun ) THEN
525
526
527
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 )
532 maxwrk = m*m + wrkbl
533 minwrk = 2*m + n
534 ELSE IF( wntvs .AND. wntuo ) THEN
535
536
537
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
544 minwrk = 2*m + n
545 ELSE IF( wntvs .AND. wntuas ) THEN
546
547
548
549
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 )
555 maxwrk = m*m + wrkbl
556 minwrk = 2*m + n
557 ELSE IF( wntva .AND. wntun ) THEN
558
559
560
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 )
565 maxwrk = m*m + wrkbl
566 minwrk = 2*m + n
567 ELSE IF( wntva .AND. wntuo ) THEN
568
569
570
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
577 minwrk = 2*m + n
578 ELSE IF( wntva .AND. wntuas ) THEN
579
580
581
582
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 )
588 maxwrk = m*m + wrkbl
589 minwrk = 2*m + n
590 END IF
591 ELSE
592
593
594
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
600
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 )
605 END IF
606 IF( wntva ) THEN
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 )
611 END IF
612 IF( .NOT.wntun ) THEN
613 maxwrk = max( maxwrk, 2*m+lwork_zungbr_q )
614 END IF
615 minwrk = 2*m + n
616 END IF
617 END IF
618 maxwrk = max( maxwrk, minwrk )
619 work( 1 ) = maxwrk
620
621 IF( lwork.LT.minwrk .AND. .NOT.lquery ) THEN
622 info = -13
623 END IF
624 END IF
625
626 IF( info.NE.0 ) THEN
627 CALL xerbla(
'ZGESVD', -info )
628 RETURN
629 ELSE IF( lquery ) THEN
630 RETURN
631 END IF
632
633
634
635 IF( m.EQ.0 .OR. n.EQ.0 ) THEN
636 RETURN
637 END IF
638
639
640
642 smlnum = sqrt(
dlamch(
'S' ) ) / eps
643 bignum = one / smlnum
644
645
646
647 anrm =
zlange(
'M', m, n, a, lda, dum )
648 iscl = 0
649 IF( anrm.GT.zero .AND. anrm.LT.smlnum ) THEN
650 iscl = 1
651 CALL zlascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, ierr )
652 ELSE IF( anrm.GT.bignum ) THEN
653 iscl = 1
654 CALL zlascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, ierr )
655 END IF
656
657 IF( m.GE.n ) THEN
658
659
660
661
662
663 IF( m.GE.mnthr ) THEN
664
665 IF( wntun ) THEN
666
667
668
669
670 itau = 1
671 iwork = itau + n
672
673
674
675
676
677 CALL zgeqrf( m, n, a, lda, work( itau ),
678 $ work( iwork ),
679 $ lwork-iwork+1, ierr )
680
681
682
683 IF( n .GT. 1 ) THEN
684 CALL zlaset(
'L', n-1, n-1, czero, czero, a( 2,
685 $ 1 ),
686 $ lda )
687 END IF
688 ie = 1
689 itauq = 1
690 itaup = itauq + n
691 iwork = itaup + n
692
693
694
695
696
697 CALL zgebrd( n, n, a, lda, s, rwork( ie ),
698 $ work( itauq ),
699 $ work( itaup ), work( iwork ), lwork-iwork+1,
700 $ ierr )
701 ncvt = 0
702 IF( wntvo .OR. wntvas ) THEN
703
704
705
706
707
708 CALL zungbr(
'P', n, n, n, a, lda, work( itaup ),
709 $ work( iwork ), lwork-iwork+1, ierr )
710 ncvt = n
711 END IF
712 irwork = ie + n
713
714
715
716
717
718
719 CALL zbdsqr(
'U', n, ncvt, 0, 0, s, rwork( ie ), a,
720 $ lda,
721 $ cdum, 1, cdum, 1, rwork( irwork ), info )
722
723
724
725 IF( wntvas )
726 $
CALL zlacpy(
'F', n, n, a, lda, vt, ldvt )
727
728 ELSE IF( wntuo .AND. wntvn ) THEN
729
730
731
732
733
734 IF( lwork.GE.n*n+3*n ) THEN
735
736
737
738 ir = 1
739 IF( lwork.GE.max( wrkbl, lda*n )+lda*n ) THEN
740
741
742
743 ldwrku = lda
744 ldwrkr = lda
745 ELSE IF( lwork.GE.max( wrkbl, lda*n )+n*n ) THEN
746
747
748
749 ldwrku = lda
750 ldwrkr = n
751 ELSE
752
753
754
755 ldwrku = ( lwork-n*n ) / n
756 ldwrkr = n
757 END IF
758 itau = ir + ldwrkr*n
759 iwork = itau + n
760
761
762
763
764
765 CALL zgeqrf( m, n, a, lda, work( itau ),
766 $ work( iwork ), lwork-iwork+1, ierr )
767
768
769
770 CALL zlacpy(
'U', n, n, a, lda, work( ir ),
771 $ ldwrkr )
772 CALL zlaset(
'L', n-1, n-1, czero, czero,
773 $ work( ir+1 ), ldwrkr )
774
775
776
777
778
779 CALL zungqr( m, n, n, a, lda, work( itau ),
780 $ work( iwork ), lwork-iwork+1, ierr )
781 ie = 1
782 itauq = itau
783 itaup = itauq + n
784 iwork = itaup + n
785
786
787
788
789
790 CALL zgebrd( n, n, work( ir ), ldwrkr, s,
791 $ rwork( ie ),
792 $ work( itauq ), work( itaup ),
793 $ work( iwork ), lwork-iwork+1, ierr )
794
795
796
797
798
799 CALL zungbr(
'Q', n, n, n, work( ir ), ldwrkr,
800 $ work( itauq ), work( iwork ),
801 $ lwork-iwork+1, ierr )
802 irwork = ie + n
803
804
805
806
807
808
809 CALL zbdsqr(
'U', n, 0, n, 0, s, rwork( ie ), cdum,
810 $ 1,
811 $ work( ir ), ldwrkr, cdum, 1,
812 $ rwork( irwork ), info )
813 iu = itauq
814
815
816
817
818
819
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,
823 $ 1 ),
824 $ lda, work( ir ), ldwrkr, czero,
825 $ work( iu ), ldwrku )
826 CALL zlacpy(
'F', chunk, n, work( iu ), ldwrku,
827 $ a( i, 1 ), lda )
828 10 CONTINUE
829
830 ELSE
831
832
833
834 ie = 1
835 itauq = 1
836 itaup = itauq + n
837 iwork = itaup + n
838
839
840
841
842
843 CALL zgebrd( m, n, a, lda, s, rwork( ie ),
844 $ work( itauq ), work( itaup ),
845 $ work( iwork ), lwork-iwork+1, ierr )
846
847
848
849
850
851 CALL zungbr(
'Q', m, n, n, a, lda, work( itauq ),
852 $ work( iwork ), lwork-iwork+1, ierr )
853 irwork = ie + n
854
855
856
857
858
859
860 CALL zbdsqr(
'U', n, 0, m, 0, s, rwork( ie ), cdum,
861 $ 1,
862 $ a, lda, cdum, 1, rwork( irwork ), info )
863
864 END IF
865
866 ELSE IF( wntuo .AND. wntvas ) THEN
867
868
869
870
871
872 IF( lwork.GE.n*n+3*n ) THEN
873
874
875
876 ir = 1
877 IF( lwork.GE.max( wrkbl, lda*n )+lda*n ) THEN
878
879
880
881 ldwrku = lda
882 ldwrkr = lda
883 ELSE IF( lwork.GE.max( wrkbl, lda*n )+n*n ) THEN
884
885
886
887 ldwrku = lda
888 ldwrkr = n
889 ELSE
890
891
892
893 ldwrku = ( lwork-n*n ) / n
894 ldwrkr = n
895 END IF
896 itau = ir + ldwrkr*n
897 iwork = itau + n
898
899
900
901
902
903 CALL zgeqrf( m, n, a, lda, work( itau ),
904 $ work( iwork ), lwork-iwork+1, ierr )
905
906
907
908 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
909 IF( n.GT.1 )
910 $
CALL zlaset(
'L', n-1, n-1, czero, czero,
911 $ vt( 2, 1 ), ldvt )
912
913
914
915
916
917 CALL zungqr( m, n, n, a, lda, work( itau ),
918 $ work( iwork ), lwork-iwork+1, ierr )
919 ie = 1
920 itauq = itau
921 itaup = itauq + n
922 iwork = itaup + n
923
924
925
926
927
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 ),
932 $ ldwrkr )
933
934
935
936
937
938 CALL zungbr(
'Q', n, n, n, work( ir ), ldwrkr,
939 $ work( itauq ), work( iwork ),
940 $ lwork-iwork+1, ierr )
941
942
943
944
945
946 CALL zungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
947 $ work( iwork ), lwork-iwork+1, ierr )
948 irwork = ie + n
949
950
951
952
953
954
955
956 CALL zbdsqr(
'U', n, n, n, 0, s, rwork( ie ), vt,
957 $ ldvt, work( ir ), ldwrkr, cdum, 1,
958 $ rwork( irwork ), info )
959 iu = itauq
960
961
962
963
964
965
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,
969 $ 1 ),
970 $ lda, work( ir ), ldwrkr, czero,
971 $ work( iu ), ldwrku )
972 CALL zlacpy(
'F', chunk, n, work( iu ), ldwrku,
973 $ a( i, 1 ), lda )
974 20 CONTINUE
975
976 ELSE
977
978
979
980 itau = 1
981 iwork = itau + n
982
983
984
985
986
987 CALL zgeqrf( m, n, a, lda, work( itau ),
988 $ work( iwork ), lwork-iwork+1, ierr )
989
990
991
992 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
993 IF( n.GT.1 )
994 $
CALL zlaset(
'L', n-1, n-1, czero, czero,
995 $ vt( 2, 1 ), ldvt )
996
997
998
999
1000
1001 CALL zungqr( m, n, n, a, lda, work( itau ),
1002 $ work( iwork ), lwork-iwork+1, ierr )
1003 ie = 1
1004 itauq = itau
1005 itaup = itauq + n
1006 iwork = itaup + n
1007
1008
1009
1010
1011
1012 CALL zgebrd( n, n, vt, ldvt, s, rwork( ie ),
1013 $ work( itauq ), work( itaup ),
1014 $ work( iwork ), lwork-iwork+1, ierr )
1015
1016
1017
1018
1019
1020 CALL zunmbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1021 $ work( itauq ), a, lda, work( iwork ),
1022 $ lwork-iwork+1, ierr )
1023
1024
1025
1026
1027
1028 CALL zungbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1029 $ work( iwork ), lwork-iwork+1, ierr )
1030 irwork = ie + n
1031
1032
1033
1034
1035
1036
1037
1038 CALL zbdsqr(
'U', n, n, m, 0, s, rwork( ie ), vt,
1039 $ ldvt, a, lda, cdum, 1, rwork( irwork ),
1040 $ info )
1041
1042 END IF
1043
1044 ELSE IF( wntus ) THEN
1045
1046 IF( wntvn ) THEN
1047
1048
1049
1050
1051
1052 IF( lwork.GE.n*n+3*n ) THEN
1053
1054
1055
1056 ir = 1
1057 IF( lwork.GE.wrkbl+lda*n ) THEN
1058
1059
1060
1061 ldwrkr = lda
1062 ELSE
1063
1064
1065
1066 ldwrkr = n
1067 END IF
1068 itau = ir + ldwrkr*n
1069 iwork = itau + n
1070
1071
1072
1073
1074
1075 CALL zgeqrf( m, n, a, lda, work( itau ),
1076 $ work( iwork ), lwork-iwork+1, ierr )
1077
1078
1079
1080 CALL zlacpy(
'U', n, n, a, lda, work( ir ),
1081 $ ldwrkr )
1082 CALL zlaset(
'L', n-1, n-1, czero, czero,
1083 $ work( ir+1 ), ldwrkr )
1084
1085
1086
1087
1088
1089 CALL zungqr( m, n, n, a, lda, work( itau ),
1090 $ work( iwork ), lwork-iwork+1, ierr )
1091 ie = 1
1092 itauq = itau
1093 itaup = itauq + n
1094 iwork = itaup + n
1095
1096
1097
1098
1099
1100 CALL zgebrd( n, n, work( ir ), ldwrkr, s,
1101 $ rwork( ie ), work( itauq ),
1102 $ work( itaup ), work( iwork ),
1103 $ lwork-iwork+1, ierr )
1104
1105
1106
1107
1108
1109 CALL zungbr(
'Q', n, n, n, work( ir ), ldwrkr,
1110 $ work( itauq ), work( iwork ),
1111 $ lwork-iwork+1, ierr )
1112 irwork = ie + n
1113
1114
1115
1116
1117
1118
1119 CALL zbdsqr(
'U', n, 0, n, 0, s, rwork( ie ),
1120 $ cdum,
1121 $ 1, work( ir ), ldwrkr, cdum, 1,
1122 $ rwork( irwork ), info )
1123
1124
1125
1126
1127
1128
1129 CALL zgemm(
'N',
'N', m, n, n, cone, a, lda,
1130 $ work( ir ), ldwrkr, czero, u, ldu )
1131
1132 ELSE
1133
1134
1135
1136 itau = 1
1137 iwork = itau + n
1138
1139
1140
1141
1142
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 )
1146
1147
1148
1149
1150
1151 CALL zungqr( m, n, n, u, ldu, work( itau ),
1152 $ work( iwork ), lwork-iwork+1, ierr )
1153 ie = 1
1154 itauq = itau
1155 itaup = itauq + n
1156 iwork = itaup + n
1157
1158
1159
1160 IF( n .GT. 1 ) THEN
1161 CALL zlaset(
'L', n-1, n-1, czero, czero,
1162 $ a( 2, 1 ), lda )
1163 END IF
1164
1165
1166
1167
1168
1169 CALL zgebrd( n, n, a, lda, s, rwork( ie ),
1170 $ work( itauq ), work( itaup ),
1171 $ work( iwork ), lwork-iwork+1, ierr )
1172
1173
1174
1175
1176
1177 CALL zunmbr(
'Q',
'R',
'N', m, n, n, a, lda,
1178 $ work( itauq ), u, ldu, work( iwork ),
1179 $ lwork-iwork+1, ierr )
1180 irwork = ie + n
1181
1182
1183
1184
1185
1186
1187 CALL zbdsqr(
'U', n, 0, m, 0, s, rwork( ie ),
1188 $ cdum,
1189 $ 1, u, ldu, cdum, 1, rwork( irwork ),
1190 $ info )
1191
1192 END IF
1193
1194 ELSE IF( wntvo ) THEN
1195
1196
1197
1198
1199
1200 IF( lwork.GE.2*n*n+3*n ) THEN
1201
1202
1203
1204 iu = 1
1205 IF( lwork.GE.wrkbl+2*lda*n ) THEN
1206
1207
1208
1209 ldwrku = lda
1210 ir = iu + ldwrku*n
1211 ldwrkr = lda
1212 ELSE IF( lwork.GE.wrkbl+( lda+n )*n ) THEN
1213
1214
1215
1216 ldwrku = lda
1217 ir = iu + ldwrku*n
1218 ldwrkr = n
1219 ELSE
1220
1221
1222
1223 ldwrku = n
1224 ir = iu + ldwrku*n
1225 ldwrkr = n
1226 END IF
1227 itau = ir + ldwrkr*n
1228 iwork = itau + n
1229
1230
1231
1232
1233
1234 CALL zgeqrf( m, n, a, lda, work( itau ),
1235 $ work( iwork ), lwork-iwork+1, ierr )
1236
1237
1238
1239 CALL zlacpy(
'U', n, n, a, lda, work( iu ),
1240 $ ldwrku )
1241 CALL zlaset(
'L', n-1, n-1, czero, czero,
1242 $ work( iu+1 ), ldwrku )
1243
1244
1245
1246
1247
1248 CALL zungqr( m, n, n, a, lda, work( itau ),
1249 $ work( iwork ), lwork-iwork+1, ierr )
1250 ie = 1
1251 itauq = itau
1252 itaup = itauq + n
1253 iwork = itaup + n
1254
1255
1256
1257
1258
1259
1260
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 )
1267
1268
1269
1270
1271
1272 CALL zungbr(
'Q', n, n, n, work( iu ), ldwrku,
1273 $ work( itauq ), work( iwork ),
1274 $ lwork-iwork+1, ierr )
1275
1276
1277
1278
1279
1280
1281 CALL zungbr(
'P', n, n, n, work( ir ), ldwrkr,
1282 $ work( itaup ), work( iwork ),
1283 $ lwork-iwork+1, ierr )
1284 irwork = ie + n
1285
1286
1287
1288
1289
1290
1291
1292 CALL zbdsqr(
'U', n, n, n, 0, s, rwork( ie ),
1293 $ work( ir ), ldwrkr, work( iu ),
1294 $ ldwrku, cdum, 1, rwork( irwork ),
1295 $ info )
1296
1297
1298
1299
1300
1301
1302 CALL zgemm(
'N',
'N', m, n, n, cone, a, lda,
1303 $ work( iu ), ldwrku, czero, u, ldu )
1304
1305
1306
1307
1308
1309 CALL zlacpy(
'F', n, n, work( ir ), ldwrkr, a,
1310 $ lda )
1311
1312 ELSE
1313
1314
1315
1316 itau = 1
1317 iwork = itau + n
1318
1319
1320
1321
1322
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 )
1326
1327
1328
1329
1330
1331 CALL zungqr( m, n, n, u, ldu, work( itau ),
1332 $ work( iwork ), lwork-iwork+1, ierr )
1333 ie = 1
1334 itauq = itau
1335 itaup = itauq + n
1336 iwork = itaup + n
1337
1338
1339
1340 IF( n .GT. 1 ) THEN
1341 CALL zlaset(
'L', n-1, n-1, czero, czero,
1342 $ a( 2, 1 ), lda )
1343 END IF
1344
1345
1346
1347
1348
1349 CALL zgebrd( n, n, a, lda, s, rwork( ie ),
1350 $ work( itauq ), work( itaup ),
1351 $ work( iwork ), lwork-iwork+1, ierr )
1352
1353
1354
1355
1356
1357 CALL zunmbr(
'Q',
'R',
'N', m, n, n, a, lda,
1358 $ work( itauq ), u, ldu, work( iwork ),
1359 $ lwork-iwork+1, ierr )
1360
1361
1362
1363
1364
1365 CALL zungbr(
'P', n, n, n, a, lda,
1366 $ work( itaup ),
1367 $ work( iwork ), lwork-iwork+1, ierr )
1368 irwork = ie + n
1369
1370
1371
1372
1373
1374
1375
1376 CALL zbdsqr(
'U', n, n, m, 0, s, rwork( ie ), a,
1377 $ lda, u, ldu, cdum, 1, rwork( irwork ),
1378 $ info )
1379
1380 END IF
1381
1382 ELSE IF( wntvas ) THEN
1383
1384
1385
1386
1387
1388
1389 IF( lwork.GE.n*n+3*n ) THEN
1390
1391
1392
1393 iu = 1
1394 IF( lwork.GE.wrkbl+lda*n ) THEN
1395
1396
1397
1398 ldwrku = lda
1399 ELSE
1400
1401
1402
1403 ldwrku = n
1404 END IF
1405 itau = iu + ldwrku*n
1406 iwork = itau + n
1407
1408
1409
1410
1411
1412 CALL zgeqrf( m, n, a, lda, work( itau ),
1413 $ work( iwork ), lwork-iwork+1, ierr )
1414
1415
1416
1417 CALL zlacpy(
'U', n, n, a, lda, work( iu ),
1418 $ ldwrku )
1419 CALL zlaset(
'L', n-1, n-1, czero, czero,
1420 $ work( iu+1 ), ldwrku )
1421
1422
1423
1424
1425
1426 CALL zungqr( m, n, n, a, lda, work( itau ),
1427 $ work( iwork ), lwork-iwork+1, ierr )
1428 ie = 1
1429 itauq = itau
1430 itaup = itauq + n
1431 iwork = itaup + n
1432
1433
1434
1435
1436
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,
1442 $ ldvt )
1443
1444
1445
1446
1447
1448 CALL zungbr(
'Q', n, n, n, work( iu ), ldwrku,
1449 $ work( itauq ), work( iwork ),
1450 $ lwork-iwork+1, ierr )
1451
1452
1453
1454
1455
1456
1457 CALL zungbr(
'P', n, n, n, vt, ldvt,
1458 $ work( itaup ),
1459 $ work( iwork ), lwork-iwork+1, ierr )
1460 irwork = ie + n
1461
1462
1463
1464
1465
1466
1467
1468 CALL zbdsqr(
'U', n, n, n, 0, s, rwork( ie ),
1469 $ vt,
1470 $ ldvt, work( iu ), ldwrku, cdum, 1,
1471 $ rwork( irwork ), info )
1472
1473
1474
1475
1476
1477
1478 CALL zgemm(
'N',
'N', m, n, n, cone, a, lda,
1479 $ work( iu ), ldwrku, czero, u, ldu )
1480
1481 ELSE
1482
1483
1484
1485 itau = 1
1486 iwork = itau + n
1487
1488
1489
1490
1491
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 )
1495
1496
1497
1498
1499
1500 CALL zungqr( m, n, n, u, ldu, work( itau ),
1501 $ work( iwork ), lwork-iwork+1, ierr )
1502
1503
1504
1505 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
1506 IF( n.GT.1 )
1507 $
CALL zlaset(
'L', n-1, n-1, czero, czero,
1508 $ vt( 2, 1 ), ldvt )
1509 ie = 1
1510 itauq = itau
1511 itaup = itauq + n
1512 iwork = itaup + n
1513
1514
1515
1516
1517
1518 CALL zgebrd( n, n, vt, ldvt, s, rwork( ie ),
1519 $ work( itauq ), work( itaup ),
1520 $ work( iwork ), lwork-iwork+1, ierr )
1521
1522
1523
1524
1525
1526
1527 CALL zunmbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1528 $ work( itauq ), u, ldu, work( iwork ),
1529 $ lwork-iwork+1, ierr )
1530
1531
1532
1533
1534
1535 CALL zungbr(
'P', n, n, n, vt, ldvt,
1536 $ work( itaup ),
1537 $ work( iwork ), lwork-iwork+1, ierr )
1538 irwork = ie + n
1539
1540
1541
1542
1543
1544
1545
1546 CALL zbdsqr(
'U', n, n, m, 0, s, rwork( ie ),
1547 $ vt,
1548 $ ldvt, u, ldu, cdum, 1,
1549 $ rwork( irwork ), info )
1550
1551 END IF
1552
1553 END IF
1554
1555 ELSE IF( wntua ) THEN
1556
1557 IF( wntvn ) THEN
1558
1559
1560
1561
1562
1563 IF( lwork.GE.n*n+max( n+m, 3*n ) ) THEN
1564
1565
1566
1567 ir = 1
1568 IF( lwork.GE.wrkbl+lda*n ) THEN
1569
1570
1571
1572 ldwrkr = lda
1573 ELSE
1574
1575
1576
1577 ldwrkr = n
1578 END IF
1579 itau = ir + ldwrkr*n
1580 iwork = itau + n
1581
1582
1583
1584
1585
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 )
1589
1590
1591
1592 CALL zlacpy(
'U', n, n, a, lda, work( ir ),
1593 $ ldwrkr )
1594 CALL zlaset(
'L', n-1, n-1, czero, czero,
1595 $ work( ir+1 ), ldwrkr )
1596
1597
1598
1599
1600
1601 CALL zungqr( m, m, n, u, ldu, work( itau ),
1602 $ work( iwork ), lwork-iwork+1, ierr )
1603 ie = 1
1604 itauq = itau
1605 itaup = itauq + n
1606 iwork = itaup + n
1607
1608
1609
1610
1611
1612 CALL zgebrd( n, n, work( ir ), ldwrkr, s,
1613 $ rwork( ie ), work( itauq ),
1614 $ work( itaup ), work( iwork ),
1615 $ lwork-iwork+1, ierr )
1616
1617
1618
1619
1620
1621 CALL zungbr(
'Q', n, n, n, work( ir ), ldwrkr,
1622 $ work( itauq ), work( iwork ),
1623 $ lwork-iwork+1, ierr )
1624 irwork = ie + n
1625
1626
1627
1628
1629
1630
1631 CALL zbdsqr(
'U', n, 0, n, 0, s, rwork( ie ),
1632 $ cdum,
1633 $ 1, work( ir ), ldwrkr, cdum, 1,
1634 $ rwork( irwork ), info )
1635
1636
1637
1638
1639
1640
1641 CALL zgemm(
'N',
'N', m, n, n, cone, u, ldu,
1642 $ work( ir ), ldwrkr, czero, a, lda )
1643
1644
1645
1646 CALL zlacpy(
'F', m, n, a, lda, u, ldu )
1647
1648 ELSE
1649
1650
1651
1652 itau = 1
1653 iwork = itau + n
1654
1655
1656
1657
1658
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 )
1662
1663
1664
1665
1666
1667 CALL zungqr( m, m, n, u, ldu, work( itau ),
1668 $ work( iwork ), lwork-iwork+1, ierr )
1669 ie = 1
1670 itauq = itau
1671 itaup = itauq + n
1672 iwork = itaup + n
1673
1674
1675
1676 IF( n .GT. 1 ) THEN
1677 CALL zlaset(
'L', n-1, n-1, czero, czero,
1678 $ a( 2, 1 ), lda )
1679 END IF
1680
1681
1682
1683
1684
1685 CALL zgebrd( n, n, a, lda, s, rwork( ie ),
1686 $ work( itauq ), work( itaup ),
1687 $ work( iwork ), lwork-iwork+1, ierr )
1688
1689
1690
1691
1692
1693
1694 CALL zunmbr(
'Q',
'R',
'N', m, n, n, a, lda,
1695 $ work( itauq ), u, ldu, work( iwork ),
1696 $ lwork-iwork+1, ierr )
1697 irwork = ie + n
1698
1699
1700
1701
1702
1703
1704 CALL zbdsqr(
'U', n, 0, m, 0, s, rwork( ie ),
1705 $ cdum,
1706 $ 1, u, ldu, cdum, 1, rwork( irwork ),
1707 $ info )
1708
1709 END IF
1710
1711 ELSE IF( wntvo ) THEN
1712
1713
1714
1715
1716
1717 IF( lwork.GE.2*n*n+max( n+m, 3*n ) ) THEN
1718
1719
1720
1721 iu = 1
1722 IF( lwork.GE.wrkbl+2*lda*n ) THEN
1723
1724
1725
1726 ldwrku = lda
1727 ir = iu + ldwrku*n
1728 ldwrkr = lda
1729 ELSE IF( lwork.GE.wrkbl+( lda+n )*n ) THEN
1730
1731
1732
1733 ldwrku = lda
1734 ir = iu + ldwrku*n
1735 ldwrkr = n
1736 ELSE
1737
1738
1739
1740 ldwrku = n
1741 ir = iu + ldwrku*n
1742 ldwrkr = n
1743 END IF
1744 itau = ir + ldwrkr*n
1745 iwork = itau + n
1746
1747
1748
1749
1750
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 )
1754
1755
1756
1757
1758
1759 CALL zungqr( m, m, n, u, ldu, work( itau ),
1760 $ work( iwork ), lwork-iwork+1, ierr )
1761
1762
1763
1764 CALL zlacpy(
'U', n, n, a, lda, work( iu ),
1765 $ ldwrku )
1766 CALL zlaset(
'L', n-1, n-1, czero, czero,
1767 $ work( iu+1 ), ldwrku )
1768 ie = 1
1769 itauq = itau
1770 itaup = itauq + n
1771 iwork = itaup + n
1772
1773
1774
1775
1776
1777
1778
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 )
1785
1786
1787
1788
1789
1790 CALL zungbr(
'Q', n, n, n, work( iu ), ldwrku,
1791 $ work( itauq ), work( iwork ),
1792 $ lwork-iwork+1, ierr )
1793
1794
1795
1796
1797
1798
1799 CALL zungbr(
'P', n, n, n, work( ir ), ldwrkr,
1800 $ work( itaup ), work( iwork ),
1801 $ lwork-iwork+1, ierr )
1802 irwork = ie + n
1803
1804
1805
1806
1807
1808
1809
1810 CALL zbdsqr(
'U', n, n, n, 0, s, rwork( ie ),
1811 $ work( ir ), ldwrkr, work( iu ),
1812 $ ldwrku, cdum, 1, rwork( irwork ),
1813 $ info )
1814
1815
1816
1817
1818
1819
1820 CALL zgemm(
'N',
'N', m, n, n, cone, u, ldu,
1821 $ work( iu ), ldwrku, czero, a, lda )
1822
1823
1824
1825 CALL zlacpy(
'F', m, n, a, lda, u, ldu )
1826
1827
1828
1829 CALL zlacpy(
'F', n, n, work( ir ), ldwrkr, a,
1830 $ lda )
1831
1832 ELSE
1833
1834
1835
1836 itau = 1
1837 iwork = itau + n
1838
1839
1840
1841
1842
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 )
1846
1847
1848
1849
1850
1851 CALL zungqr( m, m, n, u, ldu, work( itau ),
1852 $ work( iwork ), lwork-iwork+1, ierr )
1853 ie = 1
1854 itauq = itau
1855 itaup = itauq + n
1856 iwork = itaup + n
1857
1858
1859
1860 IF( n .GT. 1 ) THEN
1861 CALL zlaset(
'L', n-1, n-1, czero, czero,
1862 $ a( 2, 1 ), lda )
1863 END IF
1864
1865
1866
1867
1868
1869 CALL zgebrd( n, n, a, lda, s, rwork( ie ),
1870 $ work( itauq ), work( itaup ),
1871 $ work( iwork ), lwork-iwork+1, ierr )
1872
1873
1874
1875
1876
1877
1878 CALL zunmbr(
'Q',
'R',
'N', m, n, n, a, lda,
1879 $ work( itauq ), u, ldu, work( iwork ),
1880 $ lwork-iwork+1, ierr )
1881
1882
1883
1884
1885
1886 CALL zungbr(
'P', n, n, n, a, lda,
1887 $ work( itaup ),
1888 $ work( iwork ), lwork-iwork+1, ierr )
1889 irwork = ie + n
1890
1891
1892
1893
1894
1895
1896
1897 CALL zbdsqr(
'U', n, n, m, 0, s, rwork( ie ), a,
1898 $ lda, u, ldu, cdum, 1, rwork( irwork ),
1899 $ info )
1900
1901 END IF
1902
1903 ELSE IF( wntvas ) THEN
1904
1905
1906
1907
1908
1909
1910 IF( lwork.GE.n*n+max( n+m, 3*n ) ) THEN
1911
1912
1913
1914 iu = 1
1915 IF( lwork.GE.wrkbl+lda*n ) THEN
1916
1917
1918
1919 ldwrku = lda
1920 ELSE
1921
1922
1923
1924 ldwrku = n
1925 END IF
1926 itau = iu + ldwrku*n
1927 iwork = itau + n
1928
1929
1930
1931
1932
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 )
1936
1937
1938
1939
1940
1941 CALL zungqr( m, m, n, u, ldu, work( itau ),
1942 $ work( iwork ), lwork-iwork+1, ierr )
1943
1944
1945
1946 CALL zlacpy(
'U', n, n, a, lda, work( iu ),
1947 $ ldwrku )
1948 CALL zlaset(
'L', n-1, n-1, czero, czero,
1949 $ work( iu+1 ), ldwrku )
1950 ie = 1
1951 itauq = itau
1952 itaup = itauq + n
1953 iwork = itaup + n
1954
1955
1956
1957
1958
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,
1964 $ ldvt )
1965
1966
1967
1968
1969
1970 CALL zungbr(
'Q', n, n, n, work( iu ), ldwrku,
1971 $ work( itauq ), work( iwork ),
1972 $ lwork-iwork+1, ierr )
1973
1974
1975
1976
1977
1978
1979 CALL zungbr(
'P', n, n, n, vt, ldvt,
1980 $ work( itaup ),
1981 $ work( iwork ), lwork-iwork+1, ierr )
1982 irwork = ie + n
1983
1984
1985
1986
1987
1988
1989
1990 CALL zbdsqr(
'U', n, n, n, 0, s, rwork( ie ),
1991 $ vt,
1992 $ ldvt, work( iu ), ldwrku, cdum, 1,
1993 $ rwork( irwork ), info )
1994
1995
1996
1997
1998
1999
2000 CALL zgemm(
'N',
'N', m, n, n, cone, u, ldu,
2001 $ work( iu ), ldwrku, czero, a, lda )
2002
2003
2004
2005 CALL zlacpy(
'F', m, n, a, lda, u, ldu )
2006
2007 ELSE
2008
2009
2010
2011 itau = 1
2012 iwork = itau + n
2013
2014
2015
2016
2017
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 )
2021
2022
2023
2024
2025
2026 CALL zungqr( m, m, n, u, ldu, work( itau ),
2027 $ work( iwork ), lwork-iwork+1, ierr )
2028
2029
2030
2031 CALL zlacpy(
'U', n, n, a, lda, vt, ldvt )
2032 IF( n.GT.1 )
2033 $
CALL zlaset(
'L', n-1, n-1, czero, czero,
2034 $ vt( 2, 1 ), ldvt )
2035 ie = 1
2036 itauq = itau
2037 itaup = itauq + n
2038 iwork = itaup + n
2039
2040
2041
2042
2043
2044 CALL zgebrd( n, n, vt, ldvt, s, rwork( ie ),
2045 $ work( itauq ), work( itaup ),
2046 $ work( iwork ), lwork-iwork+1, ierr )
2047
2048
2049
2050
2051
2052
2053 CALL zunmbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
2054 $ work( itauq ), u, ldu, work( iwork ),
2055 $ lwork-iwork+1, ierr )
2056
2057
2058
2059
2060
2061 CALL zungbr(
'P', n, n, n, vt, ldvt,
2062 $ work( itaup ),
2063 $ work( iwork ), lwork-iwork+1, ierr )
2064 irwork = ie + n
2065
2066
2067
2068
2069
2070
2071
2072 CALL zbdsqr(
'U', n, n, m, 0, s, rwork( ie ),
2073 $ vt,
2074 $ ldvt, u, ldu, cdum, 1,
2075 $ rwork( irwork ), info )
2076
2077 END IF
2078
2079 END IF
2080
2081 END IF
2082
2083 ELSE
2084
2085
2086
2087
2088
2089
2090 ie = 1
2091 itauq = 1
2092 itaup = itauq + n
2093 iwork = itaup + n
2094
2095
2096
2097
2098
2099 CALL zgebrd( m, n, a, lda, s, rwork( ie ), work( itauq ),
2100 $ work( itaup ), work( iwork ), lwork-iwork+1,
2101 $ ierr )
2102 IF( wntuas ) THEN
2103
2104
2105
2106
2107
2108
2109 CALL zlacpy(
'L', m, n, a, lda, u, ldu )
2110 IF( wntus )
2111 $ ncu = n
2112 IF( wntua )
2113 $ ncu = m
2114 CALL zungbr(
'Q', m, ncu, n, u, ldu, work( itauq ),
2115 $ work( iwork ), lwork-iwork+1, ierr )
2116 END IF
2117 IF( wntvas ) THEN
2118
2119
2120
2121
2122
2123
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 )
2127 END IF
2128 IF( wntuo ) THEN
2129
2130
2131
2132
2133
2134
2135 CALL zungbr(
'Q', m, n, n, a, lda, work( itauq ),
2136 $ work( iwork ), lwork-iwork+1, ierr )
2137 END IF
2138 IF( wntvo ) THEN
2139
2140
2141
2142
2143
2144
2145 CALL zungbr(
'P', n, n, n, a, lda, work( itaup ),
2146 $ work( iwork ), lwork-iwork+1, ierr )
2147 END IF
2148 irwork = ie + n
2149 IF( wntuas .OR. wntuo )
2150 $ nru = m
2151 IF( wntun )
2152 $ nru = 0
2153 IF( wntvas .OR. wntvo )
2154 $ ncvt = n
2155 IF( wntvn )
2156 $ ncvt = 0
2157 IF( ( .NOT.wntuo ) .AND. ( .NOT.wntvo ) ) THEN
2158
2159
2160
2161
2162
2163
2164
2165 CALL zbdsqr(
'U', n, ncvt, nru, 0, s, rwork( ie ), vt,
2166 $ ldvt, u, ldu, cdum, 1, rwork( irwork ),
2167 $ info )
2168 ELSE IF( ( .NOT.wntuo ) .AND. wntvo ) THEN
2169
2170
2171
2172
2173
2174
2175
2176 CALL zbdsqr(
'U', n, ncvt, nru, 0, s, rwork( ie ), a,
2177 $ lda, u, ldu, cdum, 1, rwork( irwork ),
2178 $ info )
2179 ELSE
2180
2181
2182
2183
2184
2185
2186
2187 CALL zbdsqr(
'U', n, ncvt, nru, 0, s, rwork( ie ), vt,
2188 $ ldvt, a, lda, cdum, 1, rwork( irwork ),
2189 $ info )
2190 END IF
2191
2192 END IF
2193
2194 ELSE
2195
2196
2197
2198
2199
2200 IF( n.GE.mnthr ) THEN
2201
2202 IF( wntvn ) THEN
2203
2204
2205
2206
2207 itau = 1
2208 iwork = itau + m
2209
2210
2211
2212
2213
2214 CALL zgelqf( m, n, a, lda, work( itau ),
2215 $ work( iwork ),
2216 $ lwork-iwork+1, ierr )
2217
2218
2219
2220 CALL zlaset(
'U', m-1, m-1, czero, czero, a( 1, 2 ),
2221 $ lda )
2222 ie = 1
2223 itauq = 1
2224 itaup = itauq + m
2225 iwork = itaup + m
2226
2227
2228
2229
2230
2231 CALL zgebrd( m, m, a, lda, s, rwork( ie ),
2232 $ work( itauq ),
2233 $ work( itaup ), work( iwork ), lwork-iwork+1,
2234 $ ierr )
2235 IF( wntuo .OR. wntuas ) THEN
2236
2237
2238
2239
2240
2241 CALL zungbr(
'Q', m, m, m, a, lda, work( itauq ),
2242 $ work( iwork ), lwork-iwork+1, ierr )
2243 END IF
2244 irwork = ie + m
2245 nru = 0
2246 IF( wntuo .OR. wntuas )
2247 $ nru = m
2248
2249
2250
2251
2252
2253
2254 CALL zbdsqr(
'U', m, 0, nru, 0, s, rwork( ie ), cdum,
2255 $ 1,
2256 $ a, lda, cdum, 1, rwork( irwork ), info )
2257
2258
2259
2260 IF( wntuas )
2261 $
CALL zlacpy(
'F', m, m, a, lda, u, ldu )
2262
2263 ELSE IF( wntvo .AND. wntun ) THEN
2264
2265
2266
2267
2268
2269 IF( lwork.GE.m*m+3*m ) THEN
2270
2271
2272
2273 ir = 1
2274 IF( lwork.GE.max( wrkbl, lda*n )+lda*m ) THEN
2275
2276
2277
2278 ldwrku = lda
2279 chunk = n
2280 ldwrkr = lda
2281 ELSE IF( lwork.GE.max( wrkbl, lda*n )+m*m ) THEN
2282
2283
2284
2285 ldwrku = lda
2286 chunk = n
2287 ldwrkr = m
2288 ELSE
2289
2290
2291
2292 ldwrku = m
2293 chunk = ( lwork-m*m ) / m
2294 ldwrkr = m
2295 END IF
2296 itau = ir + ldwrkr*m
2297 iwork = itau + m
2298
2299
2300
2301
2302
2303 CALL zgelqf( m, n, a, lda, work( itau ),
2304 $ work( iwork ), lwork-iwork+1, ierr )
2305
2306
2307
2308 CALL zlacpy(
'L', m, m, a, lda, work( ir ),
2309 $ ldwrkr )
2310 CALL zlaset(
'U', m-1, m-1, czero, czero,
2311 $ work( ir+ldwrkr ), ldwrkr )
2312
2313
2314
2315
2316
2317 CALL zunglq( m, n, m, a, lda, work( itau ),
2318 $ work( iwork ), lwork-iwork+1, ierr )
2319 ie = 1
2320 itauq = itau
2321 itaup = itauq + m
2322 iwork = itaup + m
2323
2324
2325
2326
2327
2328 CALL zgebrd( m, m, work( ir ), ldwrkr, s,
2329 $ rwork( ie ),
2330 $ work( itauq ), work( itaup ),
2331 $ work( iwork ), lwork-iwork+1, ierr )
2332
2333
2334
2335
2336
2337 CALL zungbr(
'P', m, m, m, work( ir ), ldwrkr,
2338 $ work( itaup ), work( iwork ),
2339 $ lwork-iwork+1, ierr )
2340 irwork = ie + m
2341
2342
2343
2344
2345
2346
2347 CALL zbdsqr(
'U', m, m, 0, 0, s, rwork( ie ),
2348 $ work( ir ), ldwrkr, cdum, 1, cdum, 1,
2349 $ rwork( irwork ), info )
2350 iu = itauq
2351
2352
2353
2354
2355
2356
2357 DO 30 i = 1, n, chunk
2358 blk = min( n-i+1, chunk )
2359 CALL zgemm(
'N',
'N', m, blk, m, cone,
2360 $ work( ir ),
2361 $ ldwrkr, a( 1, i ), lda, czero,
2362 $ work( iu ), ldwrku )
2363 CALL zlacpy(
'F', m, blk, work( iu ), ldwrku,
2364 $ a( 1, i ), lda )
2365 30 CONTINUE
2366
2367 ELSE
2368
2369
2370
2371 ie = 1
2372 itauq = 1
2373 itaup = itauq + m
2374 iwork = itaup + m
2375
2376
2377
2378
2379
2380 CALL zgebrd( m, n, a, lda, s, rwork( ie ),
2381 $ work( itauq ), work( itaup ),
2382 $ work( iwork ), lwork-iwork+1, ierr )
2383
2384
2385
2386
2387
2388 CALL zungbr(
'P', m, n, m, a, lda, work( itaup ),
2389 $ work( iwork ), lwork-iwork+1, ierr )
2390 irwork = ie + m
2391
2392
2393
2394
2395
2396
2397 CALL zbdsqr(
'L', m, n, 0, 0, s, rwork( ie ), a,
2398 $ lda,
2399 $ cdum, 1, cdum, 1, rwork( irwork ), info )
2400
2401 END IF
2402
2403 ELSE IF( wntvo .AND. wntuas ) THEN
2404
2405
2406
2407
2408
2409 IF( lwork.GE.m*m+3*m ) THEN
2410
2411
2412
2413 ir = 1
2414 IF( lwork.GE.max( wrkbl, lda*n )+lda*m ) THEN
2415
2416
2417
2418 ldwrku = lda
2419 chunk = n
2420 ldwrkr = lda
2421 ELSE IF( lwork.GE.max( wrkbl, lda*n )+m*m ) THEN
2422
2423
2424
2425 ldwrku = lda
2426 chunk = n
2427 ldwrkr = m
2428 ELSE
2429
2430
2431
2432 ldwrku = m
2433 chunk = ( lwork-m*m ) / m
2434 ldwrkr = m
2435 END IF
2436 itau = ir + ldwrkr*m
2437 iwork = itau + m
2438
2439
2440
2441
2442
2443 CALL zgelqf( m, n, a, lda, work( itau ),
2444 $ work( iwork ), lwork-iwork+1, ierr )
2445
2446
2447
2448 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
2449 CALL zlaset(
'U', m-1, m-1, czero, czero, u( 1,
2450 $ 2 ),
2451 $ ldu )
2452
2453
2454
2455
2456
2457 CALL zunglq( m, n, m, a, lda, work( itau ),
2458 $ work( iwork ), lwork-iwork+1, ierr )
2459 ie = 1
2460 itauq = itau
2461 itaup = itauq + m
2462 iwork = itaup + m
2463
2464
2465
2466
2467
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 ),
2472 $ ldwrkr )
2473
2474
2475
2476
2477
2478 CALL zungbr(
'P', m, m, m, work( ir ), ldwrkr,
2479 $ work( itaup ), work( iwork ),
2480 $ lwork-iwork+1, ierr )
2481
2482
2483
2484
2485
2486 CALL zungbr(
'Q', m, m, m, u, ldu, work( itauq ),
2487 $ work( iwork ), lwork-iwork+1, ierr )
2488 irwork = ie + m
2489
2490
2491
2492
2493
2494
2495
2496 CALL zbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
2497 $ work( ir ), ldwrkr, u, ldu, cdum, 1,
2498 $ rwork( irwork ), info )
2499 iu = itauq
2500
2501
2502
2503
2504
2505
2506 DO 40 i = 1, n, chunk
2507 blk = min( n-i+1, chunk )
2508 CALL zgemm(
'N',
'N', m, blk, m, cone,
2509 $ work( ir ),
2510 $ ldwrkr, a( 1, i ), lda, czero,
2511 $ work( iu ), ldwrku )
2512 CALL zlacpy(
'F', m, blk, work( iu ), ldwrku,
2513 $ a( 1, i ), lda )
2514 40 CONTINUE
2515
2516 ELSE
2517
2518
2519
2520 itau = 1
2521 iwork = itau + m
2522
2523
2524
2525
2526
2527 CALL zgelqf( m, n, a, lda, work( itau ),
2528 $ work( iwork ), lwork-iwork+1, ierr )
2529
2530
2531
2532 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
2533 CALL zlaset(
'U', m-1, m-1, czero, czero, u( 1,
2534 $ 2 ),
2535 $ ldu )
2536
2537
2538
2539
2540
2541 CALL zunglq( m, n, m, a, lda, work( itau ),
2542 $ work( iwork ), lwork-iwork+1, ierr )
2543 ie = 1
2544 itauq = itau
2545 itaup = itauq + m
2546 iwork = itaup + m
2547
2548
2549
2550
2551
2552 CALL zgebrd( m, m, u, ldu, s, rwork( ie ),
2553 $ work( itauq ), work( itaup ),
2554 $ work( iwork ), lwork-iwork+1, ierr )
2555
2556
2557
2558
2559
2560 CALL zunmbr(
'P',
'L',
'C', m, n, m, u, ldu,
2561 $ work( itaup ), a, lda, work( iwork ),
2562 $ lwork-iwork+1, ierr )
2563
2564
2565
2566
2567
2568 CALL zungbr(
'Q', m, m, m, u, ldu, work( itauq ),
2569 $ work( iwork ), lwork-iwork+1, ierr )
2570 irwork = ie + m
2571
2572
2573
2574
2575
2576
2577
2578 CALL zbdsqr(
'U', m, n, m, 0, s, rwork( ie ), a,
2579 $ lda,
2580 $ u, ldu, cdum, 1, rwork( irwork ), info )
2581
2582 END IF
2583
2584 ELSE IF( wntvs ) THEN
2585
2586 IF( wntun ) THEN
2587
2588
2589
2590
2591
2592 IF( lwork.GE.m*m+3*m ) THEN
2593
2594
2595
2596 ir = 1
2597 IF( lwork.GE.wrkbl+lda*m ) THEN
2598
2599
2600
2601 ldwrkr = lda
2602 ELSE
2603
2604
2605
2606 ldwrkr = m
2607 END IF
2608 itau = ir + ldwrkr*m
2609 iwork = itau + m
2610
2611
2612
2613
2614
2615 CALL zgelqf( m, n, a, lda, work( itau ),
2616 $ work( iwork ), lwork-iwork+1, ierr )
2617
2618
2619
2620 CALL zlacpy(
'L', m, m, a, lda, work( ir ),
2621 $ ldwrkr )
2622 CALL zlaset(
'U', m-1, m-1, czero, czero,
2623 $ work( ir+ldwrkr ), ldwrkr )
2624
2625
2626
2627
2628
2629 CALL zunglq( m, n, m, a, lda, work( itau ),
2630 $ work( iwork ), lwork-iwork+1, ierr )
2631 ie = 1
2632 itauq = itau
2633 itaup = itauq + m
2634 iwork = itaup + m
2635
2636
2637
2638
2639
2640 CALL zgebrd( m, m, work( ir ), ldwrkr, s,
2641 $ rwork( ie ), work( itauq ),
2642 $ work( itaup ), work( iwork ),
2643 $ lwork-iwork+1, ierr )
2644
2645
2646
2647
2648
2649
2650 CALL zungbr(
'P', m, m, m, work( ir ), ldwrkr,
2651 $ work( itaup ), work( iwork ),
2652 $ lwork-iwork+1, ierr )
2653 irwork = ie + m
2654
2655
2656
2657
2658
2659
2660 CALL zbdsqr(
'U', m, m, 0, 0, s, rwork( ie ),
2661 $ work( ir ), ldwrkr, cdum, 1, cdum, 1,
2662 $ rwork( irwork ), info )
2663
2664
2665
2666
2667
2668
2669 CALL zgemm(
'N',
'N', m, n, m, cone, work( ir ),
2670 $ ldwrkr, a, lda, czero, vt, ldvt )
2671
2672 ELSE
2673
2674
2675
2676 itau = 1
2677 iwork = itau + m
2678
2679
2680
2681
2682
2683 CALL zgelqf( m, n, a, lda, work( itau ),
2684 $ work( iwork ), lwork-iwork+1, ierr )
2685
2686
2687
2688 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
2689
2690
2691
2692
2693
2694 CALL zunglq( m, n, m, vt, ldvt, work( itau ),
2695 $ work( iwork ), lwork-iwork+1, ierr )
2696 ie = 1
2697 itauq = itau
2698 itaup = itauq + m
2699 iwork = itaup + m
2700
2701
2702
2703 CALL zlaset(
'U', m-1, m-1, czero, czero,
2704 $ a( 1, 2 ), lda )
2705
2706
2707
2708
2709
2710 CALL zgebrd( m, m, a, lda, s, rwork( ie ),
2711 $ work( itauq ), work( itaup ),
2712 $ work( iwork ), lwork-iwork+1, ierr )
2713
2714
2715
2716
2717
2718 CALL zunmbr(
'P',
'L',
'C', m, n, m, a, lda,
2719 $ work( itaup ), vt, ldvt,
2720 $ work( iwork ), lwork-iwork+1, ierr )
2721 irwork = ie + m
2722
2723
2724
2725
2726
2727
2728 CALL zbdsqr(
'U', m, n, 0, 0, s, rwork( ie ),
2729 $ vt,
2730 $ ldvt, cdum, 1, cdum, 1,
2731 $ rwork( irwork ), info )
2732
2733 END IF
2734
2735 ELSE IF( wntuo ) THEN
2736
2737
2738
2739
2740
2741 IF( lwork.GE.2*m*m+3*m ) THEN
2742
2743
2744
2745 iu = 1
2746 IF( lwork.GE.wrkbl+2*lda*m ) THEN
2747
2748
2749
2750 ldwrku = lda
2751 ir = iu + ldwrku*m
2752 ldwrkr = lda
2753 ELSE IF( lwork.GE.wrkbl+( lda+m )*m ) THEN
2754
2755
2756
2757 ldwrku = lda
2758 ir = iu + ldwrku*m
2759 ldwrkr = m
2760 ELSE
2761
2762
2763
2764 ldwrku = m
2765 ir = iu + ldwrku*m
2766 ldwrkr = m
2767 END IF
2768 itau = ir + ldwrkr*m
2769 iwork = itau + m
2770
2771
2772
2773
2774
2775 CALL zgelqf( m, n, a, lda, work( itau ),
2776 $ work( iwork ), lwork-iwork+1, ierr )
2777
2778
2779
2780 CALL zlacpy(
'L', m, m, a, lda, work( iu ),
2781 $ ldwrku )
2782 CALL zlaset(
'U', m-1, m-1, czero, czero,
2783 $ work( iu+ldwrku ), ldwrku )
2784
2785
2786
2787
2788
2789 CALL zunglq( m, n, m, a, lda, work( itau ),
2790 $ work( iwork ), lwork-iwork+1, ierr )
2791 ie = 1
2792 itauq = itau
2793 itaup = itauq + m
2794 iwork = itaup + m
2795
2796
2797
2798
2799
2800
2801
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 )
2808
2809
2810
2811
2812
2813
2814 CALL zungbr(
'P', m, m, m, work( iu ), ldwrku,
2815 $ work( itaup ), work( iwork ),
2816 $ lwork-iwork+1, ierr )
2817
2818
2819
2820
2821
2822 CALL zungbr(
'Q', m, m, m, work( ir ), ldwrkr,
2823 $ work( itauq ), work( iwork ),
2824 $ lwork-iwork+1, ierr )
2825 irwork = ie + m
2826
2827
2828
2829
2830
2831
2832
2833 CALL zbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
2834 $ work( iu ), ldwrku, work( ir ),
2835 $ ldwrkr, cdum, 1, rwork( irwork ),
2836 $ info )
2837
2838
2839
2840
2841
2842
2843 CALL zgemm(
'N',
'N', m, n, m, cone, work( iu ),
2844 $ ldwrku, a, lda, czero, vt, ldvt )
2845
2846
2847
2848
2849
2850 CALL zlacpy(
'F', m, m, work( ir ), ldwrkr, a,
2851 $ lda )
2852
2853 ELSE
2854
2855
2856
2857 itau = 1
2858 iwork = itau + m
2859
2860
2861
2862
2863
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 )
2867
2868
2869
2870
2871
2872 CALL zunglq( m, n, m, vt, ldvt, work( itau ),
2873 $ work( iwork ), lwork-iwork+1, ierr )
2874 ie = 1
2875 itauq = itau
2876 itaup = itauq + m
2877 iwork = itaup + m
2878
2879
2880
2881 CALL zlaset(
'U', m-1, m-1, czero, czero,
2882 $ a( 1, 2 ), lda )
2883
2884
2885
2886
2887
2888 CALL zgebrd( m, m, a, lda, s, rwork( ie ),
2889 $ work( itauq ), work( itaup ),
2890 $ work( iwork ), lwork-iwork+1, ierr )
2891
2892
2893
2894
2895
2896 CALL zunmbr(
'P',
'L',
'C', m, n, m, a, lda,
2897 $ work( itaup ), vt, ldvt,
2898 $ work( iwork ), lwork-iwork+1, ierr )
2899
2900
2901
2902
2903
2904 CALL zungbr(
'Q', m, m, m, a, lda,
2905 $ work( itauq ),
2906 $ work( iwork ), lwork-iwork+1, ierr )
2907 irwork = ie + m
2908
2909
2910
2911
2912
2913
2914
2915 CALL zbdsqr(
'U', m, n, m, 0, s, rwork( ie ),
2916 $ vt,
2917 $ ldvt, a, lda, cdum, 1,
2918 $ rwork( irwork ), info )
2919
2920 END IF
2921
2922 ELSE IF( wntuas ) THEN
2923
2924
2925
2926
2927
2928
2929 IF( lwork.GE.m*m+3*m ) THEN
2930
2931
2932
2933 iu = 1
2934 IF( lwork.GE.wrkbl+lda*m ) THEN
2935
2936
2937
2938 ldwrku = lda
2939 ELSE
2940
2941
2942
2943 ldwrku = m
2944 END IF
2945 itau = iu + ldwrku*m
2946 iwork = itau + m
2947
2948
2949
2950
2951
2952 CALL zgelqf( m, n, a, lda, work( itau ),
2953 $ work( iwork ), lwork-iwork+1, ierr )
2954
2955
2956
2957 CALL zlacpy(
'L', m, m, a, lda, work( iu ),
2958 $ ldwrku )
2959 CALL zlaset(
'U', m-1, m-1, czero, czero,
2960 $ work( iu+ldwrku ), ldwrku )
2961
2962
2963
2964
2965
2966 CALL zunglq( m, n, m, a, lda, work( itau ),
2967 $ work( iwork ), lwork-iwork+1, ierr )
2968 ie = 1
2969 itauq = itau
2970 itaup = itauq + m
2971 iwork = itaup + m
2972
2973
2974
2975
2976
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,
2982 $ ldu )
2983
2984
2985
2986
2987
2988
2989 CALL zungbr(
'P', m, m, m, work( iu ), ldwrku,
2990 $ work( itaup ), work( iwork ),
2991 $ lwork-iwork+1, ierr )
2992
2993
2994
2995
2996
2997 CALL zungbr(
'Q', m, m, m, u, ldu,
2998 $ work( itauq ),
2999 $ work( iwork ), lwork-iwork+1, ierr )
3000 irwork = ie + m
3001
3002
3003
3004
3005
3006
3007
3008 CALL zbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
3009 $ work( iu ), ldwrku, u, ldu, cdum, 1,
3010 $ rwork( irwork ), info )
3011
3012
3013
3014
3015
3016
3017 CALL zgemm(
'N',
'N', m, n, m, cone, work( iu ),
3018 $ ldwrku, a, lda, czero, vt, ldvt )
3019
3020 ELSE
3021
3022
3023
3024 itau = 1
3025 iwork = itau + m
3026
3027
3028
3029
3030
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 )
3034
3035
3036
3037
3038
3039 CALL zunglq( m, n, m, vt, ldvt, work( itau ),
3040 $ work( iwork ), lwork-iwork+1, ierr )
3041
3042
3043
3044 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
3045 CALL zlaset(
'U', m-1, m-1, czero, czero,
3046 $ u( 1, 2 ), ldu )
3047 ie = 1
3048 itauq = itau
3049 itaup = itauq + m
3050 iwork = itaup + m
3051
3052
3053
3054
3055
3056 CALL zgebrd( m, m, u, ldu, s, rwork( ie ),
3057 $ work( itauq ), work( itaup ),
3058 $ work( iwork ), lwork-iwork+1, ierr )
3059
3060
3061
3062
3063
3064
3065 CALL zunmbr(
'P',
'L',
'C', m, n, m, u, ldu,
3066 $ work( itaup ), vt, ldvt,
3067 $ work( iwork ), lwork-iwork+1, ierr )
3068
3069
3070
3071
3072
3073 CALL zungbr(
'Q', m, m, m, u, ldu,
3074 $ work( itauq ),
3075 $ work( iwork ), lwork-iwork+1, ierr )
3076 irwork = ie + m
3077
3078
3079
3080
3081
3082
3083
3084 CALL zbdsqr(
'U', m, n, m, 0, s, rwork( ie ),
3085 $ vt,
3086 $ ldvt, u, ldu, cdum, 1,
3087 $ rwork( irwork ), info )
3088
3089 END IF
3090
3091 END IF
3092
3093 ELSE IF( wntva ) THEN
3094
3095 IF( wntun ) THEN
3096
3097
3098
3099
3100
3101 IF( lwork.GE.m*m+max( n+m, 3*m ) ) THEN
3102
3103
3104
3105 ir = 1
3106 IF( lwork.GE.wrkbl+lda*m ) THEN
3107
3108
3109
3110 ldwrkr = lda
3111 ELSE
3112
3113
3114
3115 ldwrkr = m
3116 END IF
3117 itau = ir + ldwrkr*m
3118 iwork = itau + m
3119
3120
3121
3122
3123
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 )
3127
3128
3129
3130 CALL zlacpy(
'L', m, m, a, lda, work( ir ),
3131 $ ldwrkr )
3132 CALL zlaset(
'U', m-1, m-1, czero, czero,
3133 $ work( ir+ldwrkr ), ldwrkr )
3134
3135
3136
3137
3138
3139 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3140 $ work( iwork ), lwork-iwork+1, ierr )
3141 ie = 1
3142 itauq = itau
3143 itaup = itauq + m
3144 iwork = itaup + m
3145
3146
3147
3148
3149
3150 CALL zgebrd( m, m, work( ir ), ldwrkr, s,
3151 $ rwork( ie ), work( itauq ),
3152 $ work( itaup ), work( iwork ),
3153 $ lwork-iwork+1, ierr )
3154
3155
3156
3157
3158
3159
3160 CALL zungbr(
'P', m, m, m, work( ir ), ldwrkr,
3161 $ work( itaup ), work( iwork ),
3162 $ lwork-iwork+1, ierr )
3163 irwork = ie + m
3164
3165
3166
3167
3168
3169
3170 CALL zbdsqr(
'U', m, m, 0, 0, s, rwork( ie ),
3171 $ work( ir ), ldwrkr, cdum, 1, cdum, 1,
3172 $ rwork( irwork ), info )
3173
3174
3175
3176
3177
3178
3179 CALL zgemm(
'N',
'N', m, n, m, cone, work( ir ),
3180 $ ldwrkr, vt, ldvt, czero, a, lda )
3181
3182
3183
3184 CALL zlacpy(
'F', m, n, a, lda, vt, ldvt )
3185
3186 ELSE
3187
3188
3189
3190 itau = 1
3191 iwork = itau + m
3192
3193
3194
3195
3196
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 )
3200
3201
3202
3203
3204
3205 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3206 $ work( iwork ), lwork-iwork+1, ierr )
3207 ie = 1
3208 itauq = itau
3209 itaup = itauq + m
3210 iwork = itaup + m
3211
3212
3213
3214 CALL zlaset(
'U', m-1, m-1, czero, czero,
3215 $ a( 1, 2 ), lda )
3216
3217
3218
3219
3220
3221 CALL zgebrd( m, m, a, lda, s, rwork( ie ),
3222 $ work( itauq ), work( itaup ),
3223 $ work( iwork ), lwork-iwork+1, ierr )
3224
3225
3226
3227
3228
3229
3230 CALL zunmbr(
'P',
'L',
'C', m, n, m, a, lda,
3231 $ work( itaup ), vt, ldvt,
3232 $ work( iwork ), lwork-iwork+1, ierr )
3233 irwork = ie + m
3234
3235
3236
3237
3238
3239
3240 CALL zbdsqr(
'U', m, n, 0, 0, s, rwork( ie ),
3241 $ vt,
3242 $ ldvt, cdum, 1, cdum, 1,
3243 $ rwork( irwork ), info )
3244
3245 END IF
3246
3247 ELSE IF( wntuo ) THEN
3248
3249
3250
3251
3252
3253 IF( lwork.GE.2*m*m+max( n+m, 3*m ) ) THEN
3254
3255
3256
3257 iu = 1
3258 IF( lwork.GE.wrkbl+2*lda*m ) THEN
3259
3260
3261
3262 ldwrku = lda
3263 ir = iu + ldwrku*m
3264 ldwrkr = lda
3265 ELSE IF( lwork.GE.wrkbl+( lda+m )*m ) THEN
3266
3267
3268
3269 ldwrku = lda
3270 ir = iu + ldwrku*m
3271 ldwrkr = m
3272 ELSE
3273
3274
3275
3276 ldwrku = m
3277 ir = iu + ldwrku*m
3278 ldwrkr = m
3279 END IF
3280 itau = ir + ldwrkr*m
3281 iwork = itau + m
3282
3283
3284
3285
3286
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 )
3290
3291
3292
3293
3294
3295 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3296 $ work( iwork ), lwork-iwork+1, ierr )
3297
3298
3299
3300 CALL zlacpy(
'L', m, m, a, lda, work( iu ),
3301 $ ldwrku )
3302 CALL zlaset(
'U', m-1, m-1, czero, czero,
3303 $ work( iu+ldwrku ), ldwrku )
3304 ie = 1
3305 itauq = itau
3306 itaup = itauq + m
3307 iwork = itaup + m
3308
3309
3310
3311
3312
3313
3314
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 )
3321
3322
3323
3324
3325
3326
3327 CALL zungbr(
'P', m, m, m, work( iu ), ldwrku,
3328 $ work( itaup ), work( iwork ),
3329 $ lwork-iwork+1, ierr )
3330
3331
3332
3333
3334
3335 CALL zungbr(
'Q', m, m, m, work( ir ), ldwrkr,
3336 $ work( itauq ), work( iwork ),
3337 $ lwork-iwork+1, ierr )
3338 irwork = ie + m
3339
3340
3341
3342
3343
3344
3345
3346 CALL zbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
3347 $ work( iu ), ldwrku, work( ir ),
3348 $ ldwrkr, cdum, 1, rwork( irwork ),
3349 $ info )
3350
3351
3352
3353
3354
3355
3356 CALL zgemm(
'N',
'N', m, n, m, cone, work( iu ),
3357 $ ldwrku, vt, ldvt, czero, a, lda )
3358
3359
3360
3361 CALL zlacpy(
'F', m, n, a, lda, vt, ldvt )
3362
3363
3364
3365 CALL zlacpy(
'F', m, m, work( ir ), ldwrkr, a,
3366 $ lda )
3367
3368 ELSE
3369
3370
3371
3372 itau = 1
3373 iwork = itau + m
3374
3375
3376
3377
3378
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 )
3382
3383
3384
3385
3386
3387 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3388 $ work( iwork ), lwork-iwork+1, ierr )
3389 ie = 1
3390 itauq = itau
3391 itaup = itauq + m
3392 iwork = itaup + m
3393
3394
3395
3396 CALL zlaset(
'U', m-1, m-1, czero, czero,
3397 $ a( 1, 2 ), lda )
3398
3399
3400
3401
3402
3403 CALL zgebrd( m, m, a, lda, s, rwork( ie ),
3404 $ work( itauq ), work( itaup ),
3405 $ work( iwork ), lwork-iwork+1, ierr )
3406
3407
3408
3409
3410
3411
3412 CALL zunmbr(
'P',
'L',
'C', m, n, m, a, lda,
3413 $ work( itaup ), vt, ldvt,
3414 $ work( iwork ), lwork-iwork+1, ierr )
3415
3416
3417
3418
3419
3420 CALL zungbr(
'Q', m, m, m, a, lda,
3421 $ work( itauq ),
3422 $ work( iwork ), lwork-iwork+1, ierr )
3423 irwork = ie + m
3424
3425
3426
3427
3428
3429
3430
3431 CALL zbdsqr(
'U', m, n, m, 0, s, rwork( ie ),
3432 $ vt,
3433 $ ldvt, a, lda, cdum, 1,
3434 $ rwork( irwork ), info )
3435
3436 END IF
3437
3438 ELSE IF( wntuas ) THEN
3439
3440
3441
3442
3443
3444
3445 IF( lwork.GE.m*m+max( n+m, 3*m ) ) THEN
3446
3447
3448
3449 iu = 1
3450 IF( lwork.GE.wrkbl+lda*m ) THEN
3451
3452
3453
3454 ldwrku = lda
3455 ELSE
3456
3457
3458
3459 ldwrku = m
3460 END IF
3461 itau = iu + ldwrku*m
3462 iwork = itau + m
3463
3464
3465
3466
3467
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 )
3471
3472
3473
3474
3475
3476 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3477 $ work( iwork ), lwork-iwork+1, ierr )
3478
3479
3480
3481 CALL zlacpy(
'L', m, m, a, lda, work( iu ),
3482 $ ldwrku )
3483 CALL zlaset(
'U', m-1, m-1, czero, czero,
3484 $ work( iu+ldwrku ), ldwrku )
3485 ie = 1
3486 itauq = itau
3487 itaup = itauq + m
3488 iwork = itaup + m
3489
3490
3491
3492
3493
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,
3499 $ ldu )
3500
3501
3502
3503
3504
3505 CALL zungbr(
'P', m, m, m, work( iu ), ldwrku,
3506 $ work( itaup ), work( iwork ),
3507 $ lwork-iwork+1, ierr )
3508
3509
3510
3511
3512
3513 CALL zungbr(
'Q', m, m, m, u, ldu,
3514 $ work( itauq ),
3515 $ work( iwork ), lwork-iwork+1, ierr )
3516 irwork = ie + m
3517
3518
3519
3520
3521
3522
3523
3524 CALL zbdsqr(
'U', m, m, m, 0, s, rwork( ie ),
3525 $ work( iu ), ldwrku, u, ldu, cdum, 1,
3526 $ rwork( irwork ), info )
3527
3528
3529
3530
3531
3532
3533 CALL zgemm(
'N',
'N', m, n, m, cone, work( iu ),
3534 $ ldwrku, vt, ldvt, czero, a, lda )
3535
3536
3537
3538 CALL zlacpy(
'F', m, n, a, lda, vt, ldvt )
3539
3540 ELSE
3541
3542
3543
3544 itau = 1
3545 iwork = itau + m
3546
3547
3548
3549
3550
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 )
3554
3555
3556
3557
3558
3559 CALL zunglq( n, n, m, vt, ldvt, work( itau ),
3560 $ work( iwork ), lwork-iwork+1, ierr )
3561
3562
3563
3564 CALL zlacpy(
'L', m, m, a, lda, u, ldu )
3565 CALL zlaset(
'U', m-1, m-1, czero, czero,
3566 $ u( 1, 2 ), ldu )
3567 ie = 1
3568 itauq = itau
3569 itaup = itauq + m
3570 iwork = itaup + m
3571
3572
3573
3574
3575
3576 CALL zgebrd( m, m, u, ldu, s, rwork( ie ),
3577 $ work( itauq ), work( itaup ),
3578 $ work( iwork ), lwork-iwork+1, ierr )
3579
3580
3581
3582
3583
3584
3585 CALL zunmbr(
'P',
'L',
'C', m, n, m, u, ldu,
3586 $ work( itaup ), vt, ldvt,
3587 $ work( iwork ), lwork-iwork+1, ierr )
3588
3589
3590
3591
3592
3593 CALL zungbr(
'Q', m, m, m, u, ldu,
3594 $ work( itauq ),
3595 $ work( iwork ), lwork-iwork+1, ierr )
3596 irwork = ie + m
3597
3598
3599
3600
3601
3602
3603
3604 CALL zbdsqr(
'U', m, n, m, 0, s, rwork( ie ),
3605 $ vt,
3606 $ ldvt, u, ldu, cdum, 1,
3607 $ rwork( irwork ), info )
3608
3609 END IF
3610
3611 END IF
3612
3613 END IF
3614
3615 ELSE
3616
3617
3618
3619
3620
3621
3622 ie = 1
3623 itauq = 1
3624 itaup = itauq + m
3625 iwork = itaup + m
3626
3627
3628
3629
3630
3631 CALL zgebrd( m, n, a, lda, s, rwork( ie ), work( itauq ),
3632 $ work( itaup ), work( iwork ), lwork-iwork+1,
3633 $ ierr )
3634 IF( wntuas ) THEN
3635
3636
3637
3638
3639
3640
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 )
3644 END IF
3645 IF( wntvas ) THEN
3646
3647
3648
3649
3650
3651
3652 CALL zlacpy(
'U', m, n, a, lda, vt, ldvt )
3653 IF( wntva )
3654 $ nrvt = n
3655 IF( wntvs )
3656 $ nrvt = m
3657 CALL zungbr(
'P', nrvt, n, m, vt, ldvt, work( itaup ),
3658 $ work( iwork ), lwork-iwork+1, ierr )
3659 END IF
3660 IF( wntuo ) THEN
3661
3662
3663
3664
3665
3666
3667 CALL zungbr(
'Q', m, m, n, a, lda, work( itauq ),
3668 $ work( iwork ), lwork-iwork+1, ierr )
3669 END IF
3670 IF( wntvo ) THEN
3671
3672
3673
3674
3675
3676
3677 CALL zungbr(
'P', m, n, m, a, lda, work( itaup ),
3678 $ work( iwork ), lwork-iwork+1, ierr )
3679 END IF
3680 irwork = ie + m
3681 IF( wntuas .OR. wntuo )
3682 $ nru = m
3683 IF( wntun )
3684 $ nru = 0
3685 IF( wntvas .OR. wntvo )
3686 $ ncvt = n
3687 IF( wntvn )
3688 $ ncvt = 0
3689 IF( ( .NOT.wntuo ) .AND. ( .NOT.wntvo ) ) THEN
3690
3691
3692
3693
3694
3695
3696
3697 CALL zbdsqr(
'L', m, ncvt, nru, 0, s, rwork( ie ), vt,
3698 $ ldvt, u, ldu, cdum, 1, rwork( irwork ),
3699 $ info )
3700 ELSE IF( ( .NOT.wntuo ) .AND. wntvo ) THEN
3701
3702
3703
3704
3705
3706
3707
3708 CALL zbdsqr(
'L', m, ncvt, nru, 0, s, rwork( ie ), a,
3709 $ lda, u, ldu, cdum, 1, rwork( irwork ),
3710 $ info )
3711 ELSE
3712
3713
3714
3715
3716
3717
3718
3719 CALL zbdsqr(
'L', m, ncvt, nru, 0, s, rwork( ie ), vt,
3720 $ ldvt, a, lda, cdum, 1, rwork( irwork ),
3721 $ info )
3722 END IF
3723
3724 END IF
3725
3726 END IF
3727
3728
3729
3730 IF( iscl.EQ.1 ) THEN
3731 IF( anrm.GT.bignum )
3732 $
CALL dlascl(
'G', 0, 0, bignum, anrm, minmn, 1, s, minmn,
3733 $ ierr )
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,
3739 $ ierr )
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 )
3743 END IF
3744
3745
3746
3747 work( 1 ) = maxwrk
3748
3749 RETURN
3750
3751
3752
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
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
subroutine zlacpy(uplo, m, n, a, lda, b, ldb)
ZLACPY copies all or part of one two-dimensional array to another.
double precision function dlamch(cmach)
DLAMCH
double precision function zlange(norm, m, n, a, lda, work)
ZLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value ...
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.
logical function lsame(ca, cb)
LSAME
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