1 *> \brief \b SLA_GERCOND estimates the Skeel condition number for a general matrix.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SLA_GERCOND + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sla_gercond.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sla_gercond.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sla_gercond.f">
21 * REAL FUNCTION SLA_GERCOND ( TRANS, N, A, LDA, AF, LDAF, IPIV,
22 * CMODE, C, INFO, WORK, IWORK )
24 * .. Scalar Arguments ..
26 * INTEGER N, LDA, LDAF, INFO, CMODE
28 * .. Array Arguments ..
29 * INTEGER IPIV( * ), IWORK( * )
30 * REAL A( LDA, * ), AF( LDAF, * ), WORK( * ),
40 *> SLA_GERCOND estimates the Skeel condition number of op(A) * op2(C)
41 *> where op2 is determined by CMODE as follows
42 *> CMODE = 1 op2(C) = C
43 *> CMODE = 0 op2(C) = I
44 *> CMODE = -1 op2(C) = inv(C)
45 *> The Skeel condition number cond(A) = norminf( |inv(A)||A| )
46 *> is computed by computing scaling factors R such that
47 *> diag(R)*A*op2(C) is row equilibrated and computing the standard
48 *> infinity-norm condition number.
56 *> TRANS is CHARACTER*1
57 *> Specifies the form of the system of equations:
58 *> = 'N': A * X = B (No transpose)
59 *> = 'T': A**T * X = B (Transpose)
60 *> = 'C': A**H * X = B (Conjugate Transpose = Transpose)
66 *> The number of linear equations, i.e., the order of the
72 *> A is REAL array, dimension (LDA,N)
73 *> On entry, the N-by-N matrix A.
79 *> The leading dimension of the array A. LDA >= max(1,N).
84 *> AF is REAL array, dimension (LDAF,N)
85 *> The factors L and U from the factorization
86 *> A = P*L*U as computed by SGETRF.
92 *> The leading dimension of the array AF. LDAF >= max(1,N).
97 *> IPIV is INTEGER array, dimension (N)
98 *> The pivot indices from the factorization A = P*L*U
99 *> as computed by SGETRF; row i of the matrix was interchanged
106 *> Determines op2(C) in the formula op(A) * op2(C) as follows:
107 *> CMODE = 1 op2(C) = C
108 *> CMODE = 0 op2(C) = I
109 *> CMODE = -1 op2(C) = inv(C)
114 *> C is REAL array, dimension (N)
115 *> The vector C in the formula op(A) * op2(C).
121 *> = 0: Successful exit.
122 *> i > 0: The ith argument is invalid.
127 *> WORK is REAL array, dimension (3*N).
133 *> IWORK is INTEGER array, dimension (N).
140 *> \author Univ. of Tennessee
141 *> \author Univ. of California Berkeley
142 *> \author Univ. of Colorado Denver
145 *> \date September 2012
147 *> \ingroup realGEcomputational
149 * =====================================================================
150 REAL FUNCTION SLA_GERCOND ( TRANS, N, A, LDA, AF, LDAF, IPIV,
151 $ CMODE, C, INFO, WORK, IWORK )
153 * -- LAPACK computational routine (version 3.4.2) --
154 * -- LAPACK is a software package provided by Univ. of Tennessee, --
155 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
158 * .. Scalar Arguments ..
160 INTEGER N, LDA, LDAF, INFO, CMODE
162 * .. Array Arguments ..
163 INTEGER IPIV( * ), IWORK( * )
164 REAL A( LDA, * ), AF( LDAF, * ), WORK( * ),
168 * =====================================================================
170 * .. Local Scalars ..
178 * .. External Functions ..
182 * .. External Subroutines ..
183 EXTERNAL SLACN2, SGETRS, XERBLA
185 * .. Intrinsic Functions ..
188 * .. Executable Statements ..
193 NOTRANS = LSAME( TRANS, 'N' )
194 IF ( .NOT. NOTRANS .AND. .NOT. LSAME(TRANS, 'T')
195 $ .AND. .NOT. LSAME(TRANS, 'C') ) THEN
197 ELSE IF( N.LT.0 ) THEN
199 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
201 ELSE IF( LDAF.LT.MAX( 1, N ) ) THEN
205 CALL XERBLA( 'SLA_GERCOND', -INFO )
213 * Compute the equilibration matrix R such that
214 * inv(R)*A*C has unit 1-norm.
219 IF ( CMODE .EQ. 1 ) THEN
221 TMP = TMP + ABS( A( I, J ) * C( J ) )
223 ELSE IF ( CMODE .EQ. 0 ) THEN
225 TMP = TMP + ABS( A( I, J ) )
229 TMP = TMP + ABS( A( I, J ) / C( J ) )
237 IF ( CMODE .EQ. 1 ) THEN
239 TMP = TMP + ABS( A( J, I ) * C( J ) )
241 ELSE IF ( CMODE .EQ. 0 ) THEN
243 TMP = TMP + ABS( A( J, I ) )
247 TMP = TMP + ABS( A( J, I ) / C( J ) )
254 * Estimate the norm of inv(op(A)).
260 CALL SLACN2( N, WORK( N+1 ), WORK, IWORK, AINVNM, KASE, ISAVE )
267 WORK(I) = WORK(I) * WORK(2*N+I)
271 CALL SGETRS( 'No transpose', N, 1, AF, LDAF, IPIV,
274 CALL SGETRS( 'Transpose', N, 1, AF, LDAF, IPIV,
278 * Multiply by inv(C).
280 IF ( CMODE .EQ. 1 ) THEN
282 WORK( I ) = WORK( I ) / C( I )
284 ELSE IF ( CMODE .EQ. -1 ) THEN
286 WORK( I ) = WORK( I ) * C( I )
291 * Multiply by inv(C**T).
293 IF ( CMODE .EQ. 1 ) THEN
295 WORK( I ) = WORK( I ) / C( I )
297 ELSE IF ( CMODE .EQ. -1 ) THEN
299 WORK( I ) = WORK( I ) * C( I )
304 CALL SGETRS( 'Transpose', N, 1, AF, LDAF, IPIV,
307 CALL SGETRS( 'No transpose', N, 1, AF, LDAF, IPIV,
314 WORK( I ) = WORK( I ) * WORK( 2*N+I )
320 * Compute the estimate of the reciprocal condition number.
322 IF( AINVNM .NE. 0.0 )
323 $ SLA_GERCOND = ( 1.0 / AINVNM )