Annotation of rpl/lapack/lapack/zlahef_aa.f, revision 1.4

1.1       bertrand    1: *> \brief \b ZLAHEF_AA
                      2: *
                      3: *  =========== DOCUMENTATION ===========
                      4: *
                      5: * Online html documentation available at
                      6: *            http://www.netlib.org/lapack/explore-html/
                      7: *
                      8: *> \htmlonly
                      9: *> Download ZLAHEF_AA + dependencies
                     10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlahef_aa.f">
                     11: *> [TGZ]</a>
                     12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlahef_aa.f">
                     13: *> [ZIP]</a>
                     14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlahef_aa.f">
                     15: *> [TXT]</a>
                     16: *> \endhtmlonly
                     17: *
                     18: *  Definition:
                     19: *  ===========
                     20: *
                     21: *       SUBROUTINE ZLAHEF_AA( UPLO, J1, M, NB, A, LDA, IPIV,
1.3       bertrand   22: *                             H, LDH, WORK )
1.1       bertrand   23: *
                     24: *       .. Scalar Arguments ..
                     25: *       CHARACTER    UPLO
1.3       bertrand   26: *       INTEGER      J1, M, NB, LDA, LDH
1.1       bertrand   27: *       ..
                     28: *       .. Array Arguments ..
                     29: *       INTEGER      IPIV( * )
                     30: *       COMPLEX*16   A( LDA, * ), H( LDH, * ), WORK( * )
                     31: *       ..
                     32: *
                     33: *
                     34: *> \par Purpose:
                     35: *  =============
                     36: *>
                     37: *> \verbatim
                     38: *>
                     39: *> DLAHEF_AA factorizes a panel of a complex hermitian matrix A using
                     40: *> the Aasen's algorithm. The panel consists of a set of NB rows of A
                     41: *> when UPLO is U, or a set of NB columns when UPLO is L.
                     42: *>
                     43: *> In order to factorize the panel, the Aasen's algorithm requires the
                     44: *> last row, or column, of the previous panel. The first row, or column,
                     45: *> of A is set to be the first row, or column, of an identity matrix,
                     46: *> which is used to factorize the first panel.
                     47: *>
                     48: *> The resulting J-th row of U, or J-th column of L, is stored in the
                     49: *> (J-1)-th row, or column, of A (without the unit diagonals), while
                     50: *> the diagonal and subdiagonal of A are overwritten by those of T.
                     51: *>
                     52: *> \endverbatim
                     53: *
                     54: *  Arguments:
                     55: *  ==========
                     56: *
                     57: *> \param[in] UPLO
                     58: *> \verbatim
                     59: *>          UPLO is CHARACTER*1
                     60: *>          = 'U':  Upper triangle of A is stored;
                     61: *>          = 'L':  Lower triangle of A is stored.
                     62: *> \endverbatim
                     63: *>
                     64: *> \param[in] J1
                     65: *> \verbatim
                     66: *>          J1 is INTEGER
                     67: *>          The location of the first row, or column, of the panel
                     68: *>          within the submatrix of A, passed to this routine, e.g.,
                     69: *>          when called by ZHETRF_AA, for the first panel, J1 is 1,
                     70: *>          while for the remaining panels, J1 is 2.
                     71: *> \endverbatim
                     72: *>
                     73: *> \param[in] M
                     74: *> \verbatim
                     75: *>          M is INTEGER
                     76: *>          The dimension of the submatrix. M >= 0.
                     77: *> \endverbatim
                     78: *>
                     79: *> \param[in] NB
                     80: *> \verbatim
                     81: *>          NB is INTEGER
                     82: *>          The dimension of the panel to be facotorized.
                     83: *> \endverbatim
                     84: *>
                     85: *> \param[in,out] A
                     86: *> \verbatim
                     87: *>          A is COMPLEX*16 array, dimension (LDA,M) for
                     88: *>          the first panel, while dimension (LDA,M+1) for the
                     89: *>          remaining panels.
                     90: *>
                     91: *>          On entry, A contains the last row, or column, of
                     92: *>          the previous panel, and the trailing submatrix of A
                     93: *>          to be factorized, except for the first panel, only
                     94: *>          the panel is passed.
                     95: *>
                     96: *>          On exit, the leading panel is factorized.
                     97: *> \endverbatim
                     98: *>
                     99: *> \param[in] LDA
                    100: *> \verbatim
                    101: *>          LDA is INTEGER
                    102: *>          The leading dimension of the array A.  LDA >= max(1,N).
                    103: *> \endverbatim
                    104: *>
                    105: *> \param[out] IPIV
                    106: *> \verbatim
                    107: *>          IPIV is INTEGER array, dimension (N)
                    108: *>          Details of the row and column interchanges,
                    109: *>          the row and column k were interchanged with the row and
                    110: *>          column IPIV(k).
                    111: *> \endverbatim
                    112: *>
                    113: *> \param[in,out] H
                    114: *> \verbatim
                    115: *>          H is COMPLEX*16 workspace, dimension (LDH,NB).
                    116: *>
                    117: *> \endverbatim
                    118: *>
                    119: *> \param[in] LDH
                    120: *> \verbatim
                    121: *>          LDH is INTEGER
                    122: *>          The leading dimension of the workspace H. LDH >= max(1,M).
                    123: *> \endverbatim
                    124: *>
                    125: *> \param[out] WORK
                    126: *> \verbatim
                    127: *>          WORK is COMPLEX*16 workspace, dimension (M).
                    128: *> \endverbatim
                    129: *>
                    130: *
                    131: *  Authors:
                    132: *  ========
                    133: *
                    134: *> \author Univ. of Tennessee
                    135: *> \author Univ. of California Berkeley
                    136: *> \author Univ. of Colorado Denver
                    137: *> \author NAG Ltd.
                    138: *
