159 $ IPIV2, WORK, LWORK, INFO )
169 INTEGER N, LDA, LTB, LWORK, INFO
172 INTEGER IPIV( * ), IPIV2( * )
173 COMPLEX A( LDA, * ), TB( * ), WORK( * )
179 parameter( zero = ( 0.0e+0, 0.0e+0 ),
180 $ one = ( 1.0e+0, 0.0e+0 ) )
183 LOGICAL UPPER, TQUERY, WQUERY
184 INTEGER I, J, K, I1, I2, TD
185 INTEGER LDTB, NB, KB, JB, NT, IINFO
191 EXTERNAL lsame, ilaenv
200 INTRINSIC conjg, min, max
207 upper = lsame( uplo,
'U' )
208 wquery = ( lwork.EQ.-1 )
209 tquery = ( ltb.EQ.-1 )
210 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
212 ELSE IF( n.LT.0 )
THEN
214 ELSE IF( lda.LT.max( 1, n ) )
THEN
216 ELSE IF ( ltb .LT. 4*n .AND. .NOT.tquery )
THEN
218 ELSE IF ( lwork .LT. n .AND. .NOT.wquery )
THEN
223 CALL xerbla(
'CHETRF_AA_2STAGE', -info )
229 nb = ilaenv( 1,
'CHETRF_AA_2STAGE', uplo, n, -1, -1, -1 )
238 IF( tquery .OR. wquery )
THEN
251 IF( ldtb .LT. 3*nb+1 )
THEN
254 IF( lwork .LT. nb*n )
THEN
288 IF( i .EQ. (j-1) )
THEN
293 CALL cgemm(
'NoTranspose',
'NoTranspose',
295 $ one, tb( td+1 + (i*nb)*ldtb ), ldtb-1,
296 $ a( (i-1)*nb+1, j*nb+1 ), lda,
297 $ zero, work( i*nb+1 ), n )
300 IF( i .EQ. (j-1) )
THEN
305 CALL cgemm(
'NoTranspose',
'NoTranspose',
307 $ one, tb( td+nb+1 + ((i-1)*nb)*ldtb ),
309 $ a( (i-2)*nb+1, j*nb+1 ), lda,
310 $ zero, work( i*nb+1 ), n )
316 CALL clacpy(
'Upper', kb, kb, a( j*nb+1, j*nb+1 ), lda,
317 $ tb( td+1 + (j*nb)*ldtb ), ldtb-1 )
320 CALL cgemm(
'Conjugate transpose',
'NoTranspose',
322 $ -one, a( 1, j*nb+1 ), lda,
324 $ one, tb( td+1 + (j*nb)*ldtb ), ldtb-1 )
326 CALL cgemm(
'Conjugate transpose',
'NoTranspose',
328 $ one, a( (j-1)*nb+1, j*nb+1 ), lda,
329 $ tb( td+nb+1 + ((j-1)*nb)*ldtb ), ldtb-1,
330 $ zero, work( 1 ), n )
331 CALL cgemm(
'NoTranspose',
'NoTranspose',
333 $ -one, work( 1 ), n,
334 $ a( (j-2)*nb+1, j*nb+1 ), lda,
335 $ one, tb( td+1 + (j*nb)*ldtb ), ldtb-1 )
338 CALL chegst( 1,
'Upper', kb,
339 $ tb( td+1 + (j*nb)*ldtb ), ldtb-1,
340 $ a( (j-1)*nb+1, j*nb+1 ), lda, iinfo )
346 tb( td+1 + (j*nb+i-1)*ldtb )
347 $ = real( tb( td+1 + (j*nb+i-1)*ldtb ) )
349 tb( td+(k-i)+1 + (j*nb+i-1)*ldtb )
350 $ = conjg( tb( td-(k-(i+1)) + (j*nb+k-1)*ldtb ) )
360 CALL cgemm(
'NoTranspose',
'NoTranspose',
362 $ one, tb( td+1 + (j*nb)*ldtb ), ldtb-1,
363 $ a( (j-1)*nb+1, j*nb+1 ), lda,
364 $ zero, work( j*nb+1 ), n )
366 CALL cgemm(
'NoTranspose',
'NoTranspose',
368 $ one, tb( td+nb+1 + ((j-1)*nb)*ldtb ),
370 $ a( (j-2)*nb+1, j*nb+1 ), lda,
371 $ zero, work( j*nb+1 ), n )
376 CALL cgemm(
'Conjugate transpose',
'NoTranspose',
377 $ nb, n-(j+1)*nb, j*nb,
378 $ -one, work( nb+1 ), n,
379 $ a( 1, (j+1)*nb+1 ), lda,
380 $ one, a( j*nb+1, (j+1)*nb+1 ), lda )
386 CALL ccopy( n-(j+1)*nb,
387 $ a( j*nb+k, (j+1)*nb+1 ), lda,
388 $ work( 1+(k-1)*n ), 1 )
393 CALL cgetrf( n-(j+1)*nb, nb,
395 $ ipiv( (j+1)*nb+1 ), iinfo )
406 CALL ccopy( n-k-(j+1)*nb,
407 $ work( k+1+(k-1)*n ), 1,
408 $ a( j*nb+k, (j+1)*nb+k+1 ), lda )
412 CALL clacgv( k, work( 1+(k-1)*n ), 1 )
417 kb = min(nb, n-(j+1)*nb)
418 CALL claset(
'Full', kb, nb, zero, zero,
419 $ tb( td+nb+1 + (j*nb)*ldtb), ldtb-1 )
420 CALL clacpy(
'Upper', kb, nb,
422 $ tb( td+nb+1 + (j*nb)*ldtb ), ldtb-1 )
424 CALL ctrsm(
'R',
'U',
'N',
'U', kb, nb, one,
425 $ a( (j-1)*nb+1, j*nb+1 ), lda,
426 $ tb( td+nb+1 + (j*nb)*ldtb ), ldtb-1 )
434 tb( td-nb+k-i+1 + (j*nb+nb+i-1)*ldtb )
435 $ = conjg( tb( td+nb+i-k+1 + (j*nb+k-1)*ldtb ) )
438 CALL claset(
'Lower', kb, nb, zero, one,
439 $ a( j*nb+1, (j+1)*nb+1), lda )
445 ipiv( (j+1)*nb+k ) = ipiv( (j+1)*nb+k ) + (j+1)*nb
448 i2 = ipiv( (j+1)*nb+k )
451 CALL cswap( k-1, a( (j+1)*nb+1, i1 ), 1,
452 $ a( (j+1)*nb+1, i2 ), 1 )
454 IF( i2.GT.(i1+1) )
THEN
455 CALL cswap( i2-i1-1, a( i1, i1+1 ), lda,
457 CALL clacgv( i2-i1-1, a( i1+1, i2 ), 1 )
459 CALL clacgv( i2-i1, a( i1, i1+1 ), lda )
462 $
CALL cswap( n-i2, a( i1, i2+1 ), lda,
463 $ a( i2, i2+1 ), lda )
466 a( i1, i1 ) = a( i2, i2 )
470 CALL cswap( j*nb, a( 1, i1 ), 1,
491 IF( i .EQ. (j-1) )
THEN
496 CALL cgemm(
'NoTranspose',
'Conjugate transpose',
498 $ one, tb( td+1 + (i*nb)*ldtb ), ldtb-1,
499 $ a( j*nb+1, (i-1)*nb+1 ), lda,
500 $ zero, work( i*nb+1 ), n )
503 IF( i .EQ. (j-1) )
THEN
508 CALL cgemm(
'NoTranspose',
'Conjugate transpose',
510 $ one, tb( td+nb+1 + ((i-1)*nb)*ldtb ),
512 $ a( j*nb+1, (i-2)*nb+1 ), lda,
513 $ zero, work( i*nb+1 ), n )
519 CALL clacpy(
'Lower', kb, kb, a( j*nb+1, j*nb+1 ), lda,
520 $ tb( td+1 + (j*nb)*ldtb ), ldtb-1 )
523 CALL cgemm(
'NoTranspose',
'NoTranspose',
525 $ -one, a( j*nb+1, 1 ), lda,
527 $ one, tb( td+1 + (j*nb)*ldtb ), ldtb-1 )
529 CALL cgemm(
'NoTranspose',
'NoTranspose',
531 $ one, a( j*nb+1, (j-1)*nb+1 ), lda,
532 $ tb( td+nb+1 + ((j-1)*nb)*ldtb ), ldtb-1,
533 $ zero, work( 1 ), n )
534 CALL cgemm(
'NoTranspose',
'Conjugate transpose',
536 $ -one, work( 1 ), n,
537 $ a( j*nb+1, (j-2)*nb+1 ), lda,
538 $ one, tb( td+1 + (j*nb)*ldtb ), ldtb-1 )
541 CALL chegst( 1,
'Lower', kb,
542 $ tb( td+1 + (j*nb)*ldtb ), ldtb-1,
543 $ a( j*nb+1, (j-1)*nb+1 ), lda, iinfo )
549 tb( td+1 + (j*nb+i-1)*ldtb )
550 $ = real( tb( td+1 + (j*nb+i-1)*ldtb ) )
552 tb( td-(k-(i+1)) + (j*nb+k-1)*ldtb )
553 $ = conjg( tb( td+(k-i)+1 + (j*nb+i-1)*ldtb ) )
563 CALL cgemm(
'NoTranspose',
'Conjugate transpose',
565 $ one, tb( td+1 + (j*nb)*ldtb ), ldtb-1,
566 $ a( j*nb+1, (j-1)*nb+1 ), lda,
567 $ zero, work( j*nb+1 ), n )
569 CALL cgemm(
'NoTranspose',
'Conjugate transpose',
571 $ one, tb( td+nb+1 + ((j-1)*nb)*ldtb ),
573 $ a( j*nb+1, (j-2)*nb+1 ), lda,
574 $ zero, work( j*nb+1 ), n )
579 CALL cgemm(
'NoTranspose',
'NoTranspose',
580 $ n-(j+1)*nb, nb, j*nb,
581 $ -one, a( (j+1)*nb+1, 1 ), lda,
583 $ one, a( (j+1)*nb+1, j*nb+1 ), lda )
588 CALL cgetrf( n-(j+1)*nb, nb,
589 $ a( (j+1)*nb+1, j*nb+1 ), lda,
590 $ ipiv( (j+1)*nb+1 ), iinfo )
597 kb = min(nb, n-(j+1)*nb)
598 CALL claset(
'Full', kb, nb, zero, zero,
599 $ tb( td+nb+1 + (j*nb)*ldtb), ldtb-1 )
600 CALL clacpy(
'Upper', kb, nb,
601 $ a( (j+1)*nb+1, j*nb+1 ), lda,
602 $ tb( td+nb+1 + (j*nb)*ldtb ), ldtb-1 )
604 CALL ctrsm(
'R',
'L',
'C',
'U', kb, nb, one,
605 $ a( j*nb+1, (j-1)*nb+1 ), lda,
606 $ tb( td+nb+1 + (j*nb)*ldtb ), ldtb-1 )
614 tb( td-nb+k-i+1 + (j*nb+nb+i-1)*ldtb )
615 $ = conjg( tb( td+nb+i-k+1 + (j*nb+k-1)*ldtb ) )
618 CALL claset(
'Upper', kb, nb, zero, one,
619 $ a( (j+1)*nb+1, j*nb+1), lda )
625 ipiv( (j+1)*nb+k ) = ipiv( (j+1)*nb+k ) + (j+1)*nb
628 i2 = ipiv( (j+1)*nb+k )
631 CALL cswap( k-1, a( i1, (j+1)*nb+1 ), lda,
632 $ a( i2, (j+1)*nb+1 ), lda )
634 IF( i2.GT.(i1+1) )
THEN
635 CALL cswap( i2-i1-1, a( i1+1, i1 ), 1,
636 $ a( i2, i1+1 ), lda )
637 CALL clacgv( i2-i1-1, a( i2, i1+1 ), lda )
639 CALL clacgv( i2-i1, a( i1+1, i1 ), 1 )
642 $
CALL cswap( n-i2, a( i2+1, i1 ), 1,
646 a( i1, i1 ) = a( i2, i2 )
650 CALL cswap( j*nb, a( i1, 1 ), lda,
665 CALL cgbtrf( n, n, nb, nb, tb, ldtb, ipiv2, info )
subroutine xerbla(srname, info)
subroutine ccopy(n, cx, incx, cy, incy)
CCOPY
subroutine cgbtrf(m, n, kl, ku, ab, ldab, ipiv, info)
CGBTRF
subroutine cgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
CGEMM
subroutine cgetrf(m, n, a, lda, ipiv, info)
CGETRF
subroutine chegst(itype, uplo, n, a, lda, b, ldb, info)
CHEGST
subroutine chetrf_aa_2stage(uplo, n, a, lda, tb, ltb, ipiv, ipiv2, work, lwork, info)
CHETRF_AA_2STAGE
subroutine clacgv(n, x, incx)
CLACGV conjugates a complex vector.
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
subroutine claset(uplo, m, n, alpha, beta, a, lda)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine cswap(n, cx, incx, cy, incy)
CSWAP
subroutine ctrsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
CTRSM