00001 SUBROUTINE ZLALS0( ICOMPQ, NL, NR, SQRE, NRHS, B, LDB, BX, LDBX,
00002 $ PERM, GIVPTR, GIVCOL, LDGCOL, GIVNUM, LDGNUM,
00003 $ POLES, DIFL, DIFR, Z, K, C, S, RWORK, INFO )
00004
00005
00006
00007
00008
00009
00010
00011 INTEGER GIVPTR, ICOMPQ, INFO, K, LDB, LDBX, LDGCOL,
00012 $ LDGNUM, NL, NR, NRHS, SQRE
00013 DOUBLE PRECISION C, S
00014
00015
00016 INTEGER GIVCOL( LDGCOL, * ), PERM( * )
00017 DOUBLE PRECISION DIFL( * ), DIFR( LDGNUM, * ),
00018 $ GIVNUM( LDGNUM, * ), POLES( LDGNUM, * ),
00019 $ RWORK( * ), Z( * )
00020 COMPLEX*16 B( LDB, * ), BX( LDBX, * )
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 DOUBLE PRECISION ONE, ZERO, NEGONE
00170 PARAMETER ( ONE = 1.0D0, ZERO = 0.0D0, NEGONE = -1.0D0 )
00171
00172
00173 INTEGER I, J, JCOL, JROW, M, N, NLP1
00174 DOUBLE PRECISION DIFLJ, DIFRJ, DJ, DSIGJ, DSIGJP, TEMP
00175
00176
00177 EXTERNAL DGEMV, XERBLA, ZCOPY, ZDROT, ZDSCAL, ZLACPY,
00178 $ ZLASCL
00179
00180
00181 DOUBLE PRECISION DLAMC3, DNRM2
00182 EXTERNAL DLAMC3, DNRM2
00183
00184
00185 INTRINSIC DBLE, DCMPLX, DIMAG, MAX
00186
00187
00188
00189
00190
00191 INFO = 0
00192
00193 IF( ( ICOMPQ.LT.0 ) .OR. ( ICOMPQ.GT.1 ) ) THEN
00194 INFO = -1
00195 ELSE IF( NL.LT.1 ) THEN
00196 INFO = -2
00197 ELSE IF( NR.LT.1 ) THEN
00198 INFO = -3
00199 ELSE IF( ( SQRE.LT.0 ) .OR. ( SQRE.GT.1 ) ) THEN
00200 INFO = -4
00201 END IF
00202
00203 N = NL + NR + 1
00204
00205 IF( NRHS.LT.1 ) THEN
00206 INFO = -5
00207 ELSE IF( LDB.LT.N ) THEN
00208 INFO = -7
00209 ELSE IF( LDBX.LT.N ) THEN
00210 INFO = -9
00211 ELSE IF( GIVPTR.LT.0 ) THEN
00212 INFO = -11
00213 ELSE IF( LDGCOL.LT.N ) THEN
00214 INFO = -13
00215 ELSE IF( LDGNUM.LT.N ) THEN
00216 INFO = -15
00217 ELSE IF( K.LT.1 ) THEN
00218 INFO = -20
00219 END IF
00220 IF( INFO.NE.0 ) THEN
00221 CALL XERBLA( 'ZLALS0', -INFO )
00222 RETURN
00223 END IF
00224
00225 M = N + SQRE
00226 NLP1 = NL + 1
00227
00228 IF( ICOMPQ.EQ.0 ) THEN
00229
00230
00231
00232
00233
00234 DO 10 I = 1, GIVPTR
00235 CALL ZDROT( NRHS, B( GIVCOL( I, 2 ), 1 ), LDB,
00236 $ B( GIVCOL( I, 1 ), 1 ), LDB, GIVNUM( I, 2 ),
00237 $ GIVNUM( I, 1 ) )
00238 10 CONTINUE
00239
00240
00241
00242 CALL ZCOPY( NRHS, B( NLP1, 1 ), LDB, BX( 1, 1 ), LDBX )
00243 DO 20 I = 2, N
00244 CALL ZCOPY( NRHS, B( PERM( I ), 1 ), LDB, BX( I, 1 ), LDBX )
00245 20 CONTINUE
00246
00247
00248
00249
00250 IF( K.EQ.1 ) THEN
00251 CALL ZCOPY( NRHS, BX, LDBX, B, LDB )
00252 IF( Z( 1 ).LT.ZERO ) THEN
00253 CALL ZDSCAL( NRHS, NEGONE, B, LDB )
00254 END IF
00255 ELSE
00256 DO 100 J = 1, K
00257 DIFLJ = DIFL( J )
00258 DJ = POLES( J, 1 )
00259 DSIGJ = -POLES( J, 2 )
00260 IF( J.LT.K ) THEN
00261 DIFRJ = -DIFR( J, 1 )
00262 DSIGJP = -POLES( J+1, 2 )
00263 END IF
00264 IF( ( Z( J ).EQ.ZERO ) .OR. ( POLES( J, 2 ).EQ.ZERO ) )
00265 $ THEN
00266 RWORK( J ) = ZERO
00267 ELSE
00268 RWORK( J ) = -POLES( J, 2 )*Z( J ) / DIFLJ /
00269 $ ( POLES( J, 2 )+DJ )
00270 END IF
00271 DO 30 I = 1, J - 1
00272 IF( ( Z( I ).EQ.ZERO ) .OR.
00273 $ ( POLES( I, 2 ).EQ.ZERO ) ) THEN
00274 RWORK( I ) = ZERO
00275 ELSE
00276 RWORK( I ) = POLES( I, 2 )*Z( I ) /
00277 $ ( DLAMC3( POLES( I, 2 ), DSIGJ )-
00278 $ DIFLJ ) / ( POLES( I, 2 )+DJ )
00279 END IF
00280 30 CONTINUE
00281 DO 40 I = J + 1, K
00282 IF( ( Z( I ).EQ.ZERO ) .OR.
00283 $ ( POLES( I, 2 ).EQ.ZERO ) ) THEN
00284 RWORK( I ) = ZERO
00285 ELSE
00286 RWORK( I ) = POLES( I, 2 )*Z( I ) /
00287 $ ( DLAMC3( POLES( I, 2 ), DSIGJP )+
00288 $ DIFRJ ) / ( POLES( I, 2 )+DJ )
00289 END IF
00290 40 CONTINUE
00291 RWORK( 1 ) = NEGONE
00292 TEMP = DNRM2( K, RWORK, 1 )
00293
00294
00295
00296
00297
00298
00299
00300 I = K + NRHS*2
00301 DO 60 JCOL = 1, NRHS
00302 DO 50 JROW = 1, K
00303 I = I + 1
00304 RWORK( I ) = DBLE( BX( JROW, JCOL ) )
00305 50 CONTINUE
00306 60 CONTINUE
00307 CALL DGEMV( 'T', K, NRHS, ONE, RWORK( 1+K+NRHS*2 ), K,
00308 $ RWORK( 1 ), 1, ZERO, RWORK( 1+K ), 1 )
00309 I = K + NRHS*2
00310 DO 80 JCOL = 1, NRHS
00311 DO 70 JROW = 1, K
00312 I = I + 1
00313 RWORK( I ) = DIMAG( BX( JROW, JCOL ) )
00314 70 CONTINUE
00315 80 CONTINUE
00316 CALL DGEMV( 'T', K, NRHS, ONE, RWORK( 1+K+NRHS*2 ), K,
00317 $ RWORK( 1 ), 1, ZERO, RWORK( 1+K+NRHS ), 1 )
00318 DO 90 JCOL = 1, NRHS
00319 B( J, JCOL ) = DCMPLX( RWORK( JCOL+K ),
00320 $ RWORK( JCOL+K+NRHS ) )
00321 90 CONTINUE
00322 CALL ZLASCL( 'G', 0, 0, TEMP, ONE, 1, NRHS, B( J, 1 ),
00323 $ LDB, INFO )
00324 100 CONTINUE
00325 END IF
00326
00327
00328
00329 IF( K.LT.MAX( M, N ) )
00330 $ CALL ZLACPY( 'A', N-K, NRHS, BX( K+1, 1 ), LDBX,
00331 $ B( K+1, 1 ), LDB )
00332 ELSE
00333
00334
00335
00336
00337
00338
00339 IF( K.EQ.1 ) THEN
00340 CALL ZCOPY( NRHS, B, LDB, BX, LDBX )
00341 ELSE
00342 DO 180 J = 1, K
00343 DSIGJ = POLES( J, 2 )
00344 IF( Z( J ).EQ.ZERO ) THEN
00345 RWORK( J ) = ZERO
00346 ELSE
00347 RWORK( J ) = -Z( J ) / DIFL( J ) /
00348 $ ( DSIGJ+POLES( J, 1 ) ) / DIFR( J, 2 )
00349 END IF
00350 DO 110 I = 1, J - 1
00351 IF( Z( J ).EQ.ZERO ) THEN
00352 RWORK( I ) = ZERO
00353 ELSE
00354 RWORK( I ) = Z( J ) / ( DLAMC3( DSIGJ, -POLES( I+1,
00355 $ 2 ) )-DIFR( I, 1 ) ) /
00356 $ ( DSIGJ+POLES( I, 1 ) ) / DIFR( I, 2 )
00357 END IF
00358 110 CONTINUE
00359 DO 120 I = J + 1, K
00360 IF( Z( J ).EQ.ZERO ) THEN
00361 RWORK( I ) = ZERO
00362 ELSE
00363 RWORK( I ) = Z( J ) / ( DLAMC3( DSIGJ, -POLES( I,
00364 $ 2 ) )-DIFL( I ) ) /
00365 $ ( DSIGJ+POLES( I, 1 ) ) / DIFR( I, 2 )
00366 END IF
00367 120 CONTINUE
00368
00369
00370
00371
00372
00373
00374
00375 I = K + NRHS*2
00376 DO 140 JCOL = 1, NRHS
00377 DO 130 JROW = 1, K
00378 I = I + 1
00379 RWORK( I ) = DBLE( B( JROW, JCOL ) )
00380 130 CONTINUE
00381 140 CONTINUE
00382 CALL DGEMV( 'T', K, NRHS, ONE, RWORK( 1+K+NRHS*2 ), K,
00383 $ RWORK( 1 ), 1, ZERO, RWORK( 1+K ), 1 )
00384 I = K + NRHS*2
00385 DO 160 JCOL = 1, NRHS
00386 DO 150 JROW = 1, K
00387 I = I + 1
00388 RWORK( I ) = DIMAG( B( JROW, JCOL ) )
00389 150 CONTINUE
00390 160 CONTINUE
00391 CALL DGEMV( 'T', K, NRHS, ONE, RWORK( 1+K+NRHS*2 ), K,
00392 $ RWORK( 1 ), 1, ZERO, RWORK( 1+K+NRHS ), 1 )
00393 DO 170 JCOL = 1, NRHS
00394 BX( J, JCOL ) = DCMPLX( RWORK( JCOL+K ),
00395 $ RWORK( JCOL+K+NRHS ) )
00396 170 CONTINUE
00397 180 CONTINUE
00398 END IF
00399
00400
00401
00402
00403 IF( SQRE.EQ.1 ) THEN
00404 CALL ZCOPY( NRHS, B( M, 1 ), LDB, BX( M, 1 ), LDBX )
00405 CALL ZDROT( NRHS, BX( 1, 1 ), LDBX, BX( M, 1 ), LDBX, C, S )
00406 END IF
00407 IF( K.LT.MAX( M, N ) )
00408 $ CALL ZLACPY( 'A', N-K, NRHS, B( K+1, 1 ), LDB, BX( K+1, 1 ),
00409 $ LDBX )
00410
00411
00412
00413 CALL ZCOPY( NRHS, BX( 1, 1 ), LDBX, B( NLP1, 1 ), LDB )
00414 IF( SQRE.EQ.1 ) THEN
00415 CALL ZCOPY( NRHS, BX( M, 1 ), LDBX, B( M, 1 ), LDB )
00416 END IF
00417 DO 190 I = 2, N
00418 CALL ZCOPY( NRHS, BX( I, 1 ), LDBX, B( PERM( I ), 1 ), LDB )
00419 190 CONTINUE
00420
00421
00422
00423 DO 200 I = GIVPTR, 1, -1
00424 CALL ZDROT( NRHS, B( GIVCOL( I, 2 ), 1 ), LDB,
00425 $ B( GIVCOL( I, 1 ), 1 ), LDB, GIVNUM( I, 2 ),
00426 $ -GIVNUM( I, 1 ) )
00427 200 CONTINUE
00428 END IF
00429
00430 RETURN
00431
00432
00433
00434 END