1.3       bertrand  139: *> \date November 2017
1.1       bertrand  140: *
                    141: *> \ingroup complex16HEcomputational
                    142: *
                    143: *  =====================================================================
                    144:       SUBROUTINE ZLAHEF_AA( UPLO, J1, M, NB, A, LDA, IPIV,
1.3       bertrand  145:      $                      H, LDH, WORK )
1.1       bertrand  146: *
1.3       bertrand  147: *  -- LAPACK computational routine (version 3.8.0) --
1.1       bertrand  148: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
                    149: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
1.3       bertrand  150: *     November 2017
1.1       bertrand  151: *
                    152:       IMPLICIT NONE
                    153: *
                    154: *     .. Scalar Arguments ..
                    155:       CHARACTER    UPLO
1.3       bertrand  156:       INTEGER      M, NB, J1, LDA, LDH
1.1       bertrand  157: *     ..
                    158: *     .. Array Arguments ..
                    159:       INTEGER      IPIV( * )
                    160:       COMPLEX*16   A( LDA, * ), H( LDH, * ), WORK( * )
                    161: *     ..
                    162: *
                    163: *  =====================================================================
                    164: *     .. Parameters ..
                    165:       COMPLEX*16   ZERO, ONE
                    166:       PARAMETER    ( ZERO = (0.0D+0, 0.0D+0), ONE = (1.0D+0, 0.0D+0) )
                    167: *
                    168: *     .. Local Scalars ..
1.3       bertrand  169:       INTEGER      J, K, K1, I1, I2, MJ
1.1       bertrand  170:       COMPLEX*16   PIV, ALPHA
                    171: *     ..
                    172: *     .. External Functions ..
                    173:       LOGICAL      LSAME
                    174:       INTEGER      IZAMAX, ILAENV
                    175:       EXTERNAL     LSAME, ILAENV, IZAMAX
                    176: *     ..
                    177: *     .. External Subroutines ..
1.3       bertrand  178:       EXTERNAL     ZGEMM, ZGEMV, ZAXPY, ZLACGV, ZCOPY, ZSCAL, ZSWAP,
                    179:      $             ZLASET, XERBLA
1.1       bertrand  180: *     ..
                    181: *     .. Intrinsic Functions ..
                    182:       INTRINSIC    DBLE, DCONJG, MAX
                    183: *     ..
                    184: *     .. Executable Statements ..
                    185: *
                    186:       J = 1
                    187: *
                    188: *     K1 is the first column of the panel to be factorized
                    189: *     i.e.,  K1 is 2 for the first block column, and 1 for the rest of the blocks
                    190: *
                    191:       K1 = (2-J1)+1
                    192: *
                    193:       IF( LSAME( UPLO, 'U' ) ) THEN
                    194: *
                    195: *        .....................................................
                    196: *        Factorize A as U**T*D*U using the upper triangle of A
                    197: *        .....................................................
                    198: *
                    199:  10      CONTINUE
                    200:          IF ( J.GT.MIN(M, NB) )
                    201:      $      GO TO 20
                    202: *
                    203: *        K is the column to be factorized
                    204: *         when being called from ZHETRF_AA,
                    205: *         > for the first block column, J1 is 1, hence J1+J-1 is J,
                    206: *         > for the rest of the columns, J1 is 2, and J1+J-1 is J+1,
                    207: *
                    208:          K = J1+J-1
