209 SUBROUTINE sgesvd( JOBU, JOBVT, M, N, A, LDA, S, U, LDU, VT, LDVT,
210 $ WORK, LWORK, INFO )
217 CHARACTER JOBU, JOBVT
218 INTEGER INFO, LDA, LDU, LDVT, LWORK, M, N
221 REAL A( LDA, * ), S( * ), U( LDU, * ),
222 $ vt( ldvt, * ), work( * )
229 parameter( zero = 0.0e0, one = 1.0e0 )
232 LOGICAL LQUERY, WNTUA, WNTUAS, WNTUN, WNTUO, WNTUS,
233 $ wntva, wntvas, wntvn, wntvo, wntvs
234 INTEGER BDSPAC, BLK, CHUNK, I, IE, IERR, IR, ISCL,
235 $ itau, itaup, itauq, iu, iwork, ldwrkr, ldwrku,
236 $ maxwrk, minmn, minwrk, mnthr, ncu, ncvt, nru,
238 INTEGER LWORK_SGEQRF, LWORK_SORGQR_N, LWORK_SORGQR_M,
239 $ lwork_sgebrd, lwork_sorgbr_p, lwork_sorgbr_q,
240 $ lwork_sgelqf, lwork_sorglq_n, lwork_sorglq_m
241 REAL ANRM, BIGNUM, EPS, SMLNUM
254 REAL SLAMCH, SLANGE, SROUNDUP_LWORK
255 EXTERNAL lsame, ilaenv, slamch, slange, sroundup_lwork
258 INTRINSIC max, min, sqrt
266 wntua = lsame( jobu,
'A' )
267 wntus = lsame( jobu,
'S' )
268 wntuas = wntua .OR. wntus
269 wntuo = lsame( jobu,
'O' )
270 wntun = lsame( jobu,
'N' )
271 wntva = lsame( jobvt,
'A' )
272 wntvs = lsame( jobvt,
'S' )
273 wntvas = wntva .OR. wntvs
274 wntvo = lsame( jobvt,
'O' )
275 wntvn = lsame( jobvt,
'N' )
276 lquery = ( lwork.EQ.-1 )
278 IF( .NOT.( wntua .OR. wntus .OR. wntuo .OR. wntun ) )
THEN
280 ELSE IF( .NOT.( wntva .OR. wntvs .OR. wntvo .OR. wntvn ) .OR.
281 $ ( wntvo .AND. wntuo ) )
THEN
283 ELSE IF( m.LT.0 )
THEN
285 ELSE IF( n.LT.0 )
THEN
287 ELSE IF( lda.LT.max( 1, m ) )
THEN
289 ELSE IF( ldu.LT.1 .OR. ( wntuas .AND. ldu.LT.m ) )
THEN
291 ELSE IF( ldvt.LT.1 .OR. ( wntva .AND. ldvt.LT.n ) .OR.
292 $ ( wntvs .AND. ldvt.LT.minmn ) )
THEN
306 IF( m.GE.n .AND. minmn.GT.0 )
THEN
310 mnthr = ilaenv( 6,
'SGESVD', jobu // jobvt, m, n, 0, 0 )
313 CALL sgeqrf( m, n, a, lda, dum(1), dum(1), -1, ierr )
314 lwork_sgeqrf = int( dum(1) )
316 CALL sorgqr( m, n, n, a, lda, dum(1), dum(1), -1, ierr )
317 lwork_sorgqr_n = int( dum(1) )
318 CALL sorgqr( m, m, n, a, lda, dum(1), dum(1), -1, ierr )
319 lwork_sorgqr_m = int( dum(1) )
321 CALL sgebrd( n, n, a, lda, s, dum(1), dum(1),
322 $ dum(1), dum(1), -1, ierr )
323 lwork_sgebrd = int( dum(1) )
325 CALL sorgbr(
'P', n, n, n, a, lda, dum(1),
327 lwork_sorgbr_p = int( dum(1) )
329 CALL sorgbr(
'Q', n, n, n, a, lda, dum(1),
331 lwork_sorgbr_q = int( dum(1) )
333 IF( m.GE.mnthr )
THEN
338 maxwrk = n + lwork_sgeqrf
339 maxwrk = max( maxwrk, 3*n+lwork_sgebrd )
340 IF( wntvo .OR. wntvas )
341 $ maxwrk = max( maxwrk, 3*n+lwork_sorgbr_p )
342 maxwrk = max( maxwrk, bdspac )
343 minwrk = max( 4*n, bdspac )
344 ELSE IF( wntuo .AND. wntvn )
THEN
348 wrkbl = n + lwork_sgeqrf
349 wrkbl = max( wrkbl, n+lwork_sorgqr_n )
350 wrkbl = max( wrkbl, 3*n+lwork_sgebrd )
351 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_q )
352 wrkbl = max( wrkbl, bdspac )
353 maxwrk = max( n*n+wrkbl, n*n+m*n+n )
354 minwrk = max( 3*n+m, bdspac )
355 ELSE IF( wntuo .AND. wntvas )
THEN
360 wrkbl = n + lwork_sgeqrf
361 wrkbl = max( wrkbl, n+lwork_sorgqr_n )
362 wrkbl = max( wrkbl, 3*n+lwork_sgebrd )
363 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_q )
364 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_p )
365 wrkbl = max( wrkbl, bdspac )
366 maxwrk = max( n*n+wrkbl, n*n+m*n+n )
367 minwrk = max( 3*n+m, bdspac )
368 ELSE IF( wntus .AND. wntvn )
THEN
372 wrkbl = n + lwork_sgeqrf
373 wrkbl = max( wrkbl, n+lwork_sorgqr_n )
374 wrkbl = max( wrkbl, 3*n+lwork_sgebrd )
375 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_q )
376 wrkbl = max( wrkbl, bdspac )
378 minwrk = max( 3*n+m, bdspac )
379 ELSE IF( wntus .AND. wntvo )
THEN
383 wrkbl = n + lwork_sgeqrf
384 wrkbl = max( wrkbl, n+lwork_sorgqr_n )
385 wrkbl = max( wrkbl, 3*n+lwork_sgebrd )
386 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_q )
387 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_p )
388 wrkbl = max( wrkbl, bdspac )
389 maxwrk = 2*n*n + wrkbl
390 minwrk = max( 3*n+m, bdspac )
391 ELSE IF( wntus .AND. wntvas )
THEN
396 wrkbl = n + lwork_sgeqrf
397 wrkbl = max( wrkbl, n+lwork_sorgqr_n )
398 wrkbl = max( wrkbl, 3*n+lwork_sgebrd )
399 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_q )
400 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_p )
401 wrkbl = max( wrkbl, bdspac )
403 minwrk = max( 3*n+m, bdspac )
404 ELSE IF( wntua .AND. wntvn )
THEN
408 wrkbl = n + lwork_sgeqrf
409 wrkbl = max( wrkbl, n+lwork_sorgqr_m )
410 wrkbl = max( wrkbl, 3*n+lwork_sgebrd )
411 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_q )
412 wrkbl = max( wrkbl, bdspac )
414 minwrk = max( 3*n+m, bdspac )
415 ELSE IF( wntua .AND. wntvo )
THEN
419 wrkbl = n + lwork_sgeqrf
420 wrkbl = max( wrkbl, n+lwork_sorgqr_m )
421 wrkbl = max( wrkbl, 3*n+lwork_sgebrd )
422 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_q )
423 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_p )
424 wrkbl = max( wrkbl, bdspac )
425 maxwrk = 2*n*n + wrkbl
426 minwrk = max( 3*n+m, bdspac )
427 ELSE IF( wntua .AND. wntvas )
THEN
432 wrkbl = n + lwork_sgeqrf
433 wrkbl = max( wrkbl, n+lwork_sorgqr_m )
434 wrkbl = max( wrkbl, 3*n+lwork_sgebrd )
435 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_q )
436 wrkbl = max( wrkbl, 3*n+lwork_sorgbr_p )
437 wrkbl = max( wrkbl, bdspac )
439 minwrk = max( 3*n+m, bdspac )
445 CALL sgebrd( m, n, a, lda, s, dum(1), dum(1),
446 $ dum(1), dum(1), -1, ierr )
447 lwork_sgebrd = int( dum(1) )
448 maxwrk = 3*n + lwork_sgebrd
449 IF( wntus .OR. wntuo )
THEN
450 CALL sorgbr(
'Q', m, n, n, a, lda, dum(1),
452 lwork_sorgbr_q = int( dum(1) )
453 maxwrk = max( maxwrk, 3*n+lwork_sorgbr_q )
456 CALL sorgbr(
'Q', m, m, n, a, lda, dum(1),
458 lwork_sorgbr_q = int( dum(1) )
459 maxwrk = max( maxwrk, 3*n+lwork_sorgbr_q )
461 IF( .NOT.wntvn )
THEN
462 maxwrk = max( maxwrk, 3*n+lwork_sorgbr_p )
464 maxwrk = max( maxwrk, bdspac )
465 minwrk = max( 3*n+m, bdspac )
467 ELSE IF( minmn.GT.0 )
THEN
471 mnthr = ilaenv( 6,
'SGESVD', jobu // jobvt, m, n, 0, 0 )
474 CALL sgelqf( m, n, a, lda, dum(1), dum(1), -1, ierr )
475 lwork_sgelqf = int( dum(1) )
477 CALL sorglq( n, n, m, dum(1), n, dum(1), dum(1), -1, ierr )
478 lwork_sorglq_n = int( dum(1) )
479 CALL sorglq( m, n, m, a, lda, dum(1), dum(1), -1, ierr )
480 lwork_sorglq_m = int( dum(1) )
482 CALL sgebrd( m, m, a, lda, s, dum(1), dum(1),
483 $ dum(1), dum(1), -1, ierr )
484 lwork_sgebrd = int( dum(1) )
486 CALL sorgbr(
'P', m, m, m, a, n, dum(1),
488 lwork_sorgbr_p = int( dum(1) )
490 CALL sorgbr(
'Q', m, m, m, a, n, dum(1),
492 lwork_sorgbr_q = int( dum(1) )
493 IF( n.GE.mnthr )
THEN
498 maxwrk = m + lwork_sgelqf
499 maxwrk = max( maxwrk, 3*m+lwork_sgebrd )
500 IF( wntuo .OR. wntuas )
501 $ maxwrk = max( maxwrk, 3*m+lwork_sorgbr_q )
502 maxwrk = max( maxwrk, bdspac )
503 minwrk = max( 4*m, bdspac )
504 ELSE IF( wntvo .AND. wntun )
THEN
508 wrkbl = m + lwork_sgelqf
509 wrkbl = max( wrkbl, m+lwork_sorglq_m )
510 wrkbl = max( wrkbl, 3*m+lwork_sgebrd )
511 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_p )
512 wrkbl = max( wrkbl, bdspac )
513 maxwrk = max( m*m+wrkbl, m*m+m*n+m )
514 minwrk = max( 3*m+n, bdspac )
515 ELSE IF( wntvo .AND. wntuas )
THEN
520 wrkbl = m + lwork_sgelqf
521 wrkbl = max( wrkbl, m+lwork_sorglq_m )
522 wrkbl = max( wrkbl, 3*m+lwork_sgebrd )
523 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_p )
524 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_q )
525 wrkbl = max( wrkbl, bdspac )
526 maxwrk = max( m*m+wrkbl, m*m+m*n+m )
527 minwrk = max( 3*m+n, bdspac )
528 ELSE IF( wntvs .AND. wntun )
THEN
532 wrkbl = m + lwork_sgelqf
533 wrkbl = max( wrkbl, m+lwork_sorglq_m )
534 wrkbl = max( wrkbl, 3*m+lwork_sgebrd )
535 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_p )
536 wrkbl = max( wrkbl, bdspac )
538 minwrk = max( 3*m+n, bdspac )
539 ELSE IF( wntvs .AND. wntuo )
THEN
543 wrkbl = m + lwork_sgelqf
544 wrkbl = max( wrkbl, m+lwork_sorglq_m )
545 wrkbl = max( wrkbl, 3*m+lwork_sgebrd )
546 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_p )
547 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_q )
548 wrkbl = max( wrkbl, bdspac )
549 maxwrk = 2*m*m + wrkbl
550 minwrk = max( 3*m+n, bdspac )
551 maxwrk = max( maxwrk, minwrk )
552 ELSE IF( wntvs .AND. wntuas )
THEN
557 wrkbl = m + lwork_sgelqf
558 wrkbl = max( wrkbl, m+lwork_sorglq_m )
559 wrkbl = max( wrkbl, 3*m+lwork_sgebrd )
560 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_p )
561 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_q )
562 wrkbl = max( wrkbl, bdspac )
564 minwrk = max( 3*m+n, bdspac )
565 ELSE IF( wntva .AND. wntun )
THEN
569 wrkbl = m + lwork_sgelqf
570 wrkbl = max( wrkbl, m+lwork_sorglq_n )
571 wrkbl = max( wrkbl, 3*m+lwork_sgebrd )
572 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_p )
573 wrkbl = max( wrkbl, bdspac )
575 minwrk = max( 3*m+n, bdspac )
576 ELSE IF( wntva .AND. wntuo )
THEN
580 wrkbl = m + lwork_sgelqf
581 wrkbl = max( wrkbl, m+lwork_sorglq_n )
582 wrkbl = max( wrkbl, 3*m+lwork_sgebrd )
583 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_p )
584 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_q )
585 wrkbl = max( wrkbl, bdspac )
586 maxwrk = 2*m*m + wrkbl
587 minwrk = max( 3*m+n, bdspac )
588 ELSE IF( wntva .AND. wntuas )
THEN
593 wrkbl = m + lwork_sgelqf
594 wrkbl = max( wrkbl, m+lwork_sorglq_n )
595 wrkbl = max( wrkbl, 3*m+lwork_sgebrd )
596 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_p )
597 wrkbl = max( wrkbl, 3*m+lwork_sorgbr_q )
598 wrkbl = max( wrkbl, bdspac )
600 minwrk = max( 3*m+n, bdspac )
606 CALL sgebrd( m, n, a, lda, s, dum(1), dum(1),
607 $ dum(1), dum(1), -1, ierr )
608 lwork_sgebrd = int( dum(1) )
609 maxwrk = 3*m + lwork_sgebrd
610 IF( wntvs .OR. wntvo )
THEN
612 CALL sorgbr(
'P', m, n, m, a, n, dum(1),
614 lwork_sorgbr_p = int( dum(1) )
615 maxwrk = max( maxwrk, 3*m+lwork_sorgbr_p )
618 CALL sorgbr(
'P', n, n, m, a, n, dum(1),
620 lwork_sorgbr_p = int( dum(1) )
621 maxwrk = max( maxwrk, 3*m+lwork_sorgbr_p )
623 IF( .NOT.wntun )
THEN
624 maxwrk = max( maxwrk, 3*m+lwork_sorgbr_q )
626 maxwrk = max( maxwrk, bdspac )
627 minwrk = max( 3*m+n, bdspac )
630 maxwrk = max( maxwrk, minwrk )
631 work( 1 ) = sroundup_lwork(maxwrk)
633 IF( lwork.LT.minwrk .AND. .NOT.lquery )
THEN
639 CALL xerbla(
'SGESVD', -info )
641 ELSE IF( lquery )
THEN
647 IF( m.EQ.0 .OR. n.EQ.0 )
THEN
654 smlnum = sqrt( slamch(
'S' ) ) / eps
655 bignum = one / smlnum
659 anrm = slange(
'M', m, n, a, lda, dum )
661 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
663 CALL slascl(
'G', 0, 0, anrm, smlnum, m, n, a, lda, ierr )
664 ELSE IF( anrm.GT.bignum )
THEN
666 CALL slascl(
'G', 0, 0, anrm, bignum, m, n, a, lda, ierr )
675 IF( m.GE.mnthr )
THEN
688 CALL sgeqrf( m, n, a, lda, work( itau ), work( iwork ),
689 $ lwork-iwork+1, ierr )
694 CALL slaset(
'L', n-1, n-1, zero, zero, a( 2, 1 ),
705 CALL sgebrd( n, n, a, lda, s, work( ie ), work( itauq ),
706 $ work( itaup ), work( iwork ), lwork-iwork+1,
709 IF( wntvo .OR. wntvas )
THEN
714 CALL sorgbr(
'P', n, n, n, a, lda, work( itaup ),
715 $ work( iwork ), lwork-iwork+1, ierr )
724 CALL sbdsqr(
'U', n, ncvt, 0, 0, s, work( ie ), a, lda,
725 $ dum, 1, dum, 1, work( iwork ), info )
730 $
CALL slacpy(
'F', n, n, a, lda, vt, ldvt )
732 ELSE IF( wntuo .AND. wntvn )
THEN
738 IF( lwork.GE.n*n+max( 4*n, bdspac ) )
THEN
743 IF( lwork.GE.max( wrkbl, lda*n+n )+lda*n )
THEN
749 ELSE IF( lwork.GE.max( wrkbl, lda*n+n )+n*n )
THEN
759 ldwrku = ( lwork-n*n-n ) / n
768 CALL sgeqrf( m, n, a, lda, work( itau ),
769 $ work( iwork ), lwork-iwork+1, ierr )
773 CALL slacpy(
'U', n, n, a, lda, work( ir ), ldwrkr )
774 CALL slaset(
'L', n-1, n-1, zero, zero, work( ir+1 ),
780 CALL sorgqr( m, n, n, a, lda, work( itau ),
781 $ work( iwork ), lwork-iwork+1, ierr )
790 CALL sgebrd( n, n, work( ir ), ldwrkr, s, work( ie ),
791 $ work( itauq ), work( itaup ),
792 $ work( iwork ), lwork-iwork+1, ierr )
797 CALL sorgbr(
'Q', n, n, n, work( ir ), ldwrkr,
798 $ work( itauq ), work( iwork ),
799 $ lwork-iwork+1, ierr )
806 CALL sbdsqr(
'U', n, 0, n, 0, s, work( ie ), dum, 1,
807 $ work( ir ), ldwrkr, dum, 1,
808 $ work( iwork ), info )
815 DO 10 i = 1, m, ldwrku
816 chunk = min( m-i+1, ldwrku )
817 CALL sgemm(
'N',
'N', chunk, n, n, one, a( i, 1 ),
818 $ lda, work( ir ), ldwrkr, zero,
819 $ work( iu ), ldwrku )
820 CALL slacpy(
'F', chunk, n, work( iu ), ldwrku,
836 CALL sgebrd( m, n, a, lda, s, work( ie ),
837 $ work( itauq ), work( itaup ),
838 $ work( iwork ), lwork-iwork+1, ierr )
843 CALL sorgbr(
'Q', m, n, n, a, lda, work( itauq ),
844 $ work( iwork ), lwork-iwork+1, ierr )
851 CALL sbdsqr(
'U', n, 0, m, 0, s, work( ie ), dum, 1,
852 $ a, lda, dum, 1, work( iwork ), info )
856 ELSE IF( wntuo .AND. wntvas )
THEN
862 IF( lwork.GE.n*n+max( 4*n, bdspac ) )
THEN
867 IF( lwork.GE.max( wrkbl, lda*n+n )+lda*n )
THEN
873 ELSE IF( lwork.GE.max( wrkbl, lda*n+n )+n*n )
THEN
883 ldwrku = ( lwork-n*n-n ) / n
892 CALL sgeqrf( m, n, a, lda, work( itau ),
893 $ work( iwork ), lwork-iwork+1, ierr )
897 CALL slacpy(
'U', n, n, a, lda, vt, ldvt )
899 $
CALL slaset(
'L', n-1, n-1, zero, zero,
905 CALL sorgqr( m, n, n, a, lda, work( itau ),
906 $ work( iwork ), lwork-iwork+1, ierr )
915 CALL sgebrd( n, n, vt, ldvt, s, work( ie ),
916 $ work( itauq ), work( itaup ),
917 $ work( iwork ), lwork-iwork+1, ierr )
918 CALL slacpy(
'L', n, n, vt, ldvt, work( ir ), ldwrkr )
923 CALL sorgbr(
'Q', n, n, n, work( ir ), ldwrkr,
924 $ work( itauq ), work( iwork ),
925 $ lwork-iwork+1, ierr )
930 CALL sorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
931 $ work( iwork ), lwork-iwork+1, ierr )
939 CALL sbdsqr(
'U', n, n, n, 0, s, work( ie ), vt, ldvt,
940 $ work( ir ), ldwrkr, dum, 1,
941 $ work( iwork ), info )
948 DO 20 i = 1, m, ldwrku
949 chunk = min( m-i+1, ldwrku )
950 CALL sgemm(
'N',
'N', chunk, n, n, one, a( i, 1 ),
951 $ lda, work( ir ), ldwrkr, zero,
952 $ work( iu ), ldwrku )
953 CALL slacpy(
'F', chunk, n, work( iu ), ldwrku,
967 CALL sgeqrf( m, n, a, lda, work( itau ),
968 $ work( iwork ), lwork-iwork+1, ierr )
972 CALL slacpy(
'U', n, n, a, lda, vt, ldvt )
974 $
CALL slaset(
'L', n-1, n-1, zero, zero,
980 CALL sorgqr( m, n, n, a, lda, work( itau ),
981 $ work( iwork ), lwork-iwork+1, ierr )
990 CALL sgebrd( n, n, vt, ldvt, s, work( ie ),
991 $ work( itauq ), work( itaup ),
992 $ work( iwork ), lwork-iwork+1, ierr )
997 CALL sormbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
998 $ work( itauq ), a, lda, work( iwork ),
999 $ lwork-iwork+1, ierr )
1004 CALL sorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1005 $ work( iwork ), lwork-iwork+1, ierr )
1013 CALL sbdsqr(
'U', n, n, m, 0, s, work( ie ), vt, ldvt,
1014 $ a, lda, dum, 1, work( iwork ), info )
1018 ELSE IF( wntus )
THEN
1026 IF( lwork.GE.n*n+max( 4*n, bdspac ) )
THEN
1031 IF( lwork.GE.wrkbl+lda*n )
THEN
1042 itau = ir + ldwrkr*n
1048 CALL sgeqrf( m, n, a, lda, work( itau ),
1049 $ work( iwork ), lwork-iwork+1, ierr )
1053 CALL slacpy(
'U', n, n, a, lda, work( ir ),
1055 CALL slaset(
'L', n-1, n-1, zero, zero,
1056 $ work( ir+1 ), ldwrkr )
1061 CALL sorgqr( m, n, n, a, lda, work( itau ),
1062 $ work( iwork ), lwork-iwork+1, ierr )
1071 CALL sgebrd( n, n, work( ir ), ldwrkr, s,
1072 $ work( ie ), work( itauq ),
1073 $ work( itaup ), work( iwork ),
1074 $ lwork-iwork+1, ierr )
1079 CALL sorgbr(
'Q', n, n, n, work( ir ), ldwrkr,
1080 $ work( itauq ), work( iwork ),
1081 $ lwork-iwork+1, ierr )
1088 CALL sbdsqr(
'U', n, 0, n, 0, s, work( ie ), dum,
1089 $ 1, work( ir ), ldwrkr, dum, 1,
1090 $ work( iwork ), info )
1096 CALL sgemm(
'N',
'N', m, n, n, one, a, lda,
1097 $ work( ir ), ldwrkr, zero, u, ldu )
1109 CALL sgeqrf( m, n, a, lda, work( itau ),
1110 $ work( iwork ), lwork-iwork+1, ierr )
1111 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1116 CALL sorgqr( m, n, n, u, ldu, work( itau ),
1117 $ work( iwork ), lwork-iwork+1, ierr )
1126 CALL slaset(
'L', n-1, n-1, zero, zero,
1133 CALL sgebrd( n, n, a, lda, s, work( ie ),
1134 $ work( itauq ), work( itaup ),
1135 $ work( iwork ), lwork-iwork+1, ierr )
1140 CALL sormbr(
'Q',
'R',
'N', m, n, n, a, lda,
1141 $ work( itauq ), u, ldu, work( iwork ),
1142 $ lwork-iwork+1, ierr )
1149 CALL sbdsqr(
'U', n, 0, m, 0, s, work( ie ), dum,
1150 $ 1, u, ldu, dum, 1, work( iwork ),
1155 ELSE IF( wntvo )
THEN
1161 IF( lwork.GE.2*n*n+max( 4*n, bdspac ) )
THEN
1166 IF( lwork.GE.wrkbl+2*lda*n )
THEN
1173 ELSE IF( lwork.GE.wrkbl+( lda+n )*n )
THEN
1188 itau = ir + ldwrkr*n
1194 CALL sgeqrf( m, n, a, lda, work( itau ),
1195 $ work( iwork ), lwork-iwork+1, ierr )
1199 CALL slacpy(
'U', n, n, a, lda, work( iu ),
1201 CALL slaset(
'L', n-1, n-1, zero, zero,
1202 $ work( iu+1 ), ldwrku )
1207 CALL sorgqr( m, n, n, a, lda, work( itau ),
1208 $ work( iwork ), lwork-iwork+1, ierr )
1219 CALL sgebrd( n, n, work( iu ), ldwrku, s,
1220 $ work( ie ), work( itauq ),
1221 $ work( itaup ), work( iwork ),
1222 $ lwork-iwork+1, ierr )
1223 CALL slacpy(
'U', n, n, work( iu ), ldwrku,
1224 $ work( ir ), ldwrkr )
1229 CALL sorgbr(
'Q', n, n, n, work( iu ), ldwrku,
1230 $ work( itauq ), work( iwork ),
1231 $ lwork-iwork+1, ierr )
1237 CALL sorgbr(
'P', n, n, n, work( ir ), ldwrkr,
1238 $ work( itaup ), work( iwork ),
1239 $ lwork-iwork+1, ierr )
1247 CALL sbdsqr(
'U', n, n, n, 0, s, work( ie ),
1248 $ work( ir ), ldwrkr, work( iu ),
1249 $ ldwrku, dum, 1, work( iwork ), info )
1255 CALL sgemm(
'N',
'N', m, n, n, one, a, lda,
1256 $ work( iu ), ldwrku, zero, u, ldu )
1261 CALL slacpy(
'F', n, n, work( ir ), ldwrkr, a,
1274 CALL sgeqrf( m, n, a, lda, work( itau ),
1275 $ work( iwork ), lwork-iwork+1, ierr )
1276 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1281 CALL sorgqr( m, n, n, u, ldu, work( itau ),
1282 $ work( iwork ), lwork-iwork+1, ierr )
1291 CALL slaset(
'L', n-1, n-1, zero, zero,
1298 CALL sgebrd( n, n, a, lda, s, work( ie ),
1299 $ work( itauq ), work( itaup ),
1300 $ work( iwork ), lwork-iwork+1, ierr )
1305 CALL sormbr(
'Q',
'R',
'N', m, n, n, a, lda,
1306 $ work( itauq ), u, ldu, work( iwork ),
1307 $ lwork-iwork+1, ierr )
1312 CALL sorgbr(
'P', n, n, n, a, lda, work( itaup ),
1313 $ work( iwork ), lwork-iwork+1, ierr )
1321 CALL sbdsqr(
'U', n, n, m, 0, s, work( ie ), a,
1322 $ lda, u, ldu, dum, 1, work( iwork ),
1327 ELSE IF( wntvas )
THEN
1334 IF( lwork.GE.n*n+max( 4*n, bdspac ) )
THEN
1339 IF( lwork.GE.wrkbl+lda*n )
THEN
1350 itau = iu + ldwrku*n
1356 CALL sgeqrf( m, n, a, lda, work( itau ),
1357 $ work( iwork ), lwork-iwork+1, ierr )
1361 CALL slacpy(
'U', n, n, a, lda, work( iu ),
1363 CALL slaset(
'L', n-1, n-1, zero, zero,
1364 $ work( iu+1 ), ldwrku )
1369 CALL sorgqr( m, n, n, a, lda, work( itau ),
1370 $ work( iwork ), lwork-iwork+1, ierr )
1379 CALL sgebrd( n, n, work( iu ), ldwrku, s,
1380 $ work( ie ), work( itauq ),
1381 $ work( itaup ), work( iwork ),
1382 $ lwork-iwork+1, ierr )
1383 CALL slacpy(
'U', n, n, work( iu ), ldwrku, vt,
1389 CALL sorgbr(
'Q', n, n, n, work( iu ), ldwrku,
1390 $ work( itauq ), work( iwork ),
1391 $ lwork-iwork+1, ierr )
1397 CALL sorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1398 $ work( iwork ), lwork-iwork+1, ierr )
1406 CALL sbdsqr(
'U', n, n, n, 0, s, work( ie ), vt,
1407 $ ldvt, work( iu ), ldwrku, dum, 1,
1408 $ work( iwork ), info )
1414 CALL sgemm(
'N',
'N', m, n, n, one, a, lda,
1415 $ work( iu ), ldwrku, zero, u, ldu )
1427 CALL sgeqrf( m, n, a, lda, work( itau ),
1428 $ work( iwork ), lwork-iwork+1, ierr )
1429 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1434 CALL sorgqr( m, n, n, u, ldu, work( itau ),
1435 $ work( iwork ), lwork-iwork+1, ierr )
1439 CALL slacpy(
'U', n, n, a, lda, vt, ldvt )
1441 $
CALL slaset(
'L', n-1, n-1, zero, zero,
1442 $ vt( 2, 1 ), ldvt )
1451 CALL sgebrd( n, n, vt, ldvt, s, work( ie ),
1452 $ work( itauq ), work( itaup ),
1453 $ work( iwork ), lwork-iwork+1, ierr )
1459 CALL sormbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1460 $ work( itauq ), u, ldu, work( iwork ),
1461 $ lwork-iwork+1, ierr )
1466 CALL sorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1467 $ work( iwork ), lwork-iwork+1, ierr )
1475 CALL sbdsqr(
'U', n, n, m, 0, s, work( ie ), vt,
1476 $ ldvt, u, ldu, dum, 1, work( iwork ),
1483 ELSE IF( wntua )
THEN
1491 IF( lwork.GE.n*n+max( n+m, 4*n, bdspac ) )
THEN
1496 IF( lwork.GE.wrkbl+lda*n )
THEN
1507 itau = ir + ldwrkr*n
1513 CALL sgeqrf( m, n, a, lda, work( itau ),
1514 $ work( iwork ), lwork-iwork+1, ierr )
1515 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1519 CALL slacpy(
'U', n, n, a, lda, work( ir ),
1521 CALL slaset(
'L', n-1, n-1, zero, zero,
1522 $ work( ir+1 ), ldwrkr )
1527 CALL sorgqr( m, m, n, u, ldu, work( itau ),
1528 $ work( iwork ), lwork-iwork+1, ierr )
1537 CALL sgebrd( n, n, work( ir ), ldwrkr, s,
1538 $ work( ie ), work( itauq ),
1539 $ work( itaup ), work( iwork ),
1540 $ lwork-iwork+1, ierr )
1545 CALL sorgbr(
'Q', n, n, n, work( ir ), ldwrkr,
1546 $ work( itauq ), work( iwork ),
1547 $ lwork-iwork+1, ierr )
1554 CALL sbdsqr(
'U', n, 0, n, 0, s, work( ie ), dum,
1555 $ 1, work( ir ), ldwrkr, dum, 1,
1556 $ work( iwork ), info )
1562 CALL sgemm(
'N',
'N', m, n, n, one, u, ldu,
1563 $ work( ir ), ldwrkr, zero, a, lda )
1567 CALL slacpy(
'F', m, n, a, lda, u, ldu )
1579 CALL sgeqrf( m, n, a, lda, work( itau ),
1580 $ work( iwork ), lwork-iwork+1, ierr )
1581 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1586 CALL sorgqr( m, m, n, u, ldu, work( itau ),
1587 $ work( iwork ), lwork-iwork+1, ierr )
1596 CALL slaset(
'L', n-1, n-1, zero, zero,
1603 CALL sgebrd( n, n, a, lda, s, work( ie ),
1604 $ work( itauq ), work( itaup ),
1605 $ work( iwork ), lwork-iwork+1, ierr )
1611 CALL sormbr(
'Q',
'R',
'N', m, n, n, a, lda,
1612 $ work( itauq ), u, ldu, work( iwork ),
1613 $ lwork-iwork+1, ierr )
1620 CALL sbdsqr(
'U', n, 0, m, 0, s, work( ie ), dum,
1621 $ 1, u, ldu, dum, 1, work( iwork ),
1626 ELSE IF( wntvo )
THEN
1632 IF( lwork.GE.2*n*n+max( n+m, 4*n, bdspac ) )
THEN
1637 IF( lwork.GE.wrkbl+2*lda*n )
THEN
1644 ELSE IF( lwork.GE.wrkbl+( lda+n )*n )
THEN
1659 itau = ir + ldwrkr*n
1665 CALL sgeqrf( m, n, a, lda, work( itau ),
1666 $ work( iwork ), lwork-iwork+1, ierr )
1667 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1672 CALL sorgqr( m, m, n, u, ldu, work( itau ),
1673 $ work( iwork ), lwork-iwork+1, ierr )
1677 CALL slacpy(
'U', n, n, a, lda, work( iu ),
1679 CALL slaset(
'L', n-1, n-1, zero, zero,
1680 $ work( iu+1 ), ldwrku )
1691 CALL sgebrd( n, n, work( iu ), ldwrku, s,
1692 $ work( ie ), work( itauq ),
1693 $ work( itaup ), work( iwork ),
1694 $ lwork-iwork+1, ierr )
1695 CALL slacpy(
'U', n, n, work( iu ), ldwrku,
1696 $ work( ir ), ldwrkr )
1701 CALL sorgbr(
'Q', n, n, n, work( iu ), ldwrku,
1702 $ work( itauq ), work( iwork ),
1703 $ lwork-iwork+1, ierr )
1709 CALL sorgbr(
'P', n, n, n, work( ir ), ldwrkr,
1710 $ work( itaup ), work( iwork ),
1711 $ lwork-iwork+1, ierr )
1719 CALL sbdsqr(
'U', n, n, n, 0, s, work( ie ),
1720 $ work( ir ), ldwrkr, work( iu ),
1721 $ ldwrku, dum, 1, work( iwork ), info )
1727 CALL sgemm(
'N',
'N', m, n, n, one, u, ldu,
1728 $ work( iu ), ldwrku, zero, a, lda )
1732 CALL slacpy(
'F', m, n, a, lda, u, ldu )
1736 CALL slacpy(
'F', n, n, work( ir ), ldwrkr, a,
1749 CALL sgeqrf( m, n, a, lda, work( itau ),
1750 $ work( iwork ), lwork-iwork+1, ierr )
1751 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1756 CALL sorgqr( m, m, n, u, ldu, work( itau ),
1757 $ work( iwork ), lwork-iwork+1, ierr )
1766 CALL slaset(
'L', n-1, n-1, zero, zero,
1773 CALL sgebrd( n, n, a, lda, s, work( ie ),
1774 $ work( itauq ), work( itaup ),
1775 $ work( iwork ), lwork-iwork+1, ierr )
1781 CALL sormbr(
'Q',
'R',
'N', m, n, n, a, lda,
1782 $ work( itauq ), u, ldu, work( iwork ),
1783 $ lwork-iwork+1, ierr )
1788 CALL sorgbr(
'P', n, n, n, a, lda, work( itaup ),
1789 $ work( iwork ), lwork-iwork+1, ierr )
1797 CALL sbdsqr(
'U', n, n, m, 0, s, work( ie ), a,
1798 $ lda, u, ldu, dum, 1, work( iwork ),
1803 ELSE IF( wntvas )
THEN
1810 IF( lwork.GE.n*n+max( n+m, 4*n, bdspac ) )
THEN
1815 IF( lwork.GE.wrkbl+lda*n )
THEN
1826 itau = iu + ldwrku*n
1832 CALL sgeqrf( m, n, a, lda, work( itau ),
1833 $ work( iwork ), lwork-iwork+1, ierr )
1834 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1839 CALL sorgqr( m, m, n, u, ldu, work( itau ),
1840 $ work( iwork ), lwork-iwork+1, ierr )
1844 CALL slacpy(
'U', n, n, a, lda, work( iu ),
1846 CALL slaset(
'L', n-1, n-1, zero, zero,
1847 $ work( iu+1 ), ldwrku )
1856 CALL sgebrd( n, n, work( iu ), ldwrku, s,
1857 $ work( ie ), work( itauq ),
1858 $ work( itaup ), work( iwork ),
1859 $ lwork-iwork+1, ierr )
1860 CALL slacpy(
'U', n, n, work( iu ), ldwrku, vt,
1866 CALL sorgbr(
'Q', n, n, n, work( iu ), ldwrku,
1867 $ work( itauq ), work( iwork ),
1868 $ lwork-iwork+1, ierr )
1874 CALL sorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1875 $ work( iwork ), lwork-iwork+1, ierr )
1883 CALL sbdsqr(
'U', n, n, n, 0, s, work( ie ), vt,
1884 $ ldvt, work( iu ), ldwrku, dum, 1,
1885 $ work( iwork ), info )
1891 CALL sgemm(
'N',
'N', m, n, n, one, u, ldu,
1892 $ work( iu ), ldwrku, zero, a, lda )
1896 CALL slacpy(
'F', m, n, a, lda, u, ldu )
1908 CALL sgeqrf( m, n, a, lda, work( itau ),
1909 $ work( iwork ), lwork-iwork+1, ierr )
1910 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1915 CALL sorgqr( m, m, n, u, ldu, work( itau ),
1916 $ work( iwork ), lwork-iwork+1, ierr )
1920 CALL slacpy(
'U', n, n, a, lda, vt, ldvt )
1922 $
CALL slaset(
'L', n-1, n-1, zero, zero,
1923 $ vt( 2, 1 ), ldvt )
1932 CALL sgebrd( n, n, vt, ldvt, s, work( ie ),
1933 $ work( itauq ), work( itaup ),
1934 $ work( iwork ), lwork-iwork+1, ierr )
1940 CALL sormbr(
'Q',
'R',
'N', m, n, n, vt, ldvt,
1941 $ work( itauq ), u, ldu, work( iwork ),
1942 $ lwork-iwork+1, ierr )
1947 CALL sorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
1948 $ work( iwork ), lwork-iwork+1, ierr )
1956 CALL sbdsqr(
'U', n, n, m, 0, s, work( ie ), vt,
1957 $ ldvt, u, ldu, dum, 1, work( iwork ),
1981 CALL sgebrd( m, n, a, lda, s, work( ie ), work( itauq ),
1982 $ work( itaup ), work( iwork ), lwork-iwork+1,
1990 CALL slacpy(
'L', m, n, a, lda, u, ldu )
1995 CALL sorgbr(
'Q', m, ncu, n, u, ldu, work( itauq ),
1996 $ work( iwork ), lwork-iwork+1, ierr )
2004 CALL slacpy(
'U', n, n, a, lda, vt, ldvt )
2005 CALL sorgbr(
'P', n, n, n, vt, ldvt, work( itaup ),
2006 $ work( iwork ), lwork-iwork+1, ierr )
2014 CALL sorgbr(
'Q', m, n, n, a, lda, work( itauq ),
2015 $ work( iwork ), lwork-iwork+1, ierr )
2023 CALL sorgbr(
'P', n, n, n, a, lda, work( itaup ),
2024 $ work( iwork ), lwork-iwork+1, ierr )
2027 IF( wntuas .OR. wntuo )
2031 IF( wntvas .OR. wntvo )
2035 IF( ( .NOT.wntuo ) .AND. ( .NOT.wntvo ) )
THEN
2042 CALL sbdsqr(
'U', n, ncvt, nru, 0, s, work( ie ), vt,
2043 $ ldvt, u, ldu, dum, 1, work( iwork ), info )
2044 ELSE IF( ( .NOT.wntuo ) .AND. wntvo )
THEN
2051 CALL sbdsqr(
'U', n, ncvt, nru, 0, s, work( ie ), a, lda,
2052 $ u, ldu, dum, 1, work( iwork ), info )
2060 CALL sbdsqr(
'U', n, ncvt, nru, 0, s, work( ie ), vt,
2061 $ ldvt, a, lda, dum, 1, work( iwork ), info )
2072 IF( n.GE.mnthr )
THEN
2085 CALL sgelqf( m, n, a, lda, work( itau ), work( iwork ),
2086 $ lwork-iwork+1, ierr )
2090 CALL slaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ), lda )
2099 CALL sgebrd( m, m, a, lda, s, work( ie ), work( itauq ),
2100 $ work( itaup ), work( iwork ), lwork-iwork+1,
2102 IF( wntuo .OR. wntuas )
THEN
2107 CALL sorgbr(
'Q', m, m, m, a, lda, work( itauq ),
2108 $ work( iwork ), lwork-iwork+1, ierr )
2112 IF( wntuo .OR. wntuas )
2119 CALL sbdsqr(
'U', m, 0, nru, 0, s, work( ie ), dum, 1, a,
2120 $ lda, dum, 1, work( iwork ), info )
2125 $
CALL slacpy(
'F', m, m, a, lda, u, ldu )
2127 ELSE IF( wntvo .AND. wntun )
THEN
2133 IF( lwork.GE.m*m+max( 4*m, bdspac ) )
THEN
2138 IF( lwork.GE.max( wrkbl, lda*n+m )+lda*m )
THEN
2145 ELSE IF( lwork.GE.max( wrkbl, lda*n+m )+m*m )
THEN
2157 chunk = ( lwork-m*m-m ) / m
2160 itau = ir + ldwrkr*m
2166 CALL sgelqf( m, n, a, lda, work( itau ),
2167 $ work( iwork ), lwork-iwork+1, ierr )
2171 CALL slacpy(
'L', m, m, a, lda, work( ir ), ldwrkr )
2172 CALL slaset(
'U', m-1, m-1, zero, zero,
2173 $ work( ir+ldwrkr ), ldwrkr )
2178 CALL sorglq( m, n, m, a, lda, work( itau ),
2179 $ work( iwork ), lwork-iwork+1, ierr )
2188 CALL sgebrd( m, m, work( ir ), ldwrkr, s, work( ie ),
2189 $ work( itauq ), work( itaup ),
2190 $ work( iwork ), lwork-iwork+1, ierr )
2195 CALL sorgbr(
'P', m, m, m, work( ir ), ldwrkr,
2196 $ work( itaup ), work( iwork ),
2197 $ lwork-iwork+1, ierr )
2204 CALL sbdsqr(
'U', m, m, 0, 0, s, work( ie ),
2205 $ work( ir ), ldwrkr, dum, 1, dum, 1,
2206 $ work( iwork ), info )
2213 DO 30 i = 1, n, chunk
2214 blk = min( n-i+1, chunk )
2215 CALL sgemm(
'N',
'N', m, blk, m, one, work( ir ),
2216 $ ldwrkr, a( 1, i ), lda, zero,
2217 $ work( iu ), ldwrku )
2218 CALL slacpy(
'F', m, blk, work( iu ), ldwrku,
2234 CALL sgebrd( m, n, a, lda, s, work( ie ),
2235 $ work( itauq ), work( itaup ),
2236 $ work( iwork ), lwork-iwork+1, ierr )
2241 CALL sorgbr(
'P', m, n, m, a, lda, work( itaup ),
2242 $ work( iwork ), lwork-iwork+1, ierr )
2249 CALL sbdsqr(
'L', m, n, 0, 0, s, work( ie ), a, lda,
2250 $ dum, 1, dum, 1, work( iwork ), info )
2254 ELSE IF( wntvo .AND. wntuas )
THEN
2260 IF( lwork.GE.m*m+max( 4*m, bdspac ) )
THEN
2265 IF( lwork.GE.max( wrkbl, lda*n+m )+lda*m )
THEN
2272 ELSE IF( lwork.GE.max( wrkbl, lda*n+m )+m*m )
THEN
2284 chunk = ( lwork-m*m-m ) / m
2287 itau = ir + ldwrkr*m
2293 CALL sgelqf( m, n, a, lda, work( itau ),
2294 $ work( iwork ), lwork-iwork+1, ierr )
2298 CALL slacpy(
'L', m, m, a, lda, u, ldu )
2299 CALL slaset(
'U', m-1, m-1, zero, zero, u( 1, 2 ),
2305 CALL sorglq( m, n, m, a, lda, work( itau ),
2306 $ work( iwork ), lwork-iwork+1, ierr )
2315 CALL sgebrd( m, m, u, ldu, s, work( ie ),
2316 $ work( itauq ), work( itaup ),
2317 $ work( iwork ), lwork-iwork+1, ierr )
2318 CALL slacpy(
'U', m, m, u, ldu, work( ir ), ldwrkr )
2323 CALL sorgbr(
'P', m, m, m, work( ir ), ldwrkr,
2324 $ work( itaup ), work( iwork ),
2325 $ lwork-iwork+1, ierr )
2330 CALL sorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
2331 $ work( iwork ), lwork-iwork+1, ierr )
2339 CALL sbdsqr(
'U', m, m, m, 0, s, work( ie ),
2340 $ work( ir ), ldwrkr, u, ldu, dum, 1,
2341 $ work( iwork ), info )
2348 DO 40 i = 1, n, chunk
2349 blk = min( n-i+1, chunk )
2350 CALL sgemm(
'N',
'N', m, blk, m, one, work( ir ),
2351 $ ldwrkr, a( 1, i ), lda, zero,
2352 $ work( iu ), ldwrku )
2353 CALL slacpy(
'F', m, blk, work( iu ), ldwrku,
2367 CALL sgelqf( m, n, a, lda, work( itau ),
2368 $ work( iwork ), lwork-iwork+1, ierr )
2372 CALL slacpy(
'L', m, m, a, lda, u, ldu )
2373 CALL slaset(
'U', m-1, m-1, zero, zero, u( 1, 2 ),
2379 CALL sorglq( m, n, m, a, lda, work( itau ),
2380 $ work( iwork ), lwork-iwork+1, ierr )
2389 CALL sgebrd( m, m, u, ldu, s, work( ie ),
2390 $ work( itauq ), work( itaup ),
2391 $ work( iwork ), lwork-iwork+1, ierr )
2396 CALL sormbr(
'P',
'L',
'T', m, n, m, u, ldu,
2397 $ work( itaup ), a, lda, work( iwork ),
2398 $ lwork-iwork+1, ierr )
2403 CALL sorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
2404 $ work( iwork ), lwork-iwork+1, ierr )
2412 CALL sbdsqr(
'U', m, n, m, 0, s, work( ie ), a, lda,
2413 $ u, ldu, dum, 1, work( iwork ), info )
2417 ELSE IF( wntvs )
THEN
2425 IF( lwork.GE.m*m+max( 4*m, bdspac ) )
THEN
2430 IF( lwork.GE.wrkbl+lda*m )
THEN
2441 itau = ir + ldwrkr*m
2447 CALL sgelqf( m, n, a, lda, work( itau ),
2448 $ work( iwork ), lwork-iwork+1, ierr )
2452 CALL slacpy(
'L', m, m, a, lda, work( ir ),
2454 CALL slaset(
'U', m-1, m-1, zero, zero,
2455 $ work( ir+ldwrkr ), ldwrkr )
2460 CALL sorglq( m, n, m, a, lda, work( itau ),
2461 $ work( iwork ), lwork-iwork+1, ierr )
2470 CALL sgebrd( m, m, work( ir ), ldwrkr, s,
2471 $ work( ie ), work( itauq ),
2472 $ work( itaup ), work( iwork ),
2473 $ lwork-iwork+1, ierr )
2479 CALL sorgbr(
'P', m, m, m, work( ir ), ldwrkr,
2480 $ work( itaup ), work( iwork ),
2481 $ lwork-iwork+1, ierr )
2488 CALL sbdsqr(
'U', m, m, 0, 0, s, work( ie ),
2489 $ work( ir ), ldwrkr, dum, 1, dum, 1,
2490 $ work( iwork ), info )
2496 CALL sgemm(
'N',
'N', m, n, m, one, work( ir ),
2497 $ ldwrkr, a, lda, zero, vt, ldvt )
2509 CALL sgelqf( m, n, a, lda, work( itau ),
2510 $ work( iwork ), lwork-iwork+1, ierr )
2514 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
2519 CALL sorglq( m, n, m, vt, ldvt, work( itau ),
2520 $ work( iwork ), lwork-iwork+1, ierr )
2528 CALL slaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ),
2534 CALL sgebrd( m, m, a, lda, s, work( ie ),
2535 $ work( itauq ), work( itaup ),
2536 $ work( iwork ), lwork-iwork+1, ierr )
2541 CALL sormbr(
'P',
'L',
'T', m, n, m, a, lda,
2542 $ work( itaup ), vt, ldvt,
2543 $ work( iwork ), lwork-iwork+1, ierr )
2550 CALL sbdsqr(
'U', m, n, 0, 0, s, work( ie ), vt,
2551 $ ldvt, dum, 1, dum, 1, work( iwork ),
2556 ELSE IF( wntuo )
THEN
2562 IF( lwork.GE.2*m*m+max( 4*m, bdspac ) )
THEN
2567 IF( lwork.GE.wrkbl+2*lda*m )
THEN
2574 ELSE IF( lwork.GE.wrkbl+( lda+m )*m )
THEN
2589 itau = ir + ldwrkr*m
2595 CALL sgelqf( m, n, a, lda, work( itau ),
2596 $ work( iwork ), lwork-iwork+1, ierr )
2600 CALL slacpy(
'L', m, m, a, lda, work( iu ),
2602 CALL slaset(
'U', m-1, m-1, zero, zero,
2603 $ work( iu+ldwrku ), ldwrku )
2608 CALL sorglq( m, n, m, a, lda, work( itau ),
2609 $ work( iwork ), lwork-iwork+1, ierr )
2620 CALL sgebrd( m, m, work( iu ), ldwrku, s,
2621 $ work( ie ), work( itauq ),
2622 $ work( itaup ), work( iwork ),
2623 $ lwork-iwork+1, ierr )
2624 CALL slacpy(
'L', m, m, work( iu ), ldwrku,
2625 $ work( ir ), ldwrkr )
2631 CALL sorgbr(
'P', m, m, m, work( iu ), ldwrku,
2632 $ work( itaup ), work( iwork ),
2633 $ lwork-iwork+1, ierr )
2638 CALL sorgbr(
'Q', m, m, m, work( ir ), ldwrkr,
2639 $ work( itauq ), work( iwork ),
2640 $ lwork-iwork+1, ierr )
2648 CALL sbdsqr(
'U', m, m, m, 0, s, work( ie ),
2649 $ work( iu ), ldwrku, work( ir ),
2650 $ ldwrkr, dum, 1, work( iwork ), info )
2656 CALL sgemm(
'N',
'N', m, n, m, one, work( iu ),
2657 $ ldwrku, a, lda, zero, vt, ldvt )
2662 CALL slacpy(
'F', m, m, work( ir ), ldwrkr, a,
2675 CALL sgelqf( m, n, a, lda, work( itau ),
2676 $ work( iwork ), lwork-iwork+1, ierr )
2677 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
2682 CALL sorglq( m, n, m, vt, ldvt, work( itau ),
2683 $ work( iwork ), lwork-iwork+1, ierr )
2691 CALL slaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ),
2697 CALL sgebrd( m, m, a, lda, s, work( ie ),
2698 $ work( itauq ), work( itaup ),
2699 $ work( iwork ), lwork-iwork+1, ierr )
2704 CALL sormbr(
'P',
'L',
'T', m, n, m, a, lda,
2705 $ work( itaup ), vt, ldvt,
2706 $ work( iwork ), lwork-iwork+1, ierr )
2711 CALL sorgbr(
'Q', m, m, m, a, lda, work( itauq ),
2712 $ work( iwork ), lwork-iwork+1, ierr )
2720 CALL sbdsqr(
'U', m, n, m, 0, s, work( ie ), vt,
2721 $ ldvt, a, lda, dum, 1, work( iwork ),
2726 ELSE IF( wntuas )
THEN
2733 IF( lwork.GE.m*m+max( 4*m, bdspac ) )
THEN
2738 IF( lwork.GE.wrkbl+lda*m )
THEN
2749 itau = iu + ldwrku*m
2755 CALL sgelqf( m, n, a, lda, work( itau ),
2756 $ work( iwork ), lwork-iwork+1, ierr )
2760 CALL slacpy(
'L', m, m, a, lda, work( iu ),
2762 CALL slaset(
'U', m-1, m-1, zero, zero,
2763 $ work( iu+ldwrku ), ldwrku )
2768 CALL sorglq( m, n, m, a, lda, work( itau ),
2769 $ work( iwork ), lwork-iwork+1, ierr )
2778 CALL sgebrd( m, m, work( iu ), ldwrku, s,
2779 $ work( ie ), work( itauq ),
2780 $ work( itaup ), work( iwork ),
2781 $ lwork-iwork+1, ierr )
2782 CALL slacpy(
'L', m, m, work( iu ), ldwrku, u,
2789 CALL sorgbr(
'P', m, m, m, work( iu ), ldwrku,
2790 $ work( itaup ), work( iwork ),
2791 $ lwork-iwork+1, ierr )
2796 CALL sorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
2797 $ work( iwork ), lwork-iwork+1, ierr )
2805 CALL sbdsqr(
'U', m, m, m, 0, s, work( ie ),
2806 $ work( iu ), ldwrku, u, ldu, dum, 1,
2807 $ work( iwork ), info )
2813 CALL sgemm(
'N',
'N', m, n, m, one, work( iu ),
2814 $ ldwrku, a, lda, zero, vt, ldvt )
2826 CALL sgelqf( m, n, a, lda, work( itau ),
2827 $ work( iwork ), lwork-iwork+1, ierr )
2828 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
2833 CALL sorglq( m, n, m, vt, ldvt, work( itau ),
2834 $ work( iwork ), lwork-iwork+1, ierr )
2838 CALL slacpy(
'L', m, m, a, lda, u, ldu )
2839 CALL slaset(
'U', m-1, m-1, zero, zero, u( 1, 2 ),
2849 CALL sgebrd( m, m, u, ldu, s, work( ie ),
2850 $ work( itauq ), work( itaup ),
2851 $ work( iwork ), lwork-iwork+1, ierr )
2857 CALL sormbr(
'P',
'L',
'T', m, n, m, u, ldu,
2858 $ work( itaup ), vt, ldvt,
2859 $ work( iwork ), lwork-iwork+1, ierr )
2864 CALL sorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
2865 $ work( iwork ), lwork-iwork+1, ierr )
2873 CALL sbdsqr(
'U', m, n, m, 0, s, work( ie ), vt,
2874 $ ldvt, u, ldu, dum, 1, work( iwork ),
2881 ELSE IF( wntva )
THEN
2889 IF( lwork.GE.m*m+max( n+m, 4*m, bdspac ) )
THEN
2894 IF( lwork.GE.wrkbl+lda*m )
THEN
2905 itau = ir + ldwrkr*m
2911 CALL sgelqf( m, n, a, lda, work( itau ),
2912 $ work( iwork ), lwork-iwork+1, ierr )
2913 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
2917 CALL slacpy(
'L', m, m, a, lda, work( ir ),
2919 CALL slaset(
'U', m-1, m-1, zero, zero,
2920 $ work( ir+ldwrkr ), ldwrkr )
2925 CALL sorglq( n, n, m, vt, ldvt, work( itau ),
2926 $ work( iwork ), lwork-iwork+1, ierr )
2935 CALL sgebrd( m, m, work( ir ), ldwrkr, s,
2936 $ work( ie ), work( itauq ),
2937 $ work( itaup ), work( iwork ),
2938 $ lwork-iwork+1, ierr )
2944 CALL sorgbr(
'P', m, m, m, work( ir ), ldwrkr,
2945 $ work( itaup ), work( iwork ),
2946 $ lwork-iwork+1, ierr )
2953 CALL sbdsqr(
'U', m, m, 0, 0, s, work( ie ),
2954 $ work( ir ), ldwrkr, dum, 1, dum, 1,
2955 $ work( iwork ), info )
2961 CALL sgemm(
'N',
'N', m, n, m, one, work( ir ),
2962 $ ldwrkr, vt, ldvt, zero, a, lda )
2966 CALL slacpy(
'F', m, n, a, lda, vt, ldvt )
2978 CALL sgelqf( m, n, a, lda, work( itau ),
2979 $ work( iwork ), lwork-iwork+1, ierr )
2980 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
2985 CALL sorglq( n, n, m, vt, ldvt, work( itau ),
2986 $ work( iwork ), lwork-iwork+1, ierr )
2994 CALL slaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ),
3000 CALL sgebrd( m, m, a, lda, s, work( ie ),
3001 $ work( itauq ), work( itaup ),
3002 $ work( iwork ), lwork-iwork+1, ierr )
3008 CALL sormbr(
'P',
'L',
'T', m, n, m, a, lda,
3009 $ work( itaup ), vt, ldvt,
3010 $ work( iwork ), lwork-iwork+1, ierr )
3017 CALL sbdsqr(
'U', m, n, 0, 0, s, work( ie ), vt,
3018 $ ldvt, dum, 1, dum, 1, work( iwork ),
3023 ELSE IF( wntuo )
THEN
3029 IF( lwork.GE.2*m*m+max( n+m, 4*m, bdspac ) )
THEN
3034 IF( lwork.GE.wrkbl+2*lda*m )
THEN
3041 ELSE IF( lwork.GE.wrkbl+( lda+m )*m )
THEN
3056 itau = ir + ldwrkr*m
3062 CALL sgelqf( m, n, a, lda, work( itau ),
3063 $ work( iwork ), lwork-iwork+1, ierr )
3064 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
3069 CALL sorglq( n, n, m, vt, ldvt, work( itau ),
3070 $ work( iwork ), lwork-iwork+1, ierr )
3074 CALL slacpy(
'L', m, m, a, lda, work( iu ),
3076 CALL slaset(
'U', m-1, m-1, zero, zero,
3077 $ work( iu+ldwrku ), ldwrku )
3088 CALL sgebrd( m, m, work( iu ), ldwrku, s,
3089 $ work( ie ), work( itauq ),
3090 $ work( itaup ), work( iwork ),
3091 $ lwork-iwork+1, ierr )
3092 CALL slacpy(
'L', m, m, work( iu ), ldwrku,
3093 $ work( ir ), ldwrkr )
3099 CALL sorgbr(
'P', m, m, m, work( iu ), ldwrku,
3100 $ work( itaup ), work( iwork ),
3101 $ lwork-iwork+1, ierr )
3106 CALL sorgbr(
'Q', m, m, m, work( ir ), ldwrkr,
3107 $ work( itauq ), work( iwork ),
3108 $ lwork-iwork+1, ierr )
3116 CALL sbdsqr(
'U', m, m, m, 0, s, work( ie ),
3117 $ work( iu ), ldwrku, work( ir ),
3118 $ ldwrkr, dum, 1, work( iwork ), info )
3124 CALL sgemm(
'N',
'N', m, n, m, one, work( iu ),
3125 $ ldwrku, vt, ldvt, zero, a, lda )
3129 CALL slacpy(
'F', m, n, a, lda, vt, ldvt )
3133 CALL slacpy(
'F', m, m, work( ir ), ldwrkr, a,
3146 CALL sgelqf( m, n, a, lda, work( itau ),
3147 $ work( iwork ), lwork-iwork+1, ierr )
3148 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
3153 CALL sorglq( n, n, m, vt, ldvt, work( itau ),
3154 $ work( iwork ), lwork-iwork+1, ierr )
3162 CALL slaset(
'U', m-1, m-1, zero, zero, a( 1, 2 ),
3168 CALL sgebrd( m, m, a, lda, s, work( ie ),
3169 $ work( itauq ), work( itaup ),
3170 $ work( iwork ), lwork-iwork+1, ierr )
3176 CALL sormbr(
'P',
'L',
'T', m, n, m, a, lda,
3177 $ work( itaup ), vt, ldvt,
3178 $ work( iwork ), lwork-iwork+1, ierr )
3183 CALL sorgbr(
'Q', m, m, m, a, lda, work( itauq ),
3184 $ work( iwork ), lwork-iwork+1, ierr )
3192 CALL sbdsqr(
'U', m, n, m, 0, s, work( ie ), vt,
3193 $ ldvt, a, lda, dum, 1, work( iwork ),
3198 ELSE IF( wntuas )
THEN
3205 IF( lwork.GE.m*m+max( n+m, 4*m, bdspac ) )
THEN
3210 IF( lwork.GE.wrkbl+lda*m )
THEN
3221 itau = iu + ldwrku*m
3227 CALL sgelqf( m, n, a, lda, work( itau ),
3228 $ work( iwork ), lwork-iwork+1, ierr )
3229 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
3234 CALL sorglq( n, n, m, vt, ldvt, work( itau ),
3235 $ work( iwork ), lwork-iwork+1, ierr )
3239 CALL slacpy(
'L', m, m, a, lda, work( iu ),
3241 CALL slaset(
'U', m-1, m-1, zero, zero,
3242 $ work( iu+ldwrku ), ldwrku )
3251 CALL sgebrd( m, m, work( iu ), ldwrku, s,
3252 $ work( ie ), work( itauq ),
3253 $ work( itaup ), work( iwork ),
3254 $ lwork-iwork+1, ierr )
3255 CALL slacpy(
'L', m, m, work( iu ), ldwrku, u,
3261 CALL sorgbr(
'P', m, m, m, work( iu ), ldwrku,
3262 $ work( itaup ), work( iwork ),
3263 $ lwork-iwork+1, ierr )
3268 CALL sorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
3269 $ work( iwork ), lwork-iwork+1, ierr )
3277 CALL sbdsqr(
'U', m, m, m, 0, s, work( ie ),
3278 $ work( iu ), ldwrku, u, ldu, dum, 1,
3279 $ work( iwork ), info )
3285 CALL sgemm(
'N',
'N', m, n, m, one, work( iu ),
3286 $ ldwrku, vt, ldvt, zero, a, lda )
3290 CALL slacpy(
'F', m, n, a, lda, vt, ldvt )
3302 CALL sgelqf( m, n, a, lda, work( itau ),
3303 $ work( iwork ), lwork-iwork+1, ierr )
3304 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
3309 CALL sorglq( n, n, m, vt, ldvt, work( itau ),
3310 $ work( iwork ), lwork-iwork+1, ierr )
3314 CALL slacpy(
'L', m, m, a, lda, u, ldu )
3315 CALL slaset(
'U', m-1, m-1, zero, zero, u( 1, 2 ),
3325 CALL sgebrd( m, m, u, ldu, s, work( ie ),
3326 $ work( itauq ), work( itaup ),
3327 $ work( iwork ), lwork-iwork+1, ierr )
3333 CALL sormbr(
'P',
'L',
'T', m, n, m, u, ldu,
3334 $ work( itaup ), vt, ldvt,
3335 $ work( iwork ), lwork-iwork+1, ierr )
3340 CALL sorgbr(
'Q', m, m, m, u, ldu, work( itauq ),
3341 $ work( iwork ), lwork-iwork+1, ierr )
3349 CALL sbdsqr(
'U', m, n, m, 0, s, work( ie ), vt,
3350 $ ldvt, u, ldu, dum, 1, work( iwork ),
3374 CALL sgebrd( m, n, a, lda, s, work( ie ), work( itauq ),
3375 $ work( itaup ), work( iwork ), lwork-iwork+1,
3383 CALL slacpy(
'L', m, m, a, lda, u, ldu )
3384 CALL sorgbr(
'Q', m, m, n, u, ldu, work( itauq ),
3385 $ work( iwork ), lwork-iwork+1, ierr )
3393 CALL slacpy(
'U', m, n, a, lda, vt, ldvt )
3398 CALL sorgbr(
'P', nrvt, n, m, vt, ldvt, work( itaup ),
3399 $ work( iwork ), lwork-iwork+1, ierr )
3407 CALL sorgbr(
'Q', m, m, n, a, lda, work( itauq ),
3408 $ work( iwork ), lwork-iwork+1, ierr )
3416 CALL sorgbr(
'P', m, n, m, a, lda, work( itaup ),
3417 $ work( iwork ), lwork-iwork+1, ierr )
3420 IF( wntuas .OR. wntuo )
3424 IF( wntvas .OR. wntvo )
3428 IF( ( .NOT.wntuo ) .AND. ( .NOT.wntvo ) )
THEN
3435 CALL sbdsqr(
'L', m, ncvt, nru, 0, s, work( ie ), vt,
3436 $ ldvt, u, ldu, dum, 1, work( iwork ), info )
3437 ELSE IF( ( .NOT.wntuo ) .AND. wntvo )
THEN
3444 CALL sbdsqr(
'L', m, ncvt, nru, 0, s, work( ie ), a, lda,
3445 $ u, ldu, dum, 1, work( iwork ), info )
3453 CALL sbdsqr(
'L', m, ncvt, nru, 0, s, work( ie ), vt,
3454 $ ldvt, a, lda, dum, 1, work( iwork ), info )
3464 IF( info.NE.0 )
THEN
3466 DO 50 i = 1, minmn - 1
3467 work( i+1 ) = work( i+ie-1 )
3471 DO 60 i = minmn - 1, 1, -1
3472 work( i+1 ) = work( i+ie-1 )
3479 IF( iscl.EQ.1 )
THEN
3480 IF( anrm.GT.bignum )
3481 $
CALL slascl(
'G', 0, 0, bignum, anrm, minmn, 1, s, minmn,
3483 IF( info.NE.0 .AND. anrm.GT.bignum )
3484 $
CALL slascl(
'G', 0, 0, bignum, anrm, minmn-1, 1, work( 2 ),
3486 IF( anrm.LT.smlnum )
3487 $
CALL slascl(
'G', 0, 0, smlnum, anrm, minmn, 1, s, minmn,
3489 IF( info.NE.0 .AND. anrm.LT.smlnum )
3490 $
CALL slascl(
'G', 0, 0, smlnum, anrm, minmn-1, 1, work( 2 ),
3496 work( 1 ) = sroundup_lwork(maxwrk)
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
subroutine sgesvd(jobu, jobvt, m, n, a, lda, s, u, ldu, vt, ldvt, work, lwork, info)
SGESVD computes the singular value decomposition (SVD) for GE matrices
subroutine slacpy(uplo, m, n, a, lda, b, ldb)
SLACPY copies all or part of one two-dimensional array to another.
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.
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