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
spot05.f
Go to the documentation of this file.
1  SUBROUTINE spot05( UPLO, N, NRHS, A, LDA, B, LDB, X, LDX, XACT,
2  $ ldxact, ferr, berr, reslts )
3 *
4 * -- LAPACK test routine (version 3.1) --
5 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
6 * November 2006
7 *
8 * .. Scalar Arguments ..
9  CHARACTER uplo
10  INTEGER lda, ldb, ldx, ldxact, n, nrhs
11 * ..
12 * .. Array Arguments ..
13  REAL a( lda, * ), b( ldb, * ), berr( * ), ferr( * ),
14  $ reslts( * ), x( ldx, * ), xact( ldxact, * )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * SPOT05 tests the error bounds from iterative refinement for the
21 * computed solution to a system of equations A*X = B, where A is a
22 * symmetric n by n matrix.
23 *
24 * RESLTS(1) = test of the error bound
25 * = norm(X - XACT) / ( norm(X) * FERR )
26 *
27 * A large value is returned if this ratio is not less than one.
28 *
29 * RESLTS(2) = residual from the iterative refinement routine
30 * = the maximum of BERR / ( (n+1)*EPS + (*) ), where
31 * (*) = (n+1)*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
32 *
33 * Arguments
34 * =========
35 *
36 * UPLO (input) CHARACTER*1
37 * Specifies whether the upper or lower triangular part of the
38 * symmetric matrix A is stored.
39 * = 'U': Upper triangular
40 * = 'L': Lower triangular
41 *
42 * N (input) INTEGER
43 * The number of rows of the matrices X, B, and XACT, and the
44 * order of the matrix A. N >= 0.
45 *
46 * NRHS (input) INTEGER
47 * The number of columns of the matrices X, B, and XACT.
48 * NRHS >= 0.
49 *
50 * A (input) REAL array, dimension (LDA,N)
51 * The symmetric matrix A. If UPLO = 'U', the leading n by n
52 * upper triangular part of A contains the upper triangular part
53 * of the matrix A, and the strictly lower triangular part of A
54 * is not referenced. If UPLO = 'L', the leading n by n lower
55 * triangular part of A contains the lower triangular part of
56 * the matrix A, and the strictly upper triangular part of A is
57 * not referenced.
58 *
59 * LDA (input) INTEGER
60 * The leading dimension of the array A. LDA >= max(1,N).
61 *
62 * B (input) REAL array, dimension (LDB,NRHS)
63 * The right hand side vectors for the system of linear
64 * equations.
65 *
66 * LDB (input) INTEGER
67 * The leading dimension of the array B. LDB >= max(1,N).
68 *
69 * X (input) REAL array, dimension (LDX,NRHS)
70 * The computed solution vectors. Each vector is stored as a
71 * column of the matrix X.
72 *
73 * LDX (input) INTEGER
74 * The leading dimension of the array X. LDX >= max(1,N).
75 *
76 * XACT (input) REAL array, dimension (LDX,NRHS)
77 * The exact solution vectors. Each vector is stored as a
78 * column of the matrix XACT.
79 *
80 * LDXACT (input) INTEGER
81 * The leading dimension of the array XACT. LDXACT >= max(1,N).
82 *
83 * FERR (input) REAL array, dimension (NRHS)
84 * The estimated forward error bounds for each solution vector
85 * X. If XTRUE is the true solution, FERR bounds the magnitude
86 * of the largest entry in (X - XTRUE) divided by the magnitude
87 * of the largest entry in X.
88 *
89 * BERR (input) REAL array, dimension (NRHS)
90 * The componentwise relative backward error of each solution
91 * vector (i.e., the smallest relative change in any entry of A
92 * or B that makes X an exact solution).
93 *
94 * RESLTS (output) REAL array, dimension (2)
95 * The maximum over the NRHS solution vectors of the ratios:
96 * RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR )
97 * RESLTS(2) = BERR / ( (n+1)*EPS + (*) )
98 *
99 * =====================================================================
100 *
101 * .. Parameters ..
102  REAL zero, one
103  parameter( zero = 0.0e+0, one = 1.0e+0 )
104 * ..
105 * .. Local Scalars ..
106  LOGICAL upper
107  INTEGER i, imax, j, k
108  REAL axbi, diff, eps, errbnd, ovfl, tmp, unfl, xnorm
109 * ..
110 * .. External Functions ..
111  LOGICAL lsame
112  INTEGER isamax
113  REAL slamch
114  EXTERNAL lsame, isamax, slamch
115 * ..
116 * .. Intrinsic Functions ..
117  INTRINSIC abs, max, min
118 * ..
119 * .. Executable Statements ..
120 *
121 * Quick exit if N = 0 or NRHS = 0.
122 *
123  IF( n.LE.0 .OR. nrhs.LE.0 ) THEN
124  reslts( 1 ) = zero
125  reslts( 2 ) = zero
126  return
127  END IF
128 *
129  eps = slamch( 'Epsilon' )
130  unfl = slamch( 'Safe minimum' )
131  ovfl = one / unfl
132  upper = lsame( uplo, 'U' )
133 *
134 * Test 1: Compute the maximum of
135 * norm(X - XACT) / ( norm(X) * FERR )
136 * over all the vectors X and XACT using the infinity-norm.
137 *
138  errbnd = zero
139  DO 30 j = 1, nrhs
140  imax = isamax( n, x( 1, j ), 1 )
141  xnorm = max( abs( x( imax, j ) ), unfl )
142  diff = zero
143  DO 10 i = 1, n
144  diff = max( diff, abs( x( i, j )-xact( i, j ) ) )
145  10 continue
146 *
147  IF( xnorm.GT.one ) THEN
148  go to 20
149  ELSE IF( diff.LE.ovfl*xnorm ) THEN
150  go to 20
151  ELSE
152  errbnd = one / eps
153  go to 30
154  END IF
155 *
156  20 continue
157  IF( diff / xnorm.LE.ferr( j ) ) THEN
158  errbnd = max( errbnd, ( diff / xnorm ) / ferr( j ) )
159  ELSE
160  errbnd = one / eps
161  END IF
162  30 continue
163  reslts( 1 ) = errbnd
164 *
165 * Test 2: Compute the maximum of BERR / ( (n+1)*EPS + (*) ), where
166 * (*) = (n+1)*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
167 *
168  DO 90 k = 1, nrhs
169  DO 80 i = 1, n
170  tmp = abs( b( i, k ) )
171  IF( upper ) THEN
172  DO 40 j = 1, i
173  tmp = tmp + abs( a( j, i ) )*abs( x( j, k ) )
174  40 continue
175  DO 50 j = i + 1, n
176  tmp = tmp + abs( a( i, j ) )*abs( x( j, k ) )
177  50 continue
178  ELSE
179  DO 60 j = 1, i - 1
180  tmp = tmp + abs( a( i, j ) )*abs( x( j, k ) )
181  60 continue
182  DO 70 j = i, n
183  tmp = tmp + abs( a( j, i ) )*abs( x( j, k ) )
184  70 continue
185  END IF
186  IF( i.EQ.1 ) THEN
187  axbi = tmp
188  ELSE
189  axbi = min( axbi, tmp )
190  END IF
191  80 continue
192  tmp = berr( k ) / ( ( n+1 )*eps+( n+1 )*unfl /
193  $ max( axbi, ( n+1 )*unfl ) )
194  IF( k.EQ.1 ) THEN
195  reslts( 2 ) = tmp
196  ELSE
197  reslts( 2 ) = max( reslts( 2 ), tmp )
198  END IF
199  90 continue
200 *
201  return
202 *
203 * End of SPOT05
204 *
205  END