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