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

◆ cget04()

subroutine cget04 ( integer  n,
integer  nrhs,
complex, dimension( ldx, * )  x,
integer  ldx,
complex, dimension( ldxact, * )  xact,
integer  ldxact,
real  rcond,
real  resid 
)

CGET04

Purpose:
 CGET04 computes the difference between a computed solution and the
 true solution to a system of linear equations.

 RESID =  ( norm(X-XACT) * RCOND ) / ( norm(XACT) * EPS ),
 where RCOND is the reciprocal of the condition number and EPS is the
 machine epsilon.
Parameters
[in]N
          N is INTEGER
          The number of rows of the matrices X and XACT.  N >= 0.
[in]NRHS
          NRHS is INTEGER
          The number of columns of the matrices X and XACT.  NRHS >= 0.
[in]X
          X is COMPLEX array, dimension (LDX,NRHS)
          The computed solution vectors.  Each vector is stored as a
          column of the matrix X.
[in]LDX
          LDX is INTEGER
          The leading dimension of the array X.  LDX >= max(1,N).
[in]XACT
          XACT is COMPLEX array, dimension (LDX,NRHS)
          The exact solution vectors.  Each vector is stored as a
          column of the matrix XACT.
[in]LDXACT
          LDXACT is INTEGER
          The leading dimension of the array XACT.  LDXACT >= max(1,N).
[in]RCOND
          RCOND is REAL
          The reciprocal of the condition number of the coefficient
          matrix in the system of equations.
[out]RESID
          RESID is REAL
          The maximum over the NRHS solution vectors of
          ( norm(X-XACT) * RCOND ) / ( norm(XACT) * EPS )
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 101 of file cget04.f.

102*
103* -- LAPACK test routine --
104* -- LAPACK is a software package provided by Univ. of Tennessee, --
105* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
106*
107* .. Scalar Arguments ..
108 INTEGER LDX, LDXACT, N, NRHS
109 REAL RCOND, RESID
110* ..
111* .. Array Arguments ..
112 COMPLEX X( LDX, * ), XACT( LDXACT, * )
113* ..
114*
115* =====================================================================
116*
117* .. Parameters ..
118 REAL ZERO
119 parameter( zero = 0.0e+0 )
120* ..
121* .. Local Scalars ..
122 INTEGER I, IX, J
123 REAL DIFFNM, EPS, XNORM
124 COMPLEX ZDUM
125* ..
126* .. External Functions ..
127 INTEGER ICAMAX
128 REAL SLAMCH
129 EXTERNAL icamax, slamch
130* ..
131* .. Intrinsic Functions ..
132 INTRINSIC abs, aimag, max, real
133* ..
134* .. Statement Functions ..
135 REAL CABS1
136* ..
137* .. Statement Function definitions ..
138 cabs1( zdum ) = abs( real( zdum ) ) + abs( aimag( zdum ) )
139* ..
140* .. Executable Statements ..
141*
142* Quick exit if N = 0 or NRHS = 0.
143*
144 IF( n.LE.0 .OR. nrhs.LE.0 ) THEN
145 resid = zero
146 RETURN
147 END IF
148*
149* Exit with RESID = 1/EPS if RCOND is invalid.
150*
151 eps = slamch( 'Epsilon' )
152 IF( rcond.LT.zero ) THEN
153 resid = 1.0 / eps
154 RETURN
155 END IF
156*
157* Compute the maximum of
158* norm(X - XACT) / ( norm(XACT) * EPS )
159* over all the vectors X and XACT .
160*
161 resid = zero
162 DO 20 j = 1, nrhs
163 ix = icamax( n, xact( 1, j ), 1 )
164 xnorm = cabs1( xact( ix, j ) )
165 diffnm = zero
166 DO 10 i = 1, n
167 diffnm = max( diffnm, cabs1( x( i, j )-xact( i, j ) ) )
168 10 CONTINUE
169 IF( xnorm.LE.zero ) THEN
170 IF( diffnm.GT.zero )
171 $ resid = 1.0 / eps
172 ELSE
173 resid = max( resid, ( diffnm / xnorm )*rcond )
174 END IF
175 20 CONTINUE
176 IF( resid*eps.LT.1.0 )
177 $ resid = resid / eps
178*
179 RETURN
180*
181* End of CGET04
182*
integer function icamax(n, cx, incx)
ICAMAX
Definition icamax.f:71
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
Here is the caller graph for this function: