LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
cla_gbrfsx_extended.f
Go to the documentation of this file.
1 *> \brief \b CLA_GBRFSX_EXTENDED improves the computed solution to a system of linear equations for general banded matrices by performing extra-precise iterative refinement and provides error bounds and backward error estimates for the solution.
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 *> \htmlonly
9 *> Download CLA_GBRFSX_EXTENDED + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cla_gbrfsx_extended.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cla_gbrfsx_extended.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cla_gbrfsx_extended.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * SUBROUTINE CLA_GBRFSX_EXTENDED ( PREC_TYPE, TRANS_TYPE, N, KL, KU,
22 * NRHS, AB, LDAB, AFB, LDAFB, IPIV,
23 * COLEQU, C, B, LDB, Y, LDY,
24 * BERR_OUT, N_NORMS, ERR_BNDS_NORM,
25 * ERR_BNDS_COMP, RES, AYB, DY,
26 * Y_TAIL, RCOND, ITHRESH, RTHRESH,
27 * DZ_UB, IGNORE_CWISE, INFO )
28 *
29 * .. Scalar Arguments ..
30 * INTEGER INFO, LDAB, LDAFB, LDB, LDY, N, KL, KU, NRHS,
31 * $ PREC_TYPE, TRANS_TYPE, N_NORMS, ITHRESH
32 * LOGICAL COLEQU, IGNORE_CWISE
33 * REAL RTHRESH, DZ_UB
34 * ..
35 * .. Array Arguments ..
36 * INTEGER IPIV( * )
37 * COMPLEX AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
38 * $ Y( LDY, * ), RES( * ), DY( * ), Y_TAIL( * )
39 * REAL C( * ), AYB(*), RCOND, BERR_OUT( * ),
40 * $ ERR_BNDS_NORM( NRHS, * ),
41 * $ ERR_BNDS_COMP( NRHS, * )
42 * ..
43 *
44 *
45 *> \par Purpose:
46 * =============
47 *>
48 *> \verbatim
49 *>
50 *> CLA_GBRFSX_EXTENDED improves the computed solution to a system of
51 *> linear equations by performing extra-precise iterative refinement
52 *> and provides error bounds and backward error estimates for the solution.
53 *> This subroutine is called by CGBRFSX to perform iterative refinement.
54 *> In addition to normwise error bound, the code provides maximum
55 *> componentwise error bound if possible. See comments for ERR_BNDS_NORM
56 *> and ERR_BNDS_COMP for details of the error bounds. Note that this
57 *> subroutine is only resonsible for setting the second fields of
58 *> ERR_BNDS_NORM and ERR_BNDS_COMP.
59 *> \endverbatim
60 *
61 * Arguments:
62 * ==========
63 *
64 *> \param[in] PREC_TYPE
65 *> \verbatim
66 *> PREC_TYPE is INTEGER
67 *> Specifies the intermediate precision to be used in refinement.
68 *> The value is defined by ILAPREC(P) where P is a CHARACTER and
69 *> P = 'S': Single
70 *> = 'D': Double
71 *> = 'I': Indigenous
72 *> = 'X', 'E': Extra
73 *> \endverbatim
74 *>
75 *> \param[in] TRANS_TYPE
76 *> \verbatim
77 *> TRANS_TYPE is INTEGER
78 *> Specifies the transposition operation on A.
79 *> The value is defined by ILATRANS(T) where T is a CHARACTER and
80 *> T = 'N': No transpose
81 *> = 'T': Transpose
82 *> = 'C': Conjugate transpose
83 *> \endverbatim
84 *>
85 *> \param[in] N
86 *> \verbatim
87 *> N is INTEGER
88 *> The number of linear equations, i.e., the order of the
89 *> matrix A. N >= 0.
90 *> \endverbatim
91 *>
92 *> \param[in] KL
93 *> \verbatim
94 *> KL is INTEGER
95 *> The number of subdiagonals within the band of A. KL >= 0.
96 *> \endverbatim
97 *>
98 *> \param[in] KU
99 *> \verbatim
100 *> KU is INTEGER
101 *> The number of superdiagonals within the band of A. KU >= 0
102 *> \endverbatim
103 *>
104 *> \param[in] NRHS
105 *> \verbatim
106 *> NRHS is INTEGER
107 *> The number of right-hand-sides, i.e., the number of columns of the
108 *> matrix B.
109 *> \endverbatim
110 *>
111 *> \param[in] AB
112 *> \verbatim
113 *> AB is COMPLEX array, dimension (LDAB,N)
114 *> On entry, the N-by-N matrix AB.
115 *> \endverbatim
116 *>
117 *> \param[in] LDAB
118 *> \verbatim
119 *> LDAB is INTEGER
120 *> The leading dimension of the array AB. LDAB >= max(1,N).
121 *> \endverbatim
122 *>
123 *> \param[in] AFB
124 *> \verbatim
125 *> AFB is COMPLEX array, dimension (LDAF,N)
126 *> The factors L and U from the factorization
127 *> A = P*L*U as computed by CGBTRF.
128 *> \endverbatim
129 *>
130 *> \param[in] LDAFB
131 *> \verbatim
132 *> LDAFB is INTEGER
133 *> The leading dimension of the array AF. LDAF >= max(1,N).
134 *> \endverbatim
135 *>
136 *> \param[in] IPIV
137 *> \verbatim
138 *> IPIV is INTEGER array, dimension (N)
139 *> The pivot indices from the factorization A = P*L*U
140 *> as computed by CGBTRF; row i of the matrix was interchanged
141 *> with row IPIV(i).
142 *> \endverbatim
143 *>
144 *> \param[in] COLEQU
145 *> \verbatim
146 *> COLEQU is LOGICAL
147 *> If .TRUE. then column equilibration was done to A before calling
148 *> this routine. This is needed to compute the solution and error
149 *> bounds correctly.
150 *> \endverbatim
151 *>
152 *> \param[in] C
153 *> \verbatim
154 *> C is REAL array, dimension (N)
155 *> The column scale factors for A. If COLEQU = .FALSE., C
156 *> is not accessed. If C is input, each element of C should be a power
157 *> of the radix to ensure a reliable solution and error estimates.
158 *> Scaling by powers of the radix does not cause rounding errors unless
159 *> the result underflows or overflows. Rounding errors during scaling
160 *> lead to refining with a matrix that is not equivalent to the
161 *> input matrix, producing error estimates that may not be
162 *> reliable.
163 *> \endverbatim
164 *>
165 *> \param[in] B
166 *> \verbatim
167 *> B is COMPLEX array, dimension (LDB,NRHS)
168 *> The right-hand-side matrix B.
169 *> \endverbatim
170 *>
171 *> \param[in] LDB
172 *> \verbatim
173 *> LDB is INTEGER
174 *> The leading dimension of the array B. LDB >= max(1,N).
175 *> \endverbatim
176 *>
177 *> \param[in,out] Y
178 *> \verbatim
179 *> Y is COMPLEX array, dimension (LDY,NRHS)
180 *> On entry, the solution matrix X, as computed by CGBTRS.
181 *> On exit, the improved solution matrix Y.
182 *> \endverbatim
183 *>
184 *> \param[in] LDY
185 *> \verbatim
186 *> LDY is INTEGER
187 *> The leading dimension of the array Y. LDY >= max(1,N).
188 *> \endverbatim
189 *>
190 *> \param[out] BERR_OUT
191 *> \verbatim
192 *> BERR_OUT is REAL array, dimension (NRHS)
193 *> On exit, BERR_OUT(j) contains the componentwise relative backward
194 *> error for right-hand-side j from the formula
195 *> max(i) ( abs(RES(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) )
196 *> where abs(Z) is the componentwise absolute value of the matrix
197 *> or vector Z. This is computed by CLA_LIN_BERR.
198 *> \endverbatim
199 *>
200 *> \param[in] N_NORMS
201 *> \verbatim
202 *> N_NORMS is INTEGER
203 *> Determines which error bounds to return (see ERR_BNDS_NORM
204 *> and ERR_BNDS_COMP).
205 *> If N_NORMS >= 1 return normwise error bounds.
206 *> If N_NORMS >= 2 return componentwise error bounds.
207 *> \endverbatim
208 *>
209 *> \param[in,out] ERR_BNDS_NORM
210 *> \verbatim
211 *> ERR_BNDS_NORM is REAL array, dimension
212 *> (NRHS, N_ERR_BNDS)
213 *> For each right-hand side, this array contains information about
214 *> various error bounds and condition numbers corresponding to the
215 *> normwise relative error, which is defined as follows:
216 *>
217 *> Normwise relative error in the ith solution vector:
218 *> max_j (abs(XTRUE(j,i) - X(j,i)))
219 *> ------------------------------
220 *> max_j abs(X(j,i))
221 *>
222 *> The array is indexed by the type of error information as described
223 *> below. There currently are up to three pieces of information
224 *> returned.
225 *>
226 *> The first index in ERR_BNDS_NORM(i,:) corresponds to the ith
227 *> right-hand side.
228 *>
229 *> The second index in ERR_BNDS_NORM(:,err) contains the following
230 *> three fields:
231 *> err = 1 "Trust/don't trust" boolean. Trust the answer if the
232 *> reciprocal condition number is less than the threshold
233 *> sqrt(n) * slamch('Epsilon').
234 *>
235 *> err = 2 "Guaranteed" error bound: The estimated forward error,
236 *> almost certainly within a factor of 10 of the true error
237 *> so long as the next entry is greater than the threshold
238 *> sqrt(n) * slamch('Epsilon'). This error bound should only
239 *> be trusted if the previous boolean is true.
240 *>
241 *> err = 3 Reciprocal condition number: Estimated normwise
242 *> reciprocal condition number. Compared with the threshold
243 *> sqrt(n) * slamch('Epsilon') to determine if the error
244 *> estimate is "guaranteed". These reciprocal condition
245 *> numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some
246 *> appropriately scaled matrix Z.
247 *> Let Z = S*A, where S scales each row by a power of the
248 *> radix so all absolute row sums of Z are approximately 1.
249 *>
250 *> This subroutine is only responsible for setting the second field
251 *> above.
252 *> See Lapack Working Note 165 for further details and extra
253 *> cautions.
254 *> \endverbatim
255 *>
256 *> \param[in,out] ERR_BNDS_COMP
257 *> \verbatim
258 *> ERR_BNDS_COMP is REAL array, dimension
259 *> (NRHS, N_ERR_BNDS)
260 *> For each right-hand side, this array contains information about
261 *> various error bounds and condition numbers corresponding to the
262 *> componentwise relative error, which is defined as follows:
263 *>
264 *> Componentwise relative error in the ith solution vector:
265 *> abs(XTRUE(j,i) - X(j,i))
266 *> max_j ----------------------
267 *> abs(X(j,i))
268 *>
269 *> The array is indexed by the right-hand side i (on which the
270 *> componentwise relative error depends), and the type of error
271 *> information as described below. There currently are up to three
272 *> pieces of information returned for each right-hand side. If
273 *> componentwise accuracy is not requested (PARAMS(3) = 0.0), then
274 *> ERR_BNDS_COMP is not accessed. If N_ERR_BNDS .LT. 3, then at most
275 *> the first (:,N_ERR_BNDS) entries are returned.
276 *>
277 *> The first index in ERR_BNDS_COMP(i,:) corresponds to the ith
278 *> right-hand side.
279 *>
280 *> The second index in ERR_BNDS_COMP(:,err) contains the following
281 *> three fields:
282 *> err = 1 "Trust/don't trust" boolean. Trust the answer if the
283 *> reciprocal condition number is less than the threshold
284 *> sqrt(n) * slamch('Epsilon').
285 *>
286 *> err = 2 "Guaranteed" error bound: The estimated forward error,
287 *> almost certainly within a factor of 10 of the true error
288 *> so long as the next entry is greater than the threshold
289 *> sqrt(n) * slamch('Epsilon'). This error bound should only
290 *> be trusted if the previous boolean is true.
291 *>
292 *> err = 3 Reciprocal condition number: Estimated componentwise
293 *> reciprocal condition number. Compared with the threshold
294 *> sqrt(n) * slamch('Epsilon') to determine if the error
295 *> estimate is "guaranteed". These reciprocal condition
296 *> numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some
297 *> appropriately scaled matrix Z.
298 *> Let Z = S*(A*diag(x)), where x is the solution for the
299 *> current right-hand side and S scales each row of
300 *> A*diag(x) by a power of the radix so all absolute row
301 *> sums of Z are approximately 1.
302 *>
303 *> This subroutine is only responsible for setting the second field
304 *> above.
305 *> See Lapack Working Note 165 for further details and extra
306 *> cautions.
307 *> \endverbatim
308 *>
309 *> \param[in] RES
310 *> \verbatim
311 *> RES is COMPLEX array, dimension (N)
312 *> Workspace to hold the intermediate residual.
313 *> \endverbatim
314 *>
315 *> \param[in] AYB
316 *> \verbatim
317 *> AYB is REAL array, dimension (N)
318 *> Workspace.
319 *> \endverbatim
320 *>
321 *> \param[in] DY
322 *> \verbatim
323 *> DY is COMPLEX array, dimension (N)
324 *> Workspace to hold the intermediate solution.
325 *> \endverbatim
326 *>
327 *> \param[in] Y_TAIL
328 *> \verbatim
329 *> Y_TAIL is COMPLEX array, dimension (N)
330 *> Workspace to hold the trailing bits of the intermediate solution.
331 *> \endverbatim
332 *>
333 *> \param[in] RCOND
334 *> \verbatim
335 *> RCOND is REAL
336 *> Reciprocal scaled condition number. This is an estimate of the
337 *> reciprocal Skeel condition number of the matrix A after
338 *> equilibration (if done). If this is less than the machine
339 *> precision (in particular, if it is zero), the matrix is singular
340 *> to working precision. Note that the error may still be small even
341 *> if this number is very small and the matrix appears ill-
342 *> conditioned.
343 *> \endverbatim
344 *>
345 *> \param[in] ITHRESH
346 *> \verbatim
347 *> ITHRESH is INTEGER
348 *> The maximum number of residual computations allowed for
349 *> refinement. The default is 10. For 'aggressive' set to 100 to
350 *> permit convergence using approximate factorizations or
351 *> factorizations other than LU. If the factorization uses a
352 *> technique other than Gaussian elimination, the guarantees in
353 *> ERR_BNDS_NORM and ERR_BNDS_COMP may no longer be trustworthy.
354 *> \endverbatim
355 *>
356 *> \param[in] RTHRESH
357 *> \verbatim
358 *> RTHRESH is REAL
359 *> Determines when to stop refinement if the error estimate stops
360 *> decreasing. Refinement will stop when the next solution no longer
361 *> satisfies norm(dx_{i+1}) < RTHRESH * norm(dx_i) where norm(Z) is
362 *> the infinity norm of Z. RTHRESH satisfies 0 < RTHRESH <= 1. The
363 *> default value is 0.5. For 'aggressive' set to 0.9 to permit
364 *> convergence on extremely ill-conditioned matrices. See LAWN 165
365 *> for more details.
366 *> \endverbatim
367 *>
368 *> \param[in] DZ_UB
369 *> \verbatim
370 *> DZ_UB is REAL
371 *> Determines when to start considering componentwise convergence.
372 *> Componentwise convergence is only considered after each component
373 *> of the solution Y is stable, which we definte as the relative
374 *> change in each component being less than DZ_UB. The default value
375 *> is 0.25, requiring the first bit to be stable. See LAWN 165 for
376 *> more details.
377 *> \endverbatim
378 *>
379 *> \param[in] IGNORE_CWISE
380 *> \verbatim
381 *> IGNORE_CWISE is LOGICAL
382 *> If .TRUE. then ignore componentwise convergence. Default value
383 *> is .FALSE..
384 *> \endverbatim
385 *>
386 *> \param[out] INFO
387 *> \verbatim
388 *> INFO is INTEGER
389 *> = 0: Successful exit.
390 *> < 0: if INFO = -i, the ith argument to CGBTRS had an illegal
391 *> value
392 *> \endverbatim
393 *
394 * Authors:
395 * ========
396 *
397 *> \author Univ. of Tennessee
398 *> \author Univ. of California Berkeley
399 *> \author Univ. of Colorado Denver
400 *> \author NAG Ltd.
401 *
402 *> \date September 2012
403 *
404 *> \ingroup complexGBcomputational
405 *
406 * =====================================================================
407  SUBROUTINE cla_gbrfsx_extended ( PREC_TYPE, TRANS_TYPE, N, KL, KU,
408  $ nrhs, ab, ldab, afb, ldafb, ipiv,
409  $ colequ, c, b, ldb, y, ldy,
410  $ berr_out, n_norms, err_bnds_norm,
411  $ err_bnds_comp, res, ayb, dy,
412  $ y_tail, rcond, ithresh, rthresh,
413  $ dz_ub, ignore_cwise, info )
414 *
415 * -- LAPACK computational routine (version 3.4.2) --
416 * -- LAPACK is a software package provided by Univ. of Tennessee, --
417 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
418 * September 2012
419 *
420 * .. Scalar Arguments ..
421  INTEGER info, ldab, ldafb, ldb, ldy, n, kl, ku, nrhs,
422  $ prec_type, trans_type, n_norms, ithresh
423  LOGICAL colequ, ignore_cwise
424  REAL rthresh, dz_ub
425 * ..
426 * .. Array Arguments ..
427  INTEGER ipiv( * )
428  COMPLEX ab( ldab, * ), afb( ldafb, * ), b( ldb, * ),
429  $ y( ldy, * ), res( * ), dy( * ), y_tail( * )
430  REAL c( * ), ayb(*), rcond, berr_out( * ),
431  $ err_bnds_norm( nrhs, * ),
432  $ err_bnds_comp( nrhs, * )
433 * ..
434 *
435 * =====================================================================
436 *
437 * .. Local Scalars ..
438  CHARACTER trans
439  INTEGER cnt, i, j, m, x_state, z_state, y_prec_state
440  REAL yk, dyk, ymin, normy, normx, normdx, dxrat,
441  $ dzrat, prevnormdx, prev_dz_z, dxratmax,
442  $ dzratmax, dx_x, dz_z, final_dx_x, final_dz_z,
443  $ eps, hugeval, incr_thresh
444  LOGICAL incr_prec
445  COMPLEX zdum
446 * ..
447 * .. Parameters ..
448  INTEGER unstable_state, working_state, conv_state,
449  $ noprog_state, base_residual, extra_residual,
450  $ extra_y
451  parameter( unstable_state = 0, working_state = 1,
452  $ conv_state = 2, noprog_state = 3 )
453  parameter( base_residual = 0, extra_residual = 1,
454  $ extra_y = 2 )
455  INTEGER final_nrm_err_i, final_cmp_err_i, berr_i
456  INTEGER rcond_i, nrm_rcond_i, nrm_err_i, cmp_rcond_i
457  INTEGER cmp_err_i, piv_growth_i
458  parameter( final_nrm_err_i = 1, final_cmp_err_i = 2,
459  $ berr_i = 3 )
460  parameter( rcond_i = 4, nrm_rcond_i = 5, nrm_err_i = 6 )
461  parameter( cmp_rcond_i = 7, cmp_err_i = 8,
462  $ piv_growth_i = 9 )
463  INTEGER la_linrx_itref_i, la_linrx_ithresh_i,
464  $ la_linrx_cwise_i
465  parameter( la_linrx_itref_i = 1,
466  $ la_linrx_ithresh_i = 2 )
467  parameter( la_linrx_cwise_i = 3 )
468  INTEGER la_linrx_trust_i, la_linrx_err_i,
469  $ la_linrx_rcond_i
470  parameter( la_linrx_trust_i = 1, la_linrx_err_i = 2 )
471  parameter( la_linrx_rcond_i = 3 )
472 * ..
473 * .. External Subroutines ..
474  EXTERNAL caxpy, ccopy, cgbtrs, cgbmv, blas_cgbmv_x,
475  $ blas_cgbmv2_x, cla_gbamv, cla_wwaddw, slamch,
477  REAL slamch
478  CHARACTER chla_transtype
479 * ..
480 * .. Intrinsic Functions..
481  INTRINSIC abs, max, min
482 * ..
483 * .. Statement Functions ..
484  REAL cabs1
485 * ..
486 * .. Statement Function Definitions ..
487  cabs1( zdum ) = abs( REAL( ZDUM ) ) + abs( aimag( zdum ) )
488 * ..
489 * .. Executable Statements ..
490 *
491  IF (info.NE.0) return
492  trans = chla_transtype(trans_type)
493  eps = slamch( 'Epsilon' )
494  hugeval = slamch( 'Overflow' )
495 * Force HUGEVAL to Inf
496  hugeval = hugeval * hugeval
497 * Using HUGEVAL may lead to spurious underflows.
498  incr_thresh = REAL( N ) * eps
499  m = kl+ku+1
500 
501  DO j = 1, nrhs
502  y_prec_state = extra_residual
503  IF ( y_prec_state .EQ. extra_y ) then
504  DO i = 1, n
505  y_tail( i ) = 0.0
506  END DO
507  END IF
508 
509  dxrat = 0.0e+0
510  dxratmax = 0.0e+0
511  dzrat = 0.0e+0
512  dzratmax = 0.0e+0
513  final_dx_x = hugeval
514  final_dz_z = hugeval
515  prevnormdx = hugeval
516  prev_dz_z = hugeval
517  dz_z = hugeval
518  dx_x = hugeval
519 
520  x_state = working_state
521  z_state = unstable_state
522  incr_prec = .false.
523 
524  DO cnt = 1, ithresh
525 *
526 * Compute residual RES = B_s - op(A_s) * Y,
527 * op(A) = A, A**T, or A**H depending on TRANS (and type).
528 *
529  CALL ccopy( n, b( 1, j ), 1, res, 1 )
530  IF ( y_prec_state .EQ. base_residual ) THEN
531  CALL cgbmv( trans, m, n, kl, ku, (-1.0e+0,0.0e+0), ab,
532  $ ldab, y( 1, j ), 1, (1.0e+0,0.0e+0), res, 1 )
533  ELSE IF ( y_prec_state .EQ. extra_residual ) THEN
534  CALL blas_cgbmv_x( trans_type, n, n, kl, ku,
535  $ (-1.0e+0,0.0e+0), ab, ldab, y( 1, j ), 1,
536  $ (1.0e+0,0.0e+0), res, 1, prec_type )
537  ELSE
538  CALL blas_cgbmv2_x( trans_type, n, n, kl, ku,
539  $ (-1.0e+0,0.0e+0), ab, ldab, y( 1, j ), y_tail, 1,
540  $ (1.0e+0,0.0e+0), res, 1, prec_type )
541  END IF
542 
543 ! XXX: RES is no longer needed.
544  CALL ccopy( n, res, 1, dy, 1 )
545  CALL cgbtrs( trans, n, kl, ku, 1, afb, ldafb, ipiv, dy, n,
546  $ info )
547 *
548 * Calculate relative changes DX_X, DZ_Z and ratios DXRAT, DZRAT.
549 *
550  normx = 0.0e+0
551  normy = 0.0e+0
552  normdx = 0.0e+0
553  dz_z = 0.0e+0
554  ymin = hugeval
555 
556  DO i = 1, n
557  yk = cabs1( y( i, j ) )
558  dyk = cabs1( dy( i ) )
559 
560  IF (yk .NE. 0.0) THEN
561  dz_z = max( dz_z, dyk / yk )
562  ELSE IF ( dyk .NE. 0.0 ) THEN
563  dz_z = hugeval
564  END IF
565 
566  ymin = min( ymin, yk )
567 
568  normy = max( normy, yk )
569 
570  IF ( colequ ) THEN
571  normx = max( normx, yk * c( i ) )
572  normdx = max(normdx, dyk * c(i))
573  ELSE
574  normx = normy
575  normdx = max( normdx, dyk )
576  END IF
577  END DO
578 
579  IF ( normx .NE. 0.0 ) THEN
580  dx_x = normdx / normx
581  ELSE IF ( normdx .EQ. 0.0 ) THEN
582  dx_x = 0.0
583  ELSE
584  dx_x = hugeval
585  END IF
586 
587  dxrat = normdx / prevnormdx
588  dzrat = dz_z / prev_dz_z
589 *
590 * Check termination criteria.
591 *
592  IF (.NOT.ignore_cwise
593  $ .AND. ymin*rcond .LT. incr_thresh*normy
594  $ .AND. y_prec_state .LT. extra_y )
595  $ incr_prec = .true.
596 
597  IF ( x_state .EQ. noprog_state .AND. dxrat .LE. rthresh )
598  $ x_state = working_state
599  IF ( x_state .EQ. working_state ) THEN
600  IF ( dx_x .LE. eps ) THEN
601  x_state = conv_state
602  ELSE IF ( dxrat .GT. rthresh ) THEN
603  IF ( y_prec_state .NE. extra_y ) THEN
604  incr_prec = .true.
605  ELSE
606  x_state = noprog_state
607  END IF
608  ELSE
609  IF ( dxrat .GT. dxratmax ) dxratmax = dxrat
610  END IF
611  IF ( x_state .GT. working_state ) final_dx_x = dx_x
612  END IF
613 
614  IF ( z_state .EQ. unstable_state .AND. dz_z .LE. dz_ub )
615  $ z_state = working_state
616  IF ( z_state .EQ. noprog_state .AND. dzrat .LE. rthresh )
617  $ z_state = working_state
618  IF ( z_state .EQ. working_state ) THEN
619  IF ( dz_z .LE. eps ) THEN
620  z_state = conv_state
621  ELSE IF ( dz_z .GT. dz_ub ) THEN
622  z_state = unstable_state
623  dzratmax = 0.0
624  final_dz_z = hugeval
625  ELSE IF ( dzrat .GT. rthresh ) THEN
626  IF ( y_prec_state .NE. extra_y ) THEN
627  incr_prec = .true.
628  ELSE
629  z_state = noprog_state
630  END IF
631  ELSE
632  IF ( dzrat .GT. dzratmax ) dzratmax = dzrat
633  END IF
634  IF ( z_state .GT. working_state ) final_dz_z = dz_z
635  END IF
636 *
637 * Exit if both normwise and componentwise stopped working,
638 * but if componentwise is unstable, let it go at least two
639 * iterations.
640 *
641  IF ( x_state.NE.working_state ) THEN
642  IF ( ignore_cwise ) goto 666
643  IF ( z_state.EQ.noprog_state .OR. z_state.EQ.conv_state )
644  $ goto 666
645  IF ( z_state.EQ.unstable_state .AND. cnt.GT.1 ) goto 666
646  END IF
647 
648  IF ( incr_prec ) THEN
649  incr_prec = .false.
650  y_prec_state = y_prec_state + 1
651  DO i = 1, n
652  y_tail( i ) = 0.0
653  END DO
654  END IF
655 
656  prevnormdx = normdx
657  prev_dz_z = dz_z
658 *
659 * Update soluton.
660 *
661  IF ( y_prec_state .LT. extra_y ) THEN
662  CALL caxpy( n, (1.0e+0,0.0e+0), dy, 1, y(1,j), 1 )
663  ELSE
664  CALL cla_wwaddw( n, y(1,j), y_tail, dy )
665  END IF
666 
667  END DO
668 * Target of "IF (Z_STOP .AND. X_STOP)". Sun's f77 won't EXIT.
669  666 continue
670 *
671 * Set final_* when cnt hits ithresh.
672 *
673  IF ( x_state .EQ. working_state ) final_dx_x = dx_x
674  IF ( z_state .EQ. working_state ) final_dz_z = dz_z
675 *
676 * Compute error bounds.
677 *
678  IF ( n_norms .GE. 1 ) THEN
679  err_bnds_norm( j, la_linrx_err_i ) =
680  $ final_dx_x / (1 - dxratmax)
681  END IF
682  IF ( n_norms .GE. 2 ) THEN
683  err_bnds_comp( j, la_linrx_err_i ) =
684  $ final_dz_z / (1 - dzratmax)
685  END IF
686 *
687 * Compute componentwise relative backward error from formula
688 * max(i) ( abs(R(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) )
689 * where abs(Z) is the componentwise absolute value of the matrix
690 * or vector Z.
691 *
692 * Compute residual RES = B_s - op(A_s) * Y,
693 * op(A) = A, A**T, or A**H depending on TRANS (and type).
694 *
695  CALL ccopy( n, b( 1, j ), 1, res, 1 )
696  CALL cgbmv( trans, n, n, kl, ku, (-1.0e+0,0.0e+0), ab, ldab,
697  $ y(1,j), 1, (1.0e+0,0.0e+0), res, 1 )
698 
699  DO i = 1, n
700  ayb( i ) = cabs1( b( i, j ) )
701  END DO
702 *
703 * Compute abs(op(A_s))*abs(Y) + abs(B_s).
704 *
705  CALL cla_gbamv( trans_type, n, n, kl, ku, 1.0e+0,
706  $ ab, ldab, y(1, j), 1, 1.0e+0, ayb, 1 )
707 
708  CALL cla_lin_berr( n, n, 1, res, ayb, berr_out( j ) )
709 *
710 * End of loop for each RHS.
711 *
712  END DO
713 *
714  return
715  END