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