133 SUBROUTINE dlattb( IMAT, UPLO, TRANS, DIAG, ISEED, N, KD, AB,
134 $ LDAB, B, WORK, INFO )
141 CHARACTER DIAG, TRANS, UPLO
142 INTEGER IMAT, INFO, KD, LDAB, N
146 DOUBLE PRECISION AB( LDAB, * ), B( * ), WORK( * )
152 DOUBLE PRECISION ONE, TWO, ZERO
153 parameter( one = 1.0d+0, two = 2.0d+0, zero = 0.0d+0 )
157 CHARACTER DIST, PACKIT, TYPE
159 INTEGER I, IOFF, IY, J, JCOUNT, KL, KU, LENJ, MODE
160 DOUBLE PRECISION ANORM, BIGNUM, BNORM, BSCAL, CNDNUM, PLUS1,
161 $ plus2, rexp, sfac, smlnum, star1, texp, tleft,
162 $ tnorm, tscal, ulp, unfl
167 DOUBLE PRECISION DLAMCH, DLARND
168 EXTERNAL lsame, idamax, dlamch, dlarnd
174 INTRINSIC abs, dble, max, min, sign, sqrt
178 path( 1: 1 ) =
'Double precision'
180 unfl = dlamch(
'Safe minimum' )
181 ulp = dlamch(
'Epsilon' )*dlamch(
'Base' )
183 bignum = ( one-ulp ) / smlnum
184 IF( ( imat.GE.6 .AND. imat.LE.9 ) .OR. imat.EQ.17 )
THEN
198 upper = lsame( uplo,
'U' )
200 CALL dlatb4( path, imat, n, n,
TYPE, kl, ku, anorm, mode,
203 ioff = 1 + max( 0, kd-n+1 )
207 CALL dlatb4( path, -imat, n, n,
TYPE, kl, ku, anorm, mode,
218 CALL dlatms( n, n, dist, iseed,
TYPE, b, mode, cndnum, anorm,
219 $ kl, ku, packit, ab( ioff, 1 ), ldab, work, info )
226 ELSE IF( imat.EQ.6 )
THEN
229 DO 10 i = max( 1, kd+2-j ), kd
237 DO 30 i = 2, min( kd+1, n-j+1 )
248 ELSE IF( imat.LE.9 )
THEN
249 tnorm = sqrt( cndnum )
255 DO 50 i = max( 1, kd+2-j ), kd
258 ab( kd+1, j ) = dble( j )
262 DO 70 i = 2, min( kd+1, n-j+1 )
265 ab( 1, j ) = dble( j )
274 ab( 1, 2 ) = sign( tnorm, dlarnd( 2, iseed ) )
276 CALL dlarnv( 2, iseed, lenj, work )
278 ab( 1, 2*( j+1 ) ) = tnorm*work( j )
281 ab( 2, 1 ) = sign( tnorm, dlarnd( 2, iseed ) )
283 CALL dlarnv( 2, iseed, lenj, work )
285 ab( 2, 2*j+1 ) = tnorm*work( j )
288 ELSE IF( kd.GT.1 )
THEN
306 star1 = sign( tnorm, dlarnd( 2, iseed ) )
308 plus1 = sign( sfac, dlarnd( 2, iseed ) )
310 plus2 = star1 / plus1
316 plus1 = star1 / plus2
321 rexp = dlarnd( 2, iseed )
322 IF( rexp.LT.zero )
THEN
323 star1 = -sfac**( one-rexp )
325 star1 = sfac**( one+rexp )
333 CALL dcopy( n-1, work, 1, ab( kd, 2 ), ldab )
334 CALL dcopy( n-2, work( n+1 ), 1, ab( kd-1, 3 ), ldab )
336 CALL dcopy( n-1, work, 1, ab( 2, 1 ), ldab )
337 CALL dcopy( n-2, work( n+1 ), 1, ab( 3, 1 ), ldab )
345 ELSE IF( imat.EQ.10 )
THEN
353 lenj = min( j, kd+1 )
354 CALL dlarnv( 2, iseed, lenj, ab( kd+2-lenj, j ) )
355 ab( kd+1, j ) = sign( two, ab( kd+1, j ) )
359 lenj = min( n-j+1, kd+1 )
361 $
CALL dlarnv( 2, iseed, lenj, ab( 1, j ) )
362 ab( 1, j ) = sign( two, ab( 1, j ) )
368 CALL dlarnv( 2, iseed, n, b )
369 iy = idamax( n, b, 1 )
370 bnorm = abs( b( iy ) )
371 bscal = bignum / max( one, bnorm )
372 CALL dscal( n, bscal, b, 1 )
374 ELSE IF( imat.EQ.11 )
THEN
380 CALL dlarnv( 2, iseed, n, b )
381 tscal = one / dble( kd+1 )
384 lenj = min( j, kd+1 )
385 CALL dlarnv( 2, iseed, lenj, ab( kd+2-lenj, j ) )
386 CALL dscal( lenj-1, tscal, ab( kd+2-lenj, j ), 1 )
387 ab( kd+1, j ) = sign( one, ab( kd+1, j ) )
389 ab( kd+1, n ) = smlnum*ab( kd+1, n )
392 lenj = min( n-j+1, kd+1 )
393 CALL dlarnv( 2, iseed, lenj, ab( 1, j ) )
395 $
CALL dscal( lenj-1, tscal, ab( 2, j ), 1 )
396 ab( 1, j ) = sign( one, ab( 1, j ) )
398 ab( 1, 1 ) = smlnum*ab( 1, 1 )
401 ELSE IF( imat.EQ.12 )
THEN
407 CALL dlarnv( 2, iseed, n, b )
410 lenj = min( j, kd+1 )
411 CALL dlarnv( 2, iseed, lenj, ab( kd+2-lenj, j ) )
412 ab( kd+1, j ) = sign( one, ab( kd+1, j ) )
414 ab( kd+1, n ) = smlnum*ab( kd+1, n )
417 lenj = min( n-j+1, kd+1 )
418 CALL dlarnv( 2, iseed, lenj, ab( 1, j ) )
419 ab( 1, j ) = sign( one, ab( 1, j ) )
421 ab( 1, 1 ) = smlnum*ab( 1, 1 )
424 ELSE IF( imat.EQ.13 )
THEN
433 DO 180 i = max( 1, kd+1-( j-1 ) ), kd
436 IF( jcount.LE.2 )
THEN
437 ab( kd+1, j ) = smlnum
448 DO 200 i = 2, min( n-j+1, kd+1 )
451 IF( jcount.LE.2 )
THEN
472 DO 230 i = 1, n - 1, 2
478 ELSE IF( imat.EQ.14 )
THEN
484 texp = one / dble( kd+1 )
486 CALL dlarnv( 2, iseed, n, b )
489 DO 240 i = max( 1, kd+2-j ), kd
492 IF( j.GT.1 .AND. kd.GT.0 )
494 ab( kd+1, j ) = tscal
499 DO 260 i = 3, min( n-j+1, kd+1 )
502 IF( j.LT.n .AND. kd.GT.0 )
509 ELSE IF( imat.EQ.15 )
THEN
516 lenj = min( j, kd+1 )
517 CALL dlarnv( 2, iseed, lenj, ab( kd+2-lenj, j ) )
519 ab( kd+1, j ) = sign( two, ab( kd+1, j ) )
526 lenj = min( n-j+1, kd+1 )
527 CALL dlarnv( 2, iseed, lenj, ab( 1, j ) )
529 ab( 1, j ) = sign( two, ab( 1, j ) )
535 CALL dlarnv( 2, iseed, n, b )
536 CALL dscal( n, two, b, 1 )
538 ELSE IF( imat.EQ.16 )
THEN
546 tscal = ( one-ulp ) / tscal
556 DO 320 i = j, max( 1, j-kd+1 ), -2
557 ab( 1+( j-i ), i ) = -tscal / dble( kd+2 )
559 b( i ) = texp*( one-ulp )
560 IF( i.GT.max( 1, j-kd+1 ) )
THEN
561 ab( 2+( j-i ), i-1 ) = -( tscal / dble( kd+2 ) )
563 ab( kd+1, i-1 ) = one
564 b( i-1 ) = texp*dble( ( kd+1 )*( kd+1 )+kd )
568 b( max( 1, j-kd+1 ) ) = ( dble( kd+2 ) /
569 $ dble( kd+3 ) )*tscal
574 lenj = min( kd+1, n-j+1 )
575 DO 340 i = j, min( n, j+kd-1 ), 2
576 ab( lenj-( i-j ), j ) = -tscal / dble( kd+2 )
578 b( j ) = texp*( one-ulp )
579 IF( i.LT.min( n, j+kd-1 ) )
THEN
580 ab( lenj-( i-j+1 ), i+1 ) = -( tscal /
581 $ dble( kd+2 ) ) / dble( kd+3 )
583 b( i+1 ) = texp*dble( ( kd+1 )*( kd+1 )+kd )
587 b( min( n, j+kd-1 ) ) = ( dble( kd+2 ) /
588 $ dble( kd+3 ) )*tscal
598 ELSE IF( imat.EQ.17 )
THEN
606 lenj = min( j-1, kd )
607 CALL dlarnv( 2, iseed, lenj, ab( kd+1-lenj, j ) )
608 ab( kd+1, j ) = dble( j )
612 lenj = min( n-j, kd )
614 $
CALL dlarnv( 2, iseed, lenj, ab( 2, j ) )
615 ab( 1, j ) = dble( j )
621 CALL dlarnv( 2, iseed, n, b )
622 iy = idamax( n, b, 1 )
623 bnorm = abs( b( iy ) )
624 bscal = bignum / max( one, bnorm )
625 CALL dscal( n, bscal, b, 1 )
627 ELSE IF( imat.EQ.18 )
THEN
633 tleft = bignum / max( one, dble( kd ) )
634 tscal = bignum*( dble( kd ) / dble( kd+1 ) )
637 lenj = min( j, kd+1 )
638 CALL dlarnv( 2, iseed, lenj, ab( kd+2-lenj, j ) )
639 DO 390 i = kd + 2 - lenj, kd + 1
640 ab( i, j ) = sign( tleft, ab( i, j ) ) +
646 lenj = min( n-j+1, kd+1 )
647 CALL dlarnv( 2, iseed, lenj, ab( 1, j ) )
649 ab( i, j ) = sign( tleft, ab( i, j ) ) +
654 CALL dlarnv( 2, iseed, n, b )
655 CALL dscal( n, two, b, 1 )
660 IF( .NOT.lsame( trans,
'N' ) )
THEN
663 lenj = min( n-2*j+1, kd+1 )
664 CALL dswap( lenj, ab( kd+1, j ), ldab-1,
665 $ ab( kd+2-lenj, n-j+1 ), -1 )
669 lenj = min( n-2*j+1, kd+1 )
670 CALL dswap( lenj, ab( 1, j ), 1, ab( lenj, n-j+2-lenj ),