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
zget04.f
Go to the documentation of this file.
1  SUBROUTINE zget04( 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  DOUBLE PRECISION rcond, resid
10 * ..
11 * .. Array Arguments ..
12  COMPLEX*16 x( ldx, * ), xact( ldxact, * )
13 * ..
14 *
15 * Purpose
16 * =======
17 *
18 * ZGET04 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) COMPLEX*16 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) COMPLEX*16 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) DOUBLE PRECISION
49 * The reciprocal of the condition number of the coefficient
50 * matrix in the system of equations.
51 *
52 * RESID (output) DOUBLE PRECISION
53 * The maximum over the NRHS solution vectors of
54 * ( norm(X-XACT) * RCOND ) / ( norm(XACT) * EPS )
55 *
56 * =====================================================================
57 *
58 * .. Parameters ..
59  DOUBLE PRECISION zero
60  parameter( zero = 0.0d+0 )
61 * ..
62 * .. Local Scalars ..
63  INTEGER i, ix, j
64  DOUBLE PRECISION diffnm, eps, xnorm
65  COMPLEX*16 zdum
66 * ..
67 * .. External Functions ..
68  INTEGER izamax
69  DOUBLE PRECISION dlamch
70  EXTERNAL izamax, dlamch
71 * ..
72 * .. Intrinsic Functions ..
73  INTRINSIC abs, dble, dimag, max
74 * ..
75 * .. Statement Functions ..
76  DOUBLE PRECISION cabs1
77 * ..
78 * .. Statement Function definitions ..
79  cabs1( zdum ) = abs( dble( zdum ) ) + abs( dimag( zdum ) )
80 * ..
81 * .. Executable Statements ..
82 *
83 * Quick exit if N = 0 or NRHS = 0.
84 *
85  IF( n.LE.0 .OR. nrhs.LE.0 ) THEN
86  resid = zero
87  return
88  END IF
89 *
90 * Exit with RESID = 1/EPS if RCOND is invalid.
91 *
92  eps = dlamch( 'Epsilon' )
93  IF( rcond.LT.zero ) THEN
94  resid = 1.0d0 / eps
95  return
96  END IF
97 *
98 * Compute the maximum of
99 * norm(X - XACT) / ( norm(XACT) * EPS )
100 * over all the vectors X and XACT .
101 *
102  resid = zero
103  DO 20 j = 1, nrhs
104  ix = izamax( n, xact( 1, j ), 1 )
105  xnorm = cabs1( xact( ix, j ) )
106  diffnm = zero
107  DO 10 i = 1, n
108  diffnm = max( diffnm, cabs1( x( i, j )-xact( i, j ) ) )
109  10 continue
110  IF( xnorm.LE.zero ) THEN
111  IF( diffnm.GT.zero )
112  $ resid = 1.0d0 / eps
113  ELSE
114  resid = max( resid, ( diffnm / xnorm )*rcond )
115  END IF
116  20 continue
117  IF( resid*eps.LT.1.0d0 )
118  $ resid = resid / eps
119 *
120  return
121 *
122 * End of ZGET04
123 *
124  END