3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SPFTRI + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/spftri.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/spftri.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/spftri.f">
21 * SUBROUTINE SPFTRI( TRANSR, UPLO, N, A, INFO )
23 * .. Scalar Arguments ..
24 * CHARACTER TRANSR, UPLO
26 * .. Array Arguments ..
36 *> SPFTRI computes the inverse of a real (symmetric) positive definite
37 *> matrix A using the Cholesky factorization A = U**T*U or A = L*L**T
38 *> computed by SPFTRF.
46 *> TRANSR is CHARACTER*1
47 *> = 'N': The Normal TRANSR of RFP A is stored;
48 *> = 'T': The Transpose TRANSR of RFP A is stored.
53 *> UPLO is CHARACTER*1
54 *> = 'U': Upper triangle of A is stored;
55 *> = 'L': Lower triangle of A is stored.
61 *> The order of the matrix A. N >= 0.
66 *> A is REAL array, dimension ( N*(N+1)/2 )
67 *> On entry, the symmetric matrix A in RFP format. RFP format is
68 *> described by TRANSR, UPLO, and N as follows: If TRANSR = 'N'
69 *> then RFP A is (0:N,0:k-1) when N is even; k=N/2. RFP A is
70 *> (0:N-1,0:k) when N is odd; k=N/2. IF TRANSR = 'T' then RFP is
71 *> the transpose of RFP A as defined when
72 *> TRANSR = 'N'. The contents of RFP A are defined by UPLO as
73 *> follows: If UPLO = 'U' the RFP A contains the nt elements of
74 *> upper packed A. If UPLO = 'L' the RFP A contains the elements
75 *> of lower packed A. The LDA of RFP A is (N+1)/2 when TRANSR =
76 *> 'T'. When TRANSR is 'N' the LDA is N+1 when N is even and N
77 *> is odd. See the Note below for more details.
79 *> On exit, the symmetric inverse of the original matrix, in the
80 *> same storage format.
86 *> = 0: successful exit
87 *> < 0: if INFO = -i, the i-th argument had an illegal value
88 *> > 0: if INFO = i, the (i,i) element of the factor U or L is
89 *> zero, and the inverse could not be computed.
95 *> \author Univ. of Tennessee
96 *> \author Univ. of California Berkeley
97 *> \author Univ. of Colorado Denver
100 *> \date November 2011
102 *> \ingroup realOTHERcomputational
104 *> \par Further Details:
105 * =====================
109 *> We first consider Rectangular Full Packed (RFP) Format when N is
110 *> even. We give an example where N = 6.
112 *> AP is Upper AP is Lower
114 *> 00 01 02 03 04 05 00
115 *> 11 12 13 14 15 10 11
116 *> 22 23 24 25 20 21 22
117 *> 33 34 35 30 31 32 33
118 *> 44 45 40 41 42 43 44
119 *> 55 50 51 52 53 54 55
122 *> Let TRANSR = 'N'. RFP holds AP as follows:
123 *> For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last
124 *> three columns of AP upper. The lower triangle A(4:6,0:2) consists of
125 *> the transpose of the first three columns of AP upper.
126 *> For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first
127 *> three columns of AP lower. The upper triangle A(0:2,0:2) consists of
128 *> the transpose of the last three columns of AP lower.
129 *> This covers the case N even and TRANSR = 'N'.
141 *> Now let TRANSR = 'T'. RFP A in both UPLO cases is just the
142 *> transpose of RFP A above. One therefore gets:
147 *> 03 13 23 33 00 01 02 33 00 10 20 30 40 50
148 *> 04 14 24 34 44 11 12 43 44 11 21 31 41 51
149 *> 05 15 25 35 45 55 22 53 54 55 22 32 42 52
152 *> We then consider Rectangular Full Packed (RFP) Format when N is
153 *> odd. We give an example where N = 5.
155 *> AP is Upper AP is Lower
164 *> Let TRANSR = 'N'. RFP holds AP as follows:
165 *> For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last
166 *> three columns of AP upper. The lower triangle A(3:4,0:1) consists of
167 *> the transpose of the first two columns of AP upper.
168 *> For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first
169 *> three columns of AP lower. The upper triangle A(0:1,1:2) consists of
170 *> the transpose of the last two columns of AP lower.
171 *> This covers the case N odd and TRANSR = 'N'.
181 *> Now let TRANSR = 'T'. RFP A in both UPLO cases is just the
182 *> transpose of RFP A above. One therefore gets:
186 *> 02 12 22 00 01 00 10 20 30 40 50
187 *> 03 13 23 33 11 33 11 21 31 41 51
188 *> 04 14 24 34 44 43 44 22 32 42 52
191 * =====================================================================
192 SUBROUTINE SPFTRI( TRANSR, UPLO, N, A, INFO )
194 * -- LAPACK computational routine (version 3.4.0) --
195 * -- LAPACK is a software package provided by Univ. of Tennessee, --
196 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
199 * .. Scalar Arguments ..
200 CHARACTER TRANSR, UPLO
202 * .. Array Arguments ..
206 * =====================================================================
210 PARAMETER ( ONE = 1.0E+0 )
212 * .. Local Scalars ..
213 LOGICAL LOWER, NISODD, NORMALTRANSR
216 * .. External Functions ..
220 * .. External Subroutines ..
221 EXTERNAL XERBLA, STFTRI, SLAUUM, STRMM, SSYRK
223 * .. Intrinsic Functions ..
226 * .. Executable Statements ..
228 * Test the input parameters.
231 NORMALTRANSR = LSAME( TRANSR, 'N' )
232 LOWER = LSAME( UPLO, 'L' )
233 IF( .NOT.NORMALTRANSR .AND. .NOT.LSAME( TRANSR, 'T' ) ) THEN
235 ELSE IF( .NOT.LOWER .AND. .NOT.LSAME( UPLO, 'U' ) ) THEN
237 ELSE IF( N.LT.0 ) THEN
241 CALL XERBLA( 'SPFTRI', -INFO )
245 * Quick return if possible
250 * Invert the triangular Cholesky factor U or L.
252 CALL STFTRI( TRANSR, UPLO, 'N', N, A, INFO )
256 * If N is odd, set NISODD = .TRUE.
257 * If N is even, set K = N/2 and NISODD = .FALSE.
259 IF( MOD( N, 2 ).EQ.0 ) THEN
266 * Set N1 and N2 depending on LOWER
276 * Start execution of triangular matrix multiply: inv(U)*inv(U)^C or
277 * inv(L)^C*inv(L). There are eight cases.
283 IF( NORMALTRANSR ) THEN
285 * N is odd and TRANSR = 'N'
289 * SRPA for LOWER, NORMAL and N is odd ( a(0:n-1,0:N1-1) )
290 * T1 -> a(0,0), T2 -> a(0,1), S -> a(N1,0)
291 * T1 -> a(0), T2 -> a(n), S -> a(N1)
293 CALL SLAUUM( 'L', N1, A( 0 ), N, INFO )
294 CALL SSYRK( 'L', 'T', N1, N2, ONE, A( N1 ), N, ONE,
296 CALL STRMM( 'L', 'U', 'N', 'N', N2, N1, ONE, A( N ), N,
298 CALL SLAUUM( 'U', N2, A( N ), N, INFO )
302 * SRPA for UPPER, NORMAL and N is odd ( a(0:n-1,0:N2-1)
303 * T1 -> a(N1+1,0), T2 -> a(N1,0), S -> a(0,0)
304 * T1 -> a(N2), T2 -> a(N1), S -> a(0)
306 CALL SLAUUM( 'L', N1, A( N2 ), N, INFO )
307 CALL SSYRK( 'L', 'N', N1, N2, ONE, A( 0 ), N, ONE,
309 CALL STRMM( 'R', 'U', 'T', 'N', N1, N2, ONE, A( N1 ), N,
311 CALL SLAUUM( 'U', N2, A( N1 ), N, INFO )
317 * N is odd and TRANSR = 'T'
321 * SRPA for LOWER, TRANSPOSE, and N is odd
322 * T1 -> a(0), T2 -> a(1), S -> a(0+N1*N1)
324 CALL SLAUUM( 'U', N1, A( 0 ), N1, INFO )
325 CALL SSYRK( 'U', 'N', N1, N2, ONE, A( N1*N1 ), N1, ONE,
327 CALL STRMM( 'R', 'L', 'N', 'N', N1, N2, ONE, A( 1 ), N1,
329 CALL SLAUUM( 'L', N2, A( 1 ), N1, INFO )
333 * SRPA for UPPER, TRANSPOSE, and N is odd
334 * T1 -> a(0+N2*N2), T2 -> a(0+N1*N2), S -> a(0)
336 CALL SLAUUM( 'U', N1, A( N2*N2 ), N2, INFO )
337 CALL SSYRK( 'U', 'T', N1, N2, ONE, A( 0 ), N2, ONE,
339 CALL STRMM( 'L', 'L', 'T', 'N', N2, N1, ONE, A( N1*N2 ),
341 CALL SLAUUM( 'L', N2, A( N1*N2 ), N2, INFO )
351 IF( NORMALTRANSR ) THEN
353 * N is even and TRANSR = 'N'
357 * SRPA for LOWER, NORMAL, and N is even ( a(0:n,0:k-1) )
358 * T1 -> a(1,0), T2 -> a(0,0), S -> a(k+1,0)
359 * T1 -> a(1), T2 -> a(0), S -> a(k+1)
361 CALL SLAUUM( 'L', K, A( 1 ), N+1, INFO )
362 CALL SSYRK( 'L', 'T', K, K, ONE, A( K+1 ), N+1, ONE,
364 CALL STRMM( 'L', 'U', 'N', 'N', K, K, ONE, A( 0 ), N+1,
366 CALL SLAUUM( 'U', K, A( 0 ), N+1, INFO )
370 * SRPA for UPPER, NORMAL, and N is even ( a(0:n,0:k-1) )
371 * T1 -> a(k+1,0) , T2 -> a(k,0), S -> a(0,0)
372 * T1 -> a(k+1), T2 -> a(k), S -> a(0)
374 CALL SLAUUM( 'L', K, A( K+1 ), N+1, INFO )
375 CALL SSYRK( 'L', 'N', K, K, ONE, A( 0 ), N+1, ONE,
377 CALL STRMM( 'R', 'U', 'T', 'N', K, K, ONE, A( K ), N+1,
379 CALL SLAUUM( 'U', K, A( K ), N+1, INFO )
385 * N is even and TRANSR = 'T'
389 * SRPA for LOWER, TRANSPOSE, and N is even (see paper)
390 * T1 -> B(0,1), T2 -> B(0,0), S -> B(0,k+1),
391 * T1 -> a(0+k), T2 -> a(0+0), S -> a(0+k*(k+1)); lda=k
393 CALL SLAUUM( 'U', K, A( K ), K, INFO )
394 CALL SSYRK( 'U', 'N', K, K, ONE, A( K*( K+1 ) ), K, ONE,
396 CALL STRMM( 'R', 'L', 'N', 'N', K, K, ONE, A( 0 ), K,
397 $ A( K*( K+1 ) ), K )
398 CALL SLAUUM( 'L', K, A( 0 ), K, INFO )
402 * SRPA for UPPER, TRANSPOSE, and N is even (see paper)
403 * T1 -> B(0,k+1), T2 -> B(0,k), S -> B(0,0),
404 * T1 -> a(0+k*(k+1)), T2 -> a(0+k*k), S -> a(0+0)); lda=k
406 CALL SLAUUM( 'U', K, A( K*( K+1 ) ), K, INFO )
407 CALL SSYRK( 'U', 'T', K, K, ONE, A( 0 ), K, ONE,
408 $ A( K*( K+1 ) ), K )
409 CALL STRMM( 'L', 'L', 'T', 'N', K, K, ONE, A( K*K ), K,
411 CALL SLAUUM( 'L', K, A( K*K ), K, INFO )