Annotation of rpl/lapack/lapack/zsytrs_aa.f, revision 1.5

1.1       bertrand    1: *> \brief \b ZSYTRS_AA
                      2: *
                      3: *  =========== DOCUMENTATION ===========
                      4: *
                      5: * Online html documentation available at
                      6: *            http://www.netlib.org/lapack/explore-html/
                      7: *
                      8: *> \htmlonly
                      9: *> Download ZSYTRS_AA + dependencies
                     10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zsytrs_aa.f">
                     11: *> [TGZ]</a>
                     12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zsytrs_aa.f">
                     13: *> [ZIP]</a>
                     14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zsytrs_aa.f">
                     15: *> [TXT]</a>
                     16: *> \endhtmlonly
                     17: *
                     18: *  Definition:
                     19: *  ===========
                     20: *
                     21: *       SUBROUTINE ZSYTRS_AA( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
                     22: *                             WORK, LWORK, INFO )
                     23: *
                     24: *       .. Scalar Arguments ..
                     25: *       CHARACTER          UPLO
                     26: *       INTEGER            N, NRHS, LDA, LDB, LWORK, INFO
                     27: *       ..
                     28: *       .. Array Arguments ..
                     29: *       INTEGER            IPIV( * )
                     30: *       COMPLEX*16         A( LDA, * ), B( LDB, * ), WORK( * )
                     31: *       ..
                     32: *
                     33: *
                     34: *> \par Purpose:
                     35: *  =============
                     36: *>
                     37: *> \verbatim
                     38: *>
                     39: *> ZSYTRS_AA solves a system of linear equations A*X = B with a complex
1.5     ! bertrand   40: *> symmetric matrix A using the factorization A = U**T*T*U or
1.1       bertrand   41: *> A = L*T*L**T computed by ZSYTRF_AA.
                     42: *> \endverbatim
                     43: *
                     44: *  Arguments:
                     45: *  ==========
                     46: *
                     47: *> \param[in] UPLO
                     48: *> \verbatim
                     49: *>          UPLO is CHARACTER*1
                     50: *>          Specifies whether the details of the factorization are stored
                     51: *>          as an upper or lower triangular matrix.
1.5     ! bertrand   52: *>          = 'U':  Upper triangular, form is A = U**T*T*U;
1.1       bertrand   53: *>          = 'L':  Lower triangular, form is A = L*T*L**T.
                     54: *> \endverbatim
                     55: *>
                     56: *> \param[in] N
                     57: *> \verbatim
                     58: *>          N is INTEGER
                     59: *>          The order of the matrix A.  N >= 0.
                     60: *> \endverbatim
                     61: *>
                     62: *> \param[in] NRHS
                     63: *> \verbatim
                     64: *>          NRHS is INTEGER
                     65: *>          The number of right hand sides, i.e., the number of columns
                     66: *>          of the matrix B.  NRHS >= 0.
                     67: *> \endverbatim
                     68: *>
1.3       bertrand   69: *> \param[in] A
1.1       bertrand   70: *> \verbatim
                     71: *>          A is COMPLEX*16 array, dimension (LDA,N)
                     72: *>          Details of factors computed by ZSYTRF_AA.
                     73: *> \endverbatim
                     74: *>
                     75: *> \param[in] LDA
                     76: *> \verbatim
                     77: *>          LDA is INTEGER
                     78: *>          The leading dimension of the array A.  LDA >= max(1,N).
                     79: *> \endverbatim
                     80: *>
                     81: *> \param[in] IPIV
                     82: *> \verbatim
                     83: *>          IPIV is INTEGER array, dimension (N)
                     84: *>          Details of the interchanges as computed by ZSYTRF_AA.
                     85: *> \endverbatim
                     86: *>
                     87: *> \param[in,out] B
                     88: *> \verbatim
                     89: *>          B is COMPLEX*16 array, dimension (LDB,NRHS)
                     90: *>          On entry, the right hand side matrix B.
                     91: *>          On exit, the solution matrix X.
                     92: *> \endverbatim
                     93: *>
                     94: *> \param[in] LDB
                     95: *> \verbatim
                     96: *>          LDB is INTEGER
                     97: *>          The leading dimension of the array B.  LDB >= max(1,N).
                     98: *> \endverbatim
                     99: *>
1.5     ! bertrand  100: *> \param[out] WORK
1.1       bertrand  101: *> \verbatim
1.5     ! bertrand  102: *>          WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
1.1       bertrand  103: *> \endverbatim
                    104: *>
                    105: *> \param[in] LWORK
                    106: *> \verbatim
1.5     ! bertrand  107: *>          LWORK is INTEGER
        !           108: *>          The dimension of the array WORK. LWORK >= max(1,3*N-2).
        !           109: *> \endverbatim