1.3       bertrand  209:          IF( J.EQ.M ) THEN
                    210: *
                    211: *            Only need to compute T(J, J)
                    212: *
                    213:              MJ = 1
                    214:          ELSE
                    215:              MJ = M-J+1
                    216:          END IF
1.1       bertrand  217: *
                    218: *        H(J:N, J) := A(J, J:N) - H(J:N, 1:(J-1)) * L(J1:(J-1), J),
                    219: *         where H(J:N, J) has been initialized to be A(J, J:N)
                    220: *
                    221:          IF( K.GT.2 ) THEN
                    222: *
                    223: *        K is the column to be factorized
                    224: *         > for the first block column, K is J, skipping the first two
                    225: *           columns
                    226: *         > for the rest of the columns, K is J+1, skipping only the
                    227: *           first column
                    228: *
                    229:             CALL ZLACGV( J-K1, A( 1, J ), 1 )
1.3       bertrand  230:             CALL ZGEMV( 'No transpose', MJ, J-K1,
1.1       bertrand  231:      $                 -ONE, H( J, K1 ), LDH,
                    232:      $                       A( 1, J ), 1,
                    233:      $                  ONE, H( J, J ), 1 )
                    234:             CALL ZLACGV( J-K1, A( 1, J ), 1 )
                    235:          END IF
                    236: *
                    237: *        Copy H(i:n, i) into WORK
                    238: *
1.3       bertrand  239:          CALL ZCOPY( MJ, H( J, J ), 1, WORK( 1 ), 1 )
1.1       bertrand  240: *
                    241:          IF( J.GT.K1 ) THEN
                    242: *
                    243: *           Compute WORK := WORK - L(J-1, J:N) * T(J-1,J),
                    244: *            where A(J-1, J) stores T(J-1, J) and A(J-2, J:N) stores U(J-1, J:N)
                    245: *
                    246:             ALPHA = -DCONJG( A( K-1, J ) )
