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