3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download DTFTRI + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dtftri.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dtftri.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dtftri.f">
21 * SUBROUTINE DTFTRI( TRANSR, UPLO, DIAG, N, A, INFO )
23 * .. Scalar Arguments ..
24 * CHARACTER TRANSR, UPLO, DIAG
27 * .. Array Arguments ..
28 * DOUBLE PRECISION A( 0: * )
37 *> DTFTRI computes the inverse of a triangular matrix A stored in RFP
40 *> This is a Level 3 BLAS version of the algorithm.
48 *> TRANSR is CHARACTER*1
49 *> = 'N': The Normal TRANSR of RFP A is stored;
50 *> = 'T': The Transpose TRANSR of RFP A is stored.
55 *> UPLO is CHARACTER*1
56 *> = 'U': A is upper triangular;
57 *> = 'L': A is lower triangular.
62 *> DIAG is CHARACTER*1
63 *> = 'N': A is non-unit triangular;
64 *> = 'U': A is unit triangular.
70 *> The order of the matrix A. N >= 0.
75 *> A is DOUBLE PRECISION array, dimension (0:nt-1);
76 *> nt=N*(N+1)/2. On entry, the triangular factor of a Hermitian
77 *> Positive Definite matrix A in RFP format. RFP format is
78 *> described by TRANSR, UPLO, and N as follows: If TRANSR = 'N'
79 *> then RFP A is (0:N,0:k-1) when N is even; k=N/2. RFP A is
80 *> (0:N-1,0:k) when N is odd; k=N/2. IF TRANSR = 'T' then RFP is
81 *> the transpose of RFP A as defined when
82 *> TRANSR = 'N'. The contents of RFP A are defined by UPLO as
83 *> follows: If UPLO = 'U' the RFP A contains the nt elements of
84 *> upper packed A; If UPLO = 'L' the RFP A contains the nt
85 *> elements of lower packed A. The LDA of RFP A is (N+1)/2 when
86 *> TRANSR = 'T'. When TRANSR is 'N' the LDA is N+1 when N is
87 *> even and N is odd. See the Note below for more details.
89 *> On exit, the (triangular) inverse of the original matrix, in
90 *> the same storage format.
96 *> = 0: successful exit
97 *> < 0: if INFO = -i, the i-th argument had an illegal value
98 *> > 0: if INFO = i, A(i,i) is exactly zero. The triangular
99 *> matrix is singular and its inverse can not be computed.
105 *> \author Univ. of Tennessee
106 *> \author Univ. of California Berkeley
107 *> \author Univ. of Colorado Denver
110 *> \date November 2011
112 *> \ingroup doubleOTHERcomputational
114 *> \par Further Details:
115 * =====================
119 *> We first consider Rectangular Full Packed (RFP) Format when N is
120 *> even. We give an example where N = 6.
122 *> AP is Upper AP is Lower
124 *> 00 01 02 03 04 05 00
125 *> 11 12 13 14 15 10 11
126 *> 22 23 24 25 20 21 22
127 *> 33 34 35 30 31 32 33
128 *> 44 45 40 41 42 43 44
129 *> 55 50 51 52 53 54 55
132 *> Let TRANSR = 'N'. RFP holds AP as follows:
133 *> For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last
134 *> three columns of AP upper. The lower triangle A(4:6,0:2) consists of
135 *> the transpose of the first three columns of AP upper.
136 *> For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first
137 *> three columns of AP lower. The upper triangle A(0:2,0:2) consists of
138 *> the transpose of the last three columns of AP lower.
139 *> This covers the case N even and TRANSR = 'N'.
151 *> Now let TRANSR = 'T'. RFP A in both UPLO cases is just the
152 *> transpose of RFP A above. One therefore gets:
157 *> 03 13 23 33 00 01 02 33 00 10 20 30 40 50
158 *> 04 14 24 34 44 11 12 43 44 11 21 31 41 51
159 *> 05 15 25 35 45 55 22 53 54 55 22 32 42 52
162 *> We then consider Rectangular Full Packed (RFP) Format when N is
163 *> odd. We give an example where N = 5.
165 *> AP is Upper AP is Lower
174 *> Let TRANSR = 'N'. RFP holds AP as follows:
175 *> For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last
176 *> three columns of AP upper. The lower triangle A(3:4,0:1) consists of
177 *> the transpose of the first two columns of AP upper.
178 *> For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first
179 *> three columns of AP lower. The upper triangle A(0:1,1:2) consists of
180 *> the transpose of the last two columns of AP lower.
181 *> This covers the case N odd and TRANSR = 'N'.
191 *> Now let TRANSR = 'T'. RFP A in both UPLO cases is just the
192 *> transpose of RFP A above. One therefore gets:
196 *> 02 12 22 00 01 00 10 20 30 40 50
197 *> 03 13 23 33 11 33 11 21 31 41 51
198 *> 04 14 24 34 44 43 44 22 32 42 52
201 * =====================================================================
202 SUBROUTINE DTFTRI( TRANSR, UPLO, DIAG, N, A, INFO )
204 * -- LAPACK computational routine (version 3.4.0) --
205 * -- LAPACK is a software package provided by Univ. of Tennessee, --
206 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
209 * .. Scalar Arguments ..
210 CHARACTER TRANSR, UPLO, DIAG
213 * .. Array Arguments ..
214 DOUBLE PRECISION A( 0: * )
217 * =====================================================================
221 PARAMETER ( ONE = 1.0D+0 )
223 * .. Local Scalars ..
224 LOGICAL LOWER, NISODD, NORMALTRANSR
227 * .. External Functions ..
231 * .. External Subroutines ..
232 EXTERNAL XERBLA, DTRMM, DTRTRI
234 * .. Intrinsic Functions ..
237 * .. Executable Statements ..
239 * Test the input parameters.
242 NORMALTRANSR = LSAME( TRANSR, 'N' )
243 LOWER = LSAME( UPLO, 'L' )
244 IF( .NOT.NORMALTRANSR .AND. .NOT.LSAME( TRANSR, 'T' ) ) THEN
246 ELSE IF( .NOT.LOWER .AND. .NOT.LSAME( UPLO, 'U' ) ) THEN
248 ELSE IF( .NOT.LSAME( DIAG, 'N' ) .AND. .NOT.LSAME( DIAG, 'U' ) )
251 ELSE IF( N.LT.0 ) THEN
255 CALL XERBLA( 'DTFTRI', -INFO )
259 * Quick return if possible
264 * If N is odd, set NISODD = .TRUE.
265 * If N is even, set K = N/2 and NISODD = .FALSE.
267 IF( MOD( N, 2 ).EQ.0 ) THEN
274 * Set N1 and N2 depending on LOWER
285 * start execution: there are eight cases
291 IF( NORMALTRANSR ) THEN
293 * N is odd and TRANSR = 'N'
297 * SRPA for LOWER, NORMAL and N is odd ( a(0:n-1,0:n1-1) )
298 * T1 -> a(0,0), T2 -> a(0,1), S -> a(n1,0)
299 * T1 -> a(0), T2 -> a(n), S -> a(n1)
301 CALL DTRTRI( 'L', DIAG, N1, A( 0 ), N, INFO )
304 CALL DTRMM( 'R', 'L', 'N', DIAG, N2, N1, -ONE, A( 0 ),
306 CALL DTRTRI( 'U', DIAG, N2, A( N ), N, INFO )
311 CALL DTRMM( 'L', 'U', 'T', DIAG, N2, N1, ONE, A( N ), N,
316 * SRPA for UPPER, NORMAL and N is odd ( a(0:n-1,0:n2-1)
317 * T1 -> a(n1+1,0), T2 -> a(n1,0), S -> a(0,0)
318 * T1 -> a(n2), T2 -> a(n1), S -> a(0)
320 CALL DTRTRI( 'L', DIAG, N1, A( N2 ), N, INFO )
323 CALL DTRMM( 'L', 'L', 'T', DIAG, N1, N2, -ONE, A( N2 ),
325 CALL DTRTRI( 'U', DIAG, N2, A( N1 ), N, INFO )
330 CALL DTRMM( 'R', 'U', 'N', DIAG, N1, N2, ONE, A( N1 ),
337 * N is odd and TRANSR = 'T'
341 * SRPA for LOWER, TRANSPOSE and N is odd
342 * T1 -> a(0), T2 -> a(1), S -> a(0+n1*n1)
344 CALL DTRTRI( 'U', DIAG, N1, A( 0 ), N1, INFO )
347 CALL DTRMM( 'L', 'U', 'N', DIAG, N1, N2, -ONE, A( 0 ),
348 $ N1, A( N1*N1 ), N1 )
349 CALL DTRTRI( 'L', DIAG, N2, A( 1 ), N1, INFO )
354 CALL DTRMM( 'R', 'L', 'T', DIAG, N1, N2, ONE, A( 1 ),
355 $ N1, A( N1*N1 ), N1 )
359 * SRPA for UPPER, TRANSPOSE and N is odd
360 * T1 -> a(0+n2*n2), T2 -> a(0+n1*n2), S -> a(0)
362 CALL DTRTRI( 'U', DIAG, N1, A( N2*N2 ), N2, INFO )
365 CALL DTRMM( 'R', 'U', 'T', DIAG, N2, N1, -ONE,
366 $ A( N2*N2 ), N2, A( 0 ), N2 )
367 CALL DTRTRI( 'L', DIAG, N2, A( N1*N2 ), N2, INFO )
372 CALL DTRMM( 'L', 'L', 'N', DIAG, N2, N1, ONE,
373 $ A( N1*N2 ), N2, A( 0 ), N2 )
382 IF( NORMALTRANSR ) THEN
384 * N is even and TRANSR = 'N'
388 * SRPA for LOWER, NORMAL, and N is even ( a(0:n,0:k-1) )
389 * T1 -> a(1,0), T2 -> a(0,0), S -> a(k+1,0)
390 * T1 -> a(1), T2 -> a(0), S -> a(k+1)
392 CALL DTRTRI( 'L', DIAG, K, A( 1 ), N+1, INFO )
395 CALL DTRMM( 'R', 'L', 'N', DIAG, K, K, -ONE, A( 1 ),
396 $ N+1, A( K+1 ), N+1 )
397 CALL DTRTRI( 'U', DIAG, K, A( 0 ), N+1, INFO )
402 CALL DTRMM( 'L', 'U', 'T', DIAG, K, K, ONE, A( 0 ), N+1,
407 * SRPA for UPPER, NORMAL, and N is even ( a(0:n,0:k-1) )
408 * T1 -> a(k+1,0) , T2 -> a(k,0), S -> a(0,0)
409 * T1 -> a(k+1), T2 -> a(k), S -> a(0)
411 CALL DTRTRI( 'L', DIAG, K, A( K+1 ), N+1, INFO )
414 CALL DTRMM( 'L', 'L', 'T', DIAG, K, K, -ONE, A( K+1 ),
416 CALL DTRTRI( 'U', DIAG, K, A( K ), N+1, INFO )
421 CALL DTRMM( 'R', 'U', 'N', DIAG, K, K, ONE, A( K ), N+1,
426 * N is even and TRANSR = 'T'
430 * SRPA for LOWER, TRANSPOSE and N is even (see paper)
431 * T1 -> B(0,1), T2 -> B(0,0), S -> B(0,k+1)
432 * T1 -> a(0+k), T2 -> a(0+0), S -> a(0+k*(k+1)); lda=k
434 CALL DTRTRI( 'U', DIAG, K, A( K ), K, INFO )
437 CALL DTRMM( 'L', 'U', 'N', DIAG, K, K, -ONE, A( K ), K,
438 $ A( K*( K+1 ) ), K )
439 CALL DTRTRI( 'L', DIAG, K, A( 0 ), K, INFO )
444 CALL DTRMM( 'R', 'L', 'T', DIAG, K, K, ONE, A( 0 ), K,
445 $ A( K*( K+1 ) ), K )
448 * SRPA for UPPER, TRANSPOSE and N is even (see paper)
449 * T1 -> B(0,k+1), T2 -> B(0,k), S -> B(0,0)
450 * T1 -> a(0+k*(k+1)), T2 -> a(0+k*k), S -> a(0+0)); lda=k
452 CALL DTRTRI( 'U', DIAG, K, A( K*( K+1 ) ), K, INFO )
455 CALL DTRMM( 'R', 'U', 'T', DIAG, K, K, -ONE,
456 $ A( K*( K+1 ) ), K, A( 0 ), K )
457 CALL DTRTRI( 'L', DIAG, K, A( K*K ), K, INFO )
462 CALL DTRMM( 'L', 'L', 'N', DIAG, K, K, ONE, A( K*K ), K,