Annotation of rpl/lapack/lapack/dtftri.f, revision 1.16

1.7       bertrand    1: *> \brief \b DTFTRI
                      2: *
                      3: *  =========== DOCUMENTATION ===========
1.1       bertrand    4: *
1.13      bertrand    5: * Online html documentation available at
                      6: *            http://www.netlib.org/lapack/explore-html/
1.1       bertrand    7: *
1.7       bertrand    8: *> \htmlonly
1.13      bertrand    9: *> Download DTFTRI + dependencies
                     10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dtftri.f">
                     11: *> [TGZ]</a>
                     12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dtftri.f">
                     13: *> [ZIP]</a>
                     14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dtftri.f">
1.7       bertrand   15: *> [TXT]</a>
1.13      bertrand   16: *> \endhtmlonly
1.7       bertrand   17: *
                     18: *  Definition:
                     19: *  ===========
                     20: *
                     21: *       SUBROUTINE DTFTRI( TRANSR, UPLO, DIAG, N, A, INFO )
1.13      bertrand   22: *
1.7       bertrand   23: *       .. Scalar Arguments ..
                     24: *       CHARACTER          TRANSR, UPLO, DIAG
                     25: *       INTEGER            INFO, N
                     26: *       ..
                     27: *       .. Array Arguments ..
                     28: *       DOUBLE PRECISION   A( 0: * )
                     29: *       ..
1.13      bertrand   30: *
1.7       bertrand   31: *
                     32: *> \par Purpose:
                     33: *  =============
                     34: *>
                     35: *> \verbatim
                     36: *>
                     37: *> DTFTRI computes the inverse of a triangular matrix A stored in RFP
                     38: *> format.
                     39: *>
                     40: *> This is a Level 3 BLAS version of the algorithm.
                     41: *> \endverbatim
                     42: *
                     43: *  Arguments:
                     44: *  ==========
                     45: *
                     46: *> \param[in] TRANSR
                     47: *> \verbatim
                     48: *>          TRANSR is CHARACTER*1
                     49: *>          = 'N':  The Normal TRANSR of RFP A is stored;
                     50: *>          = 'T':  The Transpose TRANSR of RFP A is stored.
                     51: *> \endverbatim
                     52: *>
                     53: *> \param[in] UPLO
                     54: *> \verbatim
                     55: *>          UPLO is CHARACTER*1
                     56: *>          = 'U':  A is upper triangular;
                     57: *>          = 'L':  A is lower triangular.
                     58: *> \endverbatim
                     59: *>
                     60: *> \param[in] DIAG
                     61: *> \verbatim
                     62: *>          DIAG is CHARACTER*1
                     63: *>          = 'N':  A is non-unit triangular;
                     64: *>          = 'U':  A is unit triangular.
                     65: *> \endverbatim
                     66: *>
                     67: *> \param[in] N
                     68: *> \verbatim
                     69: *>          N is INTEGER
                     70: *>          The order of the matrix A.  N >= 0.
                     71: *> \endverbatim
                     72: *>
                     73: *> \param[in,out] A
                     74: *> \verbatim
                     75: *>          A is DOUBLE PRECISION array, dimension (0:nt-1);
                     76: *>          nt=N*(N+1)/2. On entry, the triangular factor of a Hermitian
                     77: *>          Positive Definite matrix A in RFP format. RFP format is
                     78: *>          described by TRANSR, UPLO, and N as follows: If TRANSR = 'N'
                     79: *>          then RFP A is (0:N,0:k-1) when N is even; k=N/2. RFP A is
                     80: *>          (0:N-1,0:k) when N is odd; k=N/2. IF TRANSR = 'T' then RFP is
                     81: *>          the transpose of RFP A as defined when
                     82: *>          TRANSR = 'N'. The contents of RFP A are defined by UPLO as
                     83: *>          follows: If UPLO = 'U' the RFP A contains the nt elements of
                     84: *>          upper packed A; If UPLO = 'L' the RFP A contains the nt
                     85: *>          elements of lower packed A. The LDA of RFP A is (N+1)/2 when
                     86: *>          TRANSR = 'T'. When TRANSR is 'N' the LDA is N+1 when N is
                     87: *>          even and N is odd. See the Note below for more details.
                     88: *>
                     89: *>          On exit, the (triangular) inverse of the original matrix, in
                     90: *>          the same storage format.
                     91: *> \endverbatim
                     92: *>
                     93: *> \param[out] INFO
                     94: *> \verbatim
                     95: *>          INFO is INTEGER
                     96: *>          = 0: successful exit
                     97: *>          < 0: if INFO = -i, the i-th argument had an illegal value
                     98: *>          > 0: if INFO = i, A(i,i) is exactly zero.  The triangular
                     99: *>               matrix is singular and its inverse can not be computed.
                    100: *> \endverbatim
                    101: *
                    102: *  Authors:
                    103: *  ========
                    104: *
