LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine sget04 ( integer  N,
integer  NRHS,
real, dimension( ldx, * )  X,
integer  LDX,
real, dimension( ldxact, * )  XACT,
integer  LDXACT,
real  RCOND,
real  RESID 
)

SGET04

Purpose:
 SGET04 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 REAL 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 REAL 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.
Date
November 2011

Definition at line 104 of file sget04.f.

104 *
105 * -- LAPACK test routine (version 3.4.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 * November 2011
109 *
110 * .. Scalar Arguments ..
111  INTEGER ldx, ldxact, n, nrhs
112  REAL rcond, resid
113 * ..
114 * .. Array Arguments ..
115  REAL x( ldx, * ), xact( ldxact, * )
116 * ..
117 *
118 * =====================================================================
119 *
120 * .. Parameters ..
121  REAL zero
122  parameter ( zero = 0.0e+0 )
123 * ..
124 * .. Local Scalars ..
125  INTEGER i, ix, j
126  REAL diffnm, eps, xnorm
127 * ..
128 * .. External Functions ..
129  INTEGER isamax
130  REAL slamch
131  EXTERNAL isamax, slamch
132 * ..
133 * .. Intrinsic Functions ..
134  INTRINSIC abs, max
135 * ..
136 * .. Executable Statements ..
137 *
138 * Quick exit if N = 0 or NRHS = 0.
139 *
140  IF( n.LE.0 .OR. nrhs.LE.0 ) THEN
141  resid = zero
142  RETURN
143  END IF
144 *
145 * Exit with RESID = 1/EPS if RCOND is invalid.
146 *
147  eps = slamch( 'Epsilon' )
148  IF( rcond.LT.zero ) THEN
149  resid = 1.0 / eps
150  RETURN
151  END IF
152 *
153 * Compute the maximum of
154 * norm(X - XACT) / ( norm(XACT) * EPS )
155 * over all the vectors X and XACT .
156 *
157  resid = zero
158  DO 20 j = 1, nrhs
159  ix = isamax( n, xact( 1, j ), 1 )
160  xnorm = abs( xact( ix, j ) )
161  diffnm = zero
162  DO 10 i = 1, n
163  diffnm = max( diffnm, abs( x( i, j )-xact( i, j ) ) )
164  10 CONTINUE
165  IF( xnorm.LE.zero ) THEN
166  IF( diffnm.GT.zero )
167  $ resid = 1.0 / eps
168  ELSE
169  resid = max( resid, ( diffnm / xnorm )*rcond )
170  END IF
171  20 CONTINUE
172  IF( resid*eps.LT.1.0 )
173  $ resid = resid / eps
174 *
175  RETURN
176 *
177 * End of SGET04
178 *
integer function isamax(N, SX, INCX)
ISAMAX
Definition: isamax.f:53
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:69

Here is the caller graph for this function: