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