1.3       bertrand  247:             CALL ZAXPY( MJ, ALPHA, A( K-2, J ), LDA, WORK( 1 ), 1 )
1.1       bertrand  248:          END IF
                    249: *
                    250: *        Set A(J, J) = T(J, J)
                    251: *
                    252:          A( K, J ) = DBLE( WORK( 1 ) )
                    253: *
                    254:          IF( J.LT.M ) THEN
                    255: *
                    256: *           Compute WORK(2:N) = T(J, J) L(J, (J+1):N)
                    257: *            where A(J, J) stores T(J, J) and A(J-1, (J+1):N) stores U(J, (J+1):N)
                    258: *
                    259:             IF( K.GT.1 ) THEN
                    260:                ALPHA = -A( K, J )
                    261:                CALL ZAXPY( M-J, ALPHA, A( K-1, J+1 ), LDA,
                    262:      $                                 WORK( 2 ), 1 )
                    263:             ENDIF
                    264: *
                    265: *           Find max(|WORK(2:n)|)
                    266: *
                    267:             I2 = IZAMAX( M-J, WORK( 2 ), 1 ) + 1
                    268:             PIV = WORK( I2 )
                    269: *
                    270: *           Apply hermitian pivot
                    271: *
                    272:             IF( (I2.NE.2) .AND. (PIV.NE.0) ) THEN
                    273: *
                    274: *              Swap WORK(I1) and WORK(I2)
                    275: *
                    276:                I1 = 2
                    277:                WORK( I2 ) = WORK( I1 )
                    278:                WORK( I1 ) = PIV
                    279: *
                    280: *              Swap A(I1, I1+1:N) with A(I1+1:N, I2)
                    281: *
                    282:                I1 = I1+J-1
                    283:                I2 = I2+J-1
                    284:                CALL ZSWAP( I2-I1-1, A( J1+I1-1, I1+1 ), LDA,
                    285:      $                              A( J1+I1, I2 ), 1 )
                    286:                CALL ZLACGV( I2-I1, A( J1+I1-1, I1+1 ), LDA )
                    287:                CALL ZLACGV( I2-I1-1, A( J1+I1, I2 ), 1 )
                    288: *
                    289: *              Swap A(I1, I2+1:N) with A(I2, I2+1:N)
                    290: *
                    291:                CALL ZSWAP( M-I2, A( J1+I1-1, I2+1 ), LDA,
                    292:      $                           A( J1+I2-1, I2+1 ), LDA )
                    293: *
                    294: *              Swap A(I1, I1) with A(I2,I2)
                    295: *
                    296:                PIV = A( I1+J1-1, I1 )
                    297:                A( J1+I1-1, I1 ) = A( J1+I2-1, I2 )
                    298:                A( J1+I2-1, I2 ) = PIV
                    299: *
                    300: *              Swap H(I1, 1:J1) with H(I2, 1:J1)
                    301: *
                    302:                CALL ZSWAP( I1-1, H( I1, 1 ), LDH, H( I2, 1 ), LDH )
                    303:                IPIV( I1 ) = I2
                    304: *
                    305:                IF( I1.GT.(K1-1) ) THEN
                    306: *
                    307: *                 Swap L(1:I1-1, I1) with L(1:I1-1, I2),
                    308: *                  skipping the first column
                    309: *
                    310:                   CALL ZSWAP( I1-K1+1, A( 1, I1 ), 1,
                    311:      $                                 A( 1, I2 ), 1 )
                    312:                END IF
                    313:             ELSE
                    314:                IPIV( J+1 ) = J+1
                    315:             ENDIF
                    316: *
                    317: *           Set A(J, J+1) = T(J, J+1)
                    318: *
                    319:             A( K, J+1 ) = WORK( 2 )
                    320: *
                    321:             IF( J.LT.NB ) THEN
                    322: *
                    323: *              Copy A(J+1:N, J+1) into H(J:N, J),
                    324: *
                    325:                CALL ZCOPY( M-J, A( K+1, J+1 ), LDA,
                    326:      $                          H( J+1, J+1 ), 1 )
                    327:             END IF
                    328: *
                    329: *           Compute L(J+2, J+1) = WORK( 3:N ) / T(J, J+1),
                    330: *            where A(J, J+1) = T(J, J+1) and A(J+2:N, J) = L(J+2:N, J+1)
                    331: *
                    332:             IF( A( K, J+1 ).NE.ZERO ) THEN
                    333:                ALPHA = ONE / A( K, J+1 )
                    334:                CALL ZCOPY( M-J-1, WORK( 3 ), 1, A( K, J+2 ), LDA )
                    335:                CALL ZSCAL( M-J-1, ALPHA, A( K, J+2 ), LDA )
                    336:             ELSE
                    337:                CALL ZLASET( 'Full', 1, M-J-1, ZERO, ZERO,
                    338:      $                      A( K, J+2 ), LDA)
                    339:             END IF
                    340:          END IF
                    341:          J = J + 1
                    342:          GO TO 10
                    343:  20      CONTINUE
                    344: *
                    345:       ELSE
                    346: *
                    347: *        .....................................................
                    348: *        Factorize A as L*D*L**T using the lower triangle of A
                    349: *        .....................................................
                    350: *
                    351:  30      CONTINUE
                    352:          IF( J.GT.MIN( M, NB ) )
                    353:      $      GO TO 40
                    354: *
                    355: *        K is the column to be factorized
                    356: *         when being called from ZHETRF_AA,
                    357: *         > for the first block column, J1 is 1, hence J1+J-1 is J,
                    358: *         > for the rest of the columns, J1 is 2, and J1+J-1 is J+1,
                    359: *
                    360:          K = J1+J-1
1.3       bertrand  361:          IF( J.EQ.M ) THEN
                    362: *
                    363: *            Only need to compute T(J, J)
                    364: *
                    365:              MJ = 1
                    366:          ELSE
                    367:              MJ = M-J+1
                    368:          END IF
1.1       bertrand  369: *
                    370: *        H(J:N, J) := A(J:N, J) - H(J:N, 1:(J-1)) * L(J, J1:(J-1))^T,
                    371: *         where H(J:N, J) has been initialized to be A(J:N, J)
                    372: *
                    373:          IF( K.GT.2 ) THEN
                    374: *
                    375: *        K is the column to be factorized
                    376: *         > for the first block column, K is J, skipping the first two
                    377: *           columns
                    378: *         > for the rest of the columns, K is J+1, skipping only the
                    379: *           first column
                    380: *
                    381:             CALL ZLACGV( J-K1, A( J, 1 ), LDA )
