If TRANS = 'N', multiplies by U or U * D (or L or L * D) If TRANS = 'C', multiplies by U' or D * U' (or L' or D * L')
153
154
155
156
157
158
159 CHARACTER DIAG, TRANS, UPLO
160 INTEGER INFO, LDA, LDB, N, NRHS
161
162
163 INTEGER IPIV( * )
164 COMPLEX*16 A( LDA, * ), B( LDB, * )
165
166
167
168
169
170 COMPLEX*16 CONE
171 parameter( cone = ( 1.0d+0, 0.0d+0 ) )
172
173
174 LOGICAL NOUNIT
175 INTEGER J, K, KP
176 COMPLEX*16 D11, D12, D21, D22, T1, T2
177
178
179 LOGICAL LSAME
181
182
184
185
186 INTRINSIC abs, dconjg, max
187
188
189
190
191
192 info = 0
193 IF( .NOT.
lsame( uplo,
'U' ) .AND. .NOT.
lsame( uplo,
'L' ) )
THEN
194 info = -1
195 ELSE IF( .NOT.
lsame( trans,
'N' ) .AND. .NOT.
lsame( trans,
'C' ) )
196 $ THEN
197 info = -2
198 ELSE IF( .NOT.
lsame( diag,
'U' ) .AND. .NOT.
lsame( diag,
'N' ) )
199 $ THEN
200 info = -3
201 ELSE IF( n.LT.0 ) THEN
202 info = -4
203 ELSE IF( lda.LT.max( 1, n ) ) THEN
204 info = -6
205 ELSE IF( ldb.LT.max( 1, n ) ) THEN
206 info = -9
207 END IF
208 IF( info.NE.0 ) THEN
209 CALL xerbla(
'ZLAVHE_ROOK ', -info )
210 RETURN
211 END IF
212
213
214
215 IF( n.EQ.0 )
216 $ RETURN
217
218 nounit =
lsame( diag,
'N' )
219
220
221
222
223
224 IF(
lsame( trans,
'N' ) )
THEN
225
226
227
228
229 IF(
lsame( uplo,
'U' ) )
THEN
230
231
232
233 k = 1
234 10 CONTINUE
235 IF( k.GT.n )
236 $ GO TO 30
237 IF( ipiv( k ).GT.0 ) THEN
238
239
240
241
242
243 IF( nounit )
244 $
CALL zscal( nrhs, a( k, k ), b( k, 1 ), ldb )
245
246
247
248 IF( k.GT.1 ) THEN
249
250
251
252 CALL zgeru( k-1, nrhs, cone, a( 1, k ), 1, b( k, 1 ),
253 $ ldb, b( 1, 1 ), ldb )
254
255
256
257 kp = ipiv( k )
258 IF( kp.NE.k )
259 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
260 END IF
261 k = k + 1
262 ELSE
263
264
265
266
267
268 IF( nounit ) THEN
269 d11 = a( k, k )
270 d22 = a( k+1, k+1 )
271 d12 = a( k, k+1 )
272 d21 = dconjg( d12 )
273 DO 20 j = 1, nrhs
274 t1 = b( k, j )
275 t2 = b( k+1, j )
276 b( k, j ) = d11*t1 + d12*t2
277 b( k+1, j ) = d21*t1 + d22*t2
278 20 CONTINUE
279 END IF
280
281
282
283 IF( k.GT.1 ) THEN
284
285
286
287 CALL zgeru( k-1, nrhs, cone, a( 1, k ), 1, b( k, 1 ),
288 $ ldb, b( 1, 1 ), ldb )
289 CALL zgeru( k-1, nrhs, cone, a( 1, k+1 ), 1,
290 $ b( k+1, 1 ), ldb, b( 1, 1 ), ldb )
291
292
293
294
295
296
297 kp = abs( ipiv( k ) )
298 IF( kp.NE.k )
299 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
300
301
302
303 kp = abs( ipiv( k+1 ) )
304 IF( kp.NE.k+1 )
305 $
CALL zswap( nrhs, b( k+1, 1 ), ldb, b( kp, 1 ),
306 $ ldb )
307 END IF
308 k = k + 2
309 END IF
310 GO TO 10
311 30 CONTINUE
312
313
314
315
316 ELSE
317
318
319
320 k = n
321 40 CONTINUE
322 IF( k.LT.1 )
323 $ GO TO 60
324
325
326
327
328 IF( ipiv( k ).GT.0 ) THEN
329
330
331
332
333
334 IF( nounit )
335 $
CALL zscal( nrhs, a( k, k ), b( k, 1 ), ldb )
336
337
338
339 IF( k.NE.n ) THEN
340 kp = ipiv( k )
341
342
343
344 CALL zgeru( n-k, nrhs, cone, a( k+1, k ), 1,
345 $ b( k, 1 ), ldb, b( k+1, 1 ), ldb )
346
347
348
349
350 IF( kp.NE.k )
351 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
352 END IF
353 k = k - 1
354
355 ELSE
356
357
358
359
360
361 IF( nounit ) THEN
362 d11 = a( k-1, k-1 )
363 d22 = a( k, k )
364 d21 = a( k, k-1 )
365 d12 = dconjg( d21 )
366 DO 50 j = 1, nrhs
367 t1 = b( k-1, j )
368 t2 = b( k, j )
369 b( k-1, j ) = d11*t1 + d12*t2
370 b( k, j ) = d21*t1 + d22*t2
371 50 CONTINUE
372 END IF
373
374
375
376 IF( k.NE.n ) THEN
377
378
379
380 CALL zgeru( n-k, nrhs, cone, a( k+1, k ), 1,
381 $ b( k, 1 ), ldb, b( k+1, 1 ), ldb )
382 CALL zgeru( n-k, nrhs, cone, a( k+1, k-1 ), 1,
383 $ b( k-1, 1 ), ldb, b( k+1, 1 ), ldb )
384
385
386
387
388
389
390
391 kp = abs( ipiv( k ) )
392 IF( kp.NE.k )
393 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
394
395
396
397 kp = abs( ipiv( k-1 ) )
398 IF( kp.NE.k-1 )
399 $
CALL zswap( nrhs, b( k-1, 1 ), ldb, b( kp, 1 ),
400 $ ldb )
401
402 END IF
403 k = k - 2
404 END IF
405 GO TO 40
406 60 CONTINUE
407 END IF
408
409
410
411
412
413 ELSE
414
415
416
417
418
419 IF(
lsame( uplo,
'U' ) )
THEN
420
421
422
423 k = n
424 70 IF( k.LT.1 )
425 $ GO TO 90
426
427
428
429 IF( ipiv( k ).GT.0 ) THEN
430 IF( k.GT.1 ) THEN
431
432
433
434 kp = ipiv( k )
435 IF( kp.NE.k )
436 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
437
438
439
440
441
442 CALL zlacgv( nrhs, b( k, 1 ), ldb )
443 CALL zgemv(
'Conjugate', k-1, nrhs, cone, b, ldb,
444 $ a( 1, k ), 1, cone, b( k, 1 ), ldb )
445 CALL zlacgv( nrhs, b( k, 1 ), ldb )
446 END IF
447 IF( nounit )
448 $
CALL zscal( nrhs, a( k, k ), b( k, 1 ), ldb )
449 k = k - 1
450
451
452
453 ELSE
454 IF( k.GT.2 ) THEN
455
456
457
458 kp = abs( ipiv( k ) )
459 IF( kp.NE.k )
460 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
461
462
463
464 kp = abs( ipiv( k-1 ) )
465 IF( kp.NE.k-1 )
466 $
CALL zswap( nrhs, b( k-1, 1 ), ldb, b( kp, 1 ),
467 $ ldb )
468
469
470
471
472
473
474 CALL zlacgv( nrhs, b( k, 1 ), ldb )
475 CALL zgemv(
'Conjugate', k-2, nrhs, cone, b, ldb,
476 $ a( 1, k ), 1, cone, b( k, 1 ), ldb )
477 CALL zlacgv( nrhs, b( k, 1 ), ldb )
478
479 CALL zlacgv( nrhs, b( k-1, 1 ), ldb )
480 CALL zgemv(
'Conjugate', k-2, nrhs, cone, b, ldb,
481 $ a( 1, k-1 ), 1, cone, b( k-1, 1 ), ldb )
482 CALL zlacgv( nrhs, b( k-1, 1 ), ldb )
483 END IF
484
485
486
487 IF( nounit ) THEN
488 d11 = a( k-1, k-1 )
489 d22 = a( k, k )
490 d12 = a( k-1, k )
491 d21 = dconjg( d12 )
492 DO 80 j = 1, nrhs
493 t1 = b( k-1, j )
494 t2 = b( k, j )
495 b( k-1, j ) = d11*t1 + d12*t2
496 b( k, j ) = d21*t1 + d22*t2
497 80 CONTINUE
498 END IF
499 k = k - 2
500 END IF
501 GO TO 70
502 90 CONTINUE
503
504
505
506
507
508 ELSE
509
510
511
512 k = 1
513 100 CONTINUE
514 IF( k.GT.n )
515 $ GO TO 120
516
517
518
519 IF( ipiv( k ).GT.0 ) THEN
520 IF( k.LT.n ) THEN
521
522
523
524 kp = ipiv( k )
525 IF( kp.NE.k )
526 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
527
528
529
530 CALL zlacgv( nrhs, b( k, 1 ), ldb )
531 CALL zgemv(
'Conjugate', n-k, nrhs, cone, b( k+1, 1 ),
532 $ ldb, a( k+1, k ), 1, cone, b( k, 1 ), ldb )
533 CALL zlacgv( nrhs, b( k, 1 ), ldb )
534 END IF
535 IF( nounit )
536 $
CALL zscal( nrhs, a( k, k ), b( k, 1 ), ldb )
537 k = k + 1
538
539
540
541 ELSE
542 IF( k.LT.n-1 ) THEN
543
544
545
546 kp = abs( ipiv( k ) )
547 IF( kp.NE.k )
548 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
549
550
551
552 kp = abs( ipiv( k+1 ) )
553 IF( kp.NE.k+1 )
554 $
CALL zswap( nrhs, b( k+1, 1 ), ldb, b( kp, 1 ),
555 $ ldb )
556
557
558
559 CALL zlacgv( nrhs, b( k+1, 1 ), ldb )
560 CALL zgemv(
'Conjugate', n-k-1, nrhs, cone,
561 $ b( k+2, 1 ), ldb, a( k+2, k+1 ), 1, cone,
562 $ b( k+1, 1 ), ldb )
563 CALL zlacgv( nrhs, b( k+1, 1 ), ldb )
564
565 CALL zlacgv( nrhs, b( k, 1 ), ldb )
566 CALL zgemv(
'Conjugate', n-k-1, nrhs, cone,
567 $ b( k+2, 1 ), ldb, a( k+2, k ), 1, cone,
568 $ b( k, 1 ), ldb )
569 CALL zlacgv( nrhs, b( k, 1 ), ldb )
570 END IF
571
572
573
574 IF( nounit ) THEN
575 d11 = a( k, k )
576 d22 = a( k+1, k+1 )
577 d21 = a( k+1, k )
578 d12 = dconjg( d21 )
579 DO 110 j = 1, nrhs
580 t1 = b( k, j )
581 t2 = b( k+1, j )
582 b( k, j ) = d11*t1 + d12*t2
583 b( k+1, j ) = d21*t1 + d22*t2
584 110 CONTINUE
585 END IF
586 k = k + 2
587 END IF
588 GO TO 100
589 120 CONTINUE
590 END IF
591
592 END IF
593 RETURN
594
595
596
subroutine xerbla(srname, info)
subroutine zgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
ZGEMV
subroutine zgeru(m, n, alpha, x, incx, y, incy, a, lda)
ZGERU
subroutine zlacgv(n, x, incx)
ZLACGV conjugates a complex vector.
logical function lsame(ca, cb)
LSAME
subroutine zscal(n, za, zx, incx)
ZSCAL
subroutine zswap(n, zx, incx, zy, incy)
ZSWAP