1.1       bertrand  110: *>
                    111: *> \param[out] INFO
                    112: *> \verbatim
                    113: *>          INFO is INTEGER
                    114: *>          = 0:  successful exit
                    115: *>          < 0:  if INFO = -i, the i-th argument had an illegal value
                    116: *> \endverbatim
                    117: *
                    118: *  Authors:
                    119: *  ========
                    120: *
                    121: *> \author Univ. of Tennessee
                    122: *> \author Univ. of California Berkeley
                    123: *> \author Univ. of Colorado Denver
                    124: *> \author NAG Ltd.
                    125: *
1.3       bertrand  126: *> \date November 2017
1.1       bertrand  127: *
                    128: *> \ingroup complex16SYcomputational
                    129: *
                    130: *  =====================================================================
                    131:       SUBROUTINE ZSYTRS_AA( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
                    132:      $                      WORK, LWORK, INFO )
                    133: *
1.3       bertrand  134: *  -- LAPACK computational routine (version 3.8.0) --
1.1       bertrand  135: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
                    136: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
1.3       bertrand  137: *     November 2017
1.1       bertrand  138: *
                    139:       IMPLICIT NONE
                    140: *
                    141: *     .. Scalar Arguments ..
                    142:       CHARACTER          UPLO
                    143:       INTEGER            N, NRHS, LDA, LDB, LWORK, INFO
                    144: *     ..
                    145: *     .. Array Arguments ..
                    146:       INTEGER            IPIV( * )
                    147:       COMPLEX*16         A( LDA, * ), B( LDB, * ), WORK( * )
                    148: *     ..
                    149: *
                    150: *  =====================================================================
                    151: *
                    152:       COMPLEX*16         ONE
                    153:       PARAMETER          ( ONE = 1.0D+0 )
                    154: *     ..
                    155: *     .. Local Scalars ..
                    156:       LOGICAL            LQUERY, UPPER
                    157:       INTEGER            K, KP, LWKOPT
                    158: *     ..
                    159: *     .. External Functions ..
                    160:       LOGICAL            LSAME
                    161:       EXTERNAL           LSAME
                    162: *     ..
                    163: *     .. External Subroutines ..
1.3       bertrand  164:       EXTERNAL           ZGTSV, ZSWAP, ZLACPY, ZTRSM, XERBLA
1.1       bertrand  165: *     ..
                    166: *     .. Intrinsic Functions ..
                    167:       INTRINSIC          MAX
                    168: *     ..
                    169: *     .. Executable Statements ..
                    170: *
                    171:       INFO = 0
                    172:       UPPER = LSAME( UPLO, 'U' )
                    173:       LQUERY = ( LWORK.EQ.-1 )
                    174:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
                    175:          INFO = -1
                    176:       ELSE IF( N.LT.0 ) THEN
                    177:          INFO = -2
                    178:       ELSE IF( NRHS.LT.0 ) THEN
                    179:          INFO = -3
                    180:       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
                    181:          INFO = -5
                    182:       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
                    183:          INFO = -8
                    184:       ELSE IF( LWORK.LT.MAX( 1, 3*N-2 ) .AND. .NOT.LQUERY ) THEN
                    185:          INFO = -10
                    186:       END IF
                    187:       IF( INFO.NE.0 ) THEN
                    188:          CALL XERBLA( 'ZSYTRS_AA', -INFO )
                    189:          RETURN
                    190:       ELSE IF( LQUERY ) THEN
                    191:          LWKOPT = (3*N-2)
                    192:          WORK( 1 ) = LWKOPT
                    193:          RETURN
                    194:       END IF
                    195: *
                    196: *     Quick return if possible
                    197: *
                    198:       IF( N.EQ.0 .OR. NRHS.EQ.0 )
                    199:      $   RETURN
                    200: *
                    201:       IF( UPPER ) THEN
                    202: *
1.5     ! bertrand  203: *        Solve A*X = B, where A = U**T*T*U.
        !           204: *
        !           205: *        1) Forward substitution with U**T
        !           206: *
        !           207:          IF( N.GT.1 ) THEN
        !           208: *
        !           209: *           Pivot, P**T * B -> B
1.1       bertrand  210: *
1.5     ! bertrand  211:             DO K = 1, N
        !           212:                KP = IPIV( K )
        !           213:                IF( KP.NE.K )
        !           214:      $         CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
        !           215:             END DO
1.1       bertrand  216: *
1.5     ! bertrand  217: *           Compute U**T \ B -> B    [ (U**T \P**T * B) ]
1.1       bertrand  218: *
1.5     ! bertrand  219:             CALL ZTRSM( 'L', 'U', 'T', 'U', N-1, NRHS, ONE, A( 1, 2 ),
        !           220:      $                  LDA, B( 2, 1 ), LDB)
        !           221:          END IF
