1 *> \brief \b SLA_GBRCOND estimates the Skeel condition number for a general banded matrix.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SLA_GBRCOND + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sla_gbrcond.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sla_gbrcond.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sla_gbrcond.f">
21 * REAL FUNCTION SLA_GBRCOND( TRANS, N, KL, KU, AB, LDAB, AFB, LDAFB,
22 * IPIV, CMODE, C, INFO, WORK, IWORK )
24 * .. Scalar Arguments ..
26 * INTEGER N, LDAB, LDAFB, INFO, KL, KU, CMODE
28 * .. Array Arguments ..
29 * INTEGER IWORK( * ), IPIV( * )
30 * REAL AB( LDAB, * ), AFB( LDAFB, * ), WORK( * ),
40 *> SLA_GBRCOND 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
73 *> The number of subdiagonals within the band of A. KL >= 0.
79 *> The number of superdiagonals within the band of A. KU >= 0.
84 *> AB is REAL array, dimension (LDAB,N)
85 *> On entry, the matrix A in band storage, in rows 1 to KL+KU+1.
86 *> The j-th column of A is stored in the j-th column of the
87 *> array AB as follows:
88 *> AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl)
94 *> The leading dimension of the array AB. LDAB >= KL+KU+1.
99 *> AFB is REAL array, dimension (LDAFB,N)
100 *> Details of the LU factorization of the band matrix A, as
101 *> computed by SGBTRF. U is stored as an upper triangular
102 *> band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1,
103 *> and the multipliers used during the factorization are stored
104 *> in rows KL+KU+2 to 2*KL+KU+1.
110 *> The leading dimension of the array AFB. LDAFB >= 2*KL+KU+1.
115 *> IPIV is INTEGER array, dimension (N)
116 *> The pivot indices from the factorization A = P*L*U
117 *> as computed by SGBTRF; row i of the matrix was interchanged
124 *> Determines op2(C) in the formula op(A) * op2(C) as follows:
125 *> CMODE = 1 op2(C) = C
126 *> CMODE = 0 op2(C) = I
127 *> CMODE = -1 op2(C) = inv(C)
132 *> C is REAL array, dimension (N)
133 *> The vector C in the formula op(A) * op2(C).
139 *> = 0: Successful exit.
140 *> i > 0: The ith argument is invalid.
145 *> WORK is REAL array, dimension (5*N).
151 *> IWORK is INTEGER array, dimension (N).
158 *> \author Univ. of Tennessee
159 *> \author Univ. of California Berkeley
160 *> \author Univ. of Colorado Denver
163 *> \date September 2012
165 *> \ingroup realGBcomputational
167 * =====================================================================
168 REAL FUNCTION SLA_GBRCOND( TRANS, N, KL, KU, AB, LDAB, AFB, LDAFB,
169 $ IPIV, CMODE, C, INFO, WORK, IWORK )
171 * -- LAPACK computational routine (version 3.4.2) --
172 * -- LAPACK is a software package provided by Univ. of Tennessee, --
173 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
176 * .. Scalar Arguments ..
178 INTEGER N, LDAB, LDAFB, INFO, KL, KU, CMODE
180 * .. Array Arguments ..
181 INTEGER IWORK( * ), IPIV( * )
182 REAL AB( LDAB, * ), AFB( LDAFB, * ), WORK( * ),
186 * =====================================================================
188 * .. Local Scalars ..
190 INTEGER KASE, I, J, KD, KE
196 * .. External Functions ..
200 * .. External Subroutines ..
201 EXTERNAL SLACN2, SGBTRS, XERBLA
203 * .. Intrinsic Functions ..
206 * .. Executable Statements ..
211 NOTRANS = LSAME( TRANS, 'N' )
212 IF ( .NOT. NOTRANS .AND. .NOT. LSAME(TRANS, 'T')
213 $ .AND. .NOT. LSAME(TRANS, 'C') ) THEN
215 ELSE IF( N.LT.0 ) THEN
217 ELSE IF( KL.LT.0 .OR. KL.GT.N-1 ) THEN
219 ELSE IF( KU.LT.0 .OR. KU.GT.N-1 ) THEN
221 ELSE IF( LDAB.LT.KL+KU+1 ) THEN
223 ELSE IF( LDAFB.LT.2*KL+KU+1 ) THEN
227 CALL XERBLA( 'SLA_GBRCOND', -INFO )
235 * Compute the equilibration matrix R such that
236 * inv(R)*A*C has unit 1-norm.
243 IF ( CMODE .EQ. 1 ) THEN
244 DO J = MAX( I-KL, 1 ), MIN( I+KU, N )
245 TMP = TMP + ABS( AB( KD+I-J, J ) * C( J ) )
247 ELSE IF ( CMODE .EQ. 0 ) THEN
248 DO J = MAX( I-KL, 1 ), MIN( I+KU, N )
249 TMP = TMP + ABS( AB( KD+I-J, J ) )
252 DO J = MAX( I-KL, 1 ), MIN( I+KU, N )
253 TMP = TMP + ABS( AB( KD+I-J, J ) / C( J ) )
261 IF ( CMODE .EQ. 1 ) THEN
262 DO J = MAX( I-KL, 1 ), MIN( I+KU, N )
263 TMP = TMP + ABS( AB( KE-I+J, I ) * C( J ) )
265 ELSE IF ( CMODE .EQ. 0 ) THEN
266 DO J = MAX( I-KL, 1 ), MIN( I+KU, N )
267 TMP = TMP + ABS( AB( KE-I+J, I ) )
270 DO J = MAX( I-KL, 1 ), MIN( I+KU, N )
271 TMP = TMP + ABS( AB( KE-I+J, I ) / C( J ) )
278 * Estimate the norm of inv(op(A)).
284 CALL SLACN2( N, WORK( N+1 ), WORK, IWORK, AINVNM, KASE, ISAVE )
291 WORK( I ) = WORK( I ) * WORK( 2*N+I )
295 CALL SGBTRS( 'No transpose', N, KL, KU, 1, AFB, LDAFB,
296 $ IPIV, WORK, N, INFO )
298 CALL SGBTRS( 'Transpose', N, KL, KU, 1, AFB, LDAFB, IPIV,
302 * Multiply by inv(C).
304 IF ( CMODE .EQ. 1 ) THEN
306 WORK( I ) = WORK( I ) / C( I )
308 ELSE IF ( CMODE .EQ. -1 ) THEN
310 WORK( I ) = WORK( I ) * C( I )
315 * Multiply by inv(C**T).
317 IF ( CMODE .EQ. 1 ) THEN
319 WORK( I ) = WORK( I ) / C( I )
321 ELSE IF ( CMODE .EQ. -1 ) THEN
323 WORK( I ) = WORK( I ) * C( I )
328 CALL SGBTRS( 'Transpose', N, KL, KU, 1, AFB, LDAFB, IPIV,
331 CALL SGBTRS( 'No transpose', N, KL, KU, 1, AFB, LDAFB,
332 $ IPIV, WORK, N, INFO )
338 WORK( I ) = WORK( I ) * WORK( 2*N+I )
344 * Compute the estimate of the reciprocal condition number.
346 IF( AINVNM .NE. 0.0 )
347 $ SLA_GBRCOND = ( 1.0 / AINVNM )