![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b CSYTRI 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download CSYTRI + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/csytri.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/csytri.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/csytri.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE CSYTRI( UPLO, N, A, LDA, IPIV, WORK, INFO ) 00022 * 00023 * .. Scalar Arguments .. 00024 * CHARACTER UPLO 00025 * INTEGER INFO, LDA, N 00026 * .. 00027 * .. Array Arguments .. 00028 * INTEGER IPIV( * ) 00029 * COMPLEX A( LDA, * ), WORK( * ) 00030 * .. 00031 * 00032 * 00033 *> \par Purpose: 00034 * ============= 00035 *> 00036 *> \verbatim 00037 *> 00038 *> CSYTRI computes the inverse of a complex symmetric indefinite matrix 00039 *> A using the factorization A = U*D*U**T or A = L*D*L**T computed by 00040 *> CSYTRF. 00041 *> \endverbatim 00042 * 00043 * Arguments: 00044 * ========== 00045 * 00046 *> \param[in] UPLO 00047 *> \verbatim 00048 *> UPLO is CHARACTER*1 00049 *> Specifies whether the details of the factorization are stored 00050 *> as an upper or lower triangular matrix. 00051 *> = 'U': Upper triangular, form is A = U*D*U**T; 00052 *> = 'L': Lower triangular, form is A = L*D*L**T. 00053 *> \endverbatim 00054 *> 00055 *> \param[in] N 00056 *> \verbatim 00057 *> N is INTEGER 00058 *> The order of the matrix A. N >= 0. 00059 *> \endverbatim 00060 *> 00061 *> \param[in,out] A 00062 *> \verbatim 00063 *> A is COMPLEX array, dimension (LDA,N) 00064 *> On entry, the block diagonal matrix D and the multipliers 00065 *> used to obtain the factor U or L as computed by CSYTRF. 00066 *> 00067 *> On exit, if INFO = 0, the (symmetric) inverse of the original 00068 *> matrix. If UPLO = 'U', the upper triangular part of the 00069 *> inverse is formed and the part of A below the diagonal is not 00070 *> referenced; if UPLO = 'L' the lower triangular part of the 00071 *> inverse is formed and the part of A above the diagonal is 00072 *> not referenced. 00073 *> \endverbatim 00074 *> 00075 *> \param[in] LDA 00076 *> \verbatim 00077 *> LDA is INTEGER 00078 *> The leading dimension of the array A. LDA >= max(1,N). 00079 *> \endverbatim 00080 *> 00081 *> \param[in] IPIV 00082 *> \verbatim 00083 *> IPIV is INTEGER array, dimension (N) 00084 *> Details of the interchanges and the block structure of D 00085 *> as determined by CSYTRF. 00086 *> \endverbatim 00087 *> 00088 *> \param[out] WORK 00089 *> \verbatim 00090 *> WORK is COMPLEX array, dimension (2*N) 00091 *> \endverbatim 00092 *> 00093 *> \param[out] INFO 00094 *> \verbatim 00095 *> INFO is INTEGER 00096 *> = 0: successful exit 00097 *> < 0: if INFO = -i, the i-th argument had an illegal value 00098 *> > 0: if INFO = i, D(i,i) = 0; the matrix is singular and its 00099 *> inverse could not be computed. 00100 *> \endverbatim 00101 * 00102 * Authors: 00103 * ======== 00104 * 00105 *> \author Univ. of Tennessee 00106 *> \author Univ. of California Berkeley 00107 *> \author Univ. of Colorado Denver 00108 *> \author NAG Ltd. 00109 * 00110 *> \date November 2011 00111 * 00112 *> \ingroup complexSYcomputational 00113 * 00114 * ===================================================================== 00115 SUBROUTINE CSYTRI( UPLO, N, A, LDA, IPIV, WORK, INFO ) 00116 * 00117 * -- LAPACK computational routine (version 3.4.0) -- 00118 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00119 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00120 * November 2011 00121 * 00122 * .. Scalar Arguments .. 00123 CHARACTER UPLO 00124 INTEGER INFO, LDA, N 00125 * .. 00126 * .. Array Arguments .. 00127 INTEGER IPIV( * ) 00128 COMPLEX A( LDA, * ), WORK( * ) 00129 * .. 00130 * 00131 * ===================================================================== 00132 * 00133 * .. Parameters .. 00134 COMPLEX ONE, ZERO 00135 PARAMETER ( ONE = ( 1.0E+0, 0.0E+0 ), 00136 $ ZERO = ( 0.0E+0, 0.0E+0 ) ) 00137 * .. 00138 * .. Local Scalars .. 00139 LOGICAL UPPER 00140 INTEGER K, KP, KSTEP 00141 COMPLEX AK, AKKP1, AKP1, D, T, TEMP 00142 * .. 00143 * .. External Functions .. 00144 LOGICAL LSAME 00145 COMPLEX CDOTU 00146 EXTERNAL LSAME, CDOTU 00147 * .. 00148 * .. External Subroutines .. 00149 EXTERNAL CCOPY, CSWAP, CSYMV, XERBLA 00150 * .. 00151 * .. Intrinsic Functions .. 00152 INTRINSIC ABS, MAX 00153 * .. 00154 * .. Executable Statements .. 00155 * 00156 * Test the input parameters. 00157 * 00158 INFO = 0 00159 UPPER = LSAME( UPLO, 'U' ) 00160 IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN 00161 INFO = -1 00162 ELSE IF( N.LT.0 ) THEN 00163 INFO = -2 00164 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN 00165 INFO = -4 00166 END IF 00167 IF( INFO.NE.0 ) THEN 00168 CALL XERBLA( 'CSYTRI', -INFO ) 00169 RETURN 00170 END IF 00171 * 00172 * Quick return if possible 00173 * 00174 IF( N.EQ.0 ) 00175 $ RETURN 00176 * 00177 * Check that the diagonal matrix D is nonsingular. 00178 * 00179 IF( UPPER ) THEN 00180 * 00181 * Upper triangular storage: examine D from bottom to top 00182 * 00183 DO 10 INFO = N, 1, -1 00184 IF( IPIV( INFO ).GT.0 .AND. A( INFO, INFO ).EQ.ZERO ) 00185 $ RETURN 00186 10 CONTINUE 00187 ELSE 00188 * 00189 * Lower triangular storage: examine D from top to bottom. 00190 * 00191 DO 20 INFO = 1, N 00192 IF( IPIV( INFO ).GT.0 .AND. A( INFO, INFO ).EQ.ZERO ) 00193 $ RETURN 00194 20 CONTINUE 00195 END IF 00196 INFO = 0 00197 * 00198 IF( UPPER ) THEN 00199 * 00200 * Compute inv(A) from the factorization A = U*D*U**T. 00201 * 00202 * K is the main loop index, increasing from 1 to N in steps of 00203 * 1 or 2, depending on the size of the diagonal blocks. 00204 * 00205 K = 1 00206 30 CONTINUE 00207 * 00208 * If K > N, exit from loop. 00209 * 00210 IF( K.GT.N ) 00211 $ GO TO 40 00212 * 00213 IF( IPIV( K ).GT.0 ) THEN 00214 * 00215 * 1 x 1 diagonal block 00216 * 00217 * Invert the diagonal block. 00218 * 00219 A( K, K ) = ONE / A( K, K ) 00220 * 00221 * Compute column K of the inverse. 00222 * 00223 IF( K.GT.1 ) THEN 00224 CALL CCOPY( K-1, A( 1, K ), 1, WORK, 1 ) 00225 CALL CSYMV( UPLO, K-1, -ONE, A, LDA, WORK, 1, ZERO, 00226 $ A( 1, K ), 1 ) 00227 A( K, K ) = A( K, K ) - CDOTU( K-1, WORK, 1, A( 1, K ), 00228 $ 1 ) 00229 END IF 00230 KSTEP = 1 00231 ELSE 00232 * 00233 * 2 x 2 diagonal block 00234 * 00235 * Invert the diagonal block. 00236 * 00237 T = A( K, K+1 ) 00238 AK = A( K, K ) / T 00239 AKP1 = A( K+1, K+1 ) / T 00240 AKKP1 = A( K, K+1 ) / T 00241 D = T*( AK*AKP1-ONE ) 00242 A( K, K ) = AKP1 / D 00243 A( K+1, K+1 ) = AK / D 00244 A( K, K+1 ) = -AKKP1 / D 00245 * 00246 * Compute columns K and K+1 of the inverse. 00247 * 00248 IF( K.GT.1 ) THEN 00249 CALL CCOPY( K-1, A( 1, K ), 1, WORK, 1 ) 00250 CALL CSYMV( UPLO, K-1, -ONE, A, LDA, WORK, 1, ZERO, 00251 $ A( 1, K ), 1 ) 00252 A( K, K ) = A( K, K ) - CDOTU( K-1, WORK, 1, A( 1, K ), 00253 $ 1 ) 00254 A( K, K+1 ) = A( K, K+1 ) - 00255 $ CDOTU( K-1, A( 1, K ), 1, A( 1, K+1 ), 1 ) 00256 CALL CCOPY( K-1, A( 1, K+1 ), 1, WORK, 1 ) 00257 CALL CSYMV( UPLO, K-1, -ONE, A, LDA, WORK, 1, ZERO, 00258 $ A( 1, K+1 ), 1 ) 00259 A( K+1, K+1 ) = A( K+1, K+1 ) - 00260 $ CDOTU( K-1, WORK, 1, A( 1, K+1 ), 1 ) 00261 END IF 00262 KSTEP = 2 00263 END IF 00264 * 00265 KP = ABS( IPIV( K ) ) 00266 IF( KP.NE.K ) THEN 00267 * 00268 * Interchange rows and columns K and KP in the leading 00269 * submatrix A(1:k+1,1:k+1) 00270 * 00271 CALL CSWAP( KP-1, A( 1, K ), 1, A( 1, KP ), 1 ) 00272 CALL CSWAP( K-KP-1, A( KP+1, K ), 1, A( KP, KP+1 ), LDA ) 00273 TEMP = A( K, K ) 00274 A( K, K ) = A( KP, KP ) 00275 A( KP, KP ) = TEMP 00276 IF( KSTEP.EQ.2 ) THEN 00277 TEMP = A( K, K+1 ) 00278 A( K, K+1 ) = A( KP, K+1 ) 00279 A( KP, K+1 ) = TEMP 00280 END IF 00281 END IF 00282 * 00283 K = K + KSTEP 00284 GO TO 30 00285 40 CONTINUE 00286 * 00287 ELSE 00288 * 00289 * Compute inv(A) from the factorization A = L*D*L**T. 00290 * 00291 * K is the main loop index, increasing from 1 to N in steps of 00292 * 1 or 2, depending on the size of the diagonal blocks. 00293 * 00294 K = N 00295 50 CONTINUE 00296 * 00297 * If K < 1, exit from loop. 00298 * 00299 IF( K.LT.1 ) 00300 $ GO TO 60 00301 * 00302 IF( IPIV( K ).GT.0 ) THEN 00303 * 00304 * 1 x 1 diagonal block 00305 * 00306 * Invert the diagonal block. 00307 * 00308 A( K, K ) = ONE / A( K, K ) 00309 * 00310 * Compute column K of the inverse. 00311 * 00312 IF( K.LT.N ) THEN 00313 CALL CCOPY( N-K, A( K+1, K ), 1, WORK, 1 ) 00314 CALL CSYMV( UPLO, N-K, -ONE, A( K+1, K+1 ), LDA, WORK, 1, 00315 $ ZERO, A( K+1, K ), 1 ) 00316 A( K, K ) = A( K, K ) - CDOTU( N-K, WORK, 1, A( K+1, K ), 00317 $ 1 ) 00318 END IF 00319 KSTEP = 1 00320 ELSE 00321 * 00322 * 2 x 2 diagonal block 00323 * 00324 * Invert the diagonal block. 00325 * 00326 T = A( K, K-1 ) 00327 AK = A( K-1, K-1 ) / T 00328 AKP1 = A( K, K ) / T 00329 AKKP1 = A( K, K-1 ) / T 00330 D = T*( AK*AKP1-ONE ) 00331 A( K-1, K-1 ) = AKP1 / D 00332 A( K, K ) = AK / D 00333 A( K, K-1 ) = -AKKP1 / D 00334 * 00335 * Compute columns K-1 and K of the inverse. 00336 * 00337 IF( K.LT.N ) THEN 00338 CALL CCOPY( N-K, A( K+1, K ), 1, WORK, 1 ) 00339 CALL CSYMV( UPLO, N-K, -ONE, A( K+1, K+1 ), LDA, WORK, 1, 00340 $ ZERO, A( K+1, K ), 1 ) 00341 A( K, K ) = A( K, K ) - CDOTU( N-K, WORK, 1, A( K+1, K ), 00342 $ 1 ) 00343 A( K, K-1 ) = A( K, K-1 ) - 00344 $ CDOTU( N-K, A( K+1, K ), 1, A( K+1, K-1 ), 00345 $ 1 ) 00346 CALL CCOPY( N-K, A( K+1, K-1 ), 1, WORK, 1 ) 00347 CALL CSYMV( UPLO, N-K, -ONE, A( K+1, K+1 ), LDA, WORK, 1, 00348 $ ZERO, A( K+1, K-1 ), 1 ) 00349 A( K-1, K-1 ) = A( K-1, K-1 ) - 00350 $ CDOTU( N-K, WORK, 1, A( K+1, K-1 ), 1 ) 00351 END IF 00352 KSTEP = 2 00353 END IF 00354 * 00355 KP = ABS( IPIV( K ) ) 00356 IF( KP.NE.K ) THEN 00357 * 00358 * Interchange rows and columns K and KP in the trailing 00359 * submatrix A(k-1:n,k-1:n) 00360 * 00361 IF( KP.LT.N ) 00362 $ CALL CSWAP( N-KP, A( KP+1, K ), 1, A( KP+1, KP ), 1 ) 00363 CALL CSWAP( KP-K-1, A( K+1, K ), 1, A( KP, K+1 ), LDA ) 00364 TEMP = A( K, K ) 00365 A( K, K ) = A( KP, KP ) 00366 A( KP, KP ) = TEMP 00367 IF( KSTEP.EQ.2 ) THEN 00368 TEMP = A( K, K-1 ) 00369 A( K, K-1 ) = A( KP, K-1 ) 00370 A( KP, K-1 ) = TEMP 00371 END IF 00372 END IF 00373 * 00374 K = K - KSTEP 00375 GO TO 50 00376 60 CONTINUE 00377 END IF 00378 * 00379 RETURN 00380 * 00381 * End of CSYTRI 00382 * 00383 END