144
145
146
147
148
149 IMPLICIT NONE
150
151
152 CHARACTER UPLO
153 INTEGER M, NB, J1, LDA, LDH
154
155
156 INTEGER IPIV( * )
157 COMPLEX*16 A( LDA, * ), H( LDH, * ), WORK( * )
158
159
160
161
162 COMPLEX*16 ZERO, ONE
163 parameter( zero = (0.0d+0, 0.0d+0), one = (1.0d+0, 0.0d+0) )
164
165
166 INTEGER J, K, K1, I1, I2, MJ
167 COMPLEX*16 PIV, ALPHA
168
169
170 LOGICAL LSAME
171 INTEGER IZAMAX, ILAENV
173
174
177
178
179 INTRINSIC dble, dconjg, max
180
181
182
183 j = 1
184
185
186
187
188 k1 = (2-j1)+1
189
190 IF(
lsame( uplo,
'U' ) )
THEN
191
192
193
194
195
196 10 CONTINUE
197 IF ( j.GT.min(m, nb) )
198 $ GO TO 20
199
200
201
202
203
204
205 k = j1+j-1
206 IF( j.EQ.m ) THEN
207
208
209
210 mj = 1
211 ELSE
212 mj = m-j+1
213 END IF
214
215
216
217
218 IF( k.GT.2 ) THEN
219
220
221
222
223
224
225
226 CALL zlacgv( j-k1, a( 1, j ), 1 )
227 CALL zgemv(
'No transpose', mj, j-k1,
228 $ -one, h( j, k1 ), ldh,
229 $ a( 1, j ), 1,
230 $ one, h( j, j ), 1 )
231 CALL zlacgv( j-k1, a( 1, j ), 1 )
232 END IF
233
234
235
236 CALL zcopy( mj, h( j, j ), 1, work( 1 ), 1 )
237
238 IF( j.GT.k1 ) THEN
239
240
241
242
243 alpha = -dconjg( a( k-1, j ) )
244 CALL zaxpy( mj, alpha, a( k-2, j ), lda, work( 1 ), 1 )
245 END IF
246
247
248
249 a( k, j ) = dble( work( 1 ) )
250
251 IF( j.LT.m ) THEN
252
253
254
255
256 IF( k.GT.1 ) THEN
257 alpha = -a( k, j )
258 CALL zaxpy( m-j, alpha, a( k-1, j+1 ), lda,
259 $ work( 2 ), 1 )
260 ENDIF
261
262
263
264 i2 =
izamax( m-j, work( 2 ), 1 ) + 1
265 piv = work( i2 )
266
267
268
269 IF( (i2.NE.2) .AND. (piv.NE.0) ) THEN
270
271
272
273 i1 = 2
274 work( i2 ) = work( i1 )
275 work( i1 ) = piv
276
277
278
279 i1 = i1+j-1
280 i2 = i2+j-1
281 CALL zswap( i2-i1-1, a( j1+i1-1, i1+1 ), lda,
282 $ a( j1+i1, i2 ), 1 )
283 CALL zlacgv( i2-i1, a( j1+i1-1, i1+1 ), lda )
284 CALL zlacgv( i2-i1-1, a( j1+i1, i2 ), 1 )
285
286
287
288 IF( i2.LT.m )
289 $
CALL zswap( m-i2, a( j1+i1-1, i2+1 ), lda,
290 $ a( j1+i2-1, i2+1 ), lda )
291
292
293
294 piv = a( i1+j1-1, i1 )
295 a( j1+i1-1, i1 ) = a( j1+i2-1, i2 )
296 a( j1+i2-1, i2 ) = piv
297
298
299
300 CALL zswap( i1-1, h( i1, 1 ), ldh, h( i2, 1 ), ldh )
301 ipiv( i1 ) = i2
302
303 IF( i1.GT.(k1-1) ) THEN
304
305
306
307
308 CALL zswap( i1-k1+1, a( 1, i1 ), 1,
309 $ a( 1, i2 ), 1 )
310 END IF
311 ELSE
312 ipiv( j+1 ) = j+1
313 ENDIF
314
315
316
317 a( k, j+1 ) = work( 2 )
318
319 IF( j.LT.nb ) THEN
320
321
322
323 CALL zcopy( m-j, a( k+1, j+1 ), lda,
324 $ h( j+1, j+1 ), 1 )
325 END IF
326
327
328
329
330 IF( j.LT.(m-1) ) THEN
331 IF( a( k, j+1 ).NE.zero ) THEN
332 alpha = one / a( k, j+1 )
333 CALL zcopy( m-j-1, work( 3 ), 1, a( k, j+2 ), lda )
334 CALL zscal( m-j-1, alpha, a( k, j+2 ), lda )
335 ELSE
336 CALL zlaset(
'Full', 1, m-j-1, zero, zero,
337 $ a( k, j+2 ), lda)
338 END IF
339 END IF
340 END IF
341 j = j + 1
342 GO TO 10
343 20 CONTINUE
344
345 ELSE
346
347
348
349
350
351 30 CONTINUE
352 IF( j.GT.min( m, nb ) )
353 $ GO TO 40
354
355
356
357
358
359
360 k = j1+j-1
361 IF( j.EQ.m ) THEN
362
363
364
365 mj = 1
366 ELSE
367 mj = m-j+1
368 END IF
369
370
371
372
373 IF( k.GT.2 ) THEN
374
375
376
377
378
379
380
381 CALL zlacgv( j-k1, a( j, 1 ), lda )
382 CALL zgemv(
'No transpose', mj, j-k1,
383 $ -one, h( j, k1 ), ldh,
384 $ a( j, 1 ), lda,
385 $ one, h( j, j ), 1 )
386 CALL zlacgv( j-k1, a( j, 1 ), lda )
387 END IF
388
389
390
391 CALL zcopy( mj, h( j, j ), 1, work( 1 ), 1 )
392
393 IF( j.GT.k1 ) THEN
394
395
396
397
398 alpha = -dconjg( a( j, k-1 ) )
399 CALL zaxpy( mj, alpha, a( j, k-2 ), 1, work( 1 ), 1 )
400 END IF
401
402
403
404 a( j, k ) = dble( work( 1 ) )
405
406 IF( j.LT.m ) THEN
407
408
409
410
411 IF( k.GT.1 ) THEN
412 alpha = -a( j, k )
413 CALL zaxpy( m-j, alpha, a( j+1, k-1 ), 1,
414 $ work( 2 ), 1 )
415 ENDIF
416
417
418
419 i2 =
izamax( m-j, work( 2 ), 1 ) + 1
420 piv = work( i2 )
421
422
423
424 IF( (i2.NE.2) .AND. (piv.NE.0) ) THEN
425
426
427
428 i1 = 2
429 work( i2 ) = work( i1 )
430 work( i1 ) = piv
431
432
433
434 i1 = i1+j-1
435 i2 = i2+j-1
436 CALL zswap( i2-i1-1, a( i1+1, j1+i1-1 ), 1,
437 $ a( i2, j1+i1 ), lda )
438 CALL zlacgv( i2-i1, a( i1+1, j1+i1-1 ), 1 )
439 CALL zlacgv( i2-i1-1, a( i2, j1+i1 ), lda )
440
441
442
443 IF( i2.LT.m )
444 $
CALL zswap( m-i2, a( i2+1, j1+i1-1 ), 1,
445 $ a( i2+1, j1+i2-1 ), 1 )
446
447
448
449 piv = a( i1, j1+i1-1 )
450 a( i1, j1+i1-1 ) = a( i2, j1+i2-1 )
451 a( i2, j1+i2-1 ) = piv
452
453
454
455 CALL zswap( i1-1, h( i1, 1 ), ldh, h( i2, 1 ), ldh )
456 ipiv( i1 ) = i2
457
458 IF( i1.GT.(k1-1) ) THEN
459
460
461
462
463 CALL zswap( i1-k1+1, a( i1, 1 ), lda,
464 $ a( i2, 1 ), lda )
465 END IF
466 ELSE
467 ipiv( j+1 ) = j+1
468 ENDIF
469
470
471
472 a( j+1, k ) = work( 2 )
473
474 IF( j.LT.nb ) THEN
475
476
477
478 CALL zcopy( m-j, a( j+1, k+1 ), 1,
479 $ h( j+1, j+1 ), 1 )
480 END IF
481
482
483
484
485 IF( j.LT.(m-1) ) THEN
486 IF( a( j+1, k ).NE.zero ) THEN
487 alpha = one / a( j+1, k )
488 CALL zcopy( m-j-1, work( 3 ), 1, a( j+2, k ), 1 )
489 CALL zscal( m-j-1, alpha, a( j+2, k ), 1 )
490 ELSE
491 CALL zlaset(
'Full', m-j-1, 1, zero, zero,
492 $ a( j+2, k ), lda )
493 END IF
494 END IF
495 END IF
496 j = j + 1
497 GO TO 30
498 40 CONTINUE
499 END IF
500 RETURN
501
502
503
subroutine xerbla(srname, info)
subroutine zaxpy(n, za, zx, incx, zy, incy)
ZAXPY
subroutine zcopy(n, zx, incx, zy, incy)
ZCOPY
subroutine zgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
ZGEMM
subroutine zgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
ZGEMV
integer function izamax(n, zx, incx)
IZAMAX
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
subroutine zlacgv(n, x, incx)
ZLACGV conjugates a complex vector.
subroutine zlaset(uplo, m, n, alpha, beta, a, lda)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
logical function lsame(ca, cb)
LSAME
subroutine zscal(n, za, zx, incx)
ZSCAL
subroutine zswap(n, zx, incx, zy, incy)
ZSWAP