1 SUBROUTINE CPTT05( N, NRHS, D, E, B, LDB, X, LDX, XACT, LDXACT,
2 $ 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 INTEGER LDB, LDX, LDXACT, N, NRHS
10 * ..
11 * .. Array Arguments ..
12 REAL BERR( * ), D( * ), FERR( * ), RESLTS( * )
13 COMPLEX B( LDB, * ), E( * ), X( LDX, * ),
14 $ XACT( LDXACT, * )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * CPTT05 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 * Hermitian tridiagonal matrix of order n.
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 / ( NZ*EPS + (*) ), where
31 * (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
32 * and NZ = max. number of nonzeros in any row of A, plus 1
33 *
34 * Arguments
35 * =========
36 *
37 * N (input) INTEGER
38 * The number of rows of the matrices X, B, and XACT, and the
39 * order of the matrix A. N >= 0.
40 *
41 * NRHS (input) INTEGER
42 * The number of columns of the matrices X, B, and XACT.
43 * NRHS >= 0.
44 *
45 * D (input) REAL array, dimension (N)
46 * The n diagonal elements of the tridiagonal matrix A.
47 *
48 * E (input) COMPLEX array, dimension (N-1)
49 * The (n-1) subdiagonal elements of the tridiagonal matrix A.
50 *
51 * B (input) COMPLEX array, dimension (LDB,NRHS)
52 * The right hand side vectors for the system of linear
53 * equations.
54 *
55 * LDB (input) INTEGER
56 * The leading dimension of the array B. LDB >= max(1,N).
57 *
58 * X (input) COMPLEX array, dimension (LDX,NRHS)
59 * The computed solution vectors. Each vector is stored as a
60 * column of the matrix X.
61 *
62 * LDX (input) INTEGER
63 * The leading dimension of the array X. LDX >= max(1,N).
64 *
65 * XACT (input) COMPLEX array, dimension (LDX,NRHS)
66 * The exact solution vectors. Each vector is stored as a
67 * column of the matrix XACT.
68 *
69 * LDXACT (input) INTEGER
70 * The leading dimension of the array XACT. LDXACT >= max(1,N).
71 *
72 * FERR (input) REAL array, dimension (NRHS)
73 * The estimated forward error bounds for each solution vector
74 * X. If XTRUE is the true solution, FERR bounds the magnitude
75 * of the largest entry in (X - XTRUE) divided by the magnitude
76 * of the largest entry in X.
77 *
78 * BERR (input) REAL array, dimension (NRHS)
79 * The componentwise relative backward error of each solution
80 * vector (i.e., the smallest relative change in any entry of A
81 * or B that makes X an exact solution).
82 *
83 * RESLTS (output) REAL array, dimension (2)
84 * The maximum over the NRHS solution vectors of the ratios:
85 * RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR )
86 * RESLTS(2) = BERR / ( NZ*EPS + (*) )
87 *
88 * =====================================================================
89 *
90 * .. Parameters ..
91 REAL ZERO, ONE
92 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
93 * ..
94 * .. Local Scalars ..
95 INTEGER I, IMAX, J, K, NZ
96 REAL AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM
97 COMPLEX ZDUM
98 * ..
99 * .. External Functions ..
100 INTEGER ICAMAX
101 REAL SLAMCH
102 EXTERNAL ICAMAX, SLAMCH
103 * ..
104 * .. Intrinsic Functions ..
105 INTRINSIC ABS, AIMAG, MAX, MIN, REAL
106 * ..
107 * .. Statement Functions ..
108 REAL CABS1
109 * ..
110 * .. Statement Function definitions ..
111 CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
112 * ..
113 * .. Executable Statements ..
114 *
115 * Quick exit if N = 0 or NRHS = 0.
116 *
117 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
118 RESLTS( 1 ) = ZERO
119 RESLTS( 2 ) = ZERO
120 RETURN
121 END IF
122 *
123 EPS = SLAMCH( 'Epsilon' )
124 UNFL = SLAMCH( 'Safe minimum' )
125 OVFL = ONE / UNFL
126 NZ = 4
127 *
128 * Test 1: Compute the maximum of
129 * norm(X - XACT) / ( norm(X) * FERR )
130 * over all the vectors X and XACT using the infinity-norm.
131 *
132 ERRBND = ZERO
133 DO 30 J = 1, NRHS
134 IMAX = ICAMAX( N, X( 1, J ), 1 )
135 XNORM = MAX( CABS1( X( IMAX, J ) ), UNFL )
136 DIFF = ZERO
137 DO 10 I = 1, N
138 DIFF = MAX( DIFF, CABS1( X( I, J )-XACT( I, J ) ) )
139 10 CONTINUE
140 *
141 IF( XNORM.GT.ONE ) THEN
142 GO TO 20
143 ELSE IF( DIFF.LE.OVFL*XNORM ) THEN
144 GO TO 20
145 ELSE
146 ERRBND = ONE / EPS
147 GO TO 30
148 END IF
149 *
150 20 CONTINUE
151 IF( DIFF / XNORM.LE.FERR( J ) ) THEN
152 ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) )
153 ELSE
154 ERRBND = ONE / EPS
155 END IF
156 30 CONTINUE
157 RESLTS( 1 ) = ERRBND
158 *
159 * Test 2: Compute the maximum of BERR / ( NZ*EPS + (*) ), where
160 * (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
161 *
162 DO 50 K = 1, NRHS
163 IF( N.EQ.1 ) THEN
164 AXBI = CABS1( B( 1, K ) ) + CABS1( D( 1 )*X( 1, K ) )
165 ELSE
166 AXBI = CABS1( B( 1, K ) ) + CABS1( D( 1 )*X( 1, K ) ) +
167 $ CABS1( E( 1 ) )*CABS1( X( 2, K ) )
168 DO 40 I = 2, N - 1
169 TMP = CABS1( B( I, K ) ) + CABS1( E( I-1 ) )*
170 $ CABS1( X( I-1, K ) ) + CABS1( D( I )*X( I, K ) ) +
171 $ CABS1( E( I ) )*CABS1( X( I+1, K ) )
172 AXBI = MIN( AXBI, TMP )
173 40 CONTINUE
174 TMP = CABS1( B( N, K ) ) + CABS1( E( N-1 ) )*
175 $ CABS1( X( N-1, K ) ) + CABS1( D( N )*X( N, K ) )
176 AXBI = MIN( AXBI, TMP )
177 END IF
178 TMP = BERR( K ) / ( NZ*EPS+NZ*UNFL / MAX( AXBI, NZ*UNFL ) )
179 IF( K.EQ.1 ) THEN
180 RESLTS( 2 ) = TMP
181 ELSE
182 RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP )
183 END IF
184 50 CONTINUE
185 *
186 RETURN
187 *
188 * End of CPTT05
189 *
190 END
2 $ 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 INTEGER LDB, LDX, LDXACT, N, NRHS
10 * ..
11 * .. Array Arguments ..
12 REAL BERR( * ), D( * ), FERR( * ), RESLTS( * )
13 COMPLEX B( LDB, * ), E( * ), X( LDX, * ),
14 $ XACT( LDXACT, * )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * CPTT05 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 * Hermitian tridiagonal matrix of order n.
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 / ( NZ*EPS + (*) ), where
31 * (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
32 * and NZ = max. number of nonzeros in any row of A, plus 1
33 *
34 * Arguments
35 * =========
36 *
37 * N (input) INTEGER
38 * The number of rows of the matrices X, B, and XACT, and the
39 * order of the matrix A. N >= 0.
40 *
41 * NRHS (input) INTEGER
42 * The number of columns of the matrices X, B, and XACT.
43 * NRHS >= 0.
44 *
45 * D (input) REAL array, dimension (N)
46 * The n diagonal elements of the tridiagonal matrix A.
47 *
48 * E (input) COMPLEX array, dimension (N-1)
49 * The (n-1) subdiagonal elements of the tridiagonal matrix A.
50 *
51 * B (input) COMPLEX array, dimension (LDB,NRHS)
52 * The right hand side vectors for the system of linear
53 * equations.
54 *
55 * LDB (input) INTEGER
56 * The leading dimension of the array B. LDB >= max(1,N).
57 *
58 * X (input) COMPLEX array, dimension (LDX,NRHS)
59 * The computed solution vectors. Each vector is stored as a
60 * column of the matrix X.
61 *
62 * LDX (input) INTEGER
63 * The leading dimension of the array X. LDX >= max(1,N).
64 *
65 * XACT (input) COMPLEX array, dimension (LDX,NRHS)
66 * The exact solution vectors. Each vector is stored as a
67 * column of the matrix XACT.
68 *
69 * LDXACT (input) INTEGER
70 * The leading dimension of the array XACT. LDXACT >= max(1,N).
71 *
72 * FERR (input) REAL array, dimension (NRHS)
73 * The estimated forward error bounds for each solution vector
74 * X. If XTRUE is the true solution, FERR bounds the magnitude
75 * of the largest entry in (X - XTRUE) divided by the magnitude
76 * of the largest entry in X.
77 *
78 * BERR (input) REAL array, dimension (NRHS)
79 * The componentwise relative backward error of each solution
80 * vector (i.e., the smallest relative change in any entry of A
81 * or B that makes X an exact solution).
82 *
83 * RESLTS (output) REAL array, dimension (2)
84 * The maximum over the NRHS solution vectors of the ratios:
85 * RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR )
86 * RESLTS(2) = BERR / ( NZ*EPS + (*) )
87 *
88 * =====================================================================
89 *
90 * .. Parameters ..
91 REAL ZERO, ONE
92 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
93 * ..
94 * .. Local Scalars ..
95 INTEGER I, IMAX, J, K, NZ
96 REAL AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM
97 COMPLEX ZDUM
98 * ..
99 * .. External Functions ..
100 INTEGER ICAMAX
101 REAL SLAMCH
102 EXTERNAL ICAMAX, SLAMCH
103 * ..
104 * .. Intrinsic Functions ..
105 INTRINSIC ABS, AIMAG, MAX, MIN, REAL
106 * ..
107 * .. Statement Functions ..
108 REAL CABS1
109 * ..
110 * .. Statement Function definitions ..
111 CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
112 * ..
113 * .. Executable Statements ..
114 *
115 * Quick exit if N = 0 or NRHS = 0.
116 *
117 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
118 RESLTS( 1 ) = ZERO
119 RESLTS( 2 ) = ZERO
120 RETURN
121 END IF
122 *
123 EPS = SLAMCH( 'Epsilon' )
124 UNFL = SLAMCH( 'Safe minimum' )
125 OVFL = ONE / UNFL
126 NZ = 4
127 *
128 * Test 1: Compute the maximum of
129 * norm(X - XACT) / ( norm(X) * FERR )
130 * over all the vectors X and XACT using the infinity-norm.
131 *
132 ERRBND = ZERO
133 DO 30 J = 1, NRHS
134 IMAX = ICAMAX( N, X( 1, J ), 1 )
135 XNORM = MAX( CABS1( X( IMAX, J ) ), UNFL )
136 DIFF = ZERO
137 DO 10 I = 1, N
138 DIFF = MAX( DIFF, CABS1( X( I, J )-XACT( I, J ) ) )
139 10 CONTINUE
140 *
141 IF( XNORM.GT.ONE ) THEN
142 GO TO 20
143 ELSE IF( DIFF.LE.OVFL*XNORM ) THEN
144 GO TO 20
145 ELSE
146 ERRBND = ONE / EPS
147 GO TO 30
148 END IF
149 *
150 20 CONTINUE
151 IF( DIFF / XNORM.LE.FERR( J ) ) THEN
152 ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) )
153 ELSE
154 ERRBND = ONE / EPS
155 END IF
156 30 CONTINUE
157 RESLTS( 1 ) = ERRBND
158 *
159 * Test 2: Compute the maximum of BERR / ( NZ*EPS + (*) ), where
160 * (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
161 *
162 DO 50 K = 1, NRHS
163 IF( N.EQ.1 ) THEN
164 AXBI = CABS1( B( 1, K ) ) + CABS1( D( 1 )*X( 1, K ) )
165 ELSE
166 AXBI = CABS1( B( 1, K ) ) + CABS1( D( 1 )*X( 1, K ) ) +
167 $ CABS1( E( 1 ) )*CABS1( X( 2, K ) )
168 DO 40 I = 2, N - 1
169 TMP = CABS1( B( I, K ) ) + CABS1( E( I-1 ) )*
170 $ CABS1( X( I-1, K ) ) + CABS1( D( I )*X( I, K ) ) +
171 $ CABS1( E( I ) )*CABS1( X( I+1, K ) )
172 AXBI = MIN( AXBI, TMP )
173 40 CONTINUE
174 TMP = CABS1( B( N, K ) ) + CABS1( E( N-1 ) )*
175 $ CABS1( X( N-1, K ) ) + CABS1( D( N )*X( N, K ) )
176 AXBI = MIN( AXBI, TMP )
177 END IF
178 TMP = BERR( K ) / ( NZ*EPS+NZ*UNFL / MAX( AXBI, NZ*UNFL ) )
179 IF( K.EQ.1 ) THEN
180 RESLTS( 2 ) = TMP
181 ELSE
182 RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP )
183 END IF
184 50 CONTINUE
185 *
186 RETURN
187 *
188 * End of CPTT05
189 *
190 END