1 SUBROUTINE dlatms( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX,
2 $ KL, KU, PACK, A, LDA, WORK, INFO )
9 CHARACTER DIST, PACK, SYM
10 INTEGER INFO, KL, KU, LDA, M, MODE, N
11 DOUBLE PRECISION COND, DMAX
15 DOUBLE PRECISION A( LDA, * ), D( * ), WORK( * )
253 DOUBLE PRECISION ZERO
254 parameter( zero = 0.0d0 )
256 parameter( one = 1.0d0 )
257 DOUBLE PRECISION TWOPI
258 parameter( twopi = 6.2831853071795864769252867663d+0 )
261 LOGICAL GIVENS, ILEXTR, ILTEMP, TOPDWN
262 INTEGER I, IC, ICOL, IDIST, IENDCH, IINFO, IL, ILDA,
263 $ ioffg, ioffst, ipack, ipackg, ir, ir1, ir2,
264 $ irow, irsign, iskew, isym, isympk, j, jc, jch,
265 $ jkl, jku, jr, k, llb, minlda, mnmin, mr, nc,
267 DOUBLE PRECISION ALPHA, ANGLE, C, DUMMY, EXTRA, S, TEMP
271 DOUBLE PRECISION DLARND
272 EXTERNAL lsame, dlarnd
279 INTRINSIC abs, cos, dble,
max,
min, mod, sin
290 IF( m.EQ.0 .OR. n.EQ.0 )
295 IF( lsame( dist,
'U' ) )
THEN
297 ELSE IF( lsame( dist,
'S' ) )
THEN
299 ELSE IF( lsame( dist,
'N' ) )
THEN
307 IF( lsame( sym,
'N' ) )
THEN
310 ELSE IF( lsame( sym,
'P' ) )
THEN
313 ELSE IF( lsame( sym,
'S' ) )
THEN
316 ELSE IF( lsame( sym,
'H' ) )
THEN
326 IF( lsame( pack,
'N' ) )
THEN
328 ELSE IF( lsame( pack,
'U' ) )
THEN
331 ELSE IF( lsame( pack,
'L' ) )
THEN
334 ELSE IF( lsame( pack,
'C' ) )
THEN
337 ELSE IF( lsame( pack,
'R' ) )
THEN
340 ELSE IF( lsame( pack,
'B' ) )
THEN
343 ELSE IF( lsame( pack,
'Q' ) )
THEN
346 ELSE IF( lsame( pack,
'Z' ) )
THEN
362 IF( ipack.EQ.5 .OR. ipack.EQ.6 )
THEN
364 ELSE IF( ipack.EQ.7 )
THEN
365 minlda = llb + uub + 1
375 IF( dble( llb+uub ).LT.0.3d0*dble(
max( 1, mr+nc ) ) )
381 IF( lda.LT.m .AND. lda.GE.minlda )
388 ELSE IF( m.NE.n .AND. isym.NE.1 )
THEN
390 ELSE IF( n.LT.0 )
THEN
392 ELSE IF( idist.EQ.-1 )
THEN
394 ELSE IF( isym.EQ.-1 )
THEN
396 ELSE IF( abs( mode ).GT.6 )
THEN
398 ELSE IF( ( mode.NE.0 .AND. abs( mode ).NE.6 ) .AND. cond.LT.one )
401 ELSE IF( kl.LT.0 )
THEN
403 ELSE IF( ku.LT.0 .OR. ( isym.NE.1 .AND. kl.NE.ku ) )
THEN
405 ELSE IF( ipack.EQ.-1 .OR. ( isympk.EQ.1 .AND. isym.EQ.1 ) .OR.
406 $ ( isympk.EQ.2 .AND. isym.EQ.1 .AND. kl.GT.0 ) .OR.
407 $ ( isympk.EQ.3 .AND. isym.EQ.1 .AND. ku.GT.0 ) .OR.
408 $ ( isympk.NE.0 .AND. m.NE.n ) )
THEN
410 ELSE IF( lda.LT.
max( 1, minlda ) )
THEN
415 CALL xerbla(
'DLATMS', -info )
422 iseed( i ) = mod( abs( iseed( i ) ), 4096 )
425 IF( mod( iseed( 4 ), 2 ).NE.1 )
426 $ iseed( 4 ) = iseed( 4 ) + 1
432 CALL dlatm1( mode, cond, irsign, idist, iseed, d, mnmin, iinfo )
433 IF( iinfo.NE.0 )
THEN
441 IF( abs( d( 1 ) ).LE.abs( d( mnmin ) ) )
THEN
447 IF( mode.NE.0 .AND. abs( mode ).NE.6 )
THEN
453 temp =
max( temp, abs( d( i ) ) )
456 IF( temp.GT.zero )
THEN
463 CALL dscal( mnmin, alpha, d, 1 )
476 IF( ipack.GT.4 )
THEN
479 IF( ipack.GT.5 )
THEN
495 CALL dlaset(
'Full', lda, n, zero, zero, a, lda )
500 IF( llb.EQ.0 .AND. uub.EQ.0 )
THEN
501 CALL dcopy( mnmin, d, 1, a( 1-iskew+ioffst, 1 ), ilda+1 )
502 IF( ipack.LE.2 .OR. ipack.GE.5 )
505 ELSE IF( givens )
THEN
514 IF( ipack.GT.4 )
THEN
520 CALL dcopy( mnmin, d, 1, a( 1-iskew+ioffst, 1 ), ilda+1 )
531 DO 40 jr = 1,
min( m+jku, n ) + jkl - 1
533 angle = twopi*dlarnd( 1, iseed )
536 icol =
max( 1, jr-jkl )
538 il =
min( n, jr+jku ) + 1 - icol
539 CALL dlarot( .true., jr.GT.jkl, .false., il, c,
540 $ s, a( jr-iskew*icol+ioffst, icol ),
541 $ ilda, extra, dummy )
548 DO 30 jch = jr - jkl, 1, -jkl - jku
550 CALL dlartg( a( ir+1-iskew*( ic+1 )+ioffst,
551 $ ic+1 ), extra, c, s, dummy )
553 irow =
max( 1, jch-jku )
557 CALL dlarot( .false., iltemp, .true., il, c, -s,
558 $ a( irow-iskew*ic+ioffst, ic ),
559 $ ilda, temp, extra )
561 CALL dlartg( a( irow+1-iskew*( ic+1 )+ioffst,
562 $ ic+1 ), temp, c, s, dummy )
563 icol =
max( 1, jch-jku-jkl )
566 CALL dlarot( .true., jch.GT.jku+jkl, .true.,
567 $ il, c, -s, a( irow-iskew*icol+
568 $ ioffst, icol ), ilda, extra,
582 DO 70 jc = 1,
min( n+jkl, m ) + jku - 1
584 angle = twopi*dlarnd( 1, iseed )
587 irow =
max( 1, jc-jku )
589 il =
min( m, jc+jkl ) + 1 - irow
590 CALL dlarot( .false., jc.GT.jku, .false., il, c,
591 $ s, a( irow-iskew*jc+ioffst, jc ),
592 $ ilda, extra, dummy )
599 DO 60 jch = jc - jku, 1, -jkl - jku
601 CALL dlartg( a( ir+1-iskew*( ic+1 )+ioffst,
602 $ ic+1 ), extra, c, s, dummy )
604 icol =
max( 1, jch-jkl )
608 CALL dlarot( .true., iltemp, .true., il, c, -s,
609 $ a( ir-iskew*icol+ioffst, icol ),
610 $ ilda, temp, extra )
612 CALL dlartg( a( ir+1-iskew*( icol+1 )+ioffst,
613 $ icol+1 ), temp, c, s, dummy )
614 irow =
max( 1, jch-jkl-jku )
617 CALL dlarot( .false., jch.GT.jkl+jku, .true.,
618 $ il, c, -s, a( irow-iskew*icol+
619 $ ioffst, icol ), ilda, extra,
640 iendch =
min( m, n+jkl ) - 1
641 DO 100 jc =
min( m+jku, n ) - 1, 1 - jkl, -1
643 angle = twopi*dlarnd( 1, iseed )
646 irow =
max( 1, jc-jku+1 )
648 il =
min( m, jc+jkl+1 ) + 1 - irow
649 CALL dlarot( .false., .false., jc+jkl.LT.m, il,
650 $ c, s, a( irow-iskew*jc+ioffst,
651 $ jc ), ilda, dummy, extra )
657 DO 90 jch = jc + jkl, iendch, jkl + jku
660 CALL dlartg( a( jch-iskew*ic+ioffst, ic ),
661 $ extra, c, s, dummy )
664 icol =
min( n-1, jch+jku )
665 iltemp = jch + jku.LT.n
667 CALL dlarot( .true., ilextr, iltemp, icol+2-ic,
668 $ c, s, a( jch-iskew*ic+ioffst, ic ),
669 $ ilda, extra, temp )
671 CALL dlartg( a( jch-iskew*icol+ioffst,
672 $ icol ), temp, c, s, dummy )
673 il =
min( iendch, jch+jkl+jku ) + 2 - jch
675 CALL dlarot( .false., .true.,
676 $ jch+jkl+jku.LE.iendch, il, c, s,
677 $ a( jch-iskew*icol+ioffst,
678 $ icol ), ilda, temp, extra )
693 iendch =
min( n, m+jku ) - 1
694 DO 130 jr =
min( n+jkl, m ) - 1, 1 - jku, -1
696 angle = twopi*dlarnd( 1, iseed )
699 icol =
max( 1, jr-jkl+1 )
701 il =
min( n, jr+jku+1 ) + 1 - icol
702 CALL dlarot( .true., .false., jr+jku.LT.n, il,
703 $ c, s, a( jr-iskew*icol+ioffst,
704 $ icol ), ilda, dummy, extra )
710 DO 120 jch = jr + jku, iendch, jkl + jku
713 CALL dlartg( a( ir-iskew*jch+ioffst, jch ),
714 $ extra, c, s, dummy )
717 irow =
min( m-1, jch+jkl )
718 iltemp = jch + jkl.LT.m
720 CALL dlarot( .false., ilextr, iltemp, irow+2-ir,
721 $ c, s, a( ir-iskew*jch+ioffst,
722 $ jch ), ilda, extra, temp )
724 CALL dlartg( a( irow-iskew*jch+ioffst, jch ),
725 $ temp, c, s, dummy )
726 il =
min( iendch, jch+jkl+jku ) + 2 - jch
728 CALL dlarot( .true., .true.,
729 $ jch+jkl+jku.LE.iendch, il, c, s,
730 $ a( irow-iskew*jch+ioffst, jch ),
731 $ ilda, temp, extra )
750 IF( ipack.GE.5 )
THEN
756 CALL dcopy( mnmin, d, 1, a( 1-iskew+ioffg, 1 ), ilda+1 )
760 irow =
max( 1, jc-k )
761 il =
min( jc+1, k+2 )
763 temp = a( jc-iskew*( jc+1 )+ioffg, jc+1 )
764 angle = twopi*dlarnd( 1, iseed )
767 CALL dlarot( .false., jc.GT.k, .true., il, c, s,
768 $ a( irow-iskew*jc+ioffg, jc ), ilda,
770 CALL dlarot( .true., .true., .false.,
771 $
min( k, n-jc )+1, c, s,
772 $ a( ( 1-iskew )*jc+ioffg, jc ), ilda,
778 DO 150 jch = jc - k, 1, -k
779 CALL dlartg( a( jch+1-iskew*( icol+1 )+ioffg,
780 $ icol+1 ), extra, c, s, dummy )
781 temp = a( jch-iskew*( jch+1 )+ioffg, jch+1 )
782 CALL dlarot( .true., .true., .true., k+2, c, -s,
783 $ a( ( 1-iskew )*jch+ioffg, jch ),
784 $ ilda, temp, extra )
785 irow =
max( 1, jch-k )
786 il =
min( jch+1, k+2 )
788 CALL dlarot( .false., jch.GT.k, .true., il, c,
789 $ -s, a( irow-iskew*jch+ioffg, jch ),
790 $ ilda, extra, temp )
799 IF( ipack.NE.ipackg .AND. ipack.NE.3 )
THEN
801 irow = ioffst - iskew*jc
802 DO 180 jr = jc,
min( n, jc+uub )
803 a( jr+irow, jc ) = a( jc-iskew*jr+ioffg, jr )
806 IF( ipack.EQ.5 )
THEN
807 DO 210 jc = n - uub + 1, n
808 DO 200 jr = n + 2 - jc, uub + 1
813 IF( ipackg.EQ.6 )
THEN
823 IF( ipack.GE.5 )
THEN
830 CALL dcopy( mnmin, d, 1, a( 1-iskew+ioffg, 1 ), ilda+1 )
833 DO 230 jc = n - 1, 1, -1
834 il =
min( n+1-jc, k+2 )
836 temp = a( 1+( 1-iskew )*jc+ioffg, jc )
837 angle = twopi*dlarnd( 1, iseed )
840 CALL dlarot( .false., .true., n-jc.GT.k, il, c, s,
841 $ a( ( 1-iskew )*jc+ioffg, jc ), ilda,
843 icol =
max( 1, jc-k+1 )
844 CALL dlarot( .true., .false., .true., jc+2-icol, c,
845 $ s, a( jc-iskew*icol+ioffg, icol ),
846 $ ilda, dummy, temp )
851 DO 220 jch = jc + k, n - 1, k
852 CALL dlartg( a( jch-iskew*icol+ioffg, icol ),
853 $ extra, c, s, dummy )
854 temp = a( 1+( 1-iskew )*jch+ioffg, jch )
855 CALL dlarot( .true., .true., .true., k+2, c, s,
856 $ a( jch-iskew*icol+ioffg, icol ),
857 $ ilda, extra, temp )
858 il =
min( n+1-jch, k+2 )
860 CALL dlarot( .false., .true., n-jch.GT.k, il, c,
861 $ s, a( ( 1-iskew )*jch+ioffg, jch ),
862 $ ilda, temp, extra )
871 IF( ipack.NE.ipackg .AND. ipack.NE.4 )
THEN
873 irow = ioffst - iskew*jc
874 DO 250 jr = jc,
max( 1, jc-uub ), -1
875 a( jr+irow, jc ) = a( jc-iskew*jr+ioffg, jr )
878 IF( ipack.EQ.6 )
THEN
880 DO 270 jr = 1, uub + 1 - jc
885 IF( ipackg.EQ.5 )
THEN
907 CALL dlagge( mr, nc, llb, uub, d, a, lda, iseed, work,
913 CALL dlagsy( m, llb, d, a, lda, iseed, work, iinfo )
916 IF( iinfo.NE.0 )
THEN
924 IF( ipack.NE.ipackg )
THEN
925 IF( ipack.EQ.1 )
THEN
935 ELSE IF( ipack.EQ.2 )
THEN
945 ELSE IF( ipack.EQ.3 )
THEN
954 IF( irow.GT.lda )
THEN
958 a( irow, icol ) = a( i, j )
962 ELSE IF( ipack.EQ.4 )
THEN
971 IF( irow.GT.lda )
THEN
975 a( irow, icol ) = a( i, j )
979 ELSE IF( ipack.GE.5 )
THEN
991 DO 370 i =
min( j+llb, m ), 1, -1
992 a( i-j+uub+1, j ) = a( i, j )
996 DO 400 j = uub + 2, n
997 DO 390 i = j - uub,
min( j+llb, m )
998 a( i-j+uub+1, j ) = a( i, j )
1008 IF( ipack.EQ.3 .OR. ipack.EQ.4 )
THEN
1010 DO 410 jr = irow + 1, lda
1016 ELSE IF( ipack.GE.5 )
THEN
1027 DO 430 jr = 1, uub + 1 - jc
1030 DO 440 jr =
max( 1,
min( ir1, ir2-jc ) ), lda