220 CHARACTER jobu, jobvt
221 INTEGER info, lda, ldu, ldvt, lwork, m, n
224 REAL a( lda, * ), s( * ), u( ldu, * ),
225 $ vt( ldvt, * ), work( * )
232 parameter ( zero = 0.0e0, one = 1.0e0 )
235 LOGICAL lquery, wntua, wntuas, wntun, wntuo, wntus,
236 $ wntva, wntvas, wntvn, wntvo, wntvs
237 INTEGER bdspac, blk, chunk, i, ie, ierr, ir, iscl,
238 $ itau, itaup, itauq, iu, iwork, ldwrkr, ldwrku,
239 $ maxwrk, minmn, minwrk, mnthr, ncu, ncvt, nru,
241 INTEGER lwork_sgeqrf, lwork_sorgqr_n, lwork_sorgqr_m,
242 $ lwork_sgebrd, lwork_sorgbr_p, lwork_sorgbr_q,
243 $ lwork_sgelqf, lwork_sorglq_n, lwork_sorglq_m
244 REAL anrm, bignum, eps, smlnum
261 INTRINSIC max, min, sqrt
269 wntua =
lsame( jobu,
'A' )
270 wntus =
lsame( jobu,
'S' )
271 wntuas = wntua .OR. wntus
272 wntuo =
lsame( jobu,
'O' )
273 wntun =
lsame( jobu,
'N' )
274 wntva =
lsame( jobvt,
'A' )
275 wntvs =
lsame( jobvt,
'S' )
276 wntvas = wntva .OR. wntvs
277 wntvo =
lsame( jobvt,
'O' )
278 wntvn =
lsame( jobvt,
'N' )
279 lquery = ( lwork.EQ.-1 )
281 IF( .NOT.( wntua .OR. wntus .OR. wntuo .OR. wntun ) )
THEN
283 ELSE IF( .NOT.( wntva .OR. wntvs .OR. wntvo .OR. wntvn ) .OR.
284 $ ( wntvo .AND. wntuo ) )
THEN
286 ELSE IF( m.LT.0 )
THEN
288 ELSE IF( n.LT.0 )
THEN
290 ELSE IF( lda.LT.max( 1, m ) )
THEN
292 ELSE IF( ldu.LT.1 .OR. ( wntuas .AND. ldu.LT.m ) )
THEN
294 ELSE IF( ldvt.LT.1 .OR. ( wntva .AND. ldvt.LT.n ) .OR.
295 $ ( wntvs .AND. ldvt.LT.minmn ) )
THEN
309 IF( m.GE.n .AND. minmn.GT.0 )
THEN
313 mnthr =
ilaenv( 6,
'SGESVD', jobu // jobvt, m, n, 0, 0 )
316 CALL sgeqrf( m, n, a, lda, dum(1), dum(1), -1, ierr )
317 lwork_sgeqrf = int( dum(1) )
319 CALL sorgqr( m, n, n, a, lda, dum(1), dum(1), -1, ierr )
320 lwork_sorgqr_n = int( dum(1) )
321 CALL sorgqr( m, m, n, a, lda, dum(1), dum(1), -1, ierr )
322 lwork_sorgqr_m = int( dum(1) )
324 CALL sgebrd( n, n, a, lda, s, dum(1), dum(1),
325 $ dum(1), dum(1), -1, ierr )
326 lwork_sgebrd = int( dum(1) )
328 CALL sorgbr(
'P', n, n, n, a, lda, dum(1),
330 lwork_sorgbr_p = int( dum(1) )
332 CALL sorgbr(
'Q', n, n, n, a, lda, dum(1),
334 lwork_sorgbr_q = int( dum(1) )
336 IF( m.GE.mnthr )
THEN
341 maxwrk = n + lwork_sgeqrf
342 maxwrk = max( maxwrk, 3*n+lwork_sgebrd )
343 IF( wntvo .OR. wntvas )
344 $ maxwrk = max( maxwrk, 3*n+lwork_sorgbr_p )
345 maxwrk = max( maxwrk, bdspac )
346 minwrk = max( 4*n, bdspac )
347 ELSE IF( wntuo .AND. wntvn )
THEN
351 wrkbl = n + lwork_sgeqrf
352 wrkbl = max( wrkbl, n+lwork_sorgqr_n )
353 wrkbl = max( wrkbl, 3*n+lwork_sgebrd )
354 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_q )
355 wrkbl = max( wrkbl, bdspac )
356 maxwrk = max( n*n+wrkbl, n*n+m*n+n )
357 minwrk = max( 3*n+m, bdspac )
358 ELSE IF( wntuo .AND. wntvas )
THEN
363 wrkbl = n + lwork_sgeqrf
364 wrkbl = max( wrkbl, n+lwork_sorgqr_n )
365 wrkbl = max( wrkbl, 3*n+lwork_sgebrd )
366 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_q )
367 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_p )
368 wrkbl = max( wrkbl, bdspac )
369 maxwrk = max( n*n+wrkbl, n*n+m*n+n )
370 minwrk = max( 3*n+m, bdspac )
371 ELSE IF( wntus .AND. wntvn )
THEN
375 wrkbl = n + lwork_sgeqrf
376 wrkbl = max( wrkbl, n+lwork_sorgqr_n )
377 wrkbl = max( wrkbl, 3*n+lwork_sgebrd )
378 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_q )
379 wrkbl = max( wrkbl, bdspac )
381 minwrk = max( 3*n+m, bdspac )
382 ELSE IF( wntus .AND. wntvo )
THEN
386 wrkbl = n + lwork_sgeqrf
387 wrkbl = max( wrkbl, n+lwork_sorgqr_n )
388 wrkbl = max( wrkbl, 3*n+lwork_sgebrd )
389 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_q )
390 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_p )
391 wrkbl = max( wrkbl, bdspac )
392 maxwrk = 2*n*n + wrkbl
393 minwrk = max( 3*n+m, bdspac )
394 ELSE IF( wntus .AND. wntvas )
THEN
399 wrkbl = n + lwork_sgeqrf
400 wrkbl = max( wrkbl, n+lwork_sorgqr_n )
401 wrkbl = max( wrkbl, 3*n+lwork_sgebrd )
402 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_q )
403 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_p )
404 wrkbl = max( wrkbl, bdspac )
406 minwrk = max( 3*n+m, bdspac )
407 ELSE IF( wntua .AND. wntvn )
THEN
411 wrkbl = n + lwork_sgeqrf
412 wrkbl = max( wrkbl, n+lwork_sorgqr_m )
413 wrkbl = max( wrkbl, 3*n+lwork_sgebrd )
414 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_q )
415 wrkbl = max( wrkbl, bdspac )
417 minwrk = max( 3*n+m, bdspac )
418 ELSE IF( wntua .AND. wntvo )
THEN
422 wrkbl = n + lwork_sgeqrf
423 wrkbl = max( wrkbl, n+lwork_sorgqr_m )
424 wrkbl = max( wrkbl, 3*n+lwork_sgebrd )
425 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_q )
426 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_p )
427 wrkbl = max( wrkbl, bdspac )
428 maxwrk = 2*n*n + wrkbl
429 minwrk = max( 3*n+m, bdspac )
430 ELSE IF( wntua .AND. wntvas )
THEN
435 wrkbl = n + lwork_sgeqrf
436 wrkbl = max( wrkbl, n+lwork_sorgqr_m )
437 wrkbl = max( wrkbl, 3*n+lwork_sgebrd )
438 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_q )
439 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_p )
440 wrkbl = max( wrkbl, bdspac )
442 minwrk = max( 3*n+m, bdspac )
448 CALL sgebrd( m, n, a, lda, s, dum(1), dum(1),
449 $ dum(1), dum(1), -1, ierr )
450 lwork_sgebrd = int( dum(1) )
451 maxwrk = 3*n + lwork_sgebrd
452 IF( wntus .OR. wntuo )
THEN
453 CALL sorgbr(
'Q', m, n, n, a, lda, dum(1),
455 lwork_sorgbr_q = int( dum(1) )
456 maxwrk = max( maxwrk, 3*n+lwork_sorgbr_q )
459 CALL sorgbr(
'Q', m, m, n, a, lda, dum(1),
461 lwork_sorgbr_q = int( dum(1) )
462 maxwrk = max( maxwrk, 3*n+lwork_sorgbr_q )
464 IF( .NOT.wntvn )
THEN
465 maxwrk = max( maxwrk, 3*n+lwork_sorgbr_p )
467 maxwrk = max( maxwrk, bdspac )
468 minwrk = max( 3*n+m, bdspac )
470 ELSE IF( minmn.GT.0 )
THEN
474 mnthr =
ilaenv( 6,
'SGESVD', jobu // jobvt, m, n, 0, 0 )
477 CALL sgelqf( m, n, a, lda, dum(1), dum(1), -1, ierr )
478 lwork_sgelqf = int( dum(1) )
480 CALL sorglq( n, n, m, dum(1), n, dum(1), dum(1), -1, ierr )
481 lwork_sorglq_n = int( dum(1) )
482 CALL sorglq( m, n, m, a, lda, dum(1), dum(1), -1, ierr )
483 lwork_sorglq_m = int( dum(1) )
485 CALL sgebrd( m, m, a, lda, s, dum(1), dum(1),
486 $ dum(1), dum(1), -1, ierr )
487 lwork_sgebrd = int( dum(1) )
489 CALL sorgbr(
'P', m, m, m, a, n, dum(1),
491 lwork_sorgbr_p = int( dum(1) )
493 CALL sorgbr(
'Q', m, m, m, a, n, dum(1),
495 lwork_sorgbr_q = int( dum(1) )
496 IF( n.GE.mnthr )
THEN
501 maxwrk = m + lwork_sgelqf
502 maxwrk = max( maxwrk, 3*m+lwork_sgebrd )
503 IF( wntuo .OR. wntuas )
504 $ maxwrk = max( maxwrk, 3*m+lwork_sorgbr_q )
505 maxwrk = max( maxwrk, bdspac )
506 minwrk = max( 4*m, bdspac )
507 ELSE IF( wntvo .AND. wntun )
THEN
511 wrkbl = m + lwork_sgelqf
512 wrkbl = max( wrkbl, m+lwork_sorglq_m )
513 wrkbl = max( wrkbl, 3*m+lwork_sgebrd )
514 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_p )
515 wrkbl = max( wrkbl, bdspac )
516 maxwrk = max( m*m+wrkbl, m*m+m*n+m )
517 minwrk = max( 3*m+n, bdspac )
518 ELSE IF( wntvo .AND. wntuas )
THEN
523 wrkbl = m + lwork_sgelqf
524 wrkbl = max( wrkbl, m+lwork_sorglq_m )
525 wrkbl = max( wrkbl, 3*m+lwork_sgebrd )
526 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_p )
527 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_q )
528 wrkbl = max( wrkbl, bdspac )
529 maxwrk = max( m*m+wrkbl, m*m+m*n+m )
530 minwrk = max( 3*m+n, bdspac )
531 ELSE IF( wntvs .AND. wntun )
THEN
535 wrkbl = m + lwork_sgelqf
536 wrkbl = max( wrkbl, m+lwork_sorglq_m )
537 wrkbl = max( wrkbl, 3*m+lwork_sgebrd )
538 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_p )
539 wrkbl = max( wrkbl, bdspac )
541 minwrk = max( 3*m+n, bdspac )
542 ELSE IF( wntvs .AND. wntuo )
THEN
546 wrkbl = m + lwork_sgelqf
547 wrkbl = max( wrkbl, m+lwork_sorglq_m )
548 wrkbl = max( wrkbl, 3*m+lwork_sgebrd )
549 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_p )
550 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_q )
551 wrkbl = max( wrkbl, bdspac )
552 maxwrk = 2*m*m + wrkbl
553 minwrk = max( 3*m+n, bdspac )
554 maxwrk = max( maxwrk, minwrk )
555 ELSE IF( wntvs .AND. wntuas )
THEN
560 wrkbl = m + lwork_sgelqf
561 wrkbl = max( wrkbl, m+lwork_sorglq_m )
562 wrkbl = max( wrkbl, 3*m+lwork_sgebrd )
563 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_p )
564 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_q )
565 wrkbl = max( wrkbl, bdspac )
567 minwrk = max( 3*m+n, bdspac )
568 ELSE IF( wntva .AND. wntun )
THEN
572 wrkbl = m + lwork_sgelqf
573 wrkbl = max( wrkbl, m+lwork_sorglq_n )
574 wrkbl = max( wrkbl, 3*m+lwork_sgebrd )
575 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_p )
576 wrkbl = max( wrkbl, bdspac )
578 minwrk = max( 3*m+n, bdspac )
579 ELSE IF( wntva .AND. wntuo )
THEN
583 wrkbl = m + lwork_sgelqf
584 wrkbl = max( wrkbl, m+lwork_sorglq_n )
585 wrkbl = max( wrkbl, 3*m+lwork_sgebrd )
586 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_p )
587 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_q )
588 wrkbl = max( wrkbl, bdspac )
589 maxwrk = 2*m*m + wrkbl
590 minwrk = max( 3*m+n, bdspac )
591 ELSE IF( wntva .AND. wntuas )
THEN
596 wrkbl = m + lwork_sgelqf
597 wrkbl = max( wrkbl, m+lwork_sorglq_n )
598 wrkbl = max( wrkbl, 3*m+lwork_sgebrd )
599 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_p )
600 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_q )
601 wrkbl = max( wrkbl, bdspac )
603 minwrk = max( 3*m+n, bdspac )
609 CALL sgebrd( m, n, a, lda, s, dum(1), dum(1),
610 $ dum(1), dum(1), -1, ierr )
611 lwork_sgebrd = int( dum(1) )
612 maxwrk = 3*m + lwork_sgebrd
613 IF( wntvs .OR. wntvo )
THEN
615 CALL sorgbr(
'P', m, n, m, a, n, dum(1),
617 lwork_sorgbr_p = int( dum(1) )
618 maxwrk = max( maxwrk, 3*m+lwork_sorgbr_p )
621 CALL sorgbr(
'P', n, n, m, a, n, dum(1),
623 lwork_sorgbr_p = int( dum(1) )
624 maxwrk = max( maxwrk, 3*m+lwork_sorgbr_p )
626 IF( .NOT.wntun )
THEN
627 maxwrk = max( maxwrk, 3*m+lwork_sorgbr_q )
629 maxwrk = max( maxwrk, bdspac )
630 minwrk = max( 3*m+n, bdspac )
633 maxwrk = max( maxwrk, minwrk )
636 IF( lwork.LT.minwrk .AND. .NOT.lquery )
THEN
642 CALL xerbla(
'SGESVD', -info )
644 ELSE IF( lquery )
THEN
650 IF( m.EQ.0 .OR. n.EQ.0 )
THEN
657 smlnum = sqrt(
slamch(
'S' ) ) / eps
658 bignum = one / smlnum
662 anrm =
slange(
'M', m, n, a, lda, dum )
664 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
666 CALL slascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, ierr )
667 ELSE IF( anrm.GT.bignum )
THEN
669 CALL slascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, ierr )
678 IF( m.GE.mnthr )
THEN
691 CALL sgeqrf( m, n, a, lda, work( itau ), work( iwork ),
692 $ lwork-iwork+1, ierr )
697 CALL slaset(
'L', n-1, n-1, zero, zero, a( 2, 1 ),
708 CALL sgebrd( n, n, a, lda, s, work( ie ), work( itauq ),
709 $ work( itaup ), work( iwork ), lwork-iwork+1,
712 IF( wntvo .OR. wntvas )
THEN
717 CALL sorgbr(
'P', n, n, n, a, lda, work( itaup ),
718 $ work( iwork ), lwork-iwork+1, ierr )
727 CALL sbdsqr(
'U', n, ncvt, 0, 0, s, work( ie ), a, lda,
728 $ dum, 1, dum, 1, work( iwork ), info )
733 $
CALL slacpy(
'F', n, n, a, lda, vt, ldvt )
735 ELSE IF( wntuo .AND. wntvn )
THEN
741 IF( lwork.GE.n*n+max( 4*n, bdspac ) )
THEN
746 IF( lwork.GE.max( wrkbl, lda*n+n )+lda*n )
THEN
752 ELSE IF( lwork.GE.max( wrkbl, lda*n+n )+n*n )
THEN
762 ldwrku = ( lwork-n*n-n ) / n
771 CALL sgeqrf( m, n, a, lda, work( itau ),
772 $ work( iwork ), lwork-iwork+1, ierr )
776 CALL slacpy(
'U', n, n, a, lda, work( ir ), ldwrkr )
777 CALL slaset(
'L', n-1, n-1, zero, zero, work( ir+1 ),
783 CALL sorgqr( m, n, n, a, lda, work( itau ),
784 $ work( iwork ), lwork-iwork+1, ierr )
793 CALL sgebrd( n, n, work( ir ), ldwrkr, s, work( ie ),
794 $ work( itauq ), work( itaup ),
795 $ work( iwork ), lwork-iwork+1, ierr )
800 CALL sorgbr(
'Q', n, n, n, work( ir ), ldwrkr,
801 $ work( itauq ), work( iwork ),
802 $ lwork-iwork+1, ierr )
809 CALL sbdsqr(
'U', n, 0, n, 0, s, work( ie ), dum, 1,
810 $ work( ir ), ldwrkr, dum, 1,
811 $ work( iwork ), info )
818 DO 10 i = 1, m, ldwrku
819 chunk = min( m-i+1, ldwrku )
820 CALL sgemm(
'N',
'N', chunk, n, n, one, a( i, 1 ),
821 $ lda, work( ir ), ldwrkr, zero,
822 $ work( iu ), ldwrku )
823 CALL slacpy(
'F', chunk, n, work( iu ), ldwrku,
839 CALL sgebrd( m, n, a, lda, s, work( ie ),
840 $ work( itauq ), work( itaup ),
841 $ work( iwork ), lwork-iwork+1, ierr )
846 CALL sorgbr(
'Q', m, n, n, a, lda, work( itauq ),
847 $ work( iwork ), lwork-iwork+1, ierr )
854 CALL sbdsqr(
'U', n, 0, m, 0, s, work( ie ), dum, 1,
855 $ a, lda, dum, 1, work( iwork ), info )
859 ELSE IF( wntuo .AND. wntvas )
THEN
865 IF( lwork.GE.n*n+max( 4*n, bdspac ) )
THEN
870 IF( lwork.GE.max( wrkbl, lda*n+n )+lda*n )
THEN
876 ELSE IF( lwork.GE.max( wrkbl, lda*n+n )+n*n )
THEN
886 ldwrku = ( lwork-n*n-n ) / n
895 CALL sgeqrf( m, n, a, lda, work( itau ),
896 $ work( iwork ), lwork-iwork+1, ierr )
900 CALL slacpy(
'U', n, n, a, lda, vt, ldvt )
902 $
CALL slaset(
'L', n-1, n-1, zero, zero,
908 CALL sorgqr( m, n, n, a, lda, work( itau ),
909 $ work( iwork ), lwork-iwork+1, ierr )
918 CALL sgebrd( n, n, vt, ldvt, s, work( ie ),
919 $ work( itauq ), work( itaup ),
920 $ work( iwork ), lwork-iwork+1, ierr )
921 CALL slacpy(
'L', n, n, vt, ldvt, work( ir ), ldwrkr )
926 CALL sorgbr(
'Q', n, n, n, work( ir ), ldwrkr,
927 $ work( itauq ), work( iwork ),
928 $ lwork-iwork+1, ierr )
933 CALL sorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
934 $ work( iwork ), lwork-iwork+1, ierr )
942 CALL sbdsqr(
'U', n, n, n, 0, s, work( ie ), vt, ldvt,
943 $ work( ir ), ldwrkr, dum, 1,
944 $ work( iwork ), info )
951 DO 20 i = 1, m, ldwrku
952 chunk = min( m-i+1, ldwrku )
953 CALL sgemm(
'N',
'N', chunk, n, n, one, a( i, 1 ),
954 $ lda, work( ir ), ldwrkr, zero,
955 $ work( iu ), ldwrku )
956 CALL slacpy(
'F', chunk, n, work( iu ), ldwrku,
970 CALL sgeqrf( m, n, a, lda, work( itau ),
971 $ work( iwork ), lwork-iwork+1, ierr )
975 CALL slacpy(
'U', n, n, a, lda, vt, ldvt )
977 $
CALL slaset(
'L', n-1, n-1, zero, zero,
983 CALL sorgqr( m, n, n, a, lda, work( itau ),
984 $ work( iwork ), lwork-iwork+1, ierr )
993 CALL sgebrd( n, n, vt, ldvt, s, work( ie ),
994 $ work( itauq ), work( itaup ),
995 $ work( iwork ), lwork-iwork+1, ierr )
1000 CALL sormbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1001 $ work( itauq ), a, lda, work( iwork ),
1002 $ lwork-iwork+1, ierr )
1007 CALL sorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1008 $ work( iwork ), lwork-iwork+1, ierr )
1016 CALL sbdsqr(
'U', n, n, m, 0, s, work( ie ), vt, ldvt,
1017 $ a, lda, dum, 1, work( iwork ), info )
1021 ELSE IF( wntus )
THEN
1029 IF( lwork.GE.n*n+max( 4*n, bdspac ) )
THEN
1034 IF( lwork.GE.wrkbl+lda*n )
THEN
1045 itau = ir + ldwrkr*n
1051 CALL sgeqrf( m, n, a, lda, work( itau ),
1052 $ work( iwork ), lwork-iwork+1, ierr )
1056 CALL slacpy(
'U', n, n, a, lda, work( ir ),
1058 CALL slaset(
'L', n-1, n-1, zero, zero,
1059 $ work( ir+1 ), ldwrkr )
1064 CALL sorgqr( m, n, n, a, lda, work( itau ),
1065 $ work( iwork ), lwork-iwork+1, ierr )
1074 CALL sgebrd( n, n, work( ir ), ldwrkr, s,
1075 $ work( ie ), work( itauq ),
1076 $ work( itaup ), work( iwork ),
1077 $ lwork-iwork+1, ierr )
1082 CALL sorgbr(
'Q', n, n, n, work( ir ), ldwrkr,
1083 $ work( itauq ), work( iwork ),
1084 $ lwork-iwork+1, ierr )
1091 CALL sbdsqr(
'U', n, 0, n, 0, s, work( ie ), dum,
1092 $ 1, work( ir ), ldwrkr, dum, 1,
1093 $ work( iwork ), info )
1099 CALL sgemm(
'N',
'N', m, n, n, one, a, lda,
1100 $ work( ir ), ldwrkr, zero, u, ldu )
1112 CALL sgeqrf( m, n, a, lda, work( itau ),
1113 $ work( iwork ), lwork-iwork+1, ierr )
1114 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1119 CALL sorgqr( m, n, n, u, ldu, work( itau ),
1120 $ work( iwork ), lwork-iwork+1, ierr )
1129 CALL slaset(
'L', n-1, n-1, zero, zero,
1136 CALL sgebrd( n, n, a, lda, s, work( ie ),
1137 $ work( itauq ), work( itaup ),
1138 $ work( iwork ), lwork-iwork+1, ierr )
1143 CALL sormbr(
'Q',
'R',
'N', m, n, n, a, lda,
1144 $ work( itauq ), u, ldu, work( iwork ),
1145 $ lwork-iwork+1, ierr )
1152 CALL sbdsqr(
'U', n, 0, m, 0, s, work( ie ), dum,
1153 $ 1, u, ldu, dum, 1, work( iwork ),
1158 ELSE IF( wntvo )
THEN
1164 IF( lwork.GE.2*n*n+max( 4*n, bdspac ) )
THEN
1169 IF( lwork.GE.wrkbl+2*lda*n )
THEN
1176 ELSE IF( lwork.GE.wrkbl+( lda+n )*n )
THEN
1191 itau = ir + ldwrkr*n
1197 CALL sgeqrf( m, n, a, lda, work( itau ),
1198 $ work( iwork ), lwork-iwork+1, ierr )
1202 CALL slacpy(
'U', n, n, a, lda, work( iu ),
1204 CALL slaset(
'L', n-1, n-1, zero, zero,
1205 $ work( iu+1 ), ldwrku )
1210 CALL sorgqr( m, n, n, a, lda, work( itau ),
1211 $ work( iwork ), lwork-iwork+1, ierr )
1222 CALL sgebrd( n, n, work( iu ), ldwrku, s,
1223 $ work( ie ), work( itauq ),
1224 $ work( itaup ), work( iwork ),
1225 $ lwork-iwork+1, ierr )
1226 CALL slacpy(
'U', n, n, work( iu ), ldwrku,
1227 $ work( ir ), ldwrkr )
1232 CALL sorgbr(
'Q', n, n, n, work( iu ), ldwrku,
1233 $ work( itauq ), work( iwork ),
1234 $ lwork-iwork+1, ierr )
1240 CALL sorgbr(
'P', n, n, n, work( ir ), ldwrkr,
1241 $ work( itaup ), work( iwork ),
1242 $ lwork-iwork+1, ierr )
1250 CALL sbdsqr(
'U', n, n, n, 0, s, work( ie ),
1251 $ work( ir ), ldwrkr, work( iu ),
1252 $ ldwrku, dum, 1, work( iwork ), info )
1258 CALL sgemm(
'N',
'N', m, n, n, one, a, lda,
1259 $ work( iu ), ldwrku, zero, u, ldu )
1264 CALL slacpy(
'F', n, n, work( ir ), ldwrkr, a,
1277 CALL sgeqrf( m, n, a, lda, work( itau ),
1278 $ work( iwork ), lwork-iwork+1, ierr )
1279 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1284 CALL sorgqr( m, n, n, u, ldu, work( itau ),
1285 $ work( iwork ), lwork-iwork+1, ierr )
1294 CALL slaset(
'L', n-1, n-1, zero, zero,
1301 CALL sgebrd( n, n, a, lda, s, work( ie ),
1302 $ work( itauq ), work( itaup ),
1303 $ work( iwork ), lwork-iwork+1, ierr )
1308 CALL sormbr(
'Q',
'R',
'N', m, n, n, a, lda,
1309 $ work( itauq ), u, ldu, work( iwork ),
1310 $ lwork-iwork+1, ierr )
1315 CALL sorgbr(
'P', n, n, n, a, lda, work( itaup ),
1316 $ work( iwork ), lwork-iwork+1, ierr )
1324 CALL sbdsqr(
'U', n, n, m, 0, s, work( ie ), a,
1325 $ lda, u, ldu, dum, 1, work( iwork ),
1330 ELSE IF( wntvas )
THEN
1337 IF( lwork.GE.n*n+max( 4*n, bdspac ) )
THEN
1342 IF( lwork.GE.wrkbl+lda*n )
THEN
1353 itau = iu + ldwrku*n
1359 CALL sgeqrf( m, n, a, lda, work( itau ),
1360 $ work( iwork ), lwork-iwork+1, ierr )
1364 CALL slacpy(
'U', n, n, a, lda, work( iu ),
1366 CALL slaset(
'L', n-1, n-1, zero, zero,
1367 $ work( iu+1 ), ldwrku )
1372 CALL sorgqr( m, n, n, a, lda, work( itau ),
1373 $ work( iwork ), lwork-iwork+1, ierr )
1382 CALL sgebrd( n, n, work( iu ), ldwrku, s,
1383 $ work( ie ), work( itauq ),
1384 $ work( itaup ), work( iwork ),
1385 $ lwork-iwork+1, ierr )
1386 CALL slacpy(
'U', n, n, work( iu ), ldwrku, vt,
1392 CALL sorgbr(
'Q', n, n, n, work( iu ), ldwrku,
1393 $ work( itauq ), work( iwork ),
1394 $ lwork-iwork+1, ierr )
1400 CALL sorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1401 $ work( iwork ), lwork-iwork+1, ierr )
1409 CALL sbdsqr(
'U', n, n, n, 0, s, work( ie ), vt,
1410 $ ldvt, work( iu ), ldwrku, dum, 1,
1411 $ work( iwork ), info )
1417 CALL sgemm(
'N',
'N', m, n, n, one, a, lda,
1418 $ work( iu ), ldwrku, zero, u, ldu )
1430 CALL sgeqrf( m, n, a, lda, work( itau ),
1431 $ work( iwork ), lwork-iwork+1, ierr )
1432 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1437 CALL sorgqr( m, n, n, u, ldu, work( itau ),
1438 $ work( iwork ), lwork-iwork+1, ierr )
1442 CALL slacpy(
'U', n, n, a, lda, vt, ldvt )
1444 $
CALL slaset(
'L', n-1, n-1, zero, zero,
1445 $ vt( 2, 1 ), ldvt )
1454 CALL sgebrd( n, n, vt, ldvt, s, work( ie ),
1455 $ work( itauq ), work( itaup ),
1456 $ work( iwork ), lwork-iwork+1, ierr )
1462 CALL sormbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1463 $ work( itauq ), u, ldu, work( iwork ),
1464 $ lwork-iwork+1, ierr )
1469 CALL sorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1470 $ work( iwork ), lwork-iwork+1, ierr )
1478 CALL sbdsqr(
'U', n, n, m, 0, s, work( ie ), vt,
1479 $ ldvt, u, ldu, dum, 1, work( iwork ),
1486 ELSE IF( wntua )
THEN
1494 IF( lwork.GE.n*n+max( n+m, 4*n, bdspac ) )
THEN
1499 IF( lwork.GE.wrkbl+lda*n )
THEN
1510 itau = ir + ldwrkr*n
1516 CALL sgeqrf( m, n, a, lda, work( itau ),
1517 $ work( iwork ), lwork-iwork+1, ierr )
1518 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1522 CALL slacpy(
'U', n, n, a, lda, work( ir ),
1524 CALL slaset(
'L', n-1, n-1, zero, zero,
1525 $ work( ir+1 ), ldwrkr )
1530 CALL sorgqr( m, m, n, u, ldu, work( itau ),
1531 $ work( iwork ), lwork-iwork+1, ierr )
1540 CALL sgebrd( n, n, work( ir ), ldwrkr, s,
1541 $ work( ie ), work( itauq ),
1542 $ work( itaup ), work( iwork ),
1543 $ lwork-iwork+1, ierr )
1548 CALL sorgbr(
'Q', n, n, n, work( ir ), ldwrkr,
1549 $ work( itauq ), work( iwork ),
1550 $ lwork-iwork+1, ierr )
1557 CALL sbdsqr(
'U', n, 0, n, 0, s, work( ie ), dum,
1558 $ 1, work( ir ), ldwrkr, dum, 1,
1559 $ work( iwork ), info )
1565 CALL sgemm(
'N',
'N', m, n, n, one, u, ldu,
1566 $ work( ir ), ldwrkr, zero, a, lda )
1570 CALL slacpy(
'F', m, n, a, lda, u, ldu )
1582 CALL sgeqrf( m, n, a, lda, work( itau ),
1583 $ work( iwork ), lwork-iwork+1, ierr )
1584 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1589 CALL sorgqr( m, m, n, u, ldu, work( itau ),
1590 $ work( iwork ), lwork-iwork+1, ierr )
1599 CALL slaset(
'L', n-1, n-1, zero, zero,
1606 CALL sgebrd( n, n, a, lda, s, work( ie ),
1607 $ work( itauq ), work( itaup ),
1608 $ work( iwork ), lwork-iwork+1, ierr )
1614 CALL sormbr(
'Q',
'R',
'N', m, n, n, a, lda,
1615 $ work( itauq ), u, ldu, work( iwork ),
1616 $ lwork-iwork+1, ierr )
1623 CALL sbdsqr(
'U', n, 0, m, 0, s, work( ie ), dum,
1624 $ 1, u, ldu, dum, 1, work( iwork ),
1629 ELSE IF( wntvo )
THEN
1635 IF( lwork.GE.2*n*n+max( n+m, 4*n, bdspac ) )
THEN
1640 IF( lwork.GE.wrkbl+2*lda*n )
THEN
1647 ELSE IF( lwork.GE.wrkbl+( lda+n )*n )
THEN
1662 itau = ir + ldwrkr*n
1668 CALL sgeqrf( m, n, a, lda, work( itau ),
1669 $ work( iwork ), lwork-iwork+1, ierr )
1670 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1675 CALL sorgqr( m, m, n, u, ldu, work( itau ),
1676 $ work( iwork ), lwork-iwork+1, ierr )
1680 CALL slacpy(
'U', n, n, a, lda, work( iu ),
1682 CALL slaset(
'L', n-1, n-1, zero, zero,
1683 $ work( iu+1 ), ldwrku )
1694 CALL sgebrd( n, n, work( iu ), ldwrku, s,
1695 $ work( ie ), work( itauq ),
1696 $ work( itaup ), work( iwork ),
1697 $ lwork-iwork+1, ierr )
1698 CALL slacpy(
'U', n, n, work( iu ), ldwrku,
1699 $ work( ir ), ldwrkr )
1704 CALL sorgbr(
'Q', n, n, n, work( iu ), ldwrku,
1705 $ work( itauq ), work( iwork ),
1706 $ lwork-iwork+1, ierr )
1712 CALL sorgbr(
'P', n, n, n, work( ir ), ldwrkr,
1713 $ work( itaup ), work( iwork ),
1714 $ lwork-iwork+1, ierr )
1722 CALL sbdsqr(
'U', n, n, n, 0, s, work( ie ),
1723 $ work( ir ), ldwrkr, work( iu ),
1724 $ ldwrku, dum, 1, work( iwork ), info )
1730 CALL sgemm(
'N',
'N', m, n, n, one, u, ldu,
1731 $ work( iu ), ldwrku, zero, a, lda )
1735 CALL slacpy(
'F', m, n, a, lda, u, ldu )
1739 CALL slacpy(
'F', n, n, work( ir ), ldwrkr, a,
1752 CALL sgeqrf( m, n, a, lda, work( itau ),
1753 $ work( iwork ), lwork-iwork+1, ierr )
1754 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1759 CALL sorgqr( m, m, n, u, ldu, work( itau ),
1760 $ work( iwork ), lwork-iwork+1, ierr )
1769 CALL slaset(
'L', n-1, n-1, zero, zero,
1776 CALL sgebrd( n, n, a, lda, s, work( ie ),
1777 $ work( itauq ), work( itaup ),
1778 $ work( iwork ), lwork-iwork+1, ierr )
1784 CALL sormbr(
'Q',
'R',
'N', m, n, n, a, lda,
1785 $ work( itauq ), u, ldu, work( iwork ),
1786 $ lwork-iwork+1, ierr )
1791 CALL sorgbr(
'P', n, n, n, a, lda, work( itaup ),
1792 $ work( iwork ), lwork-iwork+1, ierr )
1800 CALL sbdsqr(
'U', n, n, m, 0, s, work( ie ), a,
1801 $ lda, u, ldu, dum, 1, work( iwork ),
1806 ELSE IF( wntvas )
THEN
1813 IF( lwork.GE.n*n+max( n+m, 4*n, bdspac ) )
THEN
1818 IF( lwork.GE.wrkbl+lda*n )
THEN
1829 itau = iu + ldwrku*n
1835 CALL sgeqrf( m, n, a, lda, work( itau ),
1836 $ work( iwork ), lwork-iwork+1, ierr )
1837 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1842 CALL sorgqr( m, m, n, u, ldu, work( itau ),
1843 $ work( iwork ), lwork-iwork+1, ierr )
1847 CALL slacpy(
'U', n, n, a, lda, work( iu ),
1849 CALL slaset(
'L', n-1, n-1, zero, zero,
1850 $ work( iu+1 ), ldwrku )
1859 CALL sgebrd( n, n, work( iu ), ldwrku, s,
1860 $ work( ie ), work( itauq ),
1861 $ work( itaup ), work( iwork ),
1862 $ lwork-iwork+1, ierr )
1863 CALL slacpy(
'U', n, n, work( iu ), ldwrku, vt,
1869 CALL sorgbr(
'Q', n, n, n, work( iu ), ldwrku,
1870 $ work( itauq ), work( iwork ),
1871 $ lwork-iwork+1, ierr )
1877 CALL sorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1878 $ work( iwork ), lwork-iwork+1, ierr )
1886 CALL sbdsqr(
'U', n, n, n, 0, s, work( ie ), vt,
1887 $ ldvt, work( iu ), ldwrku, dum, 1,
1888 $ work( iwork ), info )
1894 CALL sgemm(
'N',
'N', m, n, n, one, u, ldu,
1895 $ work( iu ), ldwrku, zero, a, lda )
1899 CALL slacpy(
'F', m, n, a, lda, u, ldu )
1911 CALL sgeqrf( m, n, a, lda, work( itau ),
1912 $ work( iwork ), lwork-iwork+1, ierr )
1913 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1918 CALL sorgqr( m, m, n, u, ldu, work( itau ),
1919 $ work( iwork ), lwork-iwork+1, ierr )
1923 CALL slacpy(
'U', n, n, a, lda, vt, ldvt )
1925 $
CALL slaset(
'L', n-1, n-1, zero, zero,
1926 $ vt( 2, 1 ), ldvt )
1935 CALL sgebrd( n, n, vt, ldvt, s, work( ie ),
1936 $ work( itauq ), work( itaup ),
1937 $ work( iwork ), lwork-iwork+1, ierr )
1943 CALL sormbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1944 $ work( itauq ), u, ldu, work( iwork ),
1945 $ lwork-iwork+1, ierr )
1950 CALL sorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1951 $ work( iwork ), lwork-iwork+1, ierr )
1959 CALL sbdsqr(
'U', n, n, m, 0, s, work( ie ), vt,
1960 $ ldvt, u, ldu, dum, 1, work( iwork ),
1984 CALL sgebrd( m, n, a, lda, s, work( ie ), work( itauq ),
1985 $ work( itaup ), work( iwork ), lwork-iwork+1,
1993 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1998 CALL sorgbr(
'Q', m, ncu, n, u, ldu, work( itauq ),
1999 $ work( iwork ), lwork-iwork+1, ierr )
2007 CALL slacpy(
'U', n, n, a, lda, vt, ldvt )
2008 CALL sorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
2009 $ work( iwork ), lwork-iwork+1, ierr )
2017 CALL sorgbr(
'Q', m, n, n, a, lda, work( itauq ),
2018 $ work( iwork ), lwork-iwork+1, ierr )
2026 CALL sorgbr(
'P', n, n, n, a, lda, work( itaup ),
2027 $ work( iwork ), lwork-iwork+1, ierr )
2030 IF( wntuas .OR. wntuo )
2034 IF( wntvas .OR. wntvo )
2038 IF( ( .NOT.wntuo ) .AND. ( .NOT.wntvo ) )
THEN
2045 CALL sbdsqr(
'U', n, ncvt, nru, 0, s, work( ie ), vt,
2046 $ ldvt, u, ldu, dum, 1, work( iwork ), info )
2047 ELSE IF( ( .NOT.wntuo ) .AND. wntvo )
THEN
2054 CALL sbdsqr(
'U', n, ncvt, nru, 0, s, work( ie ), a, lda,
2055 $ u, ldu, dum, 1, work( iwork ), info )
2063 CALL sbdsqr(
'U', n, ncvt, nru, 0, s, work( ie ), vt,
2064 $ ldvt, a, lda, dum, 1, work( iwork ), info )
2075 IF( n.GE.mnthr )
THEN
2088 CALL sgelqf( m, n, a, lda, work( itau ), work( iwork ),
2089 $ lwork-iwork+1, ierr )
2093 CALL slaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ), lda )
2102 CALL sgebrd( m, m, a, lda, s, work( ie ), work( itauq ),
2103 $ work( itaup ), work( iwork ), lwork-iwork+1,
2105 IF( wntuo .OR. wntuas )
THEN
2110 CALL sorgbr(
'Q', m, m, m, a, lda, work( itauq ),
2111 $ work( iwork ), lwork-iwork+1, ierr )
2115 IF( wntuo .OR. wntuas )
2122 CALL sbdsqr(
'U', m, 0, nru, 0, s, work( ie ), dum, 1, a,
2123 $ lda, dum, 1, work( iwork ), info )
2128 $
CALL slacpy(
'F', m, m, a, lda, u, ldu )
2130 ELSE IF( wntvo .AND. wntun )
THEN
2136 IF( lwork.GE.m*m+max( 4*m, bdspac ) )
THEN
2141 IF( lwork.GE.max( wrkbl, lda*n+m )+lda*m )
THEN
2148 ELSE IF( lwork.GE.max( wrkbl, lda*n+m )+m*m )
THEN
2160 chunk = ( lwork-m*m-m ) / m
2163 itau = ir + ldwrkr*m
2169 CALL sgelqf( m, n, a, lda, work( itau ),
2170 $ work( iwork ), lwork-iwork+1, ierr )
2174 CALL slacpy(
'L', m, m, a, lda, work( ir ), ldwrkr )
2175 CALL slaset(
'U', m-1, m-1, zero, zero,
2176 $ work( ir+ldwrkr ), ldwrkr )
2181 CALL sorglq( m, n, m, a, lda, work( itau ),
2182 $ work( iwork ), lwork-iwork+1, ierr )
2191 CALL sgebrd( m, m, work( ir ), ldwrkr, s, work( ie ),
2192 $ work( itauq ), work( itaup ),
2193 $ work( iwork ), lwork-iwork+1, ierr )
2198 CALL sorgbr(
'P', m, m, m, work( ir ), ldwrkr,
2199 $ work( itaup ), work( iwork ),
2200 $ lwork-iwork+1, ierr )
2207 CALL sbdsqr(
'U', m, m, 0, 0, s, work( ie ),
2208 $ work( ir ), ldwrkr, dum, 1, dum, 1,
2209 $ work( iwork ), info )
2216 DO 30 i = 1, n, chunk
2217 blk = min( n-i+1, chunk )
2218 CALL sgemm(
'N',
'N', m, blk, m, one, work( ir ),
2219 $ ldwrkr, a( 1, i ), lda, zero,
2220 $ work( iu ), ldwrku )
2221 CALL slacpy(
'F', m, blk, work( iu ), ldwrku,
2237 CALL sgebrd( m, n, a, lda, s, work( ie ),
2238 $ work( itauq ), work( itaup ),
2239 $ work( iwork ), lwork-iwork+1, ierr )
2244 CALL sorgbr(
'P', m, n, m, a, lda, work( itaup ),
2245 $ work( iwork ), lwork-iwork+1, ierr )
2252 CALL sbdsqr(
'L', m, n, 0, 0, s, work( ie ), a, lda,
2253 $ dum, 1, dum, 1, work( iwork ), info )
2257 ELSE IF( wntvo .AND. wntuas )
THEN
2263 IF( lwork.GE.m*m+max( 4*m, bdspac ) )
THEN
2268 IF( lwork.GE.max( wrkbl, lda*n+m )+lda*m )
THEN
2275 ELSE IF( lwork.GE.max( wrkbl, lda*n+m )+m*m )
THEN
2287 chunk = ( lwork-m*m-m ) / m
2290 itau = ir + ldwrkr*m
2296 CALL sgelqf( m, n, a, lda, work( itau ),
2297 $ work( iwork ), lwork-iwork+1, ierr )
2301 CALL slacpy(
'L', m, m, a, lda, u, ldu )
2302 CALL slaset(
'U', m-1, m-1, zero, zero, u( 1, 2 ),
2308 CALL sorglq( m, n, m, a, lda, work( itau ),
2309 $ work( iwork ), lwork-iwork+1, ierr )
2318 CALL sgebrd( m, m, u, ldu, s, work( ie ),
2319 $ work( itauq ), work( itaup ),
2320 $ work( iwork ), lwork-iwork+1, ierr )
2321 CALL slacpy(
'U', m, m, u, ldu, work( ir ), ldwrkr )
2326 CALL sorgbr(
'P', m, m, m, work( ir ), ldwrkr,
2327 $ work( itaup ), work( iwork ),
2328 $ lwork-iwork+1, ierr )
2333 CALL sorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
2334 $ work( iwork ), lwork-iwork+1, ierr )
2342 CALL sbdsqr(
'U', m, m, m, 0, s, work( ie ),
2343 $ work( ir ), ldwrkr, u, ldu, dum, 1,
2344 $ work( iwork ), info )
2351 DO 40 i = 1, n, chunk
2352 blk = min( n-i+1, chunk )
2353 CALL sgemm(
'N',
'N', m, blk, m, one, work( ir ),
2354 $ ldwrkr, a( 1, i ), lda, zero,
2355 $ work( iu ), ldwrku )
2356 CALL slacpy(
'F', m, blk, work( iu ), ldwrku,
2370 CALL sgelqf( m, n, a, lda, work( itau ),
2371 $ work( iwork ), lwork-iwork+1, ierr )
2375 CALL slacpy(
'L', m, m, a, lda, u, ldu )
2376 CALL slaset(
'U', m-1, m-1, zero, zero, u( 1, 2 ),
2382 CALL sorglq( m, n, m, a, lda, work( itau ),
2383 $ work( iwork ), lwork-iwork+1, ierr )
2392 CALL sgebrd( m, m, u, ldu, s, work( ie ),
2393 $ work( itauq ), work( itaup ),
2394 $ work( iwork ), lwork-iwork+1, ierr )
2399 CALL sormbr(
'P',
'L',
'T', m, n, m, u, ldu,
2400 $ work( itaup ), a, lda, work( iwork ),
2401 $ lwork-iwork+1, ierr )
2406 CALL sorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
2407 $ work( iwork ), lwork-iwork+1, ierr )
2415 CALL sbdsqr(
'U', m, n, m, 0, s, work( ie ), a, lda,
2416 $ u, ldu, dum, 1, work( iwork ), info )
2420 ELSE IF( wntvs )
THEN
2428 IF( lwork.GE.m*m+max( 4*m, bdspac ) )
THEN
2433 IF( lwork.GE.wrkbl+lda*m )
THEN
2444 itau = ir + ldwrkr*m
2450 CALL sgelqf( m, n, a, lda, work( itau ),
2451 $ work( iwork ), lwork-iwork+1, ierr )
2455 CALL slacpy(
'L', m, m, a, lda, work( ir ),
2457 CALL slaset(
'U', m-1, m-1, zero, zero,
2458 $ work( ir+ldwrkr ), ldwrkr )
2463 CALL sorglq( m, n, m, a, lda, work( itau ),
2464 $ work( iwork ), lwork-iwork+1, ierr )
2473 CALL sgebrd( m, m, work( ir ), ldwrkr, s,
2474 $ work( ie ), work( itauq ),
2475 $ work( itaup ), work( iwork ),
2476 $ lwork-iwork+1, ierr )
2482 CALL sorgbr(
'P', m, m, m, work( ir ), ldwrkr,
2483 $ work( itaup ), work( iwork ),
2484 $ lwork-iwork+1, ierr )
2491 CALL sbdsqr(
'U', m, m, 0, 0, s, work( ie ),
2492 $ work( ir ), ldwrkr, dum, 1, dum, 1,
2493 $ work( iwork ), info )
2499 CALL sgemm(
'N',
'N', m, n, m, one, work( ir ),
2500 $ ldwrkr, a, lda, zero, vt, ldvt )
2512 CALL sgelqf( m, n, a, lda, work( itau ),
2513 $ work( iwork ), lwork-iwork+1, ierr )
2517 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
2522 CALL sorglq( m, n, m, vt, ldvt, work( itau ),
2523 $ work( iwork ), lwork-iwork+1, ierr )
2531 CALL slaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ),
2537 CALL sgebrd( m, m, a, lda, s, work( ie ),
2538 $ work( itauq ), work( itaup ),
2539 $ work( iwork ), lwork-iwork+1, ierr )
2544 CALL sormbr(
'P',
'L',
'T', m, n, m, a, lda,
2545 $ work( itaup ), vt, ldvt,
2546 $ work( iwork ), lwork-iwork+1, ierr )
2553 CALL sbdsqr(
'U', m, n, 0, 0, s, work( ie ), vt,
2554 $ ldvt, dum, 1, dum, 1, work( iwork ),
2559 ELSE IF( wntuo )
THEN
2565 IF( lwork.GE.2*m*m+max( 4*m, bdspac ) )
THEN
2570 IF( lwork.GE.wrkbl+2*lda*m )
THEN
2577 ELSE IF( lwork.GE.wrkbl+( lda+m )*m )
THEN
2592 itau = ir + ldwrkr*m
2598 CALL sgelqf( m, n, a, lda, work( itau ),
2599 $ work( iwork ), lwork-iwork+1, ierr )
2603 CALL slacpy(
'L', m, m, a, lda, work( iu ),
2605 CALL slaset(
'U', m-1, m-1, zero, zero,
2606 $ work( iu+ldwrku ), ldwrku )
2611 CALL sorglq( m, n, m, a, lda, work( itau ),
2612 $ work( iwork ), lwork-iwork+1, ierr )
2623 CALL sgebrd( m, m, work( iu ), ldwrku, s,
2624 $ work( ie ), work( itauq ),
2625 $ work( itaup ), work( iwork ),
2626 $ lwork-iwork+1, ierr )
2627 CALL slacpy(
'L', m, m, work( iu ), ldwrku,
2628 $ work( ir ), ldwrkr )
2634 CALL sorgbr(
'P', m, m, m, work( iu ), ldwrku,
2635 $ work( itaup ), work( iwork ),
2636 $ lwork-iwork+1, ierr )
2641 CALL sorgbr(
'Q', m, m, m, work( ir ), ldwrkr,
2642 $ work( itauq ), work( iwork ),
2643 $ lwork-iwork+1, ierr )
2651 CALL sbdsqr(
'U', m, m, m, 0, s, work( ie ),
2652 $ work( iu ), ldwrku, work( ir ),
2653 $ ldwrkr, dum, 1, work( iwork ), info )
2659 CALL sgemm(
'N',
'N', m, n, m, one, work( iu ),
2660 $ ldwrku, a, lda, zero, vt, ldvt )
2665 CALL slacpy(
'F', m, m, work( ir ), ldwrkr, a,
2678 CALL sgelqf( m, n, a, lda, work( itau ),
2679 $ work( iwork ), lwork-iwork+1, ierr )
2680 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
2685 CALL sorglq( m, n, m, vt, ldvt, work( itau ),
2686 $ work( iwork ), lwork-iwork+1, ierr )
2694 CALL slaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ),
2700 CALL sgebrd( m, m, a, lda, s, work( ie ),
2701 $ work( itauq ), work( itaup ),
2702 $ work( iwork ), lwork-iwork+1, ierr )
2707 CALL sormbr(
'P',
'L',
'T', m, n, m, a, lda,
2708 $ work( itaup ), vt, ldvt,
2709 $ work( iwork ), lwork-iwork+1, ierr )
2714 CALL sorgbr(
'Q', m, m, m, a, lda, work( itauq ),
2715 $ work( iwork ), lwork-iwork+1, ierr )
2723 CALL sbdsqr(
'U', m, n, m, 0, s, work( ie ), vt,
2724 $ ldvt, a, lda, dum, 1, work( iwork ),
2729 ELSE IF( wntuas )
THEN
2736 IF( lwork.GE.m*m+max( 4*m, bdspac ) )
THEN
2741 IF( lwork.GE.wrkbl+lda*m )
THEN
2752 itau = iu + ldwrku*m
2758 CALL sgelqf( m, n, a, lda, work( itau ),
2759 $ work( iwork ), lwork-iwork+1, ierr )
2763 CALL slacpy(
'L', m, m, a, lda, work( iu ),
2765 CALL slaset(
'U', m-1, m-1, zero, zero,
2766 $ work( iu+ldwrku ), ldwrku )
2771 CALL sorglq( m, n, m, a, lda, work( itau ),
2772 $ work( iwork ), lwork-iwork+1, ierr )
2781 CALL sgebrd( m, m, work( iu ), ldwrku, s,
2782 $ work( ie ), work( itauq ),
2783 $ work( itaup ), work( iwork ),
2784 $ lwork-iwork+1, ierr )
2785 CALL slacpy(
'L', m, m, work( iu ), ldwrku, u,
2792 CALL sorgbr(
'P', m, m, m, work( iu ), ldwrku,
2793 $ work( itaup ), work( iwork ),
2794 $ lwork-iwork+1, ierr )
2799 CALL sorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
2800 $ work( iwork ), lwork-iwork+1, ierr )
2808 CALL sbdsqr(
'U', m, m, m, 0, s, work( ie ),
2809 $ work( iu ), ldwrku, u, ldu, dum, 1,
2810 $ work( iwork ), info )
2816 CALL sgemm(
'N',
'N', m, n, m, one, work( iu ),
2817 $ ldwrku, a, lda, zero, vt, ldvt )
2829 CALL sgelqf( m, n, a, lda, work( itau ),
2830 $ work( iwork ), lwork-iwork+1, ierr )
2831 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
2836 CALL sorglq( m, n, m, vt, ldvt, work( itau ),
2837 $ work( iwork ), lwork-iwork+1, ierr )
2841 CALL slacpy(
'L', m, m, a, lda, u, ldu )
2842 CALL slaset(
'U', m-1, m-1, zero, zero, u( 1, 2 ),
2852 CALL sgebrd( m, m, u, ldu, s, work( ie ),
2853 $ work( itauq ), work( itaup ),
2854 $ work( iwork ), lwork-iwork+1, ierr )
2860 CALL sormbr(
'P',
'L',
'T', m, n, m, u, ldu,
2861 $ work( itaup ), vt, ldvt,
2862 $ work( iwork ), lwork-iwork+1, ierr )
2867 CALL sorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
2868 $ work( iwork ), lwork-iwork+1, ierr )
2876 CALL sbdsqr(
'U', m, n, m, 0, s, work( ie ), vt,
2877 $ ldvt, u, ldu, dum, 1, work( iwork ),
2884 ELSE IF( wntva )
THEN
2892 IF( lwork.GE.m*m+max( n+m, 4*m, bdspac ) )
THEN
2897 IF( lwork.GE.wrkbl+lda*m )
THEN
2908 itau = ir + ldwrkr*m
2914 CALL sgelqf( m, n, a, lda, work( itau ),
2915 $ work( iwork ), lwork-iwork+1, ierr )
2916 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
2920 CALL slacpy(
'L', m, m, a, lda, work( ir ),
2922 CALL slaset(
'U', m-1, m-1, zero, zero,
2923 $ work( ir+ldwrkr ), ldwrkr )
2928 CALL sorglq( n, n, m, vt, ldvt, work( itau ),
2929 $ work( iwork ), lwork-iwork+1, ierr )
2938 CALL sgebrd( m, m, work( ir ), ldwrkr, s,
2939 $ work( ie ), work( itauq ),
2940 $ work( itaup ), work( iwork ),
2941 $ lwork-iwork+1, ierr )
2947 CALL sorgbr(
'P', m, m, m, work( ir ), ldwrkr,
2948 $ work( itaup ), work( iwork ),
2949 $ lwork-iwork+1, ierr )
2956 CALL sbdsqr(
'U', m, m, 0, 0, s, work( ie ),
2957 $ work( ir ), ldwrkr, dum, 1, dum, 1,
2958 $ work( iwork ), info )
2964 CALL sgemm(
'N',
'N', m, n, m, one, work( ir ),
2965 $ ldwrkr, vt, ldvt, zero, a, lda )
2969 CALL slacpy(
'F', m, n, a, lda, vt, ldvt )
2981 CALL sgelqf( m, n, a, lda, work( itau ),
2982 $ work( iwork ), lwork-iwork+1, ierr )
2983 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
2988 CALL sorglq( n, n, m, vt, ldvt, work( itau ),
2989 $ work( iwork ), lwork-iwork+1, ierr )
2997 CALL slaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ),
3003 CALL sgebrd( m, m, a, lda, s, work( ie ),
3004 $ work( itauq ), work( itaup ),
3005 $ work( iwork ), lwork-iwork+1, ierr )
3011 CALL sormbr(
'P',
'L',
'T', m, n, m, a, lda,
3012 $ work( itaup ), vt, ldvt,
3013 $ work( iwork ), lwork-iwork+1, ierr )
3020 CALL sbdsqr(
'U', m, n, 0, 0, s, work( ie ), vt,
3021 $ ldvt, dum, 1, dum, 1, work( iwork ),
3026 ELSE IF( wntuo )
THEN
3032 IF( lwork.GE.2*m*m+max( n+m, 4*m, bdspac ) )
THEN
3037 IF( lwork.GE.wrkbl+2*lda*m )
THEN
3044 ELSE IF( lwork.GE.wrkbl+( lda+m )*m )
THEN
3059 itau = ir + ldwrkr*m
3065 CALL sgelqf( m, n, a, lda, work( itau ),
3066 $ work( iwork ), lwork-iwork+1, ierr )
3067 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
3072 CALL sorglq( n, n, m, vt, ldvt, work( itau ),
3073 $ work( iwork ), lwork-iwork+1, ierr )
3077 CALL slacpy(
'L', m, m, a, lda, work( iu ),
3079 CALL slaset(
'U', m-1, m-1, zero, zero,
3080 $ work( iu+ldwrku ), ldwrku )
3091 CALL sgebrd( m, m, work( iu ), ldwrku, s,
3092 $ work( ie ), work( itauq ),
3093 $ work( itaup ), work( iwork ),
3094 $ lwork-iwork+1, ierr )
3095 CALL slacpy(
'L', m, m, work( iu ), ldwrku,
3096 $ work( ir ), ldwrkr )
3102 CALL sorgbr(
'P', m, m, m, work( iu ), ldwrku,
3103 $ work( itaup ), work( iwork ),
3104 $ lwork-iwork+1, ierr )
3109 CALL sorgbr(
'Q', m, m, m, work( ir ), ldwrkr,
3110 $ work( itauq ), work( iwork ),
3111 $ lwork-iwork+1, ierr )
3119 CALL sbdsqr(
'U', m, m, m, 0, s, work( ie ),
3120 $ work( iu ), ldwrku, work( ir ),
3121 $ ldwrkr, dum, 1, work( iwork ), info )
3127 CALL sgemm(
'N',
'N', m, n, m, one, work( iu ),
3128 $ ldwrku, vt, ldvt, zero, a, lda )
3132 CALL slacpy(
'F', m, n, a, lda, vt, ldvt )
3136 CALL slacpy(
'F', m, m, work( ir ), ldwrkr, a,
3149 CALL sgelqf( m, n, a, lda, work( itau ),
3150 $ work( iwork ), lwork-iwork+1, ierr )
3151 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
3156 CALL sorglq( n, n, m, vt, ldvt, work( itau ),
3157 $ work( iwork ), lwork-iwork+1, ierr )
3165 CALL slaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ),
3171 CALL sgebrd( m, m, a, lda, s, work( ie ),
3172 $ work( itauq ), work( itaup ),
3173 $ work( iwork ), lwork-iwork+1, ierr )
3179 CALL sormbr(
'P',
'L',
'T', m, n, m, a, lda,
3180 $ work( itaup ), vt, ldvt,
3181 $ work( iwork ), lwork-iwork+1, ierr )
3186 CALL sorgbr(
'Q', m, m, m, a, lda, work( itauq ),
3187 $ work( iwork ), lwork-iwork+1, ierr )
3195 CALL sbdsqr(
'U', m, n, m, 0, s, work( ie ), vt,
3196 $ ldvt, a, lda, dum, 1, work( iwork ),
3201 ELSE IF( wntuas )
THEN
3208 IF( lwork.GE.m*m+max( n+m, 4*m, bdspac ) )
THEN
3213 IF( lwork.GE.wrkbl+lda*m )
THEN
3224 itau = iu + ldwrku*m
3230 CALL sgelqf( m, n, a, lda, work( itau ),
3231 $ work( iwork ), lwork-iwork+1, ierr )
3232 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
3237 CALL sorglq( n, n, m, vt, ldvt, work( itau ),
3238 $ work( iwork ), lwork-iwork+1, ierr )
3242 CALL slacpy(
'L', m, m, a, lda, work( iu ),
3244 CALL slaset(
'U', m-1, m-1, zero, zero,
3245 $ work( iu+ldwrku ), ldwrku )
3254 CALL sgebrd( m, m, work( iu ), ldwrku, s,
3255 $ work( ie ), work( itauq ),
3256 $ work( itaup ), work( iwork ),
3257 $ lwork-iwork+1, ierr )
3258 CALL slacpy(
'L', m, m, work( iu ), ldwrku, u,
3264 CALL sorgbr(
'P', m, m, m, work( iu ), ldwrku,
3265 $ work( itaup ), work( iwork ),
3266 $ lwork-iwork+1, ierr )
3271 CALL sorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
3272 $ work( iwork ), lwork-iwork+1, ierr )
3280 CALL sbdsqr(
'U', m, m, m, 0, s, work( ie ),
3281 $ work( iu ), ldwrku, u, ldu, dum, 1,
3282 $ work( iwork ), info )
3288 CALL sgemm(
'N',
'N', m, n, m, one, work( iu ),
3289 $ ldwrku, vt, ldvt, zero, a, lda )
3293 CALL slacpy(
'F', m, n, a, lda, vt, ldvt )
3305 CALL sgelqf( m, n, a, lda, work( itau ),
3306 $ work( iwork ), lwork-iwork+1, ierr )
3307 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
3312 CALL sorglq( n, n, m, vt, ldvt, work( itau ),
3313 $ work( iwork ), lwork-iwork+1, ierr )
3317 CALL slacpy(
'L', m, m, a, lda, u, ldu )
3318 CALL slaset(
'U', m-1, m-1, zero, zero, u( 1, 2 ),
3328 CALL sgebrd( m, m, u, ldu, s, work( ie ),
3329 $ work( itauq ), work( itaup ),
3330 $ work( iwork ), lwork-iwork+1, ierr )
3336 CALL sormbr(
'P',
'L',
'T', m, n, m, u, ldu,
3337 $ work( itaup ), vt, ldvt,
3338 $ work( iwork ), lwork-iwork+1, ierr )
3343 CALL sorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
3344 $ work( iwork ), lwork-iwork+1, ierr )
3352 CALL sbdsqr(
'U', m, n, m, 0, s, work( ie ), vt,
3353 $ ldvt, u, ldu, dum, 1, work( iwork ),
3377 CALL sgebrd( m, n, a, lda, s, work( ie ), work( itauq ),
3378 $ work( itaup ), work( iwork ), lwork-iwork+1,
3386 CALL slacpy(
'L', m, m, a, lda, u, ldu )
3387 CALL sorgbr(
'Q', m, m, n, u, ldu, work( itauq ),
3388 $ work( iwork ), lwork-iwork+1, ierr )
3396 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
3401 CALL sorgbr(
'P', nrvt, n, m, vt, ldvt, work( itaup ),
3402 $ work( iwork ), lwork-iwork+1, ierr )
3410 CALL sorgbr(
'Q', m, m, n, a, lda, work( itauq ),
3411 $ work( iwork ), lwork-iwork+1, ierr )
3419 CALL sorgbr(
'P', m, n, m, a, lda, work( itaup ),
3420 $ work( iwork ), lwork-iwork+1, ierr )
3423 IF( wntuas .OR. wntuo )
3427 IF( wntvas .OR. wntvo )
3431 IF( ( .NOT.wntuo ) .AND. ( .NOT.wntvo ) )
THEN
3438 CALL sbdsqr(
'L', m, ncvt, nru, 0, s, work( ie ), vt,
3439 $ ldvt, u, ldu, dum, 1, work( iwork ), info )
3440 ELSE IF( ( .NOT.wntuo ) .AND. wntvo )
THEN
3447 CALL sbdsqr(
'L', m, ncvt, nru, 0, s, work( ie ), a, lda,
3448 $ u, ldu, dum, 1, work( iwork ), info )
3456 CALL sbdsqr(
'L', m, ncvt, nru, 0, s, work( ie ), vt,
3457 $ ldvt, a, lda, dum, 1, work( iwork ), info )
3467 IF( info.NE.0 )
THEN
3469 DO 50 i = 1, minmn - 1
3470 work( i+1 ) = work( i+ie-1 )
3474 DO 60 i = minmn - 1, 1, -1
3475 work( i+1 ) = work( i+ie-1 )
3482 IF( iscl.EQ.1 )
THEN
3483 IF( anrm.GT.bignum )
3484 $
CALL slascl(
'G', 0, 0, bignum, anrm, minmn, 1, s, minmn,
3486 IF( info.NE.0 .AND. anrm.GT.bignum )
3487 $
CALL slascl(
'G', 0, 0, bignum, anrm, minmn-1, 1, work( 2 ),
3489 IF( anrm.LT.smlnum )
3490 $
CALL slascl(
'G', 0, 0, smlnum, anrm, minmn, 1, s, minmn,
3492 IF( info.NE.0 .AND. anrm.LT.smlnum )
3493 $
CALL slascl(
'G', 0, 0, smlnum, anrm, minmn-1, 1, work( 2 ),
subroutine sorglq(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
SORGLQ
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 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
subroutine xerbla(SRNAME, INFO)
XERBLA
subroutine slacpy(UPLO, M, N, A, LDA, B, LDB)
SLACPY copies all or part of one two-dimensional array to another.
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...
subroutine sormbr(VECT, SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
SORMBR
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 sbdsqr(UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U, LDU, C, LDC, WORK, INFO)
SBDSQR
integer function ilaenv(ISPEC, NAME, OPTS, N1, N2, N3, N4)
subroutine sgebrd(M, N, A, LDA, D, E, TAUQ, TAUP, WORK, LWORK, INFO)
SGEBRD
real function slamch(CMACH)
SLAMCH
subroutine sorgqr(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
SORGQR
logical function lsame(CA, CB)
LSAME
subroutine sorgbr(VECT, M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
SORGBR
subroutine sgelqf(M, N, A, LDA, TAU, WORK, LWORK, INFO)
SGELQF