LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
strcon.f
Go to the documentation of this file.
1 *> \brief \b STRCON
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 *> \htmlonly
9 *> Download STRCON + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/strcon.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/strcon.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/strcon.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * SUBROUTINE STRCON( NORM, UPLO, DIAG, N, A, LDA, RCOND, WORK,
22 * IWORK, INFO )
23 *
24 * .. Scalar Arguments ..
25 * CHARACTER DIAG, NORM, UPLO
26 * INTEGER INFO, LDA, N
27 * REAL RCOND
28 * ..
29 * .. Array Arguments ..
30 * INTEGER IWORK( * )
31 * REAL A( LDA, * ), WORK( * )
32 * ..
33 *
34 *
35 *> \par Purpose:
36 * =============
37 *>
38 *> \verbatim
39 *>
40 *> STRCON estimates the reciprocal of the condition number of a
41 *> triangular matrix A, in either the 1-norm or the infinity-norm.
42 *>
43 *> The norm of A is computed and an estimate is obtained for
44 *> norm(inv(A)), then the reciprocal of the condition number is
45 *> computed as
46 *> RCOND = 1 / ( norm(A) * norm(inv(A)) ).
47 *> \endverbatim
48 *
49 * Arguments:
50 * ==========
51 *
52 *> \param[in] NORM
53 *> \verbatim
54 *> NORM is CHARACTER*1
55 *> Specifies whether the 1-norm condition number or the
56 *> infinity-norm condition number is required:
57 *> = '1' or 'O': 1-norm;
58 *> = 'I': Infinity-norm.
59 *> \endverbatim
60 *>
61 *> \param[in] UPLO
62 *> \verbatim
63 *> UPLO is CHARACTER*1
64 *> = 'U': A is upper triangular;
65 *> = 'L': A is lower triangular.
66 *> \endverbatim
67 *>
68 *> \param[in] DIAG
69 *> \verbatim
70 *> DIAG is CHARACTER*1
71 *> = 'N': A is non-unit triangular;
72 *> = 'U': A is unit triangular.
73 *> \endverbatim
74 *>
75 *> \param[in] N
76 *> \verbatim
77 *> N is INTEGER
78 *> The order of the matrix A. N >= 0.
79 *> \endverbatim
80 *>
81 *> \param[in] A
82 *> \verbatim
83 *> A is REAL array, dimension (LDA,N)
84 *> The triangular matrix A. If UPLO = 'U', the leading N-by-N
85 *> upper triangular part of the array A contains the upper
86 *> triangular matrix, and the strictly lower triangular part of
87 *> A is not referenced. If UPLO = 'L', the leading N-by-N lower
88 *> triangular part of the array A contains the lower triangular
89 *> matrix, and the strictly upper triangular part of A is not
90 *> referenced. If DIAG = 'U', the diagonal elements of A are
91 *> also not referenced and are assumed to be 1.
92 *> \endverbatim
93 *>
94 *> \param[in] LDA
95 *> \verbatim
96 *> LDA is INTEGER
97 *> The leading dimension of the array A. LDA >= max(1,N).
98 *> \endverbatim
99 *>
100 *> \param[out] RCOND
101 *> \verbatim
102 *> RCOND is REAL
103 *> The reciprocal of the condition number of the matrix A,
104 *> computed as RCOND = 1/(norm(A) * norm(inv(A))).
105 *> \endverbatim
106 *>
107 *> \param[out] WORK
108 *> \verbatim
109 *> WORK is REAL array, dimension (3*N)
110 *> \endverbatim
111 *>
112 *> \param[out] IWORK
113 *> \verbatim
114 *> IWORK is INTEGER array, dimension (N)
115 *> \endverbatim
116 *>
117 *> \param[out] INFO
118 *> \verbatim
119 *> INFO is INTEGER
120 *> = 0: successful exit
121 *> < 0: if INFO = -i, the i-th argument had an illegal value
122 *> \endverbatim
123 *
124 * Authors:
125 * ========
126 *
127 *> \author Univ. of Tennessee
128 *> \author Univ. of California Berkeley
129 *> \author Univ. of Colorado Denver
130 *> \author NAG Ltd.
131 *
132 *> \date November 2011
133 *
134 *> \ingroup realOTHERcomputational
135 *
136 * =====================================================================
137  SUBROUTINE strcon( NORM, UPLO, DIAG, N, A, LDA, RCOND, WORK,
138  $ iwork, info )
139 *
140 * -- LAPACK computational routine (version 3.4.0) --
141 * -- LAPACK is a software package provided by Univ. of Tennessee, --
142 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
143 * November 2011
144 *
145 * .. Scalar Arguments ..
146  CHARACTER diag, norm, uplo
147  INTEGER info, lda, n
148  REAL rcond
149 * ..
150 * .. Array Arguments ..
151  INTEGER iwork( * )
152  REAL a( lda, * ), work( * )
153 * ..
154 *
155 * =====================================================================
156 *
157 * .. Parameters ..
158  REAL one, zero
159  parameter( one = 1.0e+0, zero = 0.0e+0 )
160 * ..
161 * .. Local Scalars ..
162  LOGICAL nounit, onenrm, upper
163  CHARACTER normin
164  INTEGER ix, kase, kase1
165  REAL ainvnm, anorm, scale, smlnum, xnorm
166 * ..
167 * .. Local Arrays ..
168  INTEGER isave( 3 )
169 * ..
170 * .. External Functions ..
171  LOGICAL lsame
172  INTEGER isamax
173  REAL slamch, slantr
174  EXTERNAL lsame, isamax, slamch, slantr
175 * ..
176 * .. External Subroutines ..
177  EXTERNAL slacn2, slatrs, srscl, xerbla
178 * ..
179 * .. Intrinsic Functions ..
180  INTRINSIC abs, max, real
181 * ..
182 * .. Executable Statements ..
183 *
184 * Test the input parameters.
185 *
186  info = 0
187  upper = lsame( uplo, 'U' )
188  onenrm = norm.EQ.'1' .OR. lsame( norm, 'O' )
189  nounit = lsame( diag, 'N' )
190 *
191  IF( .NOT.onenrm .AND. .NOT.lsame( norm, 'I' ) ) THEN
192  info = -1
193  ELSE IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
194  info = -2
195  ELSE IF( .NOT.nounit .AND. .NOT.lsame( diag, 'U' ) ) THEN
196  info = -3
197  ELSE IF( n.LT.0 ) THEN
198  info = -4
199  ELSE IF( lda.LT.max( 1, n ) ) THEN
200  info = -6
201  END IF
202  IF( info.NE.0 ) THEN
203  CALL xerbla( 'STRCON', -info )
204  return
205  END IF
206 *
207 * Quick return if possible
208 *
209  IF( n.EQ.0 ) THEN
210  rcond = one
211  return
212  END IF
213 *
214  rcond = zero
215  smlnum = slamch( 'Safe minimum' )*REAL( MAX( 1, N ) )
216 *
217 * Compute the norm of the triangular matrix A.
218 *
219  anorm = slantr( norm, uplo, diag, n, n, a, lda, work )
220 *
221 * Continue only if ANORM > 0.
222 *
223  IF( anorm.GT.zero ) THEN
224 *
225 * Estimate the norm of the inverse of A.
226 *
227  ainvnm = zero
228  normin = 'N'
229  IF( onenrm ) THEN
230  kase1 = 1
231  ELSE
232  kase1 = 2
233  END IF
234  kase = 0
235  10 continue
236  CALL slacn2( n, work( n+1 ), work, iwork, ainvnm, kase, isave )
237  IF( kase.NE.0 ) THEN
238  IF( kase.EQ.kase1 ) THEN
239 *
240 * Multiply by inv(A).
241 *
242  CALL slatrs( uplo, 'No transpose', diag, normin, n, a,
243  $ lda, work, scale, work( 2*n+1 ), info )
244  ELSE
245 *
246 * Multiply by inv(A**T).
247 *
248  CALL slatrs( uplo, 'Transpose', diag, normin, n, a, lda,
249  $ work, scale, work( 2*n+1 ), info )
250  END IF
251  normin = 'Y'
252 *
253 * Multiply by 1/SCALE if doing so will not cause overflow.
254 *
255  IF( scale.NE.one ) THEN
256  ix = isamax( n, work, 1 )
257  xnorm = abs( work( ix ) )
258  IF( scale.LT.xnorm*smlnum .OR. scale.EQ.zero )
259  $ go to 20
260  CALL srscl( n, scale, work, 1 )
261  END IF
262  go to 10
263  END IF
264 *
265 * Compute the estimate of the reciprocal condition number.
266 *
267  IF( ainvnm.NE.zero )
268  $ rcond = ( one / anorm ) / ainvnm
269  END IF
270 *
271  20 continue
272  return
273 *
274 * End of STRCON
275 *
276  END