LAPACK  3.8.0
LAPACK: Linear Algebra PACKage
zget04.f
Go to the documentation of this file.
1 *> \brief \b ZGET04
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * SUBROUTINE ZGET04( N, NRHS, X, LDX, XACT, LDXACT, RCOND, RESID )
12 *
13 * .. Scalar Arguments ..
14 * INTEGER LDX, LDXACT, N, NRHS
15 * DOUBLE PRECISION RCOND, RESID
16 * ..
17 * .. Array Arguments ..
18 * COMPLEX*16 X( LDX, * ), XACT( LDXACT, * )
19 * ..
20 *
21 *
22 *> \par Purpose:
23 * =============
24 *>
25 *> \verbatim
26 *>
27 *> ZGET04 computes the difference between a computed solution and the
28 *> true solution to a system of linear equations.
29 *>
30 *> RESID = ( norm(X-XACT) * RCOND ) / ( norm(XACT) * EPS ),
31 *> where RCOND is the reciprocal of the condition number and EPS is the
32 *> machine epsilon.
33 *> \endverbatim
34 *
35 * Arguments:
36 * ==========
37 *
38 *> \param[in] N
39 *> \verbatim
40 *> N is INTEGER
41 *> The number of rows of the matrices X and XACT. N >= 0.
42 *> \endverbatim
43 *>
44 *> \param[in] NRHS
45 *> \verbatim
46 *> NRHS is INTEGER
47 *> The number of columns of the matrices X and XACT. NRHS >= 0.
48 *> \endverbatim
49 *>
50 *> \param[in] X
51 *> \verbatim
52 *> X is COMPLEX*16 array, dimension (LDX,NRHS)
53 *> The computed solution vectors. Each vector is stored as a
54 *> column of the matrix X.
55 *> \endverbatim
56 *>
57 *> \param[in] LDX
58 *> \verbatim
59 *> LDX is INTEGER
60 *> The leading dimension of the array X. LDX >= max(1,N).
61 *> \endverbatim
62 *>
63 *> \param[in] XACT
64 *> \verbatim
65 *> XACT is COMPLEX*16 array, dimension (LDX,NRHS)
66 *> The exact solution vectors. Each vector is stored as a
67 *> column of the matrix XACT.
68 *> \endverbatim
69 *>
70 *> \param[in] LDXACT
71 *> \verbatim
72 *> LDXACT is INTEGER
73 *> The leading dimension of the array XACT. LDXACT >= max(1,N).
74 *> \endverbatim
75 *>
76 *> \param[in] RCOND
77 *> \verbatim
78 *> RCOND is DOUBLE PRECISION
79 *> The reciprocal of the condition number of the coefficient
80 *> matrix in the system of equations.
81 *> \endverbatim
82 *>
83 *> \param[out] RESID
84 *> \verbatim
85 *> RESID is DOUBLE PRECISION
86 *> The maximum over the NRHS solution vectors of
87 *> ( norm(X-XACT) * RCOND ) / ( norm(XACT) * EPS )
88 *> \endverbatim
89 *
90 * Authors:
91 * ========
92 *
93 *> \author Univ. of Tennessee
94 *> \author Univ. of California Berkeley
95 *> \author Univ. of Colorado Denver
96 *> \author NAG Ltd.
97 *
98 *> \date December 2016
99 *
100 *> \ingroup complex16_lin
101 *
102 * =====================================================================
103  SUBROUTINE zget04( N, NRHS, X, LDX, XACT, LDXACT, RCOND, RESID )
104 *
105 * -- LAPACK test routine (version 3.7.0) --
106 * -- LAPACK is a software package provided by Univ. of Tennessee, --
107 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
108 * December 2016
109 *
110 * .. Scalar Arguments ..
111  INTEGER LDX, LDXACT, N, NRHS
112  DOUBLE PRECISION RCOND, RESID
113 * ..
114 * .. Array Arguments ..
115  COMPLEX*16 X( ldx, * ), XACT( ldxact, * )
116 * ..
117 *
118 * =====================================================================
119 *
120 * .. Parameters ..
121  DOUBLE PRECISION ZERO
122  parameter( zero = 0.0d+0 )
123 * ..
124 * .. Local Scalars ..
125  INTEGER I, IX, J
126  DOUBLE PRECISION DIFFNM, EPS, XNORM
127  COMPLEX*16 ZDUM
128 * ..
129 * .. External Functions ..
130  INTEGER IZAMAX
131  DOUBLE PRECISION DLAMCH
132  EXTERNAL izamax, dlamch
133 * ..
134 * .. Intrinsic Functions ..
135  INTRINSIC abs, dble, dimag, max
136 * ..
137 * .. Statement Functions ..
138  DOUBLE PRECISION CABS1
139 * ..
140 * .. Statement Function definitions ..
141  cabs1( zdum ) = abs( dble( zdum ) ) + abs( dimag( zdum ) )
142 * ..
143 * .. Executable Statements ..
144 *
145 * Quick exit if N = 0 or NRHS = 0.
146 *
147  IF( n.LE.0 .OR. nrhs.LE.0 ) THEN
148  resid = zero
149  RETURN
150  END IF
151 *
152 * Exit with RESID = 1/EPS if RCOND is invalid.
153 *
154  eps = dlamch( 'Epsilon' )
155  IF( rcond.LT.zero ) THEN
156  resid = 1.0d0 / eps
157  RETURN
158  END IF
159 *
160 * Compute the maximum of
161 * norm(X - XACT) / ( norm(XACT) * EPS )
162 * over all the vectors X and XACT .
163 *
164  resid = zero
165  DO 20 j = 1, nrhs
166  ix = izamax( n, xact( 1, j ), 1 )
167  xnorm = cabs1( xact( ix, j ) )
168  diffnm = zero
169  DO 10 i = 1, n
170  diffnm = max( diffnm, cabs1( x( i, j )-xact( i, j ) ) )
171  10 CONTINUE
172  IF( xnorm.LE.zero ) THEN
173  IF( diffnm.GT.zero )
174  $ resid = 1.0d0 / eps
175  ELSE
176  resid = max( resid, ( diffnm / xnorm )*rcond )
177  END IF
178  20 CONTINUE
179  IF( resid*eps.LT.1.0d0 )
180  $ resid = resid / eps
181 *
182  RETURN
183 *
184 * End of ZGET04
185 *
186  END
subroutine zget04(N, NRHS, X, LDX, XACT, LDXACT, RCOND, RESID)
ZGET04
Definition: zget04.f:104