Annotation of rpl/lapack/lapack/dsytrs_aa.f, revision 1.6

1.1       bertrand    1: *> \brief \b DSYTRS_AA
                      2: *
                      3: *  =========== DOCUMENTATION ===========
                      4: *
                      5: * Online html documentation available at
                      6: *            http://www.netlib.org/lapack/explore-html/
                      7: *
                      8: *> \htmlonly
                      9: *> Download DSYTRS_AA + dependencies
                     10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsytrs_aa.f">
                     11: *> [TGZ]</a>
                     12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsytrs_aa.f">
                     13: *> [ZIP]</a>
                     14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsytrs_aa.f">
                     15: *> [TXT]</a>
                     16: *> \endhtmlonly
                     17: *
                     18: *  Definition:
                     19: *  ===========
                     20: *
                     21: *       SUBROUTINE DSYTRS_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: *       DOUBLE PRECISION   A( LDA, * ), B( LDB, * ), WORK( * )
                     31: *       ..
                     32: *
                     33: *
                     34: *> \par Purpose:
                     35: *  =============
                     36: *>
                     37: *> \verbatim
                     38: *>
                     39: *> DSYTRS_AA solves a system of linear equations A*X = B with a real
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 DSYTRF_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 DOUBLE PRECISION array, dimension (LDA,N)
                     72: *>          Details of factors computed by DSYTRF_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 DSYTRF_AA.
                     85: *> \endverbatim
                     86: *>
                     87: *> \param[in,out] B
                     88: *> \verbatim
                     89: *>          B is DOUBLE PRECISION 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 DOUBLE PRECISION 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: *
                    126: *> \ingroup doubleSYcomputational
                    127: *
                    128: *  =====================================================================
                    129:       SUBROUTINE DSYTRS_AA( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
                    130:      $                      WORK, LWORK, INFO )
                    131: *
1.6     ! bertrand  132: *  -- LAPACK computational routine --
1.1       bertrand  133: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
                    134: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
                    135: *
                    136:       IMPLICIT NONE
                    137: *
                    138: *     .. Scalar Arguments ..
                    139:       CHARACTER          UPLO
                    140:       INTEGER            N, NRHS, LDA, LDB, LWORK, INFO
                    141: *     ..
                    142: *     .. Array Arguments ..
                    143:       INTEGER            IPIV( * )
                    144:       DOUBLE PRECISION   A( LDA, * ), B( LDB, * ), WORK( * )
                    145: *     ..
                    146: *
                    147: *  =====================================================================
                    148: *
                    149:       DOUBLE PRECISION   ONE
                    150:       PARAMETER          ( ONE = 1.0D+0 )
                    151: *     ..
                    152: *     .. Local Scalars ..
                    153:       LOGICAL            LQUERY, UPPER
                    154:       INTEGER            K, KP, LWKOPT
                    155: *     ..
                    156: *     .. External Functions ..
                    157:       LOGICAL            LSAME
                    158:       EXTERNAL           LSAME
                    159: *     ..
                    160: *     .. External Subroutines ..
1.3       bertrand  161:       EXTERNAL           DLACPY, DGTSV, DSWAP, DTRSM, XERBLA
1.1       bertrand  162: *     ..
                    163: *     .. Intrinsic Functions ..
                    164:       INTRINSIC          MAX
                    165: *     ..
                    166: *     .. Executable Statements ..
                    167: *
                    168:       INFO = 0
                    169:       UPPER = LSAME( UPLO, 'U' )
                    170:       LQUERY = ( LWORK.EQ.-1 )
                    171:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
                    172:          INFO = -1
                    173:       ELSE IF( N.LT.0 ) THEN
                    174:          INFO = -2
                    175:       ELSE IF( NRHS.LT.0 ) THEN
                    176:          INFO = -3
                    177:       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
                    178:          INFO = -5
                    179:       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
                    180:          INFO = -8
                    181:       ELSE IF( LWORK.LT.MAX( 1, 3*N-2 ) .AND. .NOT.LQUERY ) THEN
                    182:          INFO = -10
                    183:       END IF
                    184:       IF( INFO.NE.0 ) THEN
                    185:          CALL XERBLA( 'DSYTRS_AA', -INFO )
                    186:          RETURN
                    187:       ELSE IF( LQUERY ) THEN
                    188:          LWKOPT = (3*N-2)
                    189:          WORK( 1 ) = LWKOPT
                    190:          RETURN
                    191:       END IF
                    192: *
                    193: *     Quick return if possible
                    194: *
                    195:       IF( N.EQ.0 .OR. NRHS.EQ.0 )
                    196:      $   RETURN
                    197: *
                    198:       IF( UPPER ) THEN
                    199: *
1.5       bertrand  200: *        Solve A*X = B, where A = U**T*T*U.
                    201: *
                    202: *        1) Forward substitution with U**T
                    203: *
                    204:          IF( N.GT.1 ) THEN
                    205: *
                    206: *           Pivot, P**T * B -> B
1.1       bertrand  207: *
1.5       bertrand  208:             DO K = 1, N
                    209:                KP = IPIV( K )
                    210:                IF( KP.NE.K )
                    211:      $             CALL DSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
                    212:             END DO
