1 SUBROUTINE CTBT05( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, B,
2 $ LDB, X, LDX, XACT, 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 DIAG, TRANS, UPLO
10 INTEGER KD, LDAB, LDB, LDX, LDXACT, N, NRHS
11 * ..
12 * .. Array Arguments ..
13 REAL BERR( * ), FERR( * ), RESLTS( * )
14 COMPLEX AB( LDAB, * ), B( LDB, * ), X( LDX, * ),
15 $ XACT( LDXACT, * )
16 * ..
17 *
18 * Purpose
19 * =======
20 *
21 * CTBT05 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 * triangular band 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 / ( NZ*EPS + (*) ), where
32 * (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
33 * and NZ = max. number of nonzeros in any row of A, plus 1
34 *
35 * Arguments
36 * =========
37 *
38 * UPLO (input) CHARACTER*1
39 * Specifies whether the matrix A is upper or lower triangular.
40 * = 'U': Upper triangular
41 * = 'L': Lower triangular
42 *
43 * TRANS (input) CHARACTER*1
44 * Specifies the form of the system of equations.
45 * = 'N': A * X = B (No transpose)
46 * = 'T': A'* X = B (Transpose)
47 * = 'C': A'* X = B (Conjugate transpose = Transpose)
48 *
49 * DIAG (input) CHARACTER*1
50 * Specifies whether or not the matrix A is unit triangular.
51 * = 'N': Non-unit triangular
52 * = 'U': Unit triangular
53 *
54 * N (input) INTEGER
55 * The number of rows of the matrices X, B, and XACT, and the
56 * order of the matrix A. N >= 0.
57 *
58 * KD (input) INTEGER
59 * The number of super-diagonals of the matrix A if UPLO = 'U',
60 * or the number of sub-diagonals if UPLO = 'L'. KD >= 0.
61 *
62 * NRHS (input) INTEGER
63 * The number of columns of the matrices X, B, and XACT.
64 * NRHS >= 0.
65 *
66 * AB (input) COMPLEX array, dimension (LDAB,N)
67 * The upper or lower triangular band matrix A, stored in the
68 * first kd+1 rows of the array. The j-th column of A is stored
69 * in the j-th column of the array AB as follows:
70 * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
71 * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
72 * If DIAG = 'U', the diagonal elements of A are not referenced
73 * and are assumed to be 1.
74 *
75 * LDAB (input) INTEGER
76 * The leading dimension of the array AB. LDAB >= KD+1.
77 *
78 * B (input) COMPLEX array, dimension (LDB,NRHS)
79 * The right hand side vectors for the system of linear
80 * equations.
81 *
82 * LDB (input) INTEGER
83 * The leading dimension of the array B. LDB >= max(1,N).
84 *
85 * X (input) COMPLEX array, dimension (LDX,NRHS)
86 * The computed solution vectors. Each vector is stored as a
87 * column of the matrix X.
88 *
89 * LDX (input) INTEGER
90 * The leading dimension of the array X. LDX >= max(1,N).
91 *
92 * XACT (input) COMPLEX array, dimension (LDX,NRHS)
93 * The exact solution vectors. Each vector is stored as a
94 * column of the matrix XACT.
95 *
96 * LDXACT (input) INTEGER
97 * The leading dimension of the array XACT. LDXACT >= max(1,N).
98 *
99 * FERR (input) REAL array, dimension (NRHS)
100 * The estimated forward error bounds for each solution vector
101 * X. If XTRUE is the true solution, FERR bounds the magnitude
102 * of the largest entry in (X - XTRUE) divided by the magnitude
103 * of the largest entry in X.
104 *
105 * BERR (input) REAL array, dimension (NRHS)
106 * The componentwise relative backward error of each solution
107 * vector (i.e., the smallest relative change in any entry of A
108 * or B that makes X an exact solution).
109 *
110 * RESLTS (output) REAL array, dimension (2)
111 * The maximum over the NRHS solution vectors of the ratios:
112 * RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR )
113 * RESLTS(2) = BERR / ( NZ*EPS + (*) )
114 *
115 * =====================================================================
116 *
117 * .. Parameters ..
118 REAL ZERO, ONE
119 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
120 * ..
121 * .. Local Scalars ..
122 LOGICAL NOTRAN, UNIT, UPPER
123 INTEGER I, IFU, IMAX, J, K, NZ
124 REAL AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM
125 COMPLEX ZDUM
126 * ..
127 * .. External Functions ..
128 LOGICAL LSAME
129 INTEGER ICAMAX
130 REAL SLAMCH
131 EXTERNAL LSAME, ICAMAX, SLAMCH
132 * ..
133 * .. Intrinsic Functions ..
134 INTRINSIC ABS, AIMAG, MAX, MIN, REAL
135 * ..
136 * .. Statement Functions ..
137 REAL CABS1
138 * ..
139 * .. Statement Function definitions ..
140 CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
141 * ..
142 * .. Executable Statements ..
143 *
144 * Quick exit if N = 0 or NRHS = 0.
145 *
146 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
147 RESLTS( 1 ) = ZERO
148 RESLTS( 2 ) = ZERO
149 RETURN
150 END IF
151 *
152 EPS = SLAMCH( 'Epsilon' )
153 UNFL = SLAMCH( 'Safe minimum' )
154 OVFL = ONE / UNFL
155 UPPER = LSAME( UPLO, 'U' )
156 NOTRAN = LSAME( TRANS, 'N' )
157 UNIT = LSAME( DIAG, 'U' )
158 NZ = MIN( KD, N-1 ) + 1
159 *
160 * Test 1: Compute the maximum of
161 * norm(X - XACT) / ( norm(X) * FERR )
162 * over all the vectors X and XACT using the infinity-norm.
163 *
164 ERRBND = ZERO
165 DO 30 J = 1, NRHS
166 IMAX = ICAMAX( N, X( 1, J ), 1 )
167 XNORM = MAX( CABS1( X( IMAX, J ) ), UNFL )
168 DIFF = ZERO
169 DO 10 I = 1, N
170 DIFF = MAX( DIFF, CABS1( X( I, J )-XACT( I, J ) ) )
171 10 CONTINUE
172 *
173 IF( XNORM.GT.ONE ) THEN
174 GO TO 20
175 ELSE IF( DIFF.LE.OVFL*XNORM ) THEN
176 GO TO 20
177 ELSE
178 ERRBND = ONE / EPS
179 GO TO 30
180 END IF
181 *
182 20 CONTINUE
183 IF( DIFF / XNORM.LE.FERR( J ) ) THEN
184 ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) )
185 ELSE
186 ERRBND = ONE / EPS
187 END IF
188 30 CONTINUE
189 RESLTS( 1 ) = ERRBND
190 *
191 * Test 2: Compute the maximum of BERR / ( NZ*EPS + (*) ), where
192 * (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
193 *
194 IFU = 0
195 IF( UNIT )
196 $ IFU = 1
197 DO 90 K = 1, NRHS
198 DO 80 I = 1, N
199 TMP = CABS1( B( I, K ) )
200 IF( UPPER ) THEN
201 IF( .NOT.NOTRAN ) THEN
202 DO 40 J = MAX( I-KD, 1 ), I - IFU
203 TMP = TMP + CABS1( AB( KD+1-I+J, I ) )*
204 $ CABS1( X( J, K ) )
205 40 CONTINUE
206 IF( UNIT )
207 $ TMP = TMP + CABS1( X( I, K ) )
208 ELSE
209 IF( UNIT )
210 $ TMP = TMP + CABS1( X( I, K ) )
211 DO 50 J = I + IFU, MIN( I+KD, N )
212 TMP = TMP + CABS1( AB( KD+1+I-J, J ) )*
213 $ CABS1( X( J, K ) )
214 50 CONTINUE
215 END IF
216 ELSE
217 IF( NOTRAN ) THEN
218 DO 60 J = MAX( I-KD, 1 ), I - IFU
219 TMP = TMP + CABS1( AB( 1+I-J, J ) )*
220 $ CABS1( X( J, K ) )
221 60 CONTINUE
222 IF( UNIT )
223 $ TMP = TMP + CABS1( X( I, K ) )
224 ELSE
225 IF( UNIT )
226 $ TMP = TMP + CABS1( X( I, K ) )
227 DO 70 J = I + IFU, MIN( I+KD, N )
228 TMP = TMP + CABS1( AB( 1+J-I, I ) )*
229 $ CABS1( X( J, K ) )
230 70 CONTINUE
231 END IF
232 END IF
233 IF( I.EQ.1 ) THEN
234 AXBI = TMP
235 ELSE
236 AXBI = MIN( AXBI, TMP )
237 END IF
238 80 CONTINUE
239 TMP = BERR( K ) / ( NZ*EPS+NZ*UNFL / MAX( AXBI, NZ*UNFL ) )
240 IF( K.EQ.1 ) THEN
241 RESLTS( 2 ) = TMP
242 ELSE
243 RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP )
244 END IF
245 90 CONTINUE
246 *
247 RETURN
248 *
249 * End of CTBT05
250 *
251 END
2 $ LDB, X, LDX, XACT, 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 DIAG, TRANS, UPLO
10 INTEGER KD, LDAB, LDB, LDX, LDXACT, N, NRHS
11 * ..
12 * .. Array Arguments ..
13 REAL BERR( * ), FERR( * ), RESLTS( * )
14 COMPLEX AB( LDAB, * ), B( LDB, * ), X( LDX, * ),
15 $ XACT( LDXACT, * )
16 * ..
17 *
18 * Purpose
19 * =======
20 *
21 * CTBT05 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 * triangular band 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 / ( NZ*EPS + (*) ), where
32 * (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
33 * and NZ = max. number of nonzeros in any row of A, plus 1
34 *
35 * Arguments
36 * =========
37 *
38 * UPLO (input) CHARACTER*1
39 * Specifies whether the matrix A is upper or lower triangular.
40 * = 'U': Upper triangular
41 * = 'L': Lower triangular
42 *
43 * TRANS (input) CHARACTER*1
44 * Specifies the form of the system of equations.
45 * = 'N': A * X = B (No transpose)
46 * = 'T': A'* X = B (Transpose)
47 * = 'C': A'* X = B (Conjugate transpose = Transpose)
48 *
49 * DIAG (input) CHARACTER*1
50 * Specifies whether or not the matrix A is unit triangular.
51 * = 'N': Non-unit triangular
52 * = 'U': Unit triangular
53 *
54 * N (input) INTEGER
55 * The number of rows of the matrices X, B, and XACT, and the
56 * order of the matrix A. N >= 0.
57 *
58 * KD (input) INTEGER
59 * The number of super-diagonals of the matrix A if UPLO = 'U',
60 * or the number of sub-diagonals if UPLO = 'L'. KD >= 0.
61 *
62 * NRHS (input) INTEGER
63 * The number of columns of the matrices X, B, and XACT.
64 * NRHS >= 0.
65 *
66 * AB (input) COMPLEX array, dimension (LDAB,N)
67 * The upper or lower triangular band matrix A, stored in the
68 * first kd+1 rows of the array. The j-th column of A is stored
69 * in the j-th column of the array AB as follows:
70 * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
71 * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
72 * If DIAG = 'U', the diagonal elements of A are not referenced
73 * and are assumed to be 1.
74 *
75 * LDAB (input) INTEGER
76 * The leading dimension of the array AB. LDAB >= KD+1.
77 *
78 * B (input) COMPLEX array, dimension (LDB,NRHS)
79 * The right hand side vectors for the system of linear
80 * equations.
81 *
82 * LDB (input) INTEGER
83 * The leading dimension of the array B. LDB >= max(1,N).
84 *
85 * X (input) COMPLEX array, dimension (LDX,NRHS)
86 * The computed solution vectors. Each vector is stored as a
87 * column of the matrix X.
88 *
89 * LDX (input) INTEGER
90 * The leading dimension of the array X. LDX >= max(1,N).
91 *
92 * XACT (input) COMPLEX array, dimension (LDX,NRHS)
93 * The exact solution vectors. Each vector is stored as a
94 * column of the matrix XACT.
95 *
96 * LDXACT (input) INTEGER
97 * The leading dimension of the array XACT. LDXACT >= max(1,N).
98 *
99 * FERR (input) REAL array, dimension (NRHS)
100 * The estimated forward error bounds for each solution vector
101 * X. If XTRUE is the true solution, FERR bounds the magnitude
102 * of the largest entry in (X - XTRUE) divided by the magnitude
103 * of the largest entry in X.
104 *
105 * BERR (input) REAL array, dimension (NRHS)
106 * The componentwise relative backward error of each solution
107 * vector (i.e., the smallest relative change in any entry of A
108 * or B that makes X an exact solution).
109 *
110 * RESLTS (output) REAL array, dimension (2)
111 * The maximum over the NRHS solution vectors of the ratios:
112 * RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR )
113 * RESLTS(2) = BERR / ( NZ*EPS + (*) )
114 *
115 * =====================================================================
116 *
117 * .. Parameters ..
118 REAL ZERO, ONE
119 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
120 * ..
121 * .. Local Scalars ..
122 LOGICAL NOTRAN, UNIT, UPPER
123 INTEGER I, IFU, IMAX, J, K, NZ
124 REAL AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM
125 COMPLEX ZDUM
126 * ..
127 * .. External Functions ..
128 LOGICAL LSAME
129 INTEGER ICAMAX
130 REAL SLAMCH
131 EXTERNAL LSAME, ICAMAX, SLAMCH
132 * ..
133 * .. Intrinsic Functions ..
134 INTRINSIC ABS, AIMAG, MAX, MIN, REAL
135 * ..
136 * .. Statement Functions ..
137 REAL CABS1
138 * ..
139 * .. Statement Function definitions ..
140 CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
141 * ..
142 * .. Executable Statements ..
143 *
144 * Quick exit if N = 0 or NRHS = 0.
145 *
146 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
147 RESLTS( 1 ) = ZERO
148 RESLTS( 2 ) = ZERO
149 RETURN
150 END IF
151 *
152 EPS = SLAMCH( 'Epsilon' )
153 UNFL = SLAMCH( 'Safe minimum' )
154 OVFL = ONE / UNFL
155 UPPER = LSAME( UPLO, 'U' )
156 NOTRAN = LSAME( TRANS, 'N' )
157 UNIT = LSAME( DIAG, 'U' )
158 NZ = MIN( KD, N-1 ) + 1
159 *
160 * Test 1: Compute the maximum of
161 * norm(X - XACT) / ( norm(X) * FERR )
162 * over all the vectors X and XACT using the infinity-norm.
163 *
164 ERRBND = ZERO
165 DO 30 J = 1, NRHS
166 IMAX = ICAMAX( N, X( 1, J ), 1 )
167 XNORM = MAX( CABS1( X( IMAX, J ) ), UNFL )
168 DIFF = ZERO
169 DO 10 I = 1, N
170 DIFF = MAX( DIFF, CABS1( X( I, J )-XACT( I, J ) ) )
171 10 CONTINUE
172 *
173 IF( XNORM.GT.ONE ) THEN
174 GO TO 20
175 ELSE IF( DIFF.LE.OVFL*XNORM ) THEN
176 GO TO 20
177 ELSE
178 ERRBND = ONE / EPS
179 GO TO 30
180 END IF
181 *
182 20 CONTINUE
183 IF( DIFF / XNORM.LE.FERR( J ) ) THEN
184 ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) )
185 ELSE
186 ERRBND = ONE / EPS
187 END IF
188 30 CONTINUE
189 RESLTS( 1 ) = ERRBND
190 *
191 * Test 2: Compute the maximum of BERR / ( NZ*EPS + (*) ), where
192 * (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
193 *
194 IFU = 0
195 IF( UNIT )
196 $ IFU = 1
197 DO 90 K = 1, NRHS
198 DO 80 I = 1, N
199 TMP = CABS1( B( I, K ) )
200 IF( UPPER ) THEN
201 IF( .NOT.NOTRAN ) THEN
202 DO 40 J = MAX( I-KD, 1 ), I - IFU
203 TMP = TMP + CABS1( AB( KD+1-I+J, I ) )*
204 $ CABS1( X( J, K ) )
205 40 CONTINUE
206 IF( UNIT )
207 $ TMP = TMP + CABS1( X( I, K ) )
208 ELSE
209 IF( UNIT )
210 $ TMP = TMP + CABS1( X( I, K ) )
211 DO 50 J = I + IFU, MIN( I+KD, N )
212 TMP = TMP + CABS1( AB( KD+1+I-J, J ) )*
213 $ CABS1( X( J, K ) )
214 50 CONTINUE
215 END IF
216 ELSE
217 IF( NOTRAN ) THEN
218 DO 60 J = MAX( I-KD, 1 ), I - IFU
219 TMP = TMP + CABS1( AB( 1+I-J, J ) )*
220 $ CABS1( X( J, K ) )
221 60 CONTINUE
222 IF( UNIT )
223 $ TMP = TMP + CABS1( X( I, K ) )
224 ELSE
225 IF( UNIT )
226 $ TMP = TMP + CABS1( X( I, K ) )
227 DO 70 J = I + IFU, MIN( I+KD, N )
228 TMP = TMP + CABS1( AB( 1+J-I, I ) )*
229 $ CABS1( X( J, K ) )
230 70 CONTINUE
231 END IF
232 END IF
233 IF( I.EQ.1 ) THEN
234 AXBI = TMP
235 ELSE
236 AXBI = MIN( AXBI, TMP )
237 END IF
238 80 CONTINUE
239 TMP = BERR( K ) / ( NZ*EPS+NZ*UNFL / MAX( AXBI, NZ*UNFL ) )
240 IF( K.EQ.1 ) THEN
241 RESLTS( 2 ) = TMP
242 ELSE
243 RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP )
244 END IF
245 90 CONTINUE
246 *
247 RETURN
248 *
249 * End of CTBT05
250 *
251 END