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