LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
sgecon.f
Go to the documentation of this file.
1*> \brief \b SGECON
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download SGECON + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgecon.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgecon.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgecon.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE SGECON( NORM, N, A, LDA, ANORM, RCOND, WORK, IWORK,
20* INFO )
21*
22* .. Scalar Arguments ..
23* CHARACTER NORM
24* INTEGER INFO, LDA, N
25* REAL ANORM, RCOND
26* ..
27* .. Array Arguments ..
28* INTEGER IWORK( * )
29* REAL A( LDA, * ), WORK( * )
30* ..
31*
32*
33*> \par Purpose:
34* =============
35*>
36*> \verbatim
37*>
38*> SGECON estimates the reciprocal of the condition number of a general
39*> real matrix A, in either the 1-norm or the infinity-norm, using
40*> the LU factorization computed by SGETRF.
41*>
42*> An estimate is obtained for norm(inv(A)), and the reciprocal of the
43*> condition number is computed as
44*> RCOND = 1 / ( norm(A) * norm(inv(A)) ).
45*> \endverbatim
46*
47* Arguments:
48* ==========
49*
50*> \param[in] NORM
51*> \verbatim
52*> NORM is CHARACTER*1
53*> Specifies whether the 1-norm condition number or the
54*> infinity-norm condition number is required:
55*> = '1' or 'O': 1-norm;
56*> = 'I': Infinity-norm.
57*> \endverbatim
58*>
59*> \param[in] N
60*> \verbatim
61*> N is INTEGER
62*> The order of the matrix A. N >= 0.
63*> \endverbatim
64*>
65*> \param[in] A
66*> \verbatim
67*> A is REAL array, dimension (LDA,N)
68*> The factors L and U from the factorization A = P*L*U
69*> as computed by SGETRF.
70*> \endverbatim
71*>
72*> \param[in] LDA
73*> \verbatim
74*> LDA is INTEGER
75*> The leading dimension of the array A. LDA >= max(1,N).
76*> \endverbatim
77*>
78*> \param[in] ANORM
79*> \verbatim
80*> ANORM is REAL
81*> If NORM = '1' or 'O', the 1-norm of the original matrix A.
82*> If NORM = 'I', the infinity-norm of the original matrix A.
83*> \endverbatim
84*>
85*> \param[out] RCOND
86*> \verbatim
87*> RCOND is REAL
88*> The reciprocal of the condition number of the matrix A,
89*> computed as RCOND = 1/(norm(A) * norm(inv(A))).
90*> \endverbatim
91*>
92*> \param[out] WORK
93*> \verbatim
94*> WORK is REAL array, dimension (4*N)
95*> \endverbatim
96*>
97*> \param[out] IWORK
98*> \verbatim
99*> IWORK is INTEGER array, dimension (N)
100*> \endverbatim
101*>
102*> \param[out] INFO
103*> \verbatim
104*> INFO is INTEGER
105*> = 0: successful exit
106*> < 0: if INFO = -i, the i-th argument had an illegal value.
107*> NaNs are illegal values for ANORM, and they propagate to
108*> the output parameter RCOND.
109*> Infinity is illegal for ANORM, and it propagates to the output
110*> parameter RCOND as 0.
111*> = 1: if RCOND = NaN, or
112*> RCOND = Inf, or
113*> the computed norm of the inverse of A is 0.
114*> In the latter, RCOND = 0 is returned.
115*> \endverbatim
116*
117* Authors:
118* ========
119*
120*> \author Univ. of Tennessee
121*> \author Univ. of California Berkeley
122*> \author Univ. of Colorado Denver
123*> \author NAG Ltd.
124*
125*> \ingroup gecon
126*
127* =====================================================================
128 SUBROUTINE sgecon( NORM, N, A, LDA, ANORM, RCOND, WORK, IWORK,
129 $ INFO )
130*
131* -- LAPACK computational routine --
132* -- LAPACK is a software package provided by Univ. of Tennessee, --
133* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
134*
135* .. Scalar Arguments ..
136 CHARACTER NORM
137 INTEGER INFO, LDA, N
138 REAL ANORM, RCOND
139* ..
140* .. Array Arguments ..
141 INTEGER IWORK( * )
142 REAL A( LDA, * ), WORK( * )
143* ..
144*
145* =====================================================================
146*
147* .. Parameters ..
148 REAL ONE, ZERO
149 parameter( one = 1.0e+0, zero = 0.0e+0 )
150* ..
151* .. Local Scalars ..
152 LOGICAL ONENRM
153 CHARACTER NORMIN
154 INTEGER IX, KASE, KASE1
155 REAL AINVNM, SCALE, SL, SMLNUM, SU, HUGEVAL
156* ..
157* .. Local Arrays ..
158 INTEGER ISAVE( 3 )
159* ..
160* .. External Functions ..
161 LOGICAL LSAME, SISNAN
162 INTEGER ISAMAX
163 REAL SLAMCH
164 EXTERNAL lsame, isamax, slamch, sisnan
165* ..
166* .. External Subroutines ..
167 EXTERNAL slacn2, slatrs, srscl, xerbla
168* ..
169* .. Intrinsic Functions ..
170 INTRINSIC abs, max
171* ..
172* .. Executable Statements ..
173*
174 hugeval = slamch( 'Overflow' )
175*
176* Test the input parameters.
177*
178 info = 0
179 onenrm = norm.EQ.'1' .OR. lsame( norm, 'O' )
180 IF( .NOT.onenrm .AND. .NOT.lsame( norm, 'I' ) ) THEN
181 info = -1
182 ELSE IF( n.LT.0 ) THEN
183 info = -2
184 ELSE IF( lda.LT.max( 1, n ) ) THEN
185 info = -4
186 ELSE IF( anorm.LT.zero ) THEN
187 info = -5
188 END IF
189 IF( info.NE.0 ) THEN
190 CALL xerbla( 'SGECON', -info )
191 RETURN
192 END IF
193*
194* Quick return if possible
195*
196 rcond = zero
197 IF( n.EQ.0 ) THEN
198 rcond = one
199 RETURN
200 ELSE IF( anorm.EQ.zero ) THEN
201 RETURN
202 ELSE IF( sisnan( anorm ) ) THEN
203 rcond = anorm
204 info = -5
205 RETURN
206 ELSE IF( anorm.GT.hugeval ) THEN
207 info = -5
208 RETURN
209 END IF
210*
211 smlnum = slamch( 'Safe minimum' )
212*
213* Estimate the norm of inv(A).
214*
215 ainvnm = zero
216 normin = 'N'
217 IF( onenrm ) THEN
218 kase1 = 1
219 ELSE
220 kase1 = 2
221 END IF
222 kase = 0
223 10 CONTINUE
224 CALL slacn2( n, work( n+1 ), work, iwork, ainvnm, kase, isave )
225 IF( kase.NE.0 ) THEN
226 IF( kase.EQ.kase1 ) THEN
227*
228* Multiply by inv(L).
229*
230 CALL slatrs( 'Lower', 'No transpose', 'Unit', normin, n,
231 $ a,
232 $ lda, work, sl, work( 2*n+1 ), info )
233*
234* Multiply by inv(U).
235*
236 CALL slatrs( 'Upper', 'No transpose', 'Non-unit', normin,
237 $ n,
238 $ a, lda, work, su, work( 3*n+1 ), info )
239 ELSE
240*
241* Multiply by inv(U**T).
242*
243 CALL slatrs( 'Upper', 'Transpose', 'Non-unit', normin, n,
244 $ a,
245 $ lda, work, su, work( 3*n+1 ), info )
246*
247* Multiply by inv(L**T).
248*
249 CALL slatrs( 'Lower', 'Transpose', 'Unit', normin, n, a,
250 $ lda, work, sl, work( 2*n+1 ), info )
251 END IF
252*
253* Divide X by 1/(SL*SU) if doing so will not cause overflow.
254*
255 scale = sl*su
256 normin = 'Y'
257 IF( scale.NE.one ) THEN
258 ix = isamax( n, work, 1 )
259 IF( scale.LT.abs( work( ix ) )*smlnum .OR. scale.EQ.zero )
260 $ GO TO 20
261 CALL srscl( n, scale, work, 1 )
262 END IF
263 GO TO 10
264 END IF
265*
266* Compute the estimate of the reciprocal condition number.
267*
268 IF( ainvnm.NE.zero ) THEN
269 rcond = ( one / ainvnm ) / anorm
270 ELSE
271 info = 1
272 RETURN
273 END IF
274*
275* Check for NaNs and Infs
276*
277 IF( sisnan( rcond ) .OR. rcond.GT.hugeval )
278 $ info = 1
279*
280 20 CONTINUE
281 RETURN
282*
283* End of SGECON
284*
285 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sgecon(norm, n, a, lda, anorm, rcond, work, iwork, info)
SGECON
Definition sgecon.f:130
subroutine slacn2(n, v, x, isgn, est, kase, isave)
SLACN2 estimates the 1-norm of a square matrix, using reverse communication for evaluating matrix-vec...
Definition slacn2.f:134
subroutine slatrs(uplo, trans, diag, normin, n, a, lda, x, scale, cnorm, info)
SLATRS solves a triangular system of equations with the scale factor set to prevent overflow.
Definition slatrs.f:237
subroutine srscl(n, sa, sx, incx)
SRSCL multiplies a vector by the reciprocal of a real scalar.
Definition srscl.f:82