1.3       bertrand  382:             CALL ZGEMV( 'No transpose', MJ, J-K1,
1.1       bertrand  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: *        Copy H(J:N, J) into WORK
                    390: *
1.3       bertrand  391:          CALL ZCOPY( MJ, H( J, J ), 1, WORK( 1 ), 1 )
1.1       bertrand  392: *
                    393:          IF( J.GT.K1 ) THEN
                    394: *
                    395: *           Compute WORK := WORK - L(J:N, J-1) * T(J-1,J),
                    396: *            where A(J-1, J) = T(J-1, J) and A(J, J-2) = L(J, J-1)
                    397: *
                    398:             ALPHA = -DCONJG( A( J, K-1 ) )
1.3       bertrand  399:             CALL ZAXPY( MJ, ALPHA, A( J, K-2 ), 1, WORK( 1 ), 1 )
1.1       bertrand  400:          END IF
                    401: *
                    402: *        Set A(J, J) = T(J, J)
                    403: *
                    404:          A( J, K ) = DBLE( WORK( 1 ) )
                    405: *
                    406:          IF( J.LT.M ) THEN
                    407: *
                    408: *           Compute WORK(2:N) = T(J, J) L((J+1):N, J)
                    409: *            where A(J, J) = T(J, J) and A((J+1):N, J-1) = L((J+1):N, J)
                    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: *           Find max(|WORK(2:n)|)
                    418: *
                    419:             I2 = IZAMAX( M-J, WORK( 2 ), 1 ) + 1
                    420:             PIV = WORK( I2 )
                    421: *
                    422: *           Apply hermitian pivot
                    423: *
                    424:             IF( (I2.NE.2) .AND. (PIV.NE.0) ) THEN
                    425: *
                    426: *              Swap WORK(I1) and WORK(I2)
                    427: *
                    428:                I1 = 2
                    429:                WORK( I2 ) = WORK( I1 )
                    430:                WORK( I1 ) = PIV
                    431: *
                    432: *              Swap A(I1+1:N, I1) with A(I2, I1+1:N)
                    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: *              Swap A(I2+1:N, I1) with A(I2+1:N, I2)
                    442: *
                    443:                CALL ZSWAP( M-I2, A( I2+1, J1+I1-1 ), 1,
                    444:      $                           A( I2+1, J1+I2-1 ), 1 )
                    445: *
                    446: *              Swap A(I1, I1) with A(I2, I2)
                    447: *
                    448:                PIV = A( I1, J1+I1-1 )
                    449:                A( I1, J1+I1-1 ) = A( I2, J1+I2-1 )
                    450:                A( I2, J1+I2-1 ) = PIV
                    451: *
                    452: *              Swap H(I1, I1:J1) with H(I2, I2:J1)
                    453: *
                    454:                CALL ZSWAP( I1-1, H( I1, 1 ), LDH, H( I2, 1 ), LDH )
                    455:                IPIV( I1 ) = I2
                    456: *
                    457:                IF( I1.GT.(K1-1) ) THEN
                    458: *
                    459: *                 Swap L(1:I1-1, I1) with L(1:I1-1, I2),
                    460: *                  skipping the first column
                    461: *
                    462:                   CALL ZSWAP( I1-K1+1, A( I1, 1 ), LDA,
                    463:      $                                 A( I2, 1 ), LDA )
                    464:                END IF
                    465:             ELSE
                    466:                IPIV( J+1 ) = J+1
                    467:             ENDIF
                    468: *
                    469: *           Set A(J+1, J) = T(J+1, J)
                    470: *
                    471:             A( J+1, K ) = WORK( 2 )
                    472: *
                    473:             IF( J.LT.NB ) THEN
                    474: *
                    475: *              Copy A(J+1:N, J+1) into H(J+1:N, J),
                    476: *
                    477:                CALL ZCOPY( M-J, A( J+1, K+1 ), 1,
                    478:      $                          H( J+1, J+1 ), 1 )
                    479:             END IF
                    480: *
                    481: *           Compute L(J+2, J+1) = WORK( 3:N ) / T(J, J+1),
                    482: *            where A(J, J+1) = T(J, J+1) and A(J+2:N, J) = L(J+2:N, J+1)
                    483: *
                    484:             IF( A( J+1, K ).NE.ZERO ) THEN
                    485:                ALPHA = ONE / A( J+1, K )
                    486:                CALL ZCOPY( M-J-1, WORK( 3 ), 1, A( J+2, K ), 1 )
                    487:                CALL ZSCAL( M-J-1, ALPHA, A( J+2, K ), 1 )
                    488:             ELSE
                    489:                CALL ZLASET( 'Full', M-J-1, 1, ZERO, ZERO,
                    490:      $                      A( J+2, K ), LDA )
                    491:             END IF
                    492:          END IF
                    493:          J = J + 1
                    494:          GO TO 30
                    495:  40      CONTINUE
                    496:       END IF
                    497:       RETURN
                    498: *
                    499: *     End of ZLAHEF_AA
                    500: *
                    501:       END

CVSweb interface <joel.bertrand@systella.fr>