00001 SUBROUTINE CLATME( N, DIST, ISEED, D, MODE, COND, DMAX, EI,
00002 $ RSIGN,
00003 $ UPPER, SIM, DS, MODES, CONDS, KL, KU, ANORM,
00004 $ A,
00005 $ LDA, WORK, INFO )
00006
00007
00008
00009
00010
00011
00012 CHARACTER DIST, EI, RSIGN, SIM, UPPER
00013 INTEGER INFO, KL, KU, LDA, MODE, MODES, N
00014 REAL ANORM, COND, CONDS
00015 COMPLEX DMAX
00016
00017
00018 INTEGER ISEED( 4 )
00019 REAL DS( * )
00020 COMPLEX A( LDA, * ), D( * ), WORK( * )
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
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
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 REAL ZERO
00223 PARAMETER ( ZERO = 0.0E+0 )
00224 REAL ONE
00225 PARAMETER ( ONE = 1.0E+0 )
00226 COMPLEX CZERO
00227 PARAMETER ( CZERO = ( 0.0E+0, 0.0E+0 ) )
00228 COMPLEX CONE
00229 PARAMETER ( CONE = ( 1.0E+0, 0.0E+0 ) )
00230
00231
00232 LOGICAL BADS
00233 INTEGER I, IC, ICOLS, IDIST, IINFO, IR, IROWS, IRSIGN,
00234 $ ISIM, IUPPER, J, JC, JCR
00235 REAL RALPHA, TEMP
00236 COMPLEX ALPHA, TAU, XNORMS
00237
00238
00239 REAL TEMPA( 1 )
00240
00241
00242 LOGICAL LSAME
00243 REAL CLANGE
00244 COMPLEX CLARND
00245 EXTERNAL LSAME, CLANGE, CLARND
00246
00247
00248 EXTERNAL CCOPY, CGEMV, CGERC, CLACGV, CLARFG, CLARGE,
00249 $ CLARNV, CLATM1, CLASET, CSCAL, CSSCAL, SLATM1,
00250 $ XERBLA
00251
00252
00253 INTRINSIC ABS, CONJG, MAX, MOD
00254
00255
00256
00257
00258
00259
00260 INFO = 0
00261
00262
00263
00264 IF( N.EQ.0 )
00265 $ RETURN
00266
00267
00268
00269 IF( LSAME( DIST, 'U' ) ) THEN
00270 IDIST = 1
00271 ELSE IF( LSAME( DIST, 'S' ) ) THEN
00272 IDIST = 2
00273 ELSE IF( LSAME( DIST, 'N' ) ) THEN
00274 IDIST = 3
00275 ELSE IF( LSAME( DIST, 'D' ) ) THEN
00276 IDIST = 4
00277 ELSE
00278 IDIST = -1
00279 END IF
00280
00281
00282
00283 IF( LSAME( RSIGN, 'T' ) ) THEN
00284 IRSIGN = 1
00285 ELSE IF( LSAME( RSIGN, 'F' ) ) THEN
00286 IRSIGN = 0
00287 ELSE
00288 IRSIGN = -1
00289 END IF
00290
00291
00292
00293 IF( LSAME( UPPER, 'T' ) ) THEN
00294 IUPPER = 1
00295 ELSE IF( LSAME( UPPER, 'F' ) ) THEN
00296 IUPPER = 0
00297 ELSE
00298 IUPPER = -1
00299 END IF
00300
00301
00302
00303 IF( LSAME( SIM, 'T' ) ) THEN
00304 ISIM = 1
00305 ELSE IF( LSAME( SIM, 'F' ) ) THEN
00306 ISIM = 0
00307 ELSE
00308 ISIM = -1
00309 END IF
00310
00311
00312
00313 BADS = .FALSE.
00314 IF( MODES.EQ.0 .AND. ISIM.EQ.1 ) THEN
00315 DO 10 J = 1, N
00316 IF( DS( J ).EQ.ZERO )
00317 $ BADS = .TRUE.
00318 10 CONTINUE
00319 END IF
00320
00321
00322
00323 IF( N.LT.0 ) THEN
00324 INFO = -1
00325 ELSE IF( IDIST.EQ.-1 ) THEN
00326 INFO = -2
00327 ELSE IF( ABS( MODE ).GT.6 ) THEN
00328 INFO = -5
00329 ELSE IF( ( MODE.NE.0 .AND. ABS( MODE ).NE.6 ) .AND. COND.LT.ONE )
00330 $ THEN
00331 INFO = -6
00332 ELSE IF( IRSIGN.EQ.-1 ) THEN
00333 INFO = -9
00334 ELSE IF( IUPPER.EQ.-1 ) THEN
00335 INFO = -10
00336 ELSE IF( ISIM.EQ.-1 ) THEN
00337 INFO = -11
00338 ELSE IF( BADS ) THEN
00339 INFO = -12
00340 ELSE IF( ISIM.EQ.1 .AND. ABS( MODES ).GT.5 ) THEN
00341 INFO = -13
00342 ELSE IF( ISIM.EQ.1 .AND. MODES.NE.0 .AND. CONDS.LT.ONE ) THEN
00343 INFO = -14
00344 ELSE IF( KL.LT.1 ) THEN
00345 INFO = -15
00346 ELSE IF( KU.LT.1 .OR. ( KU.LT.N-1 .AND. KL.LT.N-1 ) ) THEN
00347 INFO = -16
00348 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00349 INFO = -19
00350 END IF
00351
00352 IF( INFO.NE.0 ) THEN
00353 CALL XERBLA( 'CLATME', -INFO )
00354 RETURN
00355 END IF
00356
00357
00358
00359 DO 20 I = 1, 4
00360 ISEED( I ) = MOD( ABS( ISEED( I ) ), 4096 )
00361 20 CONTINUE
00362
00363 IF( MOD( ISEED( 4 ), 2 ).NE.1 )
00364 $ ISEED( 4 ) = ISEED( 4 ) + 1
00365
00366
00367
00368
00369
00370 CALL CLATM1( MODE, COND, IRSIGN, IDIST, ISEED, D, N, IINFO )
00371 IF( IINFO.NE.0 ) THEN
00372 INFO = 1
00373 RETURN
00374 END IF
00375 IF( MODE.NE.0 .AND. ABS( MODE ).NE.6 ) THEN
00376
00377
00378
00379 TEMP = ABS( D( 1 ) )
00380 DO 30 I = 2, N
00381 TEMP = MAX( TEMP, ABS( D( I ) ) )
00382 30 CONTINUE
00383
00384 IF( TEMP.GT.ZERO ) THEN
00385 ALPHA = DMAX / TEMP
00386 ELSE
00387 INFO = 2
00388 RETURN
00389 END IF
00390
00391 CALL CSCAL( N, ALPHA, D, 1 )
00392
00393 END IF
00394
00395 CALL CLASET( 'Full', N, N, CZERO, CZERO, A, LDA )
00396 CALL CCOPY( N, D, 1, A, LDA+1 )
00397
00398
00399
00400 IF( IUPPER.NE.0 ) THEN
00401 DO 40 JC = 2, N
00402 CALL CLARNV( IDIST, ISEED, JC-1, A( 1, JC ) )
00403 40 CONTINUE
00404 END IF
00405
00406
00407
00408
00409
00410
00411
00412
00413 IF( ISIM.NE.0 ) THEN
00414
00415
00416
00417
00418 CALL SLATM1( MODES, CONDS, 0, 0, ISEED, DS, N, IINFO )
00419 IF( IINFO.NE.0 ) THEN
00420 INFO = 3
00421 RETURN
00422 END IF
00423
00424
00425
00426 CALL CLARGE( N, A, LDA, ISEED, WORK, IINFO )
00427 IF( IINFO.NE.0 ) THEN
00428 INFO = 4
00429 RETURN
00430 END IF
00431
00432
00433
00434 DO 50 J = 1, N
00435 CALL CSSCAL( N, DS( J ), A( J, 1 ), LDA )
00436 IF( DS( J ).NE.ZERO ) THEN
00437 CALL CSSCAL( N, ONE / DS( J ), A( 1, J ), 1 )
00438 ELSE
00439 INFO = 5
00440 RETURN
00441 END IF
00442 50 CONTINUE
00443
00444
00445
00446 CALL CLARGE( N, A, LDA, ISEED, WORK, IINFO )
00447 IF( IINFO.NE.0 ) THEN
00448 INFO = 4
00449 RETURN
00450 END IF
00451 END IF
00452
00453
00454
00455 IF( KL.LT.N-1 ) THEN
00456
00457
00458
00459 DO 60 JCR = KL + 1, N - 1
00460 IC = JCR - KL
00461 IROWS = N + 1 - JCR
00462 ICOLS = N + KL - JCR
00463
00464 CALL CCOPY( IROWS, A( JCR, IC ), 1, WORK, 1 )
00465 XNORMS = WORK( 1 )
00466 CALL CLARFG( IROWS, XNORMS, WORK( 2 ), 1, TAU )
00467 TAU = CONJG( TAU )
00468 WORK( 1 ) = CONE
00469 ALPHA = CLARND( 5, ISEED )
00470
00471 CALL CGEMV( 'C', IROWS, ICOLS, CONE, A( JCR, IC+1 ), LDA,
00472 $ WORK, 1, CZERO, WORK( IROWS+1 ), 1 )
00473 CALL CGERC( IROWS, ICOLS, -TAU, WORK, 1, WORK( IROWS+1 ), 1,
00474 $ A( JCR, IC+1 ), LDA )
00475
00476 CALL CGEMV( 'N', N, IROWS, CONE, A( 1, JCR ), LDA, WORK, 1,
00477 $ CZERO, WORK( IROWS+1 ), 1 )
00478 CALL CGERC( N, IROWS, -CONJG( TAU ), WORK( IROWS+1 ), 1,
00479 $ WORK, 1, A( 1, JCR ), LDA )
00480
00481 A( JCR, IC ) = XNORMS
00482 CALL CLASET( 'Full', IROWS-1, 1, CZERO, CZERO,
00483 $ A( JCR+1, IC ), LDA )
00484
00485 CALL CSCAL( ICOLS+1, ALPHA, A( JCR, IC ), LDA )
00486 CALL CSCAL( N, CONJG( ALPHA ), A( 1, JCR ), 1 )
00487 60 CONTINUE
00488 ELSE IF( KU.LT.N-1 ) THEN
00489
00490
00491
00492 DO 70 JCR = KU + 1, N - 1
00493 IR = JCR - KU
00494 IROWS = N + KU - JCR
00495 ICOLS = N + 1 - JCR
00496
00497 CALL CCOPY( ICOLS, A( IR, JCR ), LDA, WORK, 1 )
00498 XNORMS = WORK( 1 )
00499 CALL CLARFG( ICOLS, XNORMS, WORK( 2 ), 1, TAU )
00500 TAU = CONJG( TAU )
00501 WORK( 1 ) = CONE
00502 CALL CLACGV( ICOLS-1, WORK( 2 ), 1 )
00503 ALPHA = CLARND( 5, ISEED )
00504
00505 CALL CGEMV( 'N', IROWS, ICOLS, CONE, A( IR+1, JCR ), LDA,
00506 $ WORK, 1, CZERO, WORK( ICOLS+1 ), 1 )
00507 CALL CGERC( IROWS, ICOLS, -TAU, WORK( ICOLS+1 ), 1, WORK, 1,
00508 $ A( IR+1, JCR ), LDA )
00509
00510 CALL CGEMV( 'C', ICOLS, N, CONE, A( JCR, 1 ), LDA, WORK, 1,
00511 $ CZERO, WORK( ICOLS+1 ), 1 )
00512 CALL CGERC( ICOLS, N, -CONJG( TAU ), WORK, 1,
00513 $ WORK( ICOLS+1 ), 1, A( JCR, 1 ), LDA )
00514
00515 A( IR, JCR ) = XNORMS
00516 CALL CLASET( 'Full', 1, ICOLS-1, CZERO, CZERO,
00517 $ A( IR, JCR+1 ), LDA )
00518
00519 CALL CSCAL( IROWS+1, ALPHA, A( IR, JCR ), 1 )
00520 CALL CSCAL( N, CONJG( ALPHA ), A( JCR, 1 ), LDA )
00521 70 CONTINUE
00522 END IF
00523
00524
00525
00526 IF( ANORM.GE.ZERO ) THEN
00527 TEMP = CLANGE( 'M', N, N, A, LDA, TEMPA )
00528 IF( TEMP.GT.ZERO ) THEN
00529 RALPHA = ANORM / TEMP
00530 DO 80 J = 1, N
00531 CALL CSSCAL( N, RALPHA, A( 1, J ), 1 )
00532 80 CONTINUE
00533 END IF
00534 END IF
00535
00536 RETURN
00537
00538
00539
00540 END