1.1       bertrand  213: *
1.5       bertrand  214: *           Compute U**T \ B -> B    [ (U**T \P**T * B) ]
1.1       bertrand  215: *
1.5       bertrand  216:             CALL DTRSM('L', 'U', 'T', 'U', N-1, NRHS, ONE, A( 1, 2 ),
                    217:      $                  LDA, B( 2, 1 ), LDB)
                    218:          END IF
1.1       bertrand  219: *
1.5       bertrand  220: *        2) Solve with triangular matrix T
1.1       bertrand  221: *
1.5       bertrand  222: *        Compute T \ B -> B   [ T \ (U**T \P**T * B) ]
1.1       bertrand  223: *
                    224:          CALL DLACPY( 'F', 1, N, A( 1, 1 ), LDA+1, WORK( N ), 1)
                    225:          IF( N.GT.1 ) THEN
                    226:             CALL DLACPY( 'F', 1, N-1, A( 1, 2 ), LDA+1, WORK( 1 ), 1 )
                    227:             CALL DLACPY( 'F', 1, N-1, A( 1, 2 ), LDA+1, WORK( 2*N ), 1 )
                    228:          END IF
                    229:          CALL DGTSV( N, NRHS, WORK( 1 ), WORK( N ), WORK( 2*N ), B, LDB,
                    230:      $               INFO )
                    231: *
1.5       bertrand  232: *        3) Backward substitution with U
                    233: *
                    234:          IF( N.GT.1 ) THEN
1.1       bertrand  235: *
1.5       bertrand  236: *           Compute U \ B -> B   [ U \ (T \ (U**T \P**T * B) ) ]
1.1       bertrand  237: *
1.5       bertrand  238:             CALL DTRSM( 'L', 'U', 'N', 'U', N-1, NRHS, ONE, A( 1, 2 ),
                    239:      $                  LDA, B( 2, 1 ), LDB)
1.1       bertrand  240: *
1.5       bertrand  241: *           Pivot, P * B -> B  [ P * (U \ (T \ (U**T \P**T * B) )) ]
                    242: *
                    243:             DO K = N, 1, -1
                    244:                KP = IPIV( K )
                    245:                IF( KP.NE.K )
                    246:      $            CALL DSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
                    247:             END DO
                    248:          END IF
1.1       bertrand  249: *
                    250:       ELSE
                    251: *
                    252: *        Solve A*X = B, where A = L*T*L**T.
                    253: *
1.5       bertrand  254: *        1) Forward substitution with L
1.1       bertrand  255: *
1.5       bertrand  256:          IF( N.GT.1 ) THEN
                    257: *
                    258: *           Pivot, P**T * B -> B
                    259: *
                    260:             DO K = 1, N
                    261:                KP = IPIV( K )
                    262:                IF( KP.NE.K )
                    263:      $            CALL DSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
                    264:             END DO
1.1       bertrand  265: *
1.5       bertrand  266: *           Compute L \ B -> B    [ (L \P**T * B) ]
                    267: *
                    268:             CALL DTRSM( 'L', 'L', 'N', 'U', N-1, NRHS, ONE, A( 2, 1 ),
                    269:      $                  LDA, B( 2, 1 ), LDB)
                    270:          END IF
1.1       bertrand  271: *
1.5       bertrand  272: *        2) Solve with triangular matrix T
1.1       bertrand  273: *
                    274: *        Compute T \ B -> B   [ T \ (L \P**T * B) ]
                    275: *
                    276:          CALL DLACPY( 'F', 1, N, A(1, 1), LDA+1, WORK(N), 1)
                    277:          IF( N.GT.1 ) THEN
                    278:             CALL DLACPY( 'F', 1, N-1, A( 2, 1 ), LDA+1, WORK( 1 ), 1 )
                    279:             CALL DLACPY( 'F', 1, N-1, A( 2, 1 ), LDA+1, WORK( 2*N ), 1 )
                    280:          END IF
                    281:          CALL DGTSV( N, NRHS, WORK( 1 ), WORK(N), WORK( 2*N ), B, LDB,
                    282:      $               INFO)
                    283: *
1.5       bertrand  284: *        3) Backward substitution with L**T
1.1       bertrand  285: *
1.5       bertrand  286:          IF( N.GT.1 ) THEN
                    287: *
                    288: *           Compute (L**T \ B) -> B   [ L**T \ (T \ (L \P**T * B) ) ]
1.1       bertrand  289: *
1.5       bertrand  290:             CALL DTRSM( 'L', 'L', 'T', 'U', N-1, NRHS, ONE, A( 2, 1 ),
                    291:      $                  LDA, B( 2, 1 ), LDB)
1.1       bertrand  292: *
1.5       bertrand  293: *           Pivot, P * B -> B  [ P * (L**T \ (T \ (L \P**T * B) )) ]
                    294: *
                    295:             DO K = N, 1, -1
                    296:                KP = IPIV( K )
                    297:                IF( KP.NE.K )
                    298:      $            CALL DSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
                    299:             END DO
                    300:          END IF
1.1       bertrand  301: *
                    302:       END IF
                    303: *
                    304:       RETURN
                    305: *
                    306: *     End of DSYTRS_AA
                    307: *
                    308:       END

CVSweb interface <joel.bertrand@systella.fr>