LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ sla_gercond()

real function sla_gercond ( character trans,
integer n,
real, dimension( lda, * ) a,
integer lda,
real, dimension( ldaf, * ) af,
integer ldaf,
integer, dimension( * ) ipiv,
integer cmode,
real, dimension( * ) c,
integer info,
real, dimension( * ) work,
integer, dimension( * ) iwork )

SLA_GERCOND estimates the Skeel condition number for a general matrix.

Download SLA_GERCOND + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!>    SLA_GERCOND estimates the Skeel condition number of op(A) * op2(C)
!>    where op2 is determined by CMODE as follows
!>    CMODE =  1    op2(C) = C
!>    CMODE =  0    op2(C) = I
!>    CMODE = -1    op2(C) = inv(C)
!>    The Skeel condition number cond(A) = norminf( |inv(A)||A| )
!>    is computed by computing scaling factors R such that
!>    diag(R)*A*op2(C) is row equilibrated and computing the standard
!>    infinity-norm condition number.
!> 
Parameters
[in]TRANS
!>          TRANS is CHARACTER*1
!>     Specifies the form of the system of equations:
!>       = 'N':  A * X = B     (No transpose)
!>       = 'T':  A**T * X = B  (Transpose)
!>       = 'C':  A**H * X = B  (Conjugate Transpose = Transpose)
!> 
[in]N
!>          N is INTEGER
!>     The number of linear equations, i.e., the order of the
!>     matrix A.  N >= 0.
!> 
[in]A
!>          A is REAL array, dimension (LDA,N)
!>     On entry, the N-by-N matrix A.
!> 
[in]LDA
!>          LDA is INTEGER
!>     The leading dimension of the array A.  LDA >= max(1,N).
!> 
[in]AF
!>          AF is REAL array, dimension (LDAF,N)
!>     The factors L and U from the factorization
!>     A = P*L*U as computed by SGETRF.
!> 
[in]LDAF
!>          LDAF is INTEGER
!>     The leading dimension of the array AF.  LDAF >= max(1,N).
!> 
[in]IPIV
!>          IPIV is INTEGER array, dimension (N)
!>     The pivot indices from the factorization A = P*L*U
!>     as computed by SGETRF; row i of the matrix was interchanged
!>     with row IPIV(i).
!> 
[in]CMODE
!>          CMODE is INTEGER
!>     Determines op2(C) in the formula op(A) * op2(C) as follows:
!>     CMODE =  1    op2(C) = C
!>     CMODE =  0    op2(C) = I
!>     CMODE = -1    op2(C) = inv(C)
!> 
[in]C
!>          C is REAL array, dimension (N)
!>     The vector C in the formula op(A) * op2(C).
!> 
[out]INFO
!>          INFO is INTEGER
!>       = 0:  Successful exit.
!>     i > 0:  The ith argument is invalid.
!> 
[out]WORK
!>          WORK is REAL array, dimension (3*N).
!>     Workspace.
!> 
[out]IWORK
!>          IWORK is INTEGER array, dimension (N).
!>     Workspace.2
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 146 of file sla_gercond.f.

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*
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
Here is the call graph for this function:
Here is the caller graph for this function: