1 SUBROUTINE DTBT05( 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 DOUBLE PRECISION AB( LDAB, * ), B( LDB, * ), BERR( * ),
14 $ FERR( * ), RESLTS( * ), X( LDX, * ),
15 $ XACT( LDXACT, * )
16 * ..
17 *
18 * Purpose
19 * =======
20 *
21 * DTBT05 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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 DOUBLE PRECISION ZERO, ONE
119 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
120 * ..
121 * .. Local Scalars ..
122 LOGICAL NOTRAN, UNIT, UPPER
123 INTEGER I, IFU, IMAX, J, K, NZ
124 DOUBLE PRECISION AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM
125 * ..
126 * .. External Functions ..
127 LOGICAL LSAME
128 INTEGER IDAMAX
129 DOUBLE PRECISION DLAMCH
130 EXTERNAL LSAME, IDAMAX, DLAMCH
131 * ..
132 * .. Intrinsic Functions ..
133 INTRINSIC ABS, MAX, MIN
134 * ..
135 * .. Executable Statements ..
136 *
137 * Quick exit if N = 0 or NRHS = 0.
138 *
139 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
140 RESLTS( 1 ) = ZERO
141 RESLTS( 2 ) = ZERO
142 RETURN
143 END IF
144 *
145 EPS = DLAMCH( 'Epsilon' )
146 UNFL = DLAMCH( 'Safe minimum' )
147 OVFL = ONE / UNFL
148 UPPER = LSAME( UPLO, 'U' )
149 NOTRAN = LSAME( TRANS, 'N' )
150 UNIT = LSAME( DIAG, 'U' )
151 NZ = MIN( KD, N-1 ) + 1
152 *
153 * Test 1: Compute the maximum of
154 * norm(X - XACT) / ( norm(X) * FERR )
155 * over all the vectors X and XACT using the infinity-norm.
156 *
157 ERRBND = ZERO
158 DO 30 J = 1, NRHS
159 IMAX = IDAMAX( N, X( 1, J ), 1 )
160 XNORM = MAX( ABS( X( IMAX, J ) ), UNFL )
161 DIFF = ZERO
162 DO 10 I = 1, N
163 DIFF = MAX( DIFF, ABS( X( I, J )-XACT( I, J ) ) )
164 10 CONTINUE
165 *
166 IF( XNORM.GT.ONE ) THEN
167 GO TO 20
168 ELSE IF( DIFF.LE.OVFL*XNORM ) THEN
169 GO TO 20
170 ELSE
171 ERRBND = ONE / EPS
172 GO TO 30
173 END IF
174 *
175 20 CONTINUE
176 IF( DIFF / XNORM.LE.FERR( J ) ) THEN
177 ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) )
178 ELSE
179 ERRBND = ONE / EPS
180 END IF
181 30 CONTINUE
182 RESLTS( 1 ) = ERRBND
183 *
184 * Test 2: Compute the maximum of BERR / ( NZ*EPS + (*) ), where
185 * (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
186 *
187 IFU = 0
188 IF( UNIT )
189 $ IFU = 1
190 DO 90 K = 1, NRHS
191 DO 80 I = 1, N
192 TMP = ABS( B( I, K ) )
193 IF( UPPER ) THEN
194 IF( .NOT.NOTRAN ) THEN
195 DO 40 J = MAX( I-KD, 1 ), I - IFU
196 TMP = TMP + ABS( AB( KD+1-I+J, I ) )*
197 $ ABS( X( J, K ) )
198 40 CONTINUE
199 IF( UNIT )
200 $ TMP = TMP + ABS( X( I, K ) )
201 ELSE
202 IF( UNIT )
203 $ TMP = TMP + ABS( X( I, K ) )
204 DO 50 J = I + IFU, MIN( I+KD, N )
205 TMP = TMP + ABS( AB( KD+1+I-J, J ) )*
206 $ ABS( X( J, K ) )
207 50 CONTINUE
208 END IF
209 ELSE
210 IF( NOTRAN ) THEN
211 DO 60 J = MAX( I-KD, 1 ), I - IFU
212 TMP = TMP + ABS( AB( 1+I-J, J ) )*ABS( X( J, K ) )
213 60 CONTINUE
214 IF( UNIT )
215 $ TMP = TMP + ABS( X( I, K ) )
216 ELSE
217 IF( UNIT )
218 $ TMP = TMP + ABS( X( I, K ) )
219 DO 70 J = I + IFU, MIN( I+KD, N )
220 TMP = TMP + ABS( AB( 1+J-I, I ) )*ABS( X( J, K ) )
221 70 CONTINUE
222 END IF
223 END IF
224 IF( I.EQ.1 ) THEN
225 AXBI = TMP
226 ELSE
227 AXBI = MIN( AXBI, TMP )
228 END IF
229 80 CONTINUE
230 TMP = BERR( K ) / ( NZ*EPS+NZ*UNFL / MAX( AXBI, NZ*UNFL ) )
231 IF( K.EQ.1 ) THEN
232 RESLTS( 2 ) = TMP
233 ELSE
234 RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP )
235 END IF
236 90 CONTINUE
237 *
238 RETURN
239 *
240 * End of DTBT05
241 *
242 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 DOUBLE PRECISION AB( LDAB, * ), B( LDB, * ), BERR( * ),
14 $ FERR( * ), RESLTS( * ), X( LDX, * ),
15 $ XACT( LDXACT, * )
16 * ..
17 *
18 * Purpose
19 * =======
20 *
21 * DTBT05 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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 DOUBLE PRECISION ZERO, ONE
119 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
120 * ..
121 * .. Local Scalars ..
122 LOGICAL NOTRAN, UNIT, UPPER
123 INTEGER I, IFU, IMAX, J, K, NZ
124 DOUBLE PRECISION AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM
125 * ..
126 * .. External Functions ..
127 LOGICAL LSAME
128 INTEGER IDAMAX
129 DOUBLE PRECISION DLAMCH
130 EXTERNAL LSAME, IDAMAX, DLAMCH
131 * ..
132 * .. Intrinsic Functions ..
133 INTRINSIC ABS, MAX, MIN
134 * ..
135 * .. Executable Statements ..
136 *
137 * Quick exit if N = 0 or NRHS = 0.
138 *
139 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
140 RESLTS( 1 ) = ZERO
141 RESLTS( 2 ) = ZERO
142 RETURN
143 END IF
144 *
145 EPS = DLAMCH( 'Epsilon' )
146 UNFL = DLAMCH( 'Safe minimum' )
147 OVFL = ONE / UNFL
148 UPPER = LSAME( UPLO, 'U' )
149 NOTRAN = LSAME( TRANS, 'N' )
150 UNIT = LSAME( DIAG, 'U' )
151 NZ = MIN( KD, N-1 ) + 1
152 *
153 * Test 1: Compute the maximum of
154 * norm(X - XACT) / ( norm(X) * FERR )
155 * over all the vectors X and XACT using the infinity-norm.
156 *
157 ERRBND = ZERO
158 DO 30 J = 1, NRHS
159 IMAX = IDAMAX( N, X( 1, J ), 1 )
160 XNORM = MAX( ABS( X( IMAX, J ) ), UNFL )
161 DIFF = ZERO
162 DO 10 I = 1, N
163 DIFF = MAX( DIFF, ABS( X( I, J )-XACT( I, J ) ) )
164 10 CONTINUE
165 *
166 IF( XNORM.GT.ONE ) THEN
167 GO TO 20
168 ELSE IF( DIFF.LE.OVFL*XNORM ) THEN
169 GO TO 20
170 ELSE
171 ERRBND = ONE / EPS
172 GO TO 30
173 END IF
174 *
175 20 CONTINUE
176 IF( DIFF / XNORM.LE.FERR( J ) ) THEN
177 ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) )
178 ELSE
179 ERRBND = ONE / EPS
180 END IF
181 30 CONTINUE
182 RESLTS( 1 ) = ERRBND
183 *
184 * Test 2: Compute the maximum of BERR / ( NZ*EPS + (*) ), where
185 * (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
186 *
187 IFU = 0
188 IF( UNIT )
189 $ IFU = 1
190 DO 90 K = 1, NRHS
191 DO 80 I = 1, N
192 TMP = ABS( B( I, K ) )
193 IF( UPPER ) THEN
194 IF( .NOT.NOTRAN ) THEN
195 DO 40 J = MAX( I-KD, 1 ), I - IFU
196 TMP = TMP + ABS( AB( KD+1-I+J, I ) )*
197 $ ABS( X( J, K ) )
198 40 CONTINUE
199 IF( UNIT )
200 $ TMP = TMP + ABS( X( I, K ) )
201 ELSE
202 IF( UNIT )
203 $ TMP = TMP + ABS( X( I, K ) )
204 DO 50 J = I + IFU, MIN( I+KD, N )
205 TMP = TMP + ABS( AB( KD+1+I-J, J ) )*
206 $ ABS( X( J, K ) )
207 50 CONTINUE
208 END IF
209 ELSE
210 IF( NOTRAN ) THEN
211 DO 60 J = MAX( I-KD, 1 ), I - IFU
212 TMP = TMP + ABS( AB( 1+I-J, J ) )*ABS( X( J, K ) )
213 60 CONTINUE
214 IF( UNIT )
215 $ TMP = TMP + ABS( X( I, K ) )
216 ELSE
217 IF( UNIT )
218 $ TMP = TMP + ABS( X( I, K ) )
219 DO 70 J = I + IFU, MIN( I+KD, N )
220 TMP = TMP + ABS( AB( 1+J-I, I ) )*ABS( X( J, K ) )
221 70 CONTINUE
222 END IF
223 END IF
224 IF( I.EQ.1 ) THEN
225 AXBI = TMP
226 ELSE
227 AXBI = MIN( AXBI, TMP )
228 END IF
229 80 CONTINUE
230 TMP = BERR( K ) / ( NZ*EPS+NZ*UNFL / MAX( AXBI, NZ*UNFL ) )
231 IF( K.EQ.1 ) THEN
232 RESLTS( 2 ) = TMP
233 ELSE
234 RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP )
235 END IF
236 90 CONTINUE
237 *
238 RETURN
239 *
240 * End of DTBT05
241 *
242 END