LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
stbt05.f
Go to the documentation of this file.
1 *> \brief \b STBT05
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * SUBROUTINE STBT05( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, B,
12 * LDB, X, LDX, XACT, LDXACT, FERR, BERR, RESLTS )
13 *
14 * .. Scalar Arguments ..
15 * CHARACTER DIAG, TRANS, UPLO
16 * INTEGER KD, LDAB, LDB, LDX, LDXACT, N, NRHS
17 * ..
18 * .. Array Arguments ..
19 * REAL AB( LDAB, * ), B( LDB, * ), BERR( * ),
20 * $ FERR( * ), RESLTS( * ), X( LDX, * ),
21 * $ XACT( LDXACT, * )
22 * ..
23 *
24 *
25 *> \par Purpose:
26 * =============
27 *>
28 *> \verbatim
29 *>
30 *> STBT05 tests the error bounds from iterative refinement for the
31 *> computed solution to a system of equations A*X = B, where A is a
32 *> triangular band matrix.
33 *>
34 *> RESLTS(1) = test of the error bound
35 *> = norm(X - XACT) / ( norm(X) * FERR )
36 *>
37 *> A large value is returned if this ratio is not less than one.
38 *>
39 *> RESLTS(2) = residual from the iterative refinement routine
40 *> = the maximum of BERR / ( NZ*EPS + (*) ), where
41 *> (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
42 *> and NZ = max. number of nonzeros in any row of A, plus 1
43 *> \endverbatim
44 *
45 * Arguments:
46 * ==========
47 *
48 *> \param[in] UPLO
49 *> \verbatim
50 *> UPLO is CHARACTER*1
51 *> Specifies whether the matrix A is upper or lower triangular.
52 *> = 'U': Upper triangular
53 *> = 'L': Lower triangular
54 *> \endverbatim
55 *>
56 *> \param[in] TRANS
57 *> \verbatim
58 *> TRANS is CHARACTER*1
59 *> Specifies the form of the system of equations.
60 *> = 'N': A * X = B (No transpose)
61 *> = 'T': A'* X = B (Transpose)
62 *> = 'C': A'* X = B (Conjugate transpose = Transpose)
63 *> \endverbatim
64 *>
65 *> \param[in] DIAG
66 *> \verbatim
67 *> DIAG is CHARACTER*1
68 *> Specifies whether or not the matrix A is unit triangular.
69 *> = 'N': Non-unit triangular
70 *> = 'U': Unit triangular
71 *> \endverbatim
72 *>
73 *> \param[in] N
74 *> \verbatim
75 *> N is INTEGER
76 *> The number of rows of the matrices X, B, and XACT, and the
77 *> order of the matrix A. N >= 0.
78 *> \endverbatim
79 *>
80 *> \param[in] KD
81 *> \verbatim
82 *> KD is INTEGER
83 *> The number of super-diagonals of the matrix A if UPLO = 'U',
84 *> or the number of sub-diagonals if UPLO = 'L'. KD >= 0.
85 *> \endverbatim
86 *>
87 *> \param[in] NRHS
88 *> \verbatim
89 *> NRHS is INTEGER
90 *> The number of columns of the matrices X, B, and XACT.
91 *> NRHS >= 0.
92 *> \endverbatim
93 *>
94 *> \param[in] AB
95 *> \verbatim
96 *> AB is REAL array, dimension (LDAB,N)
97 *> The upper or lower triangular band matrix A, stored in the
98 *> first kd+1 rows of the array. The j-th column of A is stored
99 *> in the j-th column of the array AB as follows:
100 *> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
101 *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
102 *> If DIAG = 'U', the diagonal elements of A are not referenced
103 *> and are assumed to be 1.
104 *> \endverbatim
105 *>
106 *> \param[in] LDAB
107 *> \verbatim
108 *> LDAB is INTEGER
109 *> The leading dimension of the array AB. LDAB >= KD+1.
110 *> \endverbatim
111 *>
112 *> \param[in] B
113 *> \verbatim
114 *> B is REAL array, dimension (LDB,NRHS)
115 *> The right hand side vectors for the system of linear
116 *> equations.
117 *> \endverbatim
118 *>
119 *> \param[in] LDB
120 *> \verbatim
121 *> LDB is INTEGER
122 *> The leading dimension of the array B. LDB >= max(1,N).
123 *> \endverbatim
124 *>
125 *> \param[in] X
126 *> \verbatim
127 *> X is REAL array, dimension (LDX,NRHS)
128 *> The computed solution vectors. Each vector is stored as a
129 *> column of the matrix X.
130 *> \endverbatim
131 *>
132 *> \param[in] LDX
133 *> \verbatim
134 *> LDX is INTEGER
135 *> The leading dimension of the array X. LDX >= max(1,N).
136 *> \endverbatim
137 *>
138 *> \param[in] XACT
139 *> \verbatim
140 *> XACT is REAL array, dimension (LDX,NRHS)
141 *> The exact solution vectors. Each vector is stored as a
142 *> column of the matrix XACT.
143 *> \endverbatim
144 *>
145 *> \param[in] LDXACT
146 *> \verbatim
147 *> LDXACT is INTEGER
148 *> The leading dimension of the array XACT. LDXACT >= max(1,N).
149 *> \endverbatim
150 *>
151 *> \param[in] FERR
152 *> \verbatim
153 *> FERR is REAL array, dimension (NRHS)
154 *> The estimated forward error bounds for each solution vector
155 *> X. If XTRUE is the true solution, FERR bounds the magnitude
156 *> of the largest entry in (X - XTRUE) divided by the magnitude
157 *> of the largest entry in X.
158 *> \endverbatim
159 *>
160 *> \param[in] BERR
161 *> \verbatim
162 *> BERR is REAL array, dimension (NRHS)
163 *> The componentwise relative backward error of each solution
164 *> vector (i.e., the smallest relative change in any entry of A
165 *> or B that makes X an exact solution).
166 *> \endverbatim
167 *>
168 *> \param[out] RESLTS
169 *> \verbatim
170 *> RESLTS is REAL array, dimension (2)
171 *> The maximum over the NRHS solution vectors of the ratios:
172 *> RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR )
173 *> RESLTS(2) = BERR / ( NZ*EPS + (*) )
174 *> \endverbatim
175 *
176 * Authors:
177 * ========
178 *
179 *> \author Univ. of Tennessee
180 *> \author Univ. of California Berkeley
181 *> \author Univ. of Colorado Denver
182 *> \author NAG Ltd.
183 *
184 *> \date November 2011
185 *
186 *> \ingroup single_lin
187 *
188 * =====================================================================
189  SUBROUTINE stbt05( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, B,
190  $ ldb, x, ldx, xact, ldxact, ferr, berr, reslts )
191 *
192 * -- LAPACK test routine (version 3.4.0) --
193 * -- LAPACK is a software package provided by Univ. of Tennessee, --
194 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
195 * November 2011
196 *
197 * .. Scalar Arguments ..
198  CHARACTER DIAG, TRANS, UPLO
199  INTEGER KD, LDAB, LDB, LDX, LDXACT, N, NRHS
200 * ..
201 * .. Array Arguments ..
202  REAL AB( ldab, * ), B( ldb, * ), BERR( * ),
203  $ ferr( * ), reslts( * ), x( ldx, * ),
204  $ xact( ldxact, * )
205 * ..
206 *
207 * =====================================================================
208 *
209 * .. Parameters ..
210  REAL ZERO, ONE
211  parameter ( zero = 0.0e+0, one = 1.0e+0 )
212 * ..
213 * .. Local Scalars ..
214  LOGICAL NOTRAN, UNIT, UPPER
215  INTEGER I, IFU, IMAX, J, K, NZ
216  REAL AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM
217 * ..
218 * .. External Functions ..
219  LOGICAL LSAME
220  INTEGER ISAMAX
221  REAL SLAMCH
222  EXTERNAL lsame, isamax, slamch
223 * ..
224 * .. Intrinsic Functions ..
225  INTRINSIC abs, max, min
226 * ..
227 * .. Executable Statements ..
228 *
229 * Quick exit if N = 0 or NRHS = 0.
230 *
231  IF( n.LE.0 .OR. nrhs.LE.0 ) THEN
232  reslts( 1 ) = zero
233  reslts( 2 ) = zero
234  RETURN
235  END IF
236 *
237  eps = slamch( 'Epsilon' )
238  unfl = slamch( 'Safe minimum' )
239  ovfl = one / unfl
240  upper = lsame( uplo, 'U' )
241  notran = lsame( trans, 'N' )
242  unit = lsame( diag, 'U' )
243  nz = min( kd, n-1 ) + 1
244 *
245 * Test 1: Compute the maximum of
246 * norm(X - XACT) / ( norm(X) * FERR )
247 * over all the vectors X and XACT using the infinity-norm.
248 *
249  errbnd = zero
250  DO 30 j = 1, nrhs
251  imax = isamax( n, x( 1, j ), 1 )
252  xnorm = max( abs( x( imax, j ) ), unfl )
253  diff = zero
254  DO 10 i = 1, n
255  diff = max( diff, abs( x( i, j )-xact( i, j ) ) )
256  10 CONTINUE
257 *
258  IF( xnorm.GT.one ) THEN
259  GO TO 20
260  ELSE IF( diff.LE.ovfl*xnorm ) THEN
261  GO TO 20
262  ELSE
263  errbnd = one / eps
264  GO TO 30
265  END IF
266 *
267  20 CONTINUE
268  IF( diff / xnorm.LE.ferr( j ) ) THEN
269  errbnd = max( errbnd, ( diff / xnorm ) / ferr( j ) )
270  ELSE
271  errbnd = one / eps
272  END IF
273  30 CONTINUE
274  reslts( 1 ) = errbnd
275 *
276 * Test 2: Compute the maximum of BERR / ( NZ*EPS + (*) ), where
277 * (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
278 *
279  ifu = 0
280  IF( unit )
281  $ ifu = 1
282  DO 90 k = 1, nrhs
283  DO 80 i = 1, n
284  tmp = abs( b( i, k ) )
285  IF( upper ) THEN
286  IF( .NOT.notran ) THEN
287  DO 40 j = max( i-kd, 1 ), i - ifu
288  tmp = tmp + abs( ab( kd+1-i+j, i ) )*
289  $ abs( x( j, k ) )
290  40 CONTINUE
291  IF( unit )
292  $ tmp = tmp + abs( x( i, k ) )
293  ELSE
294  IF( unit )
295  $ tmp = tmp + abs( x( i, k ) )
296  DO 50 j = i + ifu, min( i+kd, n )
297  tmp = tmp + abs( ab( kd+1+i-j, j ) )*
298  $ abs( x( j, k ) )
299  50 CONTINUE
300  END IF
301  ELSE
302  IF( notran ) THEN
303  DO 60 j = max( i-kd, 1 ), i - ifu
304  tmp = tmp + abs( ab( 1+i-j, j ) )*abs( x( j, k ) )
305  60 CONTINUE
306  IF( unit )
307  $ tmp = tmp + abs( x( i, k ) )
308  ELSE
309  IF( unit )
310  $ tmp = tmp + abs( x( i, k ) )
311  DO 70 j = i + ifu, min( i+kd, n )
312  tmp = tmp + abs( ab( 1+j-i, i ) )*abs( x( j, k ) )
313  70 CONTINUE
314  END IF
315  END IF
316  IF( i.EQ.1 ) THEN
317  axbi = tmp
318  ELSE
319  axbi = min( axbi, tmp )
320  END IF
321  80 CONTINUE
322  tmp = berr( k ) / ( nz*eps+nz*unfl / max( axbi, nz*unfl ) )
323  IF( k.EQ.1 ) THEN
324  reslts( 2 ) = tmp
325  ELSE
326  reslts( 2 ) = max( reslts( 2 ), tmp )
327  END IF
328  90 CONTINUE
329 *
330  RETURN
331 *
332 * End of STBT05
333 *
334  END
subroutine stbt05(UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, B, LDB, X, LDX, XACT, LDXACT, FERR, BERR, RESLTS)
STBT05
Definition: stbt05.f:191