PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
sget04.f
Go to the documentation of this file.
1  SUBROUTINE sget04( N, NRHS, X, LDX, XACT, LDXACT, RCOND, RESID )
2 *
3 * -- LAPACK test routine (version 3.1) --
4 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
5 * November 2006
6 *
7 * .. Scalar Arguments ..
8  INTEGER ldx, ldxact, n, nrhs
9  REAL rcond, resid
10 * ..
11 * .. Array Arguments ..
12  REAL x( ldx, * ), xact( ldxact, * )
13 * ..
14 *
15 * Purpose
16 * =======
17 *
18 * SGET04 computes the difference between a computed solution and the
19 * true solution to a system of linear equations.
20 *
21 * RESID = ( norm(X-XACT) * RCOND ) / ( norm(XACT) * EPS ),
22 * where RCOND is the reciprocal of the condition number and EPS is the
23 * machine epsilon.
24 *
25 * Arguments
26 * =========
27 *
28 * N (input) INTEGER
29 * The number of rows of the matrices X and XACT. N >= 0.
30 *
31 * NRHS (input) INTEGER
32 * The number of columns of the matrices X and XACT. NRHS >= 0.
33 *
34 * X (input) REAL array, dimension (LDX,NRHS)
35 * The computed solution vectors. Each vector is stored as a
36 * column of the matrix X.
37 *
38 * LDX (input) INTEGER
39 * The leading dimension of the array X. LDX >= max(1,N).
40 *
41 * XACT (input) REAL array, dimension( LDX, NRHS )
42 * The exact solution vectors. Each vector is stored as a
43 * column of the matrix XACT.
44 *
45 * LDXACT (input) INTEGER
46 * The leading dimension of the array XACT. LDXACT >= max(1,N).
47 *
48 * RCOND (input) REAL
49 * The reciprocal of the condition number of the coefficient
50 * matrix in the system of equations.
51 *
52 * RESID (output) REAL
53 * The maximum over the NRHS solution vectors of
54 * ( norm(X-XACT) * RCOND ) / ( norm(XACT) * EPS )
55 *
56 * =====================================================================
57 *
58 * .. Parameters ..
59  REAL zero
60  parameter( zero = 0.0e+0 )
61 * ..
62 * .. Local Scalars ..
63  INTEGER i, ix, j
64  REAL diffnm, eps, xnorm
65 * ..
66 * .. External Functions ..
67  INTEGER isamax
68  REAL slamch
69  EXTERNAL isamax, slamch
70 * ..
71 * .. Intrinsic Functions ..
72  INTRINSIC abs, max
73 * ..
74 * .. Executable Statements ..
75 *
76 * Quick exit if N = 0 or NRHS = 0.
77 *
78  IF( n.LE.0 .OR. nrhs.LE.0 ) THEN
79  resid = zero
80  return
81  END IF
82 *
83 * Exit with RESID = 1/EPS if RCOND is invalid.
84 *
85  eps = slamch( 'Epsilon' )
86  IF( rcond.LT.zero ) THEN
87  resid = 1.0 / eps
88  return
89  END IF
90 *
91 * Compute the maximum of
92 * norm(X - XACT) / ( norm(XACT) * EPS )
93 * over all the vectors X and XACT .
94 *
95  resid = zero
96  DO 20 j = 1, nrhs
97  ix = isamax( n, xact( 1, j ), 1 )
98  xnorm = abs( xact( ix, j ) )
99  diffnm = zero
100  DO 10 i = 1, n
101  diffnm = max( diffnm, abs( x( i, j )-xact( i, j ) ) )
102  10 continue
103  IF( xnorm.LE.zero ) THEN
104  IF( diffnm.GT.zero )
105  $ resid = 1.0 / eps
106  ELSE
107  resid = max( resid, ( diffnm / xnorm )*rcond )
108  END IF
109  20 continue
110  IF( resid*eps.LT.1.0 )
111  $ resid = resid / eps
112 *
113  return
114 *
115 * End of SGET04
116 *
117  END