3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download CTFTRI + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ctftri.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ctftri.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ctftri.f">
21 * SUBROUTINE CTFTRI( TRANSR, UPLO, DIAG, N, A, INFO )
23 * .. Scalar Arguments ..
24 * CHARACTER TRANSR, UPLO, DIAG
27 * .. Array Arguments ..
37 *> CTFTRI 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 *> = 'C': The Conjugate-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 COMPLEX array, dimension ( N*(N+1)/2 );
76 *> On entry, the triangular matrix A in RFP format. RFP format
77 *> is described by TRANSR, UPLO, and N as follows: If TRANSR =
78 *> 'N' then RFP A is (0:N,0:k-1) when N is even; k=N/2. RFP A is
79 *> (0:N-1,0:k) when N is odd; k=N/2. IF TRANSR = 'C' then RFP is
80 *> the Conjugate-transpose of RFP A as defined when
81 *> TRANSR = 'N'. The contents of RFP A are defined by UPLO as
82 *> follows: If UPLO = 'U' the RFP A contains the nt elements of
83 *> upper packed A; If UPLO = 'L' the RFP A contains the nt
84 *> elements of lower packed A. The LDA of RFP A is (N+1)/2 when
85 *> TRANSR = 'C'. When TRANSR is 'N' the LDA is N+1 when N is
86 *> even and N is odd. See the Note below for more details.
88 *> On exit, the (triangular) inverse of the original matrix, in
89 *> the same storage format.
95 *> = 0: successful exit
96 *> < 0: if INFO = -i, the i-th argument had an illegal value
97 *> > 0: if INFO = i, A(i,i) is exactly zero. The triangular
98 *> matrix is singular and its inverse can not be computed.
104 *> \author Univ. of Tennessee
105 *> \author Univ. of California Berkeley
106 *> \author Univ. of Colorado Denver
109 *> \date November 2011
111 *> \ingroup complexOTHERcomputational
113 *> \par Further Details:
114 * =====================
118 *> We first consider Standard Packed Format when N is even.
119 *> We give an example where N = 6.
121 *> AP is Upper AP is Lower
123 *> 00 01 02 03 04 05 00
124 *> 11 12 13 14 15 10 11
125 *> 22 23 24 25 20 21 22
126 *> 33 34 35 30 31 32 33
127 *> 44 45 40 41 42 43 44
128 *> 55 50 51 52 53 54 55
131 *> Let TRANSR = 'N'. RFP holds AP as follows:
132 *> For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last
133 *> three columns of AP upper. The lower triangle A(4:6,0:2) consists of
134 *> conjugate-transpose of the first three columns of AP upper.
135 *> For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first
136 *> three columns of AP lower. The upper triangle A(0:2,0:2) consists of
137 *> conjugate-transpose of the last three columns of AP lower.
138 *> To denote conjugate we place -- above the element. This covers the
139 *> case N even and TRANSR = 'N'.
158 *> Now let TRANSR = 'C'. RFP A in both UPLO cases is just the conjugate-
159 *> transpose of RFP A above. One therefore gets:
164 *> -- -- -- -- -- -- -- -- -- --
165 *> 03 13 23 33 00 01 02 33 00 10 20 30 40 50
166 *> -- -- -- -- -- -- -- -- -- --
167 *> 04 14 24 34 44 11 12 43 44 11 21 31 41 51
168 *> -- -- -- -- -- -- -- -- -- --
169 *> 05 15 25 35 45 55 22 53 54 55 22 32 42 52
172 *> We next consider Standard Packed Format when N is odd.
173 *> We give an example where N = 5.
175 *> AP is Upper AP is Lower
184 *> Let TRANSR = 'N'. RFP holds AP as follows:
185 *> For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last
186 *> three columns of AP upper. The lower triangle A(3:4,0:1) consists of
187 *> conjugate-transpose of the first two columns of AP upper.
188 *> For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first
189 *> three columns of AP lower. The upper triangle A(0:1,1:2) consists of
190 *> conjugate-transpose of the last two columns of AP lower.
191 *> To denote conjugate we place -- above the element. This covers the
192 *> case N odd and TRANSR = 'N'.
207 *> Now let TRANSR = 'C'. RFP A in both UPLO cases is just the conjugate-
208 *> transpose of RFP A above. One therefore gets:
213 *> -- -- -- -- -- -- -- -- --
214 *> 02 12 22 00 01 00 10 20 30 40 50
215 *> -- -- -- -- -- -- -- -- --
216 *> 03 13 23 33 11 33 11 21 31 41 51
217 *> -- -- -- -- -- -- -- -- --
218 *> 04 14 24 34 44 43 44 22 32 42 52
221 * =====================================================================
222 SUBROUTINE CTFTRI( TRANSR, UPLO, DIAG, N, A, INFO )
224 * -- LAPACK computational routine (version 3.4.0) --
225 * -- LAPACK is a software package provided by Univ. of Tennessee, --
226 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
229 * .. Scalar Arguments ..
230 CHARACTER TRANSR, UPLO, DIAG
233 * .. Array Arguments ..
237 * =====================================================================
241 PARAMETER ( CONE = ( 1.0E+0, 0.0E+0 ) )
243 * .. Local Scalars ..
244 LOGICAL LOWER, NISODD, NORMALTRANSR
247 * .. External Functions ..
251 * .. External Subroutines ..
252 EXTERNAL XERBLA, CTRMM, CTRTRI
254 * .. Intrinsic Functions ..
257 * .. Executable Statements ..
259 * Test the input parameters.
262 NORMALTRANSR = LSAME( TRANSR, 'N' )
263 LOWER = LSAME( UPLO, 'L' )
264 IF( .NOT.NORMALTRANSR .AND. .NOT.LSAME( TRANSR, 'C' ) ) THEN
266 ELSE IF( .NOT.LOWER .AND. .NOT.LSAME( UPLO, 'U' ) ) THEN
268 ELSE IF( .NOT.LSAME( DIAG, 'N' ) .AND. .NOT.LSAME( DIAG, 'U' ) )
271 ELSE IF( N.LT.0 ) THEN
275 CALL XERBLA( 'CTFTRI', -INFO )
279 * Quick return if possible
284 * If N is odd, set NISODD = .TRUE.
285 * If N is even, set K = N/2 and NISODD = .FALSE.
287 IF( MOD( N, 2 ).EQ.0 ) THEN
294 * Set N1 and N2 depending on LOWER
305 * start execution: there are eight cases
311 IF( NORMALTRANSR ) THEN
313 * N is odd and TRANSR = 'N'
317 * SRPA for LOWER, NORMAL and N is odd ( a(0:n-1,0:n1-1) )
318 * T1 -> a(0,0), T2 -> a(0,1), S -> a(n1,0)
319 * T1 -> a(0), T2 -> a(n), S -> a(n1)
321 CALL CTRTRI( 'L', DIAG, N1, A( 0 ), N, INFO )
324 CALL CTRMM( 'R', 'L', 'N', DIAG, N2, N1, -CONE, A( 0 ),
326 CALL CTRTRI( 'U', DIAG, N2, A( N ), N, INFO )
331 CALL CTRMM( 'L', 'U', 'C', DIAG, N2, N1, CONE, A( N ), N,
336 * SRPA for UPPER, NORMAL and N is odd ( a(0:n-1,0:n2-1)
337 * T1 -> a(n1+1,0), T2 -> a(n1,0), S -> a(0,0)
338 * T1 -> a(n2), T2 -> a(n1), S -> a(0)
340 CALL CTRTRI( 'L', DIAG, N1, A( N2 ), N, INFO )
343 CALL CTRMM( 'L', 'L', 'C', DIAG, N1, N2, -CONE, A( N2 ),
345 CALL CTRTRI( 'U', DIAG, N2, A( N1 ), N, INFO )
350 CALL CTRMM( 'R', 'U', 'N', DIAG, N1, N2, CONE, A( N1 ),
357 * N is odd and TRANSR = 'C'
361 * SRPA for LOWER, TRANSPOSE and N is odd
362 * T1 -> a(0), T2 -> a(1), S -> a(0+n1*n1)
364 CALL CTRTRI( 'U', DIAG, N1, A( 0 ), N1, INFO )
367 CALL CTRMM( 'L', 'U', 'N', DIAG, N1, N2, -CONE, A( 0 ),
368 $ N1, A( N1*N1 ), N1 )
369 CALL CTRTRI( 'L', DIAG, N2, A( 1 ), N1, INFO )
374 CALL CTRMM( 'R', 'L', 'C', DIAG, N1, N2, CONE, A( 1 ),
375 $ N1, A( N1*N1 ), N1 )
379 * SRPA for UPPER, TRANSPOSE and N is odd
380 * T1 -> a(0+n2*n2), T2 -> a(0+n1*n2), S -> a(0)
382 CALL CTRTRI( 'U', DIAG, N1, A( N2*N2 ), N2, INFO )
385 CALL CTRMM( 'R', 'U', 'C', DIAG, N2, N1, -CONE,
386 $ A( N2*N2 ), N2, A( 0 ), N2 )
387 CALL CTRTRI( 'L', DIAG, N2, A( N1*N2 ), N2, INFO )
392 CALL CTRMM( 'L', 'L', 'N', DIAG, N2, N1, CONE,
393 $ A( N1*N2 ), N2, A( 0 ), N2 )
402 IF( NORMALTRANSR ) THEN
404 * N is even and TRANSR = 'N'
408 * SRPA for LOWER, NORMAL, and N is even ( a(0:n,0:k-1) )
409 * T1 -> a(1,0), T2 -> a(0,0), S -> a(k+1,0)
410 * T1 -> a(1), T2 -> a(0), S -> a(k+1)
412 CALL CTRTRI( 'L', DIAG, K, A( 1 ), N+1, INFO )
415 CALL CTRMM( 'R', 'L', 'N', DIAG, K, K, -CONE, A( 1 ),
416 $ N+1, A( K+1 ), N+1 )
417 CALL CTRTRI( 'U', DIAG, K, A( 0 ), N+1, INFO )
422 CALL CTRMM( 'L', 'U', 'C', DIAG, K, K, CONE, A( 0 ), N+1,
427 * SRPA for UPPER, NORMAL, and N is even ( a(0:n,0:k-1) )
428 * T1 -> a(k+1,0) , T2 -> a(k,0), S -> a(0,0)
429 * T1 -> a(k+1), T2 -> a(k), S -> a(0)
431 CALL CTRTRI( 'L', DIAG, K, A( K+1 ), N+1, INFO )
434 CALL CTRMM( 'L', 'L', 'C', DIAG, K, K, -CONE, A( K+1 ),
436 CALL CTRTRI( 'U', DIAG, K, A( K ), N+1, INFO )
441 CALL CTRMM( 'R', 'U', 'N', DIAG, K, K, CONE, A( K ), N+1,
446 * N is even and TRANSR = 'C'
450 * SRPA for LOWER, TRANSPOSE and N is even (see paper)
451 * T1 -> B(0,1), T2 -> B(0,0), S -> B(0,k+1)
452 * T1 -> a(0+k), T2 -> a(0+0), S -> a(0+k*(k+1)); lda=k
454 CALL CTRTRI( 'U', DIAG, K, A( K ), K, INFO )
457 CALL CTRMM( 'L', 'U', 'N', DIAG, K, K, -CONE, A( K ), K,
458 $ A( K*( K+1 ) ), K )
459 CALL CTRTRI( 'L', DIAG, K, A( 0 ), K, INFO )
464 CALL CTRMM( 'R', 'L', 'C', DIAG, K, K, CONE, A( 0 ), K,
465 $ A( K*( K+1 ) ), K )
468 * SRPA for UPPER, TRANSPOSE and N is even (see paper)
469 * T1 -> B(0,k+1), T2 -> B(0,k), S -> B(0,0)
470 * T1 -> a(0+k*(k+1)), T2 -> a(0+k*k), S -> a(0+0)); lda=k
472 CALL CTRTRI( 'U', DIAG, K, A( K*( K+1 ) ), K, INFO )
475 CALL CTRMM( 'R', 'U', 'C', DIAG, K, K, -CONE,
476 $ A( K*( K+1 ) ), K, A( 0 ), K )
477 CALL CTRTRI( 'L', DIAG, K, A( K*K ), K, INFO )
482 CALL CTRMM( 'L', 'L', 'N', DIAG, K, K, CONE, A( K*K ), K,