1 SUBROUTINE ZPOT05( 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 DOUBLE PRECISION BERR( * ), FERR( * ), RESLTS( * )
14 COMPLEX*16 A( LDA, * ), B( LDB, * ), X( LDX, * ),
15 $ XACT( LDXACT, * )
16 * ..
17 *
18 * Purpose
19 * =======
20 *
21 * ZPOT05 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*16 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*16 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*16 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*16 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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 DOUBLE PRECISION ZERO, ONE
104 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
105 * ..
106 * .. Local Scalars ..
107 LOGICAL UPPER
108 INTEGER I, IMAX, J, K
109 DOUBLE PRECISION AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM
110 COMPLEX*16 ZDUM
111 * ..
112 * .. External Functions ..
113 LOGICAL LSAME
114 INTEGER IZAMAX
115 DOUBLE PRECISION DLAMCH
116 EXTERNAL LSAME, IZAMAX, DLAMCH
117 * ..
118 * .. Intrinsic Functions ..
119 INTRINSIC ABS, DBLE, DIMAG, MAX, MIN
120 * ..
121 * .. Statement Functions ..
122 DOUBLE PRECISION CABS1
123 * ..
124 * .. Statement Function definitions ..
125 CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( 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 = DLAMCH( 'Epsilon' )
138 UNFL = DLAMCH( '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 = IZAMAX( 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( DBLE( 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( DBLE( 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 ZPOT05
214 *
215 END
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 DOUBLE PRECISION BERR( * ), FERR( * ), RESLTS( * )
14 COMPLEX*16 A( LDA, * ), B( LDB, * ), X( LDX, * ),
15 $ XACT( LDXACT, * )
16 * ..
17 *
18 * Purpose
19 * =======
20 *
21 * ZPOT05 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*16 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*16 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*16 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*16 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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 DOUBLE PRECISION ZERO, ONE
104 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
105 * ..
106 * .. Local Scalars ..
107 LOGICAL UPPER
108 INTEGER I, IMAX, J, K
109 DOUBLE PRECISION AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM
110 COMPLEX*16 ZDUM
111 * ..
112 * .. External Functions ..
113 LOGICAL LSAME
114 INTEGER IZAMAX
115 DOUBLE PRECISION DLAMCH
116 EXTERNAL LSAME, IZAMAX, DLAMCH
117 * ..
118 * .. Intrinsic Functions ..
119 INTRINSIC ABS, DBLE, DIMAG, MAX, MIN
120 * ..
121 * .. Statement Functions ..
122 DOUBLE PRECISION CABS1
123 * ..
124 * .. Statement Function definitions ..
125 CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( 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 = DLAMCH( 'Epsilon' )
138 UNFL = DLAMCH( '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 = IZAMAX( 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( DBLE( 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( DBLE( 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 ZPOT05
214 *
215 END