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