LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
ctrti2.f
Go to the documentation of this file.
1 *> \brief \b CTRTI2 computes the inverse of a triangular matrix (unblocked algorithm).
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 *> \htmlonly
9 *> Download CTRTI2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ctrti2.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ctrti2.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ctrti2.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * SUBROUTINE CTRTI2( UPLO, DIAG, N, A, LDA, INFO )
22 *
23 * .. Scalar Arguments ..
24 * CHARACTER DIAG, UPLO
25 * INTEGER INFO, LDA, N
26 * ..
27 * .. Array Arguments ..
28 * COMPLEX A( LDA, * )
29 * ..
30 *
31 *
32 *> \par Purpose:
33 * =============
34 *>
35 *> \verbatim
36 *>
37 *> CTRTI2 computes the inverse of a complex upper or lower triangular
38 *> matrix.
39 *>
40 *> This is the Level 2 BLAS version of the algorithm.
41 *> \endverbatim
42 *
43 * Arguments:
44 * ==========
45 *
46 *> \param[in] UPLO
47 *> \verbatim
48 *> UPLO is CHARACTER*1
49 *> Specifies whether the matrix A is upper or lower triangular.
50 *> = 'U': Upper triangular
51 *> = 'L': Lower triangular
52 *> \endverbatim
53 *>
54 *> \param[in] DIAG
55 *> \verbatim
56 *> DIAG is CHARACTER*1
57 *> Specifies whether or not the matrix A is unit triangular.
58 *> = 'N': Non-unit triangular
59 *> = 'U': Unit triangular
60 *> \endverbatim
61 *>
62 *> \param[in] N
63 *> \verbatim
64 *> N is INTEGER
65 *> The order of the matrix A. N >= 0.
66 *> \endverbatim
67 *>
68 *> \param[in,out] A
69 *> \verbatim
70 *> A is COMPLEX array, dimension (LDA,N)
71 *> On entry, the triangular matrix A. If UPLO = 'U', the
72 *> leading n by n upper triangular part of the array A contains
73 *> the upper triangular matrix, and the strictly lower
74 *> triangular part of A is not referenced. If UPLO = 'L', the
75 *> leading n by n lower triangular part of the array A contains
76 *> the lower triangular matrix, and the strictly upper
77 *> triangular part of A is not referenced. If DIAG = 'U', the
78 *> diagonal elements of A are also not referenced and are
79 *> assumed to be 1.
80 *>
81 *> On exit, the (triangular) inverse of the original matrix, in
82 *> the same storage format.
83 *> \endverbatim
84 *>
85 *> \param[in] LDA
86 *> \verbatim
87 *> LDA is INTEGER
88 *> The leading dimension of the array A. LDA >= max(1,N).
89 *> \endverbatim
90 *>
91 *> \param[out] INFO
92 *> \verbatim
93 *> INFO is INTEGER
94 *> = 0: successful exit
95 *> < 0: if INFO = -k, the k-th argument had an illegal value
96 *> \endverbatim
97 *
98 * Authors:
99 * ========
100 *
101 *> \author Univ. of Tennessee
102 *> \author Univ. of California Berkeley
103 *> \author Univ. of Colorado Denver
104 *> \author NAG Ltd.
105 *
106 *> \date September 2012
107 *
108 *> \ingroup complexOTHERcomputational
109 *
110 * =====================================================================
111  SUBROUTINE ctrti2( UPLO, DIAG, N, A, LDA, INFO )
112 *
113 * -- LAPACK computational routine (version 3.4.2) --
114 * -- LAPACK is a software package provided by Univ. of Tennessee, --
115 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
116 * September 2012
117 *
118 * .. Scalar Arguments ..
119  CHARACTER DIAG, UPLO
120  INTEGER INFO, LDA, N
121 * ..
122 * .. Array Arguments ..
123  COMPLEX A( lda, * )
124 * ..
125 *
126 * =====================================================================
127 *
128 * .. Parameters ..
129  COMPLEX ONE
130  parameter ( one = ( 1.0e+0, 0.0e+0 ) )
131 * ..
132 * .. Local Scalars ..
133  LOGICAL NOUNIT, UPPER
134  INTEGER J
135  COMPLEX AJJ
136 * ..
137 * .. External Functions ..
138  LOGICAL LSAME
139  EXTERNAL lsame
140 * ..
141 * .. External Subroutines ..
142  EXTERNAL cscal, ctrmv, xerbla
143 * ..
144 * .. Intrinsic Functions ..
145  INTRINSIC max
146 * ..
147 * .. Executable Statements ..
148 *
149 * Test the input parameters.
150 *
151  info = 0
152  upper = lsame( uplo, 'U' )
153  nounit = lsame( diag, 'N' )
154  IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
155  info = -1
156  ELSE IF( .NOT.nounit .AND. .NOT.lsame( diag, 'U' ) ) THEN
157  info = -2
158  ELSE IF( n.LT.0 ) THEN
159  info = -3
160  ELSE IF( lda.LT.max( 1, n ) ) THEN
161  info = -5
162  END IF
163  IF( info.NE.0 ) THEN
164  CALL xerbla( 'CTRTI2', -info )
165  RETURN
166  END IF
167 *
168  IF( upper ) THEN
169 *
170 * Compute inverse of upper triangular matrix.
171 *
172  DO 10 j = 1, n
173  IF( nounit ) THEN
174  a( j, j ) = one / a( j, j )
175  ajj = -a( j, j )
176  ELSE
177  ajj = -one
178  END IF
179 *
180 * Compute elements 1:j-1 of j-th column.
181 *
182  CALL ctrmv( 'Upper', 'No transpose', diag, j-1, a, lda,
183  $ a( 1, j ), 1 )
184  CALL cscal( j-1, ajj, a( 1, j ), 1 )
185  10 CONTINUE
186  ELSE
187 *
188 * Compute inverse of lower triangular matrix.
189 *
190  DO 20 j = n, 1, -1
191  IF( nounit ) THEN
192  a( j, j ) = one / a( j, j )
193  ajj = -a( j, j )
194  ELSE
195  ajj = -one
196  END IF
197  IF( j.LT.n ) THEN
198 *
199 * Compute elements j+1:n of j-th column.
200 *
201  CALL ctrmv( 'Lower', 'No transpose', diag, n-j,
202  $ a( j+1, j+1 ), lda, a( j+1, j ), 1 )
203  CALL cscal( n-j, ajj, a( j+1, j ), 1 )
204  END IF
205  20 CONTINUE
206  END IF
207 *
208  RETURN
209 *
210 * End of CTRTI2
211 *
212  END
subroutine ctrti2(UPLO, DIAG, N, A, LDA, INFO)
CTRTI2 computes the inverse of a triangular matrix (unblocked algorithm).
Definition: ctrti2.f:112
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine cscal(N, CA, CX, INCX)
CSCAL
Definition: cscal.f:54
subroutine ctrmv(UPLO, TRANS, DIAG, N, A, LDA, X, INCX)
CTRMV
Definition: ctrmv.f:149