00001 SUBROUTINE SLATTP( IMAT, UPLO, TRANS, DIAG, ISEED, N, A, B, WORK,
00002 $ INFO )
00003
00004
00005
00006
00007
00008
00009 CHARACTER DIAG, TRANS, UPLO
00010 INTEGER IMAT, INFO, N
00011
00012
00013 INTEGER ISEED( 4 )
00014 REAL A( * ), B( * ), WORK( * )
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 REAL ONE, TWO, ZERO
00076 PARAMETER ( ONE = 1.0E+0, TWO = 2.0E+0, ZERO = 0.0E+0 )
00077
00078
00079 LOGICAL UPPER
00080 CHARACTER DIST, PACKIT, TYPE
00081 CHARACTER*3 PATH
00082 INTEGER I, IY, J, JC, JCNEXT, JCOUNT, JJ, JL, JR, JX,
00083 $ KL, KU, MODE
00084 REAL ANORM, BIGNUM, BNORM, BSCAL, C, CNDNUM, PLUS1,
00085 $ PLUS2, RA, RB, REXP, S, SFAC, SMLNUM, STAR1,
00086 $ STEMP, T, TEXP, TLEFT, TSCAL, ULP, UNFL, X, Y,
00087 $ Z
00088
00089
00090 LOGICAL LSAME
00091 INTEGER ISAMAX
00092 REAL SLAMCH, SLARND
00093 EXTERNAL LSAME, ISAMAX, SLAMCH, SLARND
00094
00095
00096 EXTERNAL SLABAD, SLARNV, SLATB4, SLATMS, SROT, SROTG,
00097 $ SSCAL
00098
00099
00100 INTRINSIC ABS, MAX, REAL, SIGN, SQRT
00101
00102
00103
00104 PATH( 1: 1 ) = 'Single precision'
00105 PATH( 2: 3 ) = 'TP'
00106 UNFL = SLAMCH( 'Safe minimum' )
00107 ULP = SLAMCH( 'Epsilon' )*SLAMCH( 'Base' )
00108 SMLNUM = UNFL
00109 BIGNUM = ( ONE-ULP ) / SMLNUM
00110 CALL SLABAD( SMLNUM, BIGNUM )
00111 IF( ( IMAT.GE.7 .AND. IMAT.LE.10 ) .OR. IMAT.EQ.18 ) THEN
00112 DIAG = 'U'
00113 ELSE
00114 DIAG = 'N'
00115 END IF
00116 INFO = 0
00117
00118
00119
00120 IF( N.LE.0 )
00121 $ RETURN
00122
00123
00124
00125 UPPER = LSAME( UPLO, 'U' )
00126 IF( UPPER ) THEN
00127 CALL SLATB4( PATH, IMAT, N, N, TYPE, KL, KU, ANORM, MODE,
00128 $ CNDNUM, DIST )
00129 PACKIT = 'C'
00130 ELSE
00131 CALL SLATB4( PATH, -IMAT, N, N, TYPE, KL, KU, ANORM, MODE,
00132 $ CNDNUM, DIST )
00133 PACKIT = 'R'
00134 END IF
00135
00136
00137
00138 IF( IMAT.LE.6 ) THEN
00139 CALL SLATMS( N, N, DIST, ISEED, TYPE, B, MODE, CNDNUM, ANORM,
00140 $ KL, KU, PACKIT, A, N, WORK, INFO )
00141
00142
00143
00144
00145
00146
00147 ELSE IF( IMAT.EQ.7 ) THEN
00148 IF( UPPER ) THEN
00149 JC = 1
00150 DO 20 J = 1, N
00151 DO 10 I = 1, J - 1
00152 A( JC+I-1 ) = ZERO
00153 10 CONTINUE
00154 A( JC+J-1 ) = J
00155 JC = JC + J
00156 20 CONTINUE
00157 ELSE
00158 JC = 1
00159 DO 40 J = 1, N
00160 A( JC ) = J
00161 DO 30 I = J + 1, N
00162 A( JC+I-J ) = ZERO
00163 30 CONTINUE
00164 JC = JC + N - J + 1
00165 40 CONTINUE
00166 END IF
00167
00168
00169
00170
00171
00172
00173
00174 ELSE IF( IMAT.LE.10 ) THEN
00175 IF( UPPER ) THEN
00176 JC = 0
00177 DO 60 J = 1, N
00178 DO 50 I = 1, J - 1
00179 A( JC+I ) = ZERO
00180 50 CONTINUE
00181 A( JC+J ) = J
00182 JC = JC + J
00183 60 CONTINUE
00184 ELSE
00185 JC = 1
00186 DO 80 J = 1, N
00187 A( JC ) = J
00188 DO 70 I = J + 1, N
00189 A( JC+I-J ) = ZERO
00190 70 CONTINUE
00191 JC = JC + N - J + 1
00192 80 CONTINUE
00193 END IF
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253 STAR1 = 0.25
00254 SFAC = 0.5
00255 PLUS1 = SFAC
00256 DO 90 J = 1, N, 2
00257 PLUS2 = STAR1 / PLUS1
00258 WORK( J ) = PLUS1
00259 WORK( N+J ) = STAR1
00260 IF( J+1.LE.N ) THEN
00261 WORK( J+1 ) = PLUS2
00262 WORK( N+J+1 ) = ZERO
00263 PLUS1 = STAR1 / PLUS2
00264 REXP = SLARND( 2, ISEED )
00265 STAR1 = STAR1*( SFAC**REXP )
00266 IF( REXP.LT.ZERO ) THEN
00267 STAR1 = -SFAC**( ONE-REXP )
00268 ELSE
00269 STAR1 = SFAC**( ONE+REXP )
00270 END IF
00271 END IF
00272 90 CONTINUE
00273
00274 X = SQRT( CNDNUM ) - ONE / SQRT( CNDNUM )
00275 IF( N.GT.2 ) THEN
00276 Y = SQRT( TWO / REAL( N-2 ) )*X
00277 ELSE
00278 Y = ZERO
00279 END IF
00280 Z = X*X
00281
00282 IF( UPPER ) THEN
00283
00284
00285
00286
00287 JC = 1
00288 DO 100 J = 2, N
00289 A( JC+1 ) = Y
00290 IF( J.GT.2 )
00291 $ A( JC+J-1 ) = WORK( J-2 )
00292 IF( J.GT.3 )
00293 $ A( JC+J-2 ) = WORK( N+J-3 )
00294 JC = JC + J
00295 100 CONTINUE
00296 JC = JC - N
00297 A( JC+1 ) = Z
00298 DO 110 J = 2, N - 1
00299 A( JC+J ) = Y
00300 110 CONTINUE
00301 ELSE
00302
00303
00304
00305
00306 DO 120 I = 2, N - 1
00307 A( I ) = Y
00308 120 CONTINUE
00309 A( N ) = Z
00310 JC = N + 1
00311 DO 130 J = 2, N - 1
00312 A( JC+1 ) = WORK( J-1 )
00313 IF( J.LT.N-1 )
00314 $ A( JC+2 ) = WORK( N+J-1 )
00315 A( JC+N-J ) = Y
00316 JC = JC + N - J + 1
00317 130 CONTINUE
00318 END IF
00319
00320
00321
00322 IF( UPPER ) THEN
00323 JC = 1
00324 DO 150 J = 1, N - 1
00325 JCNEXT = JC + J
00326 RA = A( JCNEXT+J-1 )
00327 RB = TWO
00328 CALL SROTG( RA, RB, C, S )
00329
00330
00331
00332 IF( N.GT.J+1 ) THEN
00333 JX = JCNEXT + J
00334 DO 140 I = J + 2, N
00335 STEMP = C*A( JX+J ) + S*A( JX+J+1 )
00336 A( JX+J+1 ) = -S*A( JX+J ) + C*A( JX+J+1 )
00337 A( JX+J ) = STEMP
00338 JX = JX + I
00339 140 CONTINUE
00340 END IF
00341
00342
00343
00344 IF( J.GT.1 )
00345 $ CALL SROT( J-1, A( JCNEXT ), 1, A( JC ), 1, -C, -S )
00346
00347
00348
00349 A( JCNEXT+J-1 ) = -A( JCNEXT+J-1 )
00350 JC = JCNEXT
00351 150 CONTINUE
00352 ELSE
00353 JC = 1
00354 DO 170 J = 1, N - 1
00355 JCNEXT = JC + N - J + 1
00356 RA = A( JC+1 )
00357 RB = TWO
00358 CALL SROTG( RA, RB, C, S )
00359
00360
00361
00362 IF( N.GT.J+1 )
00363 $ CALL SROT( N-J-1, A( JCNEXT+1 ), 1, A( JC+2 ), 1, C,
00364 $ -S )
00365
00366
00367
00368 IF( J.GT.1 ) THEN
00369 JX = 1
00370 DO 160 I = 1, J - 1
00371 STEMP = -C*A( JX+J-I ) + S*A( JX+J-I+1 )
00372 A( JX+J-I+1 ) = -S*A( JX+J-I ) - C*A( JX+J-I+1 )
00373 A( JX+J-I ) = STEMP
00374 JX = JX + N - I + 1
00375 160 CONTINUE
00376 END IF
00377
00378
00379
00380 A( JC+1 ) = -A( JC+1 )
00381 JC = JCNEXT
00382 170 CONTINUE
00383 END IF
00384
00385
00386
00387
00388
00389 ELSE IF( IMAT.EQ.11 ) THEN
00390
00391
00392
00393
00394
00395 IF( UPPER ) THEN
00396 JC = 1
00397 DO 180 J = 1, N
00398 CALL SLARNV( 2, ISEED, J, A( JC ) )
00399 A( JC+J-1 ) = SIGN( TWO, A( JC+J-1 ) )
00400 JC = JC + J
00401 180 CONTINUE
00402 ELSE
00403 JC = 1
00404 DO 190 J = 1, N
00405 CALL SLARNV( 2, ISEED, N-J+1, A( JC ) )
00406 A( JC ) = SIGN( TWO, A( JC ) )
00407 JC = JC + N - J + 1
00408 190 CONTINUE
00409 END IF
00410
00411
00412
00413 CALL SLARNV( 2, ISEED, N, B )
00414 IY = ISAMAX( N, B, 1 )
00415 BNORM = ABS( B( IY ) )
00416 BSCAL = BIGNUM / MAX( ONE, BNORM )
00417 CALL SSCAL( N, BSCAL, B, 1 )
00418
00419 ELSE IF( IMAT.EQ.12 ) THEN
00420
00421
00422
00423
00424
00425 CALL SLARNV( 2, ISEED, N, B )
00426 TSCAL = ONE / MAX( ONE, REAL( N-1 ) )
00427 IF( UPPER ) THEN
00428 JC = 1
00429 DO 200 J = 1, N
00430 CALL SLARNV( 2, ISEED, J-1, A( JC ) )
00431 CALL SSCAL( J-1, TSCAL, A( JC ), 1 )
00432 A( JC+J-1 ) = SIGN( ONE, SLARND( 2, ISEED ) )
00433 JC = JC + J
00434 200 CONTINUE
00435 A( N*( N+1 ) / 2 ) = SMLNUM
00436 ELSE
00437 JC = 1
00438 DO 210 J = 1, N
00439 CALL SLARNV( 2, ISEED, N-J, A( JC+1 ) )
00440 CALL SSCAL( N-J, TSCAL, A( JC+1 ), 1 )
00441 A( JC ) = SIGN( ONE, SLARND( 2, ISEED ) )
00442 JC = JC + N - J + 1
00443 210 CONTINUE
00444 A( 1 ) = SMLNUM
00445 END IF
00446
00447 ELSE IF( IMAT.EQ.13 ) THEN
00448
00449
00450
00451
00452
00453 CALL SLARNV( 2, ISEED, N, B )
00454 IF( UPPER ) THEN
00455 JC = 1
00456 DO 220 J = 1, N
00457 CALL SLARNV( 2, ISEED, J-1, A( JC ) )
00458 A( JC+J-1 ) = SIGN( ONE, SLARND( 2, ISEED ) )
00459 JC = JC + J
00460 220 CONTINUE
00461 A( N*( N+1 ) / 2 ) = SMLNUM
00462 ELSE
00463 JC = 1
00464 DO 230 J = 1, N
00465 CALL SLARNV( 2, ISEED, N-J, A( JC+1 ) )
00466 A( JC ) = SIGN( ONE, SLARND( 2, ISEED ) )
00467 JC = JC + N - J + 1
00468 230 CONTINUE
00469 A( 1 ) = SMLNUM
00470 END IF
00471
00472 ELSE IF( IMAT.EQ.14 ) THEN
00473
00474
00475
00476
00477
00478 IF( UPPER ) THEN
00479 JCOUNT = 1
00480 JC = ( N-1 )*N / 2 + 1
00481 DO 250 J = N, 1, -1
00482 DO 240 I = 1, J - 1
00483 A( JC+I-1 ) = ZERO
00484 240 CONTINUE
00485 IF( JCOUNT.LE.2 ) THEN
00486 A( JC+J-1 ) = SMLNUM
00487 ELSE
00488 A( JC+J-1 ) = ONE
00489 END IF
00490 JCOUNT = JCOUNT + 1
00491 IF( JCOUNT.GT.4 )
00492 $ JCOUNT = 1
00493 JC = JC - J + 1
00494 250 CONTINUE
00495 ELSE
00496 JCOUNT = 1
00497 JC = 1
00498 DO 270 J = 1, N
00499 DO 260 I = J + 1, N
00500 A( JC+I-J ) = ZERO
00501 260 CONTINUE
00502 IF( JCOUNT.LE.2 ) THEN
00503 A( JC ) = SMLNUM
00504 ELSE
00505 A( JC ) = ONE
00506 END IF
00507 JCOUNT = JCOUNT + 1
00508 IF( JCOUNT.GT.4 )
00509 $ JCOUNT = 1
00510 JC = JC + N - J + 1
00511 270 CONTINUE
00512 END IF
00513
00514
00515
00516 IF( UPPER ) THEN
00517 B( 1 ) = ZERO
00518 DO 280 I = N, 2, -2
00519 B( I ) = ZERO
00520 B( I-1 ) = SMLNUM
00521 280 CONTINUE
00522 ELSE
00523 B( N ) = ZERO
00524 DO 290 I = 1, N - 1, 2
00525 B( I ) = ZERO
00526 B( I+1 ) = SMLNUM
00527 290 CONTINUE
00528 END IF
00529
00530 ELSE IF( IMAT.EQ.15 ) THEN
00531
00532
00533
00534
00535
00536 TEXP = ONE / MAX( ONE, REAL( N-1 ) )
00537 TSCAL = SMLNUM**TEXP
00538 CALL SLARNV( 2, ISEED, N, B )
00539 IF( UPPER ) THEN
00540 JC = 1
00541 DO 310 J = 1, N
00542 DO 300 I = 1, J - 2
00543 A( JC+I-1 ) = ZERO
00544 300 CONTINUE
00545 IF( J.GT.1 )
00546 $ A( JC+J-2 ) = -ONE
00547 A( JC+J-1 ) = TSCAL
00548 JC = JC + J
00549 310 CONTINUE
00550 B( N ) = ONE
00551 ELSE
00552 JC = 1
00553 DO 330 J = 1, N
00554 DO 320 I = J + 2, N
00555 A( JC+I-J ) = ZERO
00556 320 CONTINUE
00557 IF( J.LT.N )
00558 $ A( JC+1 ) = -ONE
00559 A( JC ) = TSCAL
00560 JC = JC + N - J + 1
00561 330 CONTINUE
00562 B( 1 ) = ONE
00563 END IF
00564
00565 ELSE IF( IMAT.EQ.16 ) THEN
00566
00567
00568
00569 IY = N / 2 + 1
00570 IF( UPPER ) THEN
00571 JC = 1
00572 DO 340 J = 1, N
00573 CALL SLARNV( 2, ISEED, J, A( JC ) )
00574 IF( J.NE.IY ) THEN
00575 A( JC+J-1 ) = SIGN( TWO, A( JC+J-1 ) )
00576 ELSE
00577 A( JC+J-1 ) = ZERO
00578 END IF
00579 JC = JC + J
00580 340 CONTINUE
00581 ELSE
00582 JC = 1
00583 DO 350 J = 1, N
00584 CALL SLARNV( 2, ISEED, N-J+1, A( JC ) )
00585 IF( J.NE.IY ) THEN
00586 A( JC ) = SIGN( TWO, A( JC ) )
00587 ELSE
00588 A( JC ) = ZERO
00589 END IF
00590 JC = JC + N - J + 1
00591 350 CONTINUE
00592 END IF
00593 CALL SLARNV( 2, ISEED, N, B )
00594 CALL SSCAL( N, TWO, B, 1 )
00595
00596 ELSE IF( IMAT.EQ.17 ) THEN
00597
00598
00599
00600
00601
00602
00603 TSCAL = UNFL / ULP
00604 TSCAL = ( ONE-ULP ) / TSCAL
00605 DO 360 J = 1, N*( N+1 ) / 2
00606 A( J ) = ZERO
00607 360 CONTINUE
00608 TEXP = ONE
00609 IF( UPPER ) THEN
00610 JC = ( N-1 )*N / 2 + 1
00611 DO 370 J = N, 2, -2
00612 A( JC ) = -TSCAL / REAL( N+1 )
00613 A( JC+J-1 ) = ONE
00614 B( J ) = TEXP*( ONE-ULP )
00615 JC = JC - J + 1
00616 A( JC ) = -( TSCAL / REAL( N+1 ) ) / REAL( N+2 )
00617 A( JC+J-2 ) = ONE
00618 B( J-1 ) = TEXP*REAL( N*N+N-1 )
00619 TEXP = TEXP*TWO
00620 JC = JC - J + 2
00621 370 CONTINUE
00622 B( 1 ) = ( REAL( N+1 ) / REAL( N+2 ) )*TSCAL
00623 ELSE
00624 JC = 1
00625 DO 380 J = 1, N - 1, 2
00626 A( JC+N-J ) = -TSCAL / REAL( N+1 )
00627 A( JC ) = ONE
00628 B( J ) = TEXP*( ONE-ULP )
00629 JC = JC + N - J + 1
00630 A( JC+N-J-1 ) = -( TSCAL / REAL( N+1 ) ) / REAL( N+2 )
00631 A( JC ) = ONE
00632 B( J+1 ) = TEXP*REAL( N*N+N-1 )
00633 TEXP = TEXP*TWO
00634 JC = JC + N - J
00635 380 CONTINUE
00636 B( N ) = ( REAL( N+1 ) / REAL( N+2 ) )*TSCAL
00637 END IF
00638
00639 ELSE IF( IMAT.EQ.18 ) THEN
00640
00641
00642
00643
00644
00645 IF( UPPER ) THEN
00646 JC = 1
00647 DO 390 J = 1, N
00648 CALL SLARNV( 2, ISEED, J-1, A( JC ) )
00649 A( JC+J-1 ) = ZERO
00650 JC = JC + J
00651 390 CONTINUE
00652 ELSE
00653 JC = 1
00654 DO 400 J = 1, N
00655 IF( J.LT.N )
00656 $ CALL SLARNV( 2, ISEED, N-J, A( JC+1 ) )
00657 A( JC ) = ZERO
00658 JC = JC + N - J + 1
00659 400 CONTINUE
00660 END IF
00661
00662
00663
00664 CALL SLARNV( 2, ISEED, N, B )
00665 IY = ISAMAX( N, B, 1 )
00666 BNORM = ABS( B( IY ) )
00667 BSCAL = BIGNUM / MAX( ONE, BNORM )
00668 CALL SSCAL( N, BSCAL, B, 1 )
00669
00670 ELSE IF( IMAT.EQ.19 ) THEN
00671
00672
00673
00674
00675
00676 TLEFT = BIGNUM / MAX( ONE, REAL( N-1 ) )
00677 TSCAL = BIGNUM*( REAL( N-1 ) / MAX( ONE, REAL( N ) ) )
00678 IF( UPPER ) THEN
00679 JC = 1
00680 DO 420 J = 1, N
00681 CALL SLARNV( 2, ISEED, J, A( JC ) )
00682 DO 410 I = 1, J
00683 A( JC+I-1 ) = SIGN( TLEFT, A( JC+I-1 ) ) +
00684 $ TSCAL*A( JC+I-1 )
00685 410 CONTINUE
00686 JC = JC + J
00687 420 CONTINUE
00688 ELSE
00689 JC = 1
00690 DO 440 J = 1, N
00691 CALL SLARNV( 2, ISEED, N-J+1, A( JC ) )
00692 DO 430 I = J, N
00693 A( JC+I-J ) = SIGN( TLEFT, A( JC+I-J ) ) +
00694 $ TSCAL*A( JC+I-J )
00695 430 CONTINUE
00696 JC = JC + N - J + 1
00697 440 CONTINUE
00698 END IF
00699 CALL SLARNV( 2, ISEED, N, B )
00700 CALL SSCAL( N, TWO, B, 1 )
00701 END IF
00702
00703
00704
00705
00706 IF( .NOT.LSAME( TRANS, 'N' ) ) THEN
00707 IF( UPPER ) THEN
00708 JJ = 1
00709 JR = N*( N+1 ) / 2
00710 DO 460 J = 1, N / 2
00711 JL = JJ
00712 DO 450 I = J, N - J
00713 T = A( JR-I+J )
00714 A( JR-I+J ) = A( JL )
00715 A( JL ) = T
00716 JL = JL + I
00717 450 CONTINUE
00718 JJ = JJ + J + 1
00719 JR = JR - ( N-J+1 )
00720 460 CONTINUE
00721 ELSE
00722 JL = 1
00723 JJ = N*( N+1 ) / 2
00724 DO 480 J = 1, N / 2
00725 JR = JJ
00726 DO 470 I = J, N - J
00727 T = A( JL+I-J )
00728 A( JL+I-J ) = A( JR )
00729 A( JR ) = T
00730 JR = JR - I
00731 470 CONTINUE
00732 JL = JL + N - J + 1
00733 JJ = JJ - J - 1
00734 480 CONTINUE
00735 END IF
00736 END IF
00737
00738 RETURN
00739
00740
00741
00742 END