LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
sla_syrcond.f
Go to the documentation of this file.
1*> \brief \b SLA_SYRCOND estimates the Skeel condition number for a symmetric indefinite matrix.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download SLA_SYRCOND + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sla_syrcond.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sla_syrcond.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sla_syrcond.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* REAL FUNCTION SLA_SYRCOND( UPLO, N, A, LDA, AF, LDAF, IPIV, CMODE,
20* C, INFO, WORK, IWORK )
21*
22* .. Scalar Arguments ..
23* CHARACTER UPLO
24* INTEGER N, LDA, LDAF, INFO, CMODE
25* ..
26* .. Array Arguments
27* INTEGER IWORK( * ), IPIV( * )
28* REAL A( LDA, * ), AF( LDAF, * ), WORK( * ), C( * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> SLA_SYRCOND estimates the Skeel condition number of op(A) * op2(C)
38*> where op2 is determined by CMODE as follows
39*> CMODE = 1 op2(C) = C
40*> CMODE = 0 op2(C) = I
41*> CMODE = -1 op2(C) = inv(C)
42*> The Skeel condition number cond(A) = norminf( |inv(A)||A| )
43*> is computed by computing scaling factors R such that
44*> diag(R)*A*op2(C) is row equilibrated and computing the standard
45*> infinity-norm condition number.
46*> \endverbatim
47*
48* Arguments:
49* ==========
50*
51*> \param[in] UPLO
52*> \verbatim
53*> UPLO is CHARACTER*1
54*> = 'U': Upper triangle of A is stored;
55*> = 'L': Lower triangle of A is stored.
56*> \endverbatim
57*>
58*> \param[in] N
59*> \verbatim
60*> N is INTEGER
61*> The number of linear equations, i.e., the order of the
62*> matrix A. N >= 0.
63*> \endverbatim
64*>
65*> \param[in] A
66*> \verbatim
67*> A is REAL array, dimension (LDA,N)
68*> On entry, the N-by-N matrix A.
69*> \endverbatim
70*>
71*> \param[in] LDA
72*> \verbatim
73*> LDA is INTEGER
74*> The leading dimension of the array A. LDA >= max(1,N).
75*> \endverbatim
76*>
77*> \param[in] AF
78*> \verbatim
79*> AF is REAL array, dimension (LDAF,N)
80*> The block diagonal matrix D and the multipliers used to
81*> obtain the factor U or L as computed by SSYTRF.
82*> \endverbatim
83*>
84*> \param[in] LDAF
85*> \verbatim
86*> LDAF is INTEGER
87*> The leading dimension of the array AF. LDAF >= max(1,N).
88*> \endverbatim
89*>
90*> \param[in] IPIV
91*> \verbatim
92*> IPIV is INTEGER array, dimension (N)
93*> Details of the interchanges and the block structure of D
94*> as determined by SSYTRF.
95*> \endverbatim
96*>
97*> \param[in] CMODE
98*> \verbatim
99*> CMODE is INTEGER
100*> Determines op2(C) in the formula op(A) * op2(C) as follows:
101*> CMODE = 1 op2(C) = C
102*> CMODE = 0 op2(C) = I
103*> CMODE = -1 op2(C) = inv(C)
104*> \endverbatim
105*>
106*> \param[in] C
107*> \verbatim
108*> C is REAL array, dimension (N)
109*> The vector C in the formula op(A) * op2(C).
110*> \endverbatim
111*>
112*> \param[out] INFO
113*> \verbatim
114*> INFO is INTEGER
115*> = 0: Successful exit.
116*> i > 0: The ith argument is invalid.
117*> \endverbatim
118*>
119*> \param[out] WORK
120*> \verbatim
121*> WORK is REAL array, dimension (3*N).
122*> Workspace.
123*> \endverbatim
124*>
125*> \param[out] IWORK
126*> \verbatim
127*> IWORK is INTEGER array, dimension (N).
128*> Workspace.
129*> \endverbatim
130*
131* Authors:
132* ========
133*
134*> \author Univ. of Tennessee
135*> \author Univ. of California Berkeley
136*> \author Univ. of Colorado Denver
137*> \author NAG Ltd.
138*
139*> \ingroup la_hercond
140*
141* =====================================================================
142 REAL function sla_syrcond( uplo, n, a, lda, af, ldaf, ipiv,
143 $ cmode,
144 $ c, info, work, iwork )
145*
146* -- LAPACK computational routine --
147* -- LAPACK is a software package provided by Univ. of Tennessee, --
148* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
149*
150* .. Scalar Arguments ..
151 CHARACTER uplo
152 INTEGER n, lda, ldaf, info, cmode
153* ..
154* .. Array Arguments
155 INTEGER iwork( * ), ipiv( * )
156 REAL a( lda, * ), af( ldaf, * ), work( * ), c( * )
157* ..
158*
159* =====================================================================
160*
161* .. Local Scalars ..
162 CHARACTER normin
163 INTEGER kase, i, j
164 REAL ainvnm, smlnum, tmp
165 LOGICAL up
166* ..
167* .. Local Arrays ..
168 INTEGER isave( 3 )
169* ..
170* .. External Functions ..
171 LOGICAL lsame
172 REAL slamch
173 EXTERNAL lsame, slamch
174* ..
175* .. External Subroutines ..
176 EXTERNAL slacn2, xerbla, ssytrs
177* ..
178* .. Intrinsic Functions ..
179 INTRINSIC abs, max
180* ..
181* .. Executable Statements ..
182*
183 sla_syrcond = 0.0
184*
185 info = 0
186 IF( n.LT.0 ) THEN
187 info = -2
188 ELSE IF( lda.LT.max( 1, n ) ) THEN
189 info = -4
190 ELSE IF( ldaf.LT.max( 1, n ) ) THEN
191 info = -6
192 END IF
193 IF( info.NE.0 ) THEN
194 CALL xerbla( 'SLA_SYRCOND', -info )
195 RETURN
196 END IF
197 IF( n.EQ.0 ) THEN
198 sla_syrcond = 1.0
199 RETURN
200 END IF
201 up = .false.
202 IF ( lsame( uplo, 'U' ) ) up = .true.
203*
204* Compute the equilibration matrix R such that
205* inv(R)*A*C has unit 1-norm.
206*
207 IF ( up ) THEN
208 DO i = 1, n
209 tmp = 0.0
210 IF ( cmode .EQ. 1 ) THEN
211 DO j = 1, i
212 tmp = tmp + abs( a( j, i ) * c( j ) )
213 END DO
214 DO j = i+1, n
215 tmp = tmp + abs( a( i, j ) * c( j ) )
216 END DO
217 ELSE IF ( cmode .EQ. 0 ) THEN
218 DO j = 1, i
219 tmp = tmp + abs( a( j, i ) )
220 END DO
221 DO j = i+1, n
222 tmp = tmp + abs( a( i, j ) )
223 END DO
224 ELSE
225 DO j = 1, i
226 tmp = tmp + abs( a( j, i ) / c( j ) )
227 END DO
228 DO j = i+1, n
229 tmp = tmp + abs( a( i, j ) / c( j ) )
230 END DO
231 END IF
232 work( 2*n+i ) = tmp
233 END DO
234 ELSE
235 DO i = 1, n
236 tmp = 0.0
237 IF ( cmode .EQ. 1 ) THEN
238 DO j = 1, i
239 tmp = tmp + abs( a( i, j ) * c( j ) )
240 END DO
241 DO j = i+1, n
242 tmp = tmp + abs( a( j, i ) * c( j ) )
243 END DO
244 ELSE IF ( cmode .EQ. 0 ) THEN
245 DO j = 1, i
246 tmp = tmp + abs( a( i, j ) )
247 END DO
248 DO j = i+1, n
249 tmp = tmp + abs( a( j, i ) )
250 END DO
251 ELSE
252 DO j = 1, i
253 tmp = tmp + abs( a( i, j) / c( j ) )
254 END DO
255 DO j = i+1, n
256 tmp = tmp + abs( a( j, i) / c( j ) )
257 END DO
258 END IF
259 work( 2*n+i ) = tmp
260 END DO
261 ENDIF
262*
263* Estimate the norm of inv(op(A)).
264*
265 smlnum = slamch( 'Safe minimum' )
266 ainvnm = 0.0
267 normin = 'N'
268
269 kase = 0
270 10 CONTINUE
271 CALL slacn2( n, work( n+1 ), work, iwork, ainvnm, kase, isave )
272 IF( kase.NE.0 ) THEN
273 IF( kase.EQ.2 ) THEN
274*
275* Multiply by R.
276*
277 DO i = 1, n
278 work( i ) = work( i ) * work( 2*n+i )
279 END DO
280
281 IF ( up ) THEN
282 CALL ssytrs( 'U', n, 1, af, ldaf, ipiv, work, n,
283 $ info )
284 ELSE
285 CALL ssytrs( 'L', n, 1, af, ldaf, ipiv, work, n,
286 $ info )
287 ENDIF
288*
289* Multiply by inv(C).
290*
291 IF ( cmode .EQ. 1 ) THEN
292 DO i = 1, n
293 work( i ) = work( i ) / c( i )
294 END DO
295 ELSE IF ( cmode .EQ. -1 ) THEN
296 DO i = 1, n
297 work( i ) = work( i ) * c( i )
298 END DO
299 END IF
300 ELSE
301*
302* Multiply by inv(C**T).
303*
304 IF ( cmode .EQ. 1 ) THEN
305 DO i = 1, n
306 work( i ) = work( i ) / c( i )
307 END DO
308 ELSE IF ( cmode .EQ. -1 ) THEN
309 DO i = 1, n
310 work( i ) = work( i ) * c( i )
311 END DO
312 END IF
313
314 IF ( up ) THEN
315 CALL ssytrs( 'U', n, 1, af, ldaf, ipiv, work, n,
316 $ info )
317 ELSE
318 CALL ssytrs( 'L', n, 1, af, ldaf, ipiv, work, n,
319 $ info )
320 ENDIF
321*
322* Multiply by R.
323*
324 DO i = 1, n
325 work( i ) = work( i ) * work( 2*n+i )
326 END DO
327 END IF
328*
329 GO TO 10
330 END IF
331*
332* Compute the estimate of the reciprocal condition number.
333*
334 IF( ainvnm .NE. 0.0 )
335 $ sla_syrcond = ( 1.0 / ainvnm )
336*
337 RETURN
338*
339* End of SLA_SYRCOND
340*
341 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine ssytrs(uplo, n, nrhs, a, lda, ipiv, b, ldb, info)
SSYTRS
Definition ssytrs.f:118
real function sla_syrcond(uplo, n, a, lda, af, ldaf, ipiv, cmode, c, info, work, iwork)
SLA_SYRCOND estimates the Skeel condition number for a symmetric indefinite matrix.
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
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48