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