1.1       bertrand  222: *
1.5     ! bertrand  223: *        2) Solve with triangular matrix T
1.1       bertrand  224: *
1.5     ! bertrand  225: *        Compute T \ B -> B   [ T \ (U**T \P**T * B) ]
1.1       bertrand  226: *
                    227:          CALL ZLACPY( 'F', 1, N, A( 1, 1 ), LDA+1, WORK( N ), 1)
                    228:          IF( N.GT.1 ) THEN
                    229:             CALL ZLACPY( 'F', 1, N-1, A( 1, 2 ), LDA+1, WORK( 1 ), 1 )
                    230:             CALL ZLACPY( 'F', 1, N-1, A( 1, 2 ), LDA+1, WORK( 2*N ), 1 )
                    231:          END IF
                    232:          CALL ZGTSV( N, NRHS, WORK( 1 ), WORK( N ), WORK( 2*N ), B, LDB,
                    233:      $               INFO )
                    234: *
1.5     ! bertrand  235: *        3) Backward substitution with U
        !           236: *
        !           237:          IF( N.GT.1 ) THEN
        !           238: *
        !           239: *           Compute U \ B -> B   [ U \ (T \ (U**T \P**T * B) ) ]
1.1       bertrand  240: *
1.5     ! bertrand  241:             CALL ZTRSM( 'L', 'U', 'N', 'U', N-1, NRHS, ONE, A( 1, 2 ),
        !           242:      $                  LDA, B( 2, 1 ), LDB)
1.1       bertrand  243: *
1.5     ! bertrand  244: *           Pivot, P * B -> B  [ P * (U \ (T \ (U**T \P**T * B) )) ]
1.1       bertrand  245: *
1.5     ! bertrand  246:             DO K = N, 1, -1
        !           247:                KP = IPIV( K )
        !           248:                IF( KP.NE.K )
        !           249:      $            CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
        !           250:             END DO
        !           251:          END IF
1.1       bertrand  252: *
                    253:       ELSE
                    254: *
                    255: *        Solve A*X = B, where A = L*T*L**T.
                    256: *
1.5     ! bertrand  257: *        1) Forward substitution with L
1.1       bertrand  258: *
1.5     ! bertrand  259:          IF( N.GT.1 ) THEN
        !           260: *
        !           261: *           Pivot, P**T * B -> B
        !           262: *
        !           263:             DO K = 1, N
        !           264:                KP = IPIV( K )
        !           265:                IF( KP.NE.K )
        !           266:      $            CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
        !           267:             END DO
        !           268: *
        !           269: *           Compute L \ B -> B    [ (L \P**T * B) ]
1.1       bertrand  270: *
1.5     ! bertrand  271:             CALL ZTRSM( 'L', 'L', 'N', 'U', N-1, NRHS, ONE, A( 2, 1 ),
        !           272:      $                  LDA, B( 2, 1 ), LDB)
        !           273:          END IF
1.1       bertrand  274: *
1.5     ! bertrand  275: *        2) Solve with triangular matrix T
1.1       bertrand  276: *
                    277: *        Compute T \ B -> B   [ T \ (L \P**T * B) ]
                    278: *
                    279:          CALL ZLACPY( 'F', 1, N, A(1, 1), LDA+1, WORK(N), 1)
                    280:          IF( N.GT.1 ) THEN
                    281:             CALL ZLACPY( 'F', 1, N-1, A( 2, 1 ), LDA+1, WORK( 1 ), 1 )
                    282:             CALL ZLACPY( 'F', 1, N-1, A( 2, 1 ), LDA+1, WORK( 2*N ), 1 )
                    283:          END IF
                    284:          CALL ZGTSV( N, NRHS, WORK( 1 ), WORK(N), WORK( 2*N ), B, LDB,
                    285:      $               INFO)
                    286: *
1.5     ! bertrand  287: *        3) Backward substitution with L**T
1.1       bertrand  288: *
1.5     ! bertrand  289:          IF( N.GT.1 ) THEN
        !           290: *
        !           291: *           Compute (L**T \ B) -> B   [ L**T \ (T \ (L \P**T * B) ) ]
        !           292: *
        !           293:             CALL ZTRSM( 'L', 'L', 'T', 'U', N-1, NRHS, ONE, A( 2, 1 ),
        !           294:      $                  LDA, B( 2, 1 ), LDB)
1.1       bertrand  295: *
1.5     ! bertrand  296: *           Pivot, P * B -> B  [ P * (L**T \ (T \ (L \P**T * B) )) ]
1.1       bertrand  297: *
1.5     ! bertrand  298:             DO K = N, 1, -1
        !           299:                KP = IPIV( K )
        !           300:                IF( KP.NE.K )
        !           301:      $            CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
        !           302:             END DO
        !           303:          END IF
1.1       bertrand  304: *
                    305:       END IF
                    306: *
                    307:       RETURN
                    308: *
                    309: *     End of ZSYTRS_AA
                    310: *
                    311:       END

CVSweb interface <joel.bertrand@systella.fr>