PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
ctrtri.f
Go to the documentation of this file.
1  SUBROUTINE ctrtri( UPLO, DIAG, N, A, LDA, INFO )
2 *
3 * -- LAPACK routine (version 3.2) --
4 * -- LAPACK is a software package provided by Univ. of Tennessee, --
5 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
6 * November 2006
7 *
8 * .. Scalar Arguments ..
9  CHARACTER diag, uplo
10  INTEGER info, lda, n
11 * ..
12 * .. Array Arguments ..
13  COMPLEX a( lda, * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * CTRTRI computes the inverse of a complex upper or lower triangular
20 * matrix A.
21 *
22 * This is the Level 3 BLAS version of the algorithm.
23 *
24 * Arguments
25 * =========
26 *
27 * UPLO (input) CHARACTER*1
28 * = 'U': A is upper triangular;
29 * = 'L': A is lower triangular.
30 *
31 * DIAG (input) CHARACTER*1
32 * = 'N': A is non-unit triangular;
33 * = 'U': A is unit triangular.
34 *
35 * N (input) INTEGER
36 * The order of the matrix A. N >= 0.
37 *
38 * A (input/output) COMPLEX array, dimension (LDA,N)
39 * On entry, the triangular matrix A. If UPLO = 'U', the
40 * leading N-by-N upper triangular part of the array A contains
41 * the upper triangular matrix, and the strictly lower
42 * triangular part of A is not referenced. If UPLO = 'L', the
43 * leading N-by-N lower triangular part of the array A contains
44 * the lower triangular matrix, and the strictly upper
45 * triangular part of A is not referenced. If DIAG = 'U', the
46 * diagonal elements of A are also not referenced and are
47 * assumed to be 1.
48 * On exit, the (triangular) inverse of the original matrix, in
49 * the same storage format.
50 *
51 * LDA (input) INTEGER
52 * The leading dimension of the array A. LDA >= max(1,N).
53 *
54 * INFO (output) INTEGER
55 * = 0: successful exit
56 * < 0: if INFO = -i, the i-th argument had an illegal value
57 * > 0: if INFO = i, A(i,i) is exactly zero. The triangular
58 * matrix is singular and its inverse can not be computed.
59 *
60 * =====================================================================
61 *
62 * .. Parameters ..
63  COMPLEX one, zero
64  parameter( one = ( 1.0e+0, 0.0e+0 ),
65  $ zero = ( 0.0e+0, 0.0e+0 ) )
66 * ..
67 * .. Local Scalars ..
68  LOGICAL nounit, upper
69  INTEGER j, jb, nb, nn
70 * ..
71 * .. External Functions ..
72  LOGICAL lsame
73  INTEGER ilaenv
74  EXTERNAL lsame, ilaenv
75 * ..
76 * .. External Subroutines ..
77  EXTERNAL ctrmm, ctrsm, ctrti2, xerbla
78 * ..
79 * .. Intrinsic Functions ..
80  INTRINSIC max, min
81 * ..
82 * .. Executable Statements ..
83 *
84 * Test the input parameters.
85 *
86  info = 0
87  upper = lsame( uplo, 'U' )
88  nounit = lsame( diag, 'N' )
89  IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
90  info = -1
91  ELSE IF( .NOT.nounit .AND. .NOT.lsame( diag, 'U' ) ) THEN
92  info = -2
93  ELSE IF( n.LT.0 ) THEN
94  info = -3
95  ELSE IF( lda.LT.max( 1, n ) ) THEN
96  info = -5
97  END IF
98  IF( info.NE.0 ) THEN
99  CALL xerbla( 'CTRTRI', -info )
100  return
101  END IF
102 *
103 * Quick return if possible
104 *
105  IF( n.EQ.0 )
106  $ return
107 *
108 * Check for singularity if non-unit.
109 *
110  IF( nounit ) THEN
111  DO 10 info = 1, n
112  IF( a( info, info ).EQ.zero )
113  $ return
114  10 continue
115  info = 0
116  END IF
117 *
118 * Determine the block size for this environment.
119 *
120  nb = ilaenv( 1, 'CTRTRI', uplo // diag, n, -1, -1, -1 )
121  IF( nb.LE.1 .OR. nb.GE.n ) THEN
122 *
123 * Use unblocked code
124 *
125  CALL ctrti2( uplo, diag, n, a, lda, info )
126  ELSE
127 *
128 * Use blocked code
129 *
130  IF( upper ) THEN
131 *
132 * Compute inverse of upper triangular matrix
133 *
134  DO 20 j = 1, n, nb
135  jb = min( nb, n-j+1 )
136 *
137 * Compute rows 1:j-1 of current block column
138 *
139  CALL ctrmm( 'Left', 'Upper', 'No transpose', diag, j-1,
140  $ jb, one, a, lda, a( 1, j ), lda )
141  CALL ctrsm( 'Right', 'Upper', 'No transpose', diag, j-1,
142  $ jb, -one, a( j, j ), lda, a( 1, j ), lda )
143 *
144 * Compute inverse of current diagonal block
145 *
146  CALL ctrti2( 'Upper', diag, jb, a( j, j ), lda, info )
147  20 continue
148  ELSE
149 *
150 * Compute inverse of lower triangular matrix
151 *
152  nn = ( ( n-1 ) / nb )*nb + 1
153  DO 30 j = nn, 1, -nb
154  jb = min( nb, n-j+1 )
155  IF( j+jb.LE.n ) THEN
156 *
157 * Compute rows j+jb:n of current block column
158 *
159  CALL ctrmm( 'Left', 'Lower', 'No transpose', diag,
160  $ n-j-jb+1, jb, one, a( j+jb, j+jb ), lda,
161  $ a( j+jb, j ), lda )
162  CALL ctrsm( 'Right', 'Lower', 'No transpose', diag,
163  $ n-j-jb+1, jb, -one, a( j, j ), lda,
164  $ a( j+jb, j ), lda )
165  END IF
166 *
167 * Compute inverse of current diagonal block
168 *
169  CALL ctrti2( 'Lower', diag, jb, a( j, j ), lda, info )
170  30 continue
171  END IF
172  END IF
173 *
174  return
175 *
176 * End of CTRTRI
177 *
178  END