00001 SUBROUTINE ZLATME( 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 DOUBLE PRECISION ANORM, COND, CONDS
00015 COMPLEX*16 DMAX
00016
00017
00018 INTEGER ISEED( 4 )
00019 DOUBLE PRECISION DS( * )
00020 COMPLEX*16 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 DOUBLE PRECISION ZERO
00223 PARAMETER ( ZERO = 0.0D+0 )
00224 DOUBLE PRECISION ONE
00225 PARAMETER ( ONE = 1.0D+0 )
00226 COMPLEX*16 CZERO
00227 PARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ) )
00228 COMPLEX*16 CONE
00229 PARAMETER ( CONE = ( 1.0D+0, 0.0D+0 ) )
00230
00231
00232 LOGICAL BADS
00233 INTEGER I, IC, ICOLS, IDIST, IINFO, IR, IROWS, IRSIGN,
00234 $ ISIM, IUPPER, J, JC, JCR
00235 DOUBLE PRECISION RALPHA, TEMP
00236 COMPLEX*16 ALPHA, TAU, XNORMS
00237
00238
00239 DOUBLE PRECISION TEMPA( 1 )
00240
00241
00242 LOGICAL LSAME
00243 DOUBLE PRECISION ZLANGE
00244 COMPLEX*16 ZLARND
00245 EXTERNAL LSAME, ZLANGE, ZLARND
00246
00247
00248 EXTERNAL DLATM1, XERBLA, ZCOPY, ZDSCAL, ZGEMV, ZGERC,
00249 $ ZLACGV, ZLARFG, ZLARGE, ZLARNV, ZLASET, ZLATM1,
00250 $ ZSCAL
00251
00252
00253 INTRINSIC ABS, DCONJG, 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( 'ZLATME', -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 ZLATM1( 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 ZSCAL( N, ALPHA, D, 1 )
00392
00393 END IF
00394
00395 CALL ZLASET( 'Full', N, N, CZERO, CZERO, A, LDA )
00396 CALL ZCOPY( N, D, 1, A, LDA+1 )
00397
00398
00399
00400 IF( IUPPER.NE.0 ) THEN
00401 DO 40 JC = 2, N
00402 CALL ZLARNV( 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 DLATM1( 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 ZLARGE( 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 ZDSCAL( N, DS( J ), A( J, 1 ), LDA )
00436 IF( DS( J ).NE.ZERO ) THEN
00437 CALL ZDSCAL( 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 ZLARGE( 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 ZCOPY( IROWS, A( JCR, IC ), 1, WORK, 1 )
00465 XNORMS = WORK( 1 )
00466 CALL ZLARFG( IROWS, XNORMS, WORK( 2 ), 1, TAU )
00467 TAU = DCONJG( TAU )
00468 WORK( 1 ) = CONE
00469 ALPHA = ZLARND( 5, ISEED )
00470
00471 CALL ZGEMV( 'C', IROWS, ICOLS, CONE, A( JCR, IC+1 ), LDA,
00472 $ WORK, 1, CZERO, WORK( IROWS+1 ), 1 )
00473 CALL ZGERC( IROWS, ICOLS, -TAU, WORK, 1, WORK( IROWS+1 ), 1,
00474 $ A( JCR, IC+1 ), LDA )
00475
00476 CALL ZGEMV( 'N', N, IROWS, CONE, A( 1, JCR ), LDA, WORK, 1,
00477 $ CZERO, WORK( IROWS+1 ), 1 )
00478 CALL ZGERC( N, IROWS, -DCONJG( TAU ), WORK( IROWS+1 ), 1,
00479 $ WORK, 1, A( 1, JCR ), LDA )
00480
00481 A( JCR, IC ) = XNORMS
00482 CALL ZLASET( 'Full', IROWS-1, 1, CZERO, CZERO,
00483 $ A( JCR+1, IC ), LDA )
00484
00485 CALL ZSCAL( ICOLS+1, ALPHA, A( JCR, IC ), LDA )
00486 CALL ZSCAL( N, DCONJG( 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 ZCOPY( ICOLS, A( IR, JCR ), LDA, WORK, 1 )
00498 XNORMS = WORK( 1 )
00499 CALL ZLARFG( ICOLS, XNORMS, WORK( 2 ), 1, TAU )
00500 TAU = DCONJG( TAU )
00501 WORK( 1 ) = CONE
00502 CALL ZLACGV( ICOLS-1, WORK( 2 ), 1 )
00503 ALPHA = ZLARND( 5, ISEED )
00504
00505 CALL ZGEMV( 'N', IROWS, ICOLS, CONE, A( IR+1, JCR ), LDA,
00506 $ WORK, 1, CZERO, WORK( ICOLS+1 ), 1 )
00507 CALL ZGERC( IROWS, ICOLS, -TAU, WORK( ICOLS+1 ), 1, WORK, 1,
00508 $ A( IR+1, JCR ), LDA )
00509
00510 CALL ZGEMV( 'C', ICOLS, N, CONE, A( JCR, 1 ), LDA, WORK, 1,
00511 $ CZERO, WORK( ICOLS+1 ), 1 )
00512 CALL ZGERC( ICOLS, N, -DCONJG( TAU ), WORK, 1,
00513 $ WORK( ICOLS+1 ), 1, A( JCR, 1 ), LDA )
00514
00515 A( IR, JCR ) = XNORMS
00516 CALL ZLASET( 'Full', 1, ICOLS-1, CZERO, CZERO,
00517 $ A( IR, JCR+1 ), LDA )
00518
00519 CALL ZSCAL( IROWS+1, ALPHA, A( IR, JCR ), 1 )
00520 CALL ZSCAL( N, DCONJG( ALPHA ), A( JCR, 1 ), LDA )
00521 70 CONTINUE
00522 END IF
00523
00524
00525
00526 IF( ANORM.GE.ZERO ) THEN
00527 TEMP = ZLANGE( 'M', N, N, A, LDA, TEMPA )
00528 IF( TEMP.GT.ZERO ) THEN
00529 RALPHA = ANORM / TEMP
00530 DO 80 J = 1, N
00531 CALL ZDSCAL( N, RALPHA, A( 1, J ), 1 )
00532 80 CONTINUE
00533 END IF
00534 END IF
00535
00536 RETURN
00537
00538
00539
00540 END