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