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