1.13      bertrand  105: *> \author Univ. of Tennessee
                    106: *> \author Univ. of California Berkeley
                    107: *> \author Univ. of Colorado Denver
                    108: *> \author NAG Ltd.
1.7       bertrand  109: *
                    110: *> \ingroup doubleOTHERcomputational
                    111: *
                    112: *> \par Further Details:
                    113: *  =====================
                    114: *>
                    115: *> \verbatim
                    116: *>
                    117: *>  We first consider Rectangular Full Packed (RFP) Format when N is
                    118: *>  even. We give an example where N = 6.
                    119: *>
                    120: *>      AP is Upper             AP is Lower
                    121: *>
                    122: *>   00 01 02 03 04 05       00
                    123: *>      11 12 13 14 15       10 11
                    124: *>         22 23 24 25       20 21 22
                    125: *>            33 34 35       30 31 32 33
                    126: *>               44 45       40 41 42 43 44
                    127: *>                  55       50 51 52 53 54 55
                    128: *>
                    129: *>
                    130: *>  Let TRANSR = 'N'. RFP holds AP as follows:
                    131: *>  For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last
                    132: *>  three columns of AP upper. The lower triangle A(4:6,0:2) consists of
                    133: *>  the transpose of the first three columns of AP upper.
                    134: *>  For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first
                    135: *>  three columns of AP lower. The upper triangle A(0:2,0:2) consists of
                    136: *>  the transpose of the last three columns of AP lower.
                    137: *>  This covers the case N even and TRANSR = 'N'.
                    138: *>
                    139: *>         RFP A                   RFP A
                    140: *>
                    141: *>        03 04 05                33 43 53
                    142: *>        13 14 15                00 44 54
                    143: *>        23 24 25                10 11 55
                    144: *>        33 34 35                20 21 22
                    145: *>        00 44 45                30 31 32
                    146: *>        01 11 55                40 41 42
                    147: *>        02 12 22                50 51 52
                    148: *>
                    149: *>  Now let TRANSR = 'T'. RFP A in both UPLO cases is just the
                    150: *>  transpose of RFP A above. One therefore gets:
                    151: *>
                    152: *>
                    153: *>           RFP A                   RFP A
                    154: *>
                    155: *>     03 13 23 33 00 01 02    33 00 10 20 30 40 50
                    156: *>     04 14 24 34 44 11 12    43 44 11 21 31 41 51
                    157: *>     05 15 25 35 45 55 22    53 54 55 22 32 42 52
                    158: *>
                    159: *>
                    160: *>  We then consider Rectangular Full Packed (RFP) Format when N is
                    161: *>  odd. We give an example where N = 5.
                    162: *>
                    163: *>     AP is Upper                 AP is Lower
                    164: *>
                    165: *>   00 01 02 03 04              00
                    166: *>      11 12 13 14              10 11
                    167: *>         22 23 24              20 21 22
                    168: *>            33 34              30 31 32 33
                    169: *>               44              40 41 42 43 44
                    170: *>
                    171: *>
                    172: *>  Let TRANSR = 'N'. RFP holds AP as follows:
                    173: *>  For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last
                    174: *>  three columns of AP upper. The lower triangle A(3:4,0:1) consists of
                    175: *>  the transpose of the first two columns of AP upper.
                    176: *>  For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first
                    177: *>  three columns of AP lower. The upper triangle A(0:1,1:2) consists of
                    178: *>  the transpose of the last two columns of AP lower.
                    179: *>  This covers the case N odd and TRANSR = 'N'.
                    180: *>
                    181: *>         RFP A                   RFP A
                    182: *>
                    183: *>        02 03 04                00 33 43
                    184: *>        12 13 14                10 11 44
                    185: *>        22 23 24                20 21 22
                    186: *>        00 33 34                30 31 32
                    187: *>        01 11 44                40 41 42
                    188: *>
                    189: *>  Now let TRANSR = 'T'. RFP A in both UPLO cases is just the
                    190: *>  transpose of RFP A above. One therefore gets:
                    191: *>
                    192: *>           RFP A                   RFP A
                    193: *>
                    194: *>     02 12 22 00 01             00 10 20 30 40 50
                    195: *>     03 13 23 33 11             33 11 21 31 41 51
                    196: *>     04 14 24 34 44             43 44 22 32 42 52
                    197: *> \endverbatim
                    198: *>
                    199: *  =====================================================================
                    200:       SUBROUTINE DTFTRI( TRANSR, UPLO, DIAG, N, A, INFO )
1.1       bertrand  201: *
1.16    ! bertrand  202: *  -- LAPACK computational routine --
1.1       bertrand  203: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
                    204: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
                    205: *
                    206: *     .. Scalar Arguments ..
                    207:       CHARACTER          TRANSR, UPLO, DIAG
                    208:       INTEGER            INFO, N
                    209: *     ..
                    210: *     .. Array Arguments ..
                    211:       DOUBLE PRECISION   A( 0: * )
                    212: *     ..
                    213: *
                    214: *  =====================================================================
                    215: *
                    216: *     .. Parameters ..
                    217:       DOUBLE PRECISION   ONE
                    218:       PARAMETER          ( ONE = 1.0D+0 )
                    219: *     ..
                    220: *     .. Local Scalars ..
                    221:       LOGICAL            LOWER, NISODD, NORMALTRANSR
                    222:       INTEGER            N1, N2, K
                    223: *     ..
                    224: *     .. External Functions ..
                    225:       LOGICAL            LSAME
                    226:       EXTERNAL           LSAME
                    227: *     ..
                    228: *     .. External Subroutines ..
                    229:       EXTERNAL           XERBLA, DTRMM, DTRTRI
                    230: *     ..
                    231: *     .. Intrinsic Functions ..
                    232:       INTRINSIC          MOD
                    233: *     ..
                    234: *     .. Executable Statements ..
                    235: *
                    236: *     Test the input parameters.
                    237: *
                    238:       INFO = 0
                    239:       NORMALTRANSR = LSAME( TRANSR, 'N' )
                    240:       LOWER = LSAME( UPLO, 'L' )
                    241:       IF( .NOT.NORMALTRANSR .AND. .NOT.LSAME( TRANSR, 'T' ) ) THEN
                    242:          INFO = -1
                    243:       ELSE IF( .NOT.LOWER .AND. .NOT.LSAME( UPLO, 'U' ) ) THEN
                    244:          INFO = -2
                    245:       ELSE IF( .NOT.LSAME( DIAG, 'N' ) .AND. .NOT.LSAME( DIAG, 'U' ) )
1.6       bertrand  246:      $         THEN
1.1       bertrand  247:          INFO = -3
                    248:       ELSE IF( N.LT.0 ) THEN
                    249:          INFO = -4
                    250:       END IF
                    251:       IF( INFO.NE.0 ) THEN
                    252:          CALL XERBLA( 'DTFTRI', -INFO )
                    253:          RETURN
                    254:       END IF
                    255: *
                    256: *     Quick return if possible
                    257: *
                    258:       IF( N.EQ.0 )
1.6       bertrand  259:      $   RETURN
1.1       bertrand  260: *
                    261: *     If N is odd, set NISODD = .TRUE.
                    262: *     If N is even, set K = N/2 and NISODD = .FALSE.
                    263: *
                    264:       IF( MOD( N, 2 ).EQ.0 ) THEN
                    265:          K = N / 2
                    266:          NISODD = .FALSE.
                    267:       ELSE
                    268:          NISODD = .TRUE.
                    269:       END IF
                    270: *
                    271: *     Set N1 and N2 depending on LOWER
                    272: *
                    273:       IF( LOWER ) THEN
                    274:          N2 = N / 2
                    275:          N1 = N - N2
                    276:       ELSE
                    277:          N1 = N / 2
                    278:          N2 = N - N1
                    279:       END IF
                    280: *
                    281: *
                    282: *     start execution: there are eight cases
                    283: *
                    284:       IF( NISODD ) THEN
                    285: *
                    286: *        N is odd
                    287: *
                    288:          IF( NORMALTRANSR ) THEN
                    289: *
                    290: *           N is odd and TRANSR = 'N'
                    291: *
                    292:             IF( LOWER ) THEN
                    293: *
                    294: *             SRPA for LOWER, NORMAL and N is odd ( a(0:n-1,0:n1-1) )
                    295: *             T1 -> a(0,0), T2 -> a(0,1), S -> a(n1,0)
                    296: *             T1 -> a(0), T2 -> a(n), S -> a(n1)
                    297: *
                    298:                CALL DTRTRI( 'L', DIAG, N1, A( 0 ), N, INFO )
                    299:                IF( INFO.GT.0 )
1.6       bertrand  300:      $            RETURN
1.1       bertrand  301:                CALL DTRMM( 'R', 'L', 'N', DIAG, N2, N1, -ONE, A( 0 ),
1.6       bertrand  302:      $                     N, A( N1 ), N )
1.1       bertrand  303:                CALL DTRTRI( 'U', DIAG, N2, A( N ), N, INFO )
                    304:                IF( INFO.GT.0 )
1.6       bertrand  305:      $            INFO = INFO + N1
1.1       bertrand  306:                IF( INFO.GT.0 )
1.6       bertrand  307:      $            RETURN
1.1       bertrand  308:                CALL DTRMM( 'L', 'U', 'T', DIAG, N2, N1, ONE, A( N ), N,
1.6       bertrand  309:      $                     A( N1 ), N )
1.1       bertrand  310: *
                    311:             ELSE
                    312: *
                    313: *             SRPA for UPPER, NORMAL and N is odd ( a(0:n-1,0:n2-1)
                    314: *             T1 -> a(n1+1,0), T2 -> a(n1,0), S -> a(0,0)
                    315: *             T1 -> a(n2), T2 -> a(n1), S -> a(0)
                    316: *
                    317:                CALL DTRTRI( 'L', DIAG, N1, A( N2 ), N, INFO )
                    318:                IF( INFO.GT.0 )
1.6       bertrand  319:      $            RETURN
1.1       bertrand  320:                CALL DTRMM( 'L', 'L', 'T', DIAG, N1, N2, -ONE, A( N2 ),
1.6       bertrand  321:      $                     N, A( 0 ), N )
1.1       bertrand  322:                CALL DTRTRI( 'U', DIAG, N2, A( N1 ), N, INFO )
                    323:                IF( INFO.GT.0 )
1.6       bertrand  324:      $            INFO = INFO + N1
1.1       bertrand  325:                IF( INFO.GT.0 )
1.6       bertrand  326:      $            RETURN
1.1       bertrand  327:                CALL DTRMM( 'R', 'U', 'N', DIAG, N1, N2, ONE, A( N1 ),
1.6       bertrand  328:      $                     N, A( 0 ), N )
1.1       bertrand  329: *
                    330:             END IF
                    331: *
                    332:          ELSE
                    333: *
                    334: *           N is odd and TRANSR = 'T'
                    335: *
                    336:             IF( LOWER ) THEN
                    337: *
                    338: *              SRPA for LOWER, TRANSPOSE and N is odd
                    339: *              T1 -> a(0), T2 -> a(1), S -> a(0+n1*n1)
                    340: *
                    341:                CALL DTRTRI( 'U', DIAG, N1, A( 0 ), N1, INFO )
                    342:                IF( INFO.GT.0 )
1.6       bertrand  343:      $            RETURN
1.1       bertrand  344:                CALL DTRMM( 'L', 'U', 'N', DIAG, N1, N2, -ONE, A( 0 ),
1.6       bertrand  345:      $                     N1, A( N1*N1 ), N1 )
1.1       bertrand  346:                CALL DTRTRI( 'L', DIAG, N2, A( 1 ), N1, INFO )
                    347:                IF( INFO.GT.0 )
1.6       bertrand  348:      $            INFO = INFO + N1
1.1       bertrand  349:                IF( INFO.GT.0 )
1.6       bertrand  350:      $            RETURN
1.1       bertrand  351:                CALL DTRMM( 'R', 'L', 'T', DIAG, N1, N2, ONE, A( 1 ),
1.6       bertrand  352:      $                     N1, A( N1*N1 ), N1 )
1.1       bertrand  353: *
                    354:             ELSE
                    355: *
                    356: *              SRPA for UPPER, TRANSPOSE and N is odd
                    357: *              T1 -> a(0+n2*n2), T2 -> a(0+n1*n2), S -> a(0)
                    358: *
                    359:                CALL DTRTRI( 'U', DIAG, N1, A( N2*N2 ), N2, INFO )
                    360:                IF( INFO.GT.0 )
1.6       bertrand  361:      $            RETURN
1.1       bertrand  362:                CALL DTRMM( 'R', 'U', 'T', DIAG, N2, N1, -ONE,
1.6       bertrand  363:      $                     A( N2*N2 ), N2, A( 0 ), N2 )
1.1       bertrand  364:                CALL DTRTRI( 'L', DIAG, N2, A( N1*N2 ), N2, INFO )
                    365:                IF( INFO.GT.0 )
1.6       bertrand  366:      $            INFO = INFO + N1
1.1       bertrand  367:                IF( INFO.GT.0 )
1.6       bertrand  368:      $            RETURN
1.1       bertrand  369:                CALL DTRMM( 'L', 'L', 'N', DIAG, N2, N1, ONE,
1.6       bertrand  370:      $                     A( N1*N2 ), N2, A( 0 ), N2 )
1.1       bertrand  371:             END IF
                    372: *
                    373:          END IF
                    374: *
                    375:       ELSE
                    376: *
                    377: *        N is even
                    378: *
                    379:          IF( NORMALTRANSR ) THEN
                    380: *
                    381: *           N is even and TRANSR = 'N'
                    382: *
                    383:             IF( LOWER ) THEN
                    384: *
                    385: *              SRPA for LOWER, NORMAL, and N is even ( a(0:n,0:k-1) )
                    386: *              T1 -> a(1,0), T2 -> a(0,0), S -> a(k+1,0)
                    387: *              T1 -> a(1), T2 -> a(0), S -> a(k+1)
                    388: *
                    389:                CALL DTRTRI( 'L', DIAG, K, A( 1 ), N+1, INFO )
                    390:                IF( INFO.GT.0 )
1.6       bertrand  391:      $            RETURN
1.1       bertrand  392:                CALL DTRMM( 'R', 'L', 'N', DIAG, K, K, -ONE, A( 1 ),
1.6       bertrand  393:      $                     N+1, A( K+1 ), N+1 )
1.1       bertrand  394:                CALL DTRTRI( 'U', DIAG, K, A( 0 ), N+1, INFO )
                    395:                IF( INFO.GT.0 )
1.6       bertrand  396:      $            INFO = INFO + K
1.1       bertrand  397:                IF( INFO.GT.0 )
1.6       bertrand  398:      $            RETURN
1.1       bertrand  399:                CALL DTRMM( 'L', 'U', 'T', DIAG, K, K, ONE, A( 0 ), N+1,
1.6       bertrand  400:      $                     A( K+1 ), N+1 )
1.1       bertrand  401: *
                    402:             ELSE
                    403: *
                    404: *              SRPA for UPPER, NORMAL, and N is even ( a(0:n,0:k-1) )
                    405: *              T1 -> a(k+1,0) ,  T2 -> a(k,0),   S -> a(0,0)
                    406: *              T1 -> a(k+1), T2 -> a(k), S -> a(0)
                    407: *
                    408:                CALL DTRTRI( 'L', DIAG, K, A( K+1 ), N+1, INFO )
                    409:                IF( INFO.GT.0 )
1.6       bertrand  410:      $            RETURN
1.1       bertrand  411:                CALL DTRMM( 'L', 'L', 'T', DIAG, K, K, -ONE, A( K+1 ),
1.6       bertrand  412:      $                     N+1, A( 0 ), N+1 )
1.1       bertrand  413:                CALL DTRTRI( 'U', DIAG, K, A( K ), N+1, INFO )
                    414:                IF( INFO.GT.0 )
1.6       bertrand  415:      $            INFO = INFO + K
1.1       bertrand  416:                IF( INFO.GT.0 )
1.6       bertrand  417:      $            RETURN
1.1       bertrand  418:                CALL DTRMM( 'R', 'U', 'N', DIAG, K, K, ONE, A( K ), N+1,
1.6       bertrand  419:      $                     A( 0 ), N+1 )
1.1       bertrand  420:             END IF
                    421:          ELSE
                    422: *
                    423: *           N is even and TRANSR = 'T'
                    424: *
                    425:             IF( LOWER ) THEN
                    426: *
                    427: *              SRPA for LOWER, TRANSPOSE and N is even (see paper)
                    428: *              T1 -> B(0,1), T2 -> B(0,0), S -> B(0,k+1)
                    429: *              T1 -> a(0+k), T2 -> a(0+0), S -> a(0+k*(k+1)); lda=k
                    430: *
                    431:                CALL DTRTRI( 'U', DIAG, K, A( K ), K, INFO )
                    432:                IF( INFO.GT.0 )
1.6       bertrand  433:      $            RETURN
1.1       bertrand  434:                CALL DTRMM( 'L', 'U', 'N', DIAG, K, K, -ONE, A( K ), K,
1.6       bertrand  435:      $                     A( K*( K+1 ) ), K )
1.1       bertrand  436:                CALL DTRTRI( 'L', DIAG, K, A( 0 ), K, INFO )
                    437:                IF( INFO.GT.0 )
1.6       bertrand  438:      $            INFO = INFO + K
1.1       bertrand  439:                IF( INFO.GT.0 )
1.6       bertrand  440:      $            RETURN
1.1       bertrand  441:                CALL DTRMM( 'R', 'L', 'T', DIAG, K, K, ONE, A( 0 ), K,
1.6       bertrand  442:      $                     A( K*( K+1 ) ), K )
1.1       bertrand  443:             ELSE
                    444: *
                    445: *              SRPA for UPPER, TRANSPOSE and N is even (see paper)
                    446: *              T1 -> B(0,k+1),     T2 -> B(0,k),   S -> B(0,0)
                    447: *              T1 -> a(0+k*(k+1)), T2 -> a(0+k*k), S -> a(0+0)); lda=k
                    448: *
                    449:                CALL DTRTRI( 'U', DIAG, K, A( K*( K+1 ) ), K, INFO )
                    450:                IF( INFO.GT.0 )
1.6       bertrand  451:      $            RETURN
1.1       bertrand  452:                CALL DTRMM( 'R', 'U', 'T', DIAG, K, K, -ONE,
1.6       bertrand  453:      $                     A( K*( K+1 ) ), K, A( 0 ), K )
1.1       bertrand  454:                CALL DTRTRI( 'L', DIAG, K, A( K*K ), K, INFO )
                    455:                IF( INFO.GT.0 )
1.6       bertrand  456:      $            INFO = INFO + K
1.1       bertrand  457:                IF( INFO.GT.0 )
1.6       bertrand  458:      $            RETURN
1.1       bertrand  459:                CALL DTRMM( 'L', 'L', 'N', DIAG, K, K, ONE, A( K*K ), K,
1.6       bertrand  460:      $                     A( 0 ), K )
1.1       bertrand  461:             END IF
                    462:          END IF
                    463:       END IF
                    464: *
                    465:       RETURN
                    466: *
                    467: *     End of DTFTRI
                    468: *
                    469:       END

CVSweb interface <joel.bertrand@systella.fr>