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