LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
dpftri.f
Go to the documentation of this file.
00001 *> \brief \b DPFTRI
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download DPFTRI + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dpftri.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dpftri.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dpftri.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE DPFTRI( TRANSR, UPLO, N, A, INFO )
00022 * 
00023 *       .. Scalar Arguments ..
00024 *       CHARACTER          TRANSR, UPLO
00025 *       INTEGER            INFO, N
00026 *       .. Array Arguments ..
00027 *       DOUBLE PRECISION         A( 0: * )
00028 *       ..
00029 *  
00030 *
00031 *> \par Purpose:
00032 *  =============
00033 *>
00034 *> \verbatim
00035 *>
00036 *> DPFTRI computes the inverse of a (real) symmetric positive definite
00037 *> matrix A using the Cholesky factorization A = U**T*U or A = L*L**T
00038 *> computed by DPFTRF.
00039 *> \endverbatim
00040 *
00041 *  Arguments:
00042 *  ==========
00043 *
00044 *> \param[in] TRANSR
00045 *> \verbatim
00046 *>          TRANSR is CHARACTER*1
00047 *>          = 'N':  The Normal TRANSR of RFP A is stored;
00048 *>          = 'T':  The Transpose TRANSR of RFP A is stored.
00049 *> \endverbatim
00050 *>
00051 *> \param[in] UPLO
00052 *> \verbatim
00053 *>          UPLO is CHARACTER*1
00054 *>          = 'U':  Upper triangle of A is stored;
00055 *>          = 'L':  Lower triangle of A is stored.
00056 *> \endverbatim
00057 *>
00058 *> \param[in] N
00059 *> \verbatim
00060 *>          N is INTEGER
00061 *>          The order of the matrix A.  N >= 0.
00062 *> \endverbatim
00063 *>
00064 *> \param[in,out] A
00065 *> \verbatim
00066 *>          A is DOUBLE PRECISION array, dimension ( N*(N+1)/2 )
00067 *>          On entry, the symmetric matrix A in RFP format. RFP format is
00068 *>          described by TRANSR, UPLO, and N as follows: If TRANSR = 'N'
00069 *>          then RFP A is (0:N,0:k-1) when N is even; k=N/2. RFP A is
00070 *>          (0:N-1,0:k) when N is odd; k=N/2. IF TRANSR = 'T' then RFP is
00071 *>          the transpose of RFP A as defined when
00072 *>          TRANSR = 'N'. The contents of RFP A are defined by UPLO as
00073 *>          follows: If UPLO = 'U' the RFP A contains the nt elements of
00074 *>          upper packed A. If UPLO = 'L' the RFP A contains the elements
00075 *>          of lower packed A. The LDA of RFP A is (N+1)/2 when TRANSR =
00076 *>          'T'. When TRANSR is 'N' the LDA is N+1 when N is even and N
00077 *>          is odd. See the Note below for more details.
00078 *>
00079 *>          On exit, the symmetric inverse of the original matrix, in the
00080 *>          same storage format.
00081 *> \endverbatim
00082 *>
00083 *> \param[out] INFO
00084 *> \verbatim
00085 *>          INFO is INTEGER
00086 *>          = 0:  successful exit
00087 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
00088 *>          > 0:  if INFO = i, the (i,i) element of the factor U or L is
00089 *>                zero, and the inverse could not be computed.
00090 *> \endverbatim
00091 *
00092 *  Authors:
00093 *  ========
00094 *
00095 *> \author Univ. of Tennessee 
00096 *> \author Univ. of California Berkeley 
00097 *> \author Univ. of Colorado Denver 
00098 *> \author NAG Ltd. 
00099 *
00100 *> \date November 2011
00101 *
00102 *> \ingroup doubleOTHERcomputational
00103 *
00104 *> \par Further Details:
00105 *  =====================
00106 *>
00107 *> \verbatim
00108 *>
00109 *>  We first consider Rectangular Full Packed (RFP) Format when N is
00110 *>  even. We give an example where N = 6.
00111 *>
00112 *>      AP is Upper             AP is Lower
00113 *>
00114 *>   00 01 02 03 04 05       00
00115 *>      11 12 13 14 15       10 11
00116 *>         22 23 24 25       20 21 22
00117 *>            33 34 35       30 31 32 33
00118 *>               44 45       40 41 42 43 44
00119 *>                  55       50 51 52 53 54 55
00120 *>
00121 *>
00122 *>  Let TRANSR = 'N'. RFP holds AP as follows:
00123 *>  For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last
00124 *>  three columns of AP upper. The lower triangle A(4:6,0:2) consists of
00125 *>  the transpose of the first three columns of AP upper.
00126 *>  For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first
00127 *>  three columns of AP lower. The upper triangle A(0:2,0:2) consists of
00128 *>  the transpose of the last three columns of AP lower.
00129 *>  This covers the case N even and TRANSR = 'N'.
00130 *>
00131 *>         RFP A                   RFP A
00132 *>
00133 *>        03 04 05                33 43 53
00134 *>        13 14 15                00 44 54
00135 *>        23 24 25                10 11 55
00136 *>        33 34 35                20 21 22
00137 *>        00 44 45                30 31 32
00138 *>        01 11 55                40 41 42
00139 *>        02 12 22                50 51 52
00140 *>
00141 *>  Now let TRANSR = 'T'. RFP A in both UPLO cases is just the
00142 *>  transpose of RFP A above. One therefore gets:
00143 *>
00144 *>
00145 *>           RFP A                   RFP A
00146 *>
00147 *>     03 13 23 33 00 01 02    33 00 10 20 30 40 50
00148 *>     04 14 24 34 44 11 12    43 44 11 21 31 41 51
00149 *>     05 15 25 35 45 55 22    53 54 55 22 32 42 52
00150 *>
00151 *>
00152 *>  We then consider Rectangular Full Packed (RFP) Format when N is
00153 *>  odd. We give an example where N = 5.
00154 *>
00155 *>     AP is Upper                 AP is Lower
00156 *>
00157 *>   00 01 02 03 04              00
00158 *>      11 12 13 14              10 11
00159 *>         22 23 24              20 21 22
00160 *>            33 34              30 31 32 33
00161 *>               44              40 41 42 43 44
00162 *>
00163 *>
00164 *>  Let TRANSR = 'N'. RFP holds AP as follows:
00165 *>  For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last
00166 *>  three columns of AP upper. The lower triangle A(3:4,0:1) consists of
00167 *>  the transpose of the first two columns of AP upper.
00168 *>  For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first
00169 *>  three columns of AP lower. The upper triangle A(0:1,1:2) consists of
00170 *>  the transpose of the last two columns of AP lower.
00171 *>  This covers the case N odd and TRANSR = 'N'.
00172 *>
00173 *>         RFP A                   RFP A
00174 *>
00175 *>        02 03 04                00 33 43
00176 *>        12 13 14                10 11 44
00177 *>        22 23 24                20 21 22
00178 *>        00 33 34                30 31 32
00179 *>        01 11 44                40 41 42
00180 *>
00181 *>  Now let TRANSR = 'T'. RFP A in both UPLO cases is just the
00182 *>  transpose of RFP A above. One therefore gets:
00183 *>
00184 *>           RFP A                   RFP A
00185 *>
00186 *>     02 12 22 00 01             00 10 20 30 40 50
00187 *>     03 13 23 33 11             33 11 21 31 41 51
00188 *>     04 14 24 34 44             43 44 22 32 42 52
00189 *> \endverbatim
00190 *>
00191 *  =====================================================================
00192       SUBROUTINE DPFTRI( TRANSR, UPLO, N, A, INFO )
00193 *
00194 *  -- LAPACK computational routine (version 3.4.0) --
00195 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00196 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00197 *     November 2011
00198 *
00199 *     .. Scalar Arguments ..
00200       CHARACTER          TRANSR, UPLO
00201       INTEGER            INFO, N
00202 *     .. Array Arguments ..
00203       DOUBLE PRECISION         A( 0: * )
00204 *     ..
00205 *
00206 *  =====================================================================
00207 *
00208 *     .. Parameters ..
00209       DOUBLE PRECISION   ONE
00210       PARAMETER          ( ONE = 1.0D+0 )
00211 *     ..
00212 *     .. Local Scalars ..
00213       LOGICAL            LOWER, NISODD, NORMALTRANSR
00214       INTEGER            N1, N2, K
00215 *     ..
00216 *     .. External Functions ..
00217       LOGICAL            LSAME
00218       EXTERNAL           LSAME
00219 *     ..
00220 *     .. External Subroutines ..
00221       EXTERNAL           XERBLA, DTFTRI, DLAUUM, DTRMM, DSYRK
00222 *     ..
00223 *     .. Intrinsic Functions ..
00224       INTRINSIC          MOD
00225 *     ..
00226 *     .. Executable Statements ..
00227 *
00228 *     Test the input parameters.
00229 *
00230       INFO = 0
00231       NORMALTRANSR = LSAME( TRANSR, 'N' )
00232       LOWER = LSAME( UPLO, 'L' )
00233       IF( .NOT.NORMALTRANSR .AND. .NOT.LSAME( TRANSR, 'T' ) ) THEN
00234          INFO = -1
00235       ELSE IF( .NOT.LOWER .AND. .NOT.LSAME( UPLO, 'U' ) ) THEN
00236          INFO = -2
00237       ELSE IF( N.LT.0 ) THEN
00238          INFO = -3
00239       END IF
00240       IF( INFO.NE.0 ) THEN
00241          CALL XERBLA( 'DPFTRI', -INFO )
00242          RETURN
00243       END IF
00244 *
00245 *     Quick return if possible
00246 *
00247       IF( N.EQ.0 )
00248      $   RETURN
00249 *
00250 *     Invert the triangular Cholesky factor U or L.
00251 *
00252       CALL DTFTRI( TRANSR, UPLO, 'N', N, A, INFO )
00253       IF( INFO.GT.0 )
00254      $   RETURN
00255 *
00256 *     If N is odd, set NISODD = .TRUE.
00257 *     If N is even, set K = N/2 and NISODD = .FALSE.
00258 *
00259       IF( MOD( N, 2 ).EQ.0 ) THEN
00260          K = N / 2
00261          NISODD = .FALSE.
00262       ELSE
00263          NISODD = .TRUE.
00264       END IF
00265 *
00266 *     Set N1 and N2 depending on LOWER
00267 *
00268       IF( LOWER ) THEN
00269          N2 = N / 2
00270          N1 = N - N2
00271       ELSE
00272          N1 = N / 2
00273          N2 = N - N1
00274       END IF
00275 *
00276 *     Start execution of triangular matrix multiply: inv(U)*inv(U)^C or
00277 *     inv(L)^C*inv(L). There are eight cases.
00278 *
00279       IF( NISODD ) THEN
00280 *
00281 *        N is odd
00282 *
00283          IF( NORMALTRANSR ) THEN
00284 *
00285 *           N is odd and TRANSR = 'N'
00286 *
00287             IF( LOWER ) THEN
00288 *
00289 *              SRPA for LOWER, NORMAL and N is odd ( a(0:n-1,0:N1-1) )
00290 *              T1 -> a(0,0), T2 -> a(0,1), S -> a(N1,0)
00291 *              T1 -> a(0), T2 -> a(n), S -> a(N1)
00292 *
00293                CALL DLAUUM( 'L', N1, A( 0 ), N, INFO )
00294                CALL DSYRK( 'L', 'T', N1, N2, ONE, A( N1 ), N, ONE,
00295      $                     A( 0 ), N )
00296                CALL DTRMM( 'L', 'U', 'N', 'N', N2, N1, ONE, A( N ), N,
00297      $                     A( N1 ), N )
00298                CALL DLAUUM( 'U', N2, A( N ), N, INFO )
00299 *
00300             ELSE
00301 *
00302 *              SRPA for UPPER, NORMAL and N is odd ( a(0:n-1,0:N2-1)
00303 *              T1 -> a(N1+1,0), T2 -> a(N1,0), S -> a(0,0)
00304 *              T1 -> a(N2), T2 -> a(N1), S -> a(0)
00305 *
00306                CALL DLAUUM( 'L', N1, A( N2 ), N, INFO )
00307                CALL DSYRK( 'L', 'N', N1, N2, ONE, A( 0 ), N, ONE,
00308      $                     A( N2 ), N )
00309                CALL DTRMM( 'R', 'U', 'T', 'N', N1, N2, ONE, A( N1 ), N,
00310      $                     A( 0 ), N )
00311                CALL DLAUUM( 'U', N2, A( N1 ), N, INFO )
00312 *
00313             END IF
00314 *
00315          ELSE
00316 *
00317 *           N is odd and TRANSR = 'T'
00318 *
00319             IF( LOWER ) THEN
00320 *
00321 *              SRPA for LOWER, TRANSPOSE, and N is odd
00322 *              T1 -> a(0), T2 -> a(1), S -> a(0+N1*N1)
00323 *
00324                CALL DLAUUM( 'U', N1, A( 0 ), N1, INFO )
00325                CALL DSYRK( 'U', 'N', N1, N2, ONE, A( N1*N1 ), N1, ONE,
00326      $                     A( 0 ), N1 )
00327                CALL DTRMM( 'R', 'L', 'N', 'N', N1, N2, ONE, A( 1 ), N1,
00328      $                     A( N1*N1 ), N1 )
00329                CALL DLAUUM( 'L', N2, A( 1 ), N1, INFO )
00330 *
00331             ELSE
00332 *
00333 *              SRPA for UPPER, TRANSPOSE, and N is odd
00334 *              T1 -> a(0+N2*N2), T2 -> a(0+N1*N2), S -> a(0)
00335 *
00336                CALL DLAUUM( 'U', N1, A( N2*N2 ), N2, INFO )
00337                CALL DSYRK( 'U', 'T', N1, N2, ONE, A( 0 ), N2, ONE,
00338      $                     A( N2*N2 ), N2 )
00339                CALL DTRMM( 'L', 'L', 'T', 'N', N2, N1, ONE, A( N1*N2 ),
00340      $                     N2, A( 0 ), N2 )
00341                CALL DLAUUM( 'L', N2, A( N1*N2 ), N2, INFO )
00342 *
00343             END IF
00344 *
00345          END IF
00346 *
00347       ELSE
00348 *
00349 *        N is even
00350 *
00351          IF( NORMALTRANSR ) THEN
00352 *
00353 *           N is even and TRANSR = 'N'
00354 *
00355             IF( LOWER ) THEN
00356 *
00357 *              SRPA for LOWER, NORMAL, and N is even ( a(0:n,0:k-1) )
00358 *              T1 -> a(1,0), T2 -> a(0,0), S -> a(k+1,0)
00359 *              T1 -> a(1), T2 -> a(0), S -> a(k+1)
00360 *
00361                CALL DLAUUM( 'L', K, A( 1 ), N+1, INFO )
00362                CALL DSYRK( 'L', 'T', K, K, ONE, A( K+1 ), N+1, ONE,
00363      $                     A( 1 ), N+1 )
00364                CALL DTRMM( 'L', 'U', 'N', 'N', K, K, ONE, A( 0 ), N+1,
00365      $                     A( K+1 ), N+1 )
00366                CALL DLAUUM( 'U', K, A( 0 ), N+1, INFO )
00367 *
00368             ELSE
00369 *
00370 *              SRPA for UPPER, NORMAL, and N is even ( a(0:n,0:k-1) )
00371 *              T1 -> a(k+1,0) ,  T2 -> a(k,0),   S -> a(0,0)
00372 *              T1 -> a(k+1), T2 -> a(k), S -> a(0)
00373 *
00374                CALL DLAUUM( 'L', K, A( K+1 ), N+1, INFO )
00375                CALL DSYRK( 'L', 'N', K, K, ONE, A( 0 ), N+1, ONE,
00376      $                     A( K+1 ), N+1 )
00377                CALL DTRMM( 'R', 'U', 'T', 'N', K, K, ONE, A( K ), N+1,
00378      $                     A( 0 ), N+1 )
00379                CALL DLAUUM( 'U', K, A( K ), N+1, INFO )
00380 *
00381             END IF
00382 *
00383          ELSE
00384 *
00385 *           N is even and TRANSR = 'T'
00386 *
00387             IF( LOWER ) THEN
00388 *
00389 *              SRPA for LOWER, TRANSPOSE, and N is even (see paper)
00390 *              T1 -> B(0,1), T2 -> B(0,0), S -> B(0,k+1),
00391 *              T1 -> a(0+k), T2 -> a(0+0), S -> a(0+k*(k+1)); lda=k
00392 *
00393                CALL DLAUUM( 'U', K, A( K ), K, INFO )
00394                CALL DSYRK( 'U', 'N', K, K, ONE, A( K*( K+1 ) ), K, ONE,
00395      $                     A( K ), K )
00396                CALL DTRMM( 'R', 'L', 'N', 'N', K, K, ONE, A( 0 ), K,
00397      $                     A( K*( K+1 ) ), K )
00398                CALL DLAUUM( 'L', K, A( 0 ), K, INFO )
00399 *
00400             ELSE
00401 *
00402 *              SRPA for UPPER, TRANSPOSE, and N is even (see paper)
00403 *              T1 -> B(0,k+1),     T2 -> B(0,k),   S -> B(0,0),
00404 *              T1 -> a(0+k*(k+1)), T2 -> a(0+k*k), S -> a(0+0)); lda=k
00405 *
00406                CALL DLAUUM( 'U', K, A( K*( K+1 ) ), K, INFO )
00407                CALL DSYRK( 'U', 'T', K, K, ONE, A( 0 ), K, ONE,
00408      $                     A( K*( K+1 ) ), K )
00409                CALL DTRMM( 'L', 'L', 'T', 'N', K, K, ONE, A( K*K ), K,
00410      $                     A( 0 ), K )
00411                CALL DLAUUM( 'L', K, A( K*K ), K, INFO )
00412 *
00413             END IF
00414 *
00415          END IF
00416 *
00417       END IF
00418 *
00419       RETURN
00420 *
00421 *     End of DPFTRI
00422 *
00423       END
 All Files Functions