1: *> \brief \b DLA_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 DLA_GBRFSX_EXTENDED + dependencies
10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dla_gbrfsx_extended.f">
11: *> [TGZ]</a>
12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dla_gbrfsx_extended.f">
13: *> [ZIP]</a>
14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dla_gbrfsx_extended.f">
15: *> [TXT]</a>
16: *> \endhtmlonly
17: *
18: * Definition:
19: * ===========
20: *
21: * SUBROUTINE DLA_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: * DOUBLE PRECISION RTHRESH, DZ_UB
34: * ..
35: * .. Array Arguments ..
36: * INTEGER IPIV( * )
37: * DOUBLE PRECISION AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
38: * $ Y( LDY, * ), RES(*), DY(*), Y_TAIL(*)
39: * DOUBLE PRECISION 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: *>
51: *> DLA_GBRFSX_EXTENDED improves the computed solution to a system of
52: *> linear equations by performing extra-precise iterative refinement
53: *> and provides error bounds and backward error estimates for the solution.
54: *> This subroutine is called by DGBRFSX to perform iterative refinement.
55: *> In addition to normwise error bound, the code provides maximum
56: *> componentwise error bound if possible. See comments for ERR_BNDS_NORM
57: *> and ERR_BNDS_COMP for details of the error bounds. Note that this
58: *> subroutine is only resonsible for setting the second fields of
59: *> ERR_BNDS_NORM and ERR_BNDS_COMP.
60: *> \endverbatim
61: *
62: * Arguments:
63: * ==========
64: *
65: *> \param[in] PREC_TYPE
66: *> \verbatim
67: *> PREC_TYPE is INTEGER
68: *> Specifies the intermediate precision to be used in refinement.
69: *> The value is defined by ILAPREC(P) where P is a CHARACTER and
70: *> P = 'S': Single
71: *> = 'D': Double
72: *> = 'I': Indigenous
73: *> = 'X', 'E': Extra
74: *> \endverbatim
75: *>
76: *> \param[in] TRANS_TYPE
77: *> \verbatim
78: *> TRANS_TYPE is INTEGER
79: *> Specifies the transposition operation on A.
80: *> The value is defined by ILATRANS(T) where T is a CHARACTER and
81: *> T = 'N': No transpose
82: *> = 'T': Transpose
83: *> = 'C': Conjugate transpose
84: *> \endverbatim
85: *>
86: *> \param[in] N
87: *> \verbatim
88: *> N is INTEGER
89: *> The number of linear equations, i.e., the order of the
90: *> matrix A. N >= 0.
91: *> \endverbatim
92: *>
93: *> \param[in] KL
94: *> \verbatim
95: *> KL is INTEGER
96: *> The number of subdiagonals within the band of A. KL >= 0.
97: *> \endverbatim
98: *>
99: *> \param[in] KU
100: *> \verbatim
101: *> KU is INTEGER
102: *> The number of superdiagonals within the band of A. KU >= 0
103: *> \endverbatim
104: *>
105: *> \param[in] NRHS
106: *> \verbatim
107: *> NRHS is INTEGER
108: *> The number of right-hand-sides, i.e., the number of columns of the
109: *> matrix B.
110: *> \endverbatim
111: *>
112: *> \param[in] AB
113: *> \verbatim
114: *> AB is DOUBLE PRECISION array, dimension (LDAB,N)
115: *> On entry, the N-by-N matrix AB.
116: *> \endverbatim
117: *>
118: *> \param[in] LDAB
119: *> \verbatim
120: *> LDAB is INTEGER
121: *> The leading dimension of the array AB. LDBA >= max(1,N).
122: *> \endverbatim
123: *>
124: *> \param[in] AFB
125: *> \verbatim
126: *> AFB is DOUBLE PRECISION array, dimension (LDAFB,N)
127: *> The factors L and U from the factorization
128: *> A = P*L*U as computed by DGBTRF.
129: *> \endverbatim
130: *>
131: *> \param[in] LDAFB
132: *> \verbatim
133: *> LDAFB is INTEGER
134: *> The leading dimension of the array AF. LDAFB >= max(1,N).
135: *> \endverbatim
136: *>
137: *> \param[in] IPIV
138: *> \verbatim
139: *> IPIV is INTEGER array, dimension (N)
140: *> The pivot indices from the factorization A = P*L*U
141: *> as computed by DGBTRF; row i of the matrix was interchanged
142: *> with row IPIV(i).
143: *> \endverbatim
144: *>
145: *> \param[in] COLEQU
146: *> \verbatim
147: *> COLEQU is LOGICAL
148: *> If .TRUE. then column equilibration was done to A before calling
149: *> this routine. This is needed to compute the solution and error
150: *> bounds correctly.
151: *> \endverbatim
152: *>
153: *> \param[in] C
154: *> \verbatim
155: *> C is DOUBLE PRECISION array, dimension (N)
156: *> The column scale factors for A. If COLEQU = .FALSE., C
157: *> is not accessed. If C is input, each element of C should be a power
158: *> of the radix to ensure a reliable solution and error estimates.
159: *> Scaling by powers of the radix does not cause rounding errors unless
160: *> the result underflows or overflows. Rounding errors during scaling
161: *> lead to refining with a matrix that is not equivalent to the
162: *> input matrix, producing error estimates that may not be
163: *> reliable.
164: *> \endverbatim
165: *>
166: *> \param[in] B
167: *> \verbatim
168: *> B is DOUBLE PRECISION array, dimension (LDB,NRHS)
169: *> The right-hand-side matrix B.
170: *> \endverbatim
171: *>
172: *> \param[in] LDB
173: *> \verbatim
174: *> LDB is INTEGER
175: *> The leading dimension of the array B. LDB >= max(1,N).
176: *> \endverbatim
177: *>
178: *> \param[in,out] Y
179: *> \verbatim
180: *> Y is DOUBLE PRECISION array, dimension (LDY,NRHS)
181: *> On entry, the solution matrix X, as computed by DGBTRS.
182: *> On exit, the improved solution matrix Y.
183: *> \endverbatim
184: *>
185: *> \param[in] LDY
186: *> \verbatim
187: *> LDY is INTEGER
188: *> The leading dimension of the array Y. LDY >= max(1,N).
189: *> \endverbatim
190: *>
191: *> \param[out] BERR_OUT
192: *> \verbatim
193: *> BERR_OUT is DOUBLE PRECISION array, dimension (NRHS)
194: *> On exit, BERR_OUT(j) contains the componentwise relative backward
195: *> error for right-hand-side j from the formula
196: *> max(i) ( abs(RES(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) )
197: *> where abs(Z) is the componentwise absolute value of the matrix
198: *> or vector Z. This is computed by DLA_LIN_BERR.
199: *> \endverbatim
200: *>
201: *> \param[in] N_NORMS
202: *> \verbatim
203: *> N_NORMS is INTEGER
204: *> Determines which error bounds to return (see ERR_BNDS_NORM
205: *> and ERR_BNDS_COMP).
206: *> If N_NORMS >= 1 return normwise error bounds.
207: *> If N_NORMS >= 2 return componentwise error bounds.
208: *> \endverbatim
209: *>
210: *> \param[in,out] ERR_BNDS_NORM
211: *> \verbatim
212: *> ERR_BNDS_NORM is DOUBLE PRECISION array, dimension (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 DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS)
259: *> For each right-hand side, this array contains information about
260: *> various error bounds and condition numbers corresponding to the
261: *> componentwise relative error, which is defined as follows:
262: *>
263: *> Componentwise relative error in the ith solution vector:
264: *> abs(XTRUE(j,i) - X(j,i))
265: *> max_j ----------------------
266: *> abs(X(j,i))
267: *>
268: *> The array is indexed by the right-hand side i (on which the
269: *> componentwise relative error depends), and the type of error
270: *> information as described below. There currently are up to three
271: *> pieces of information returned for each right-hand side. If
272: *> componentwise accuracy is not requested (PARAMS(3) = 0.0), then
273: *> ERR_BNDS_COMP is not accessed. If N_ERR_BNDS .LT. 3, then at most
274: *> the first (:,N_ERR_BNDS) entries are returned.
275: *>
276: *> The first index in ERR_BNDS_COMP(i,:) corresponds to the ith
277: *> right-hand side.
278: *>
279: *> The second index in ERR_BNDS_COMP(:,err) contains the following
280: *> three fields:
281: *> err = 1 "Trust/don't trust" boolean. Trust the answer if the
282: *> reciprocal condition number is less than the threshold
283: *> sqrt(n) * slamch('Epsilon').
284: *>
285: *> err = 2 "Guaranteed" error bound: The estimated forward error,
286: *> almost certainly within a factor of 10 of the true error
287: *> so long as the next entry is greater than the threshold
288: *> sqrt(n) * slamch('Epsilon'). This error bound should only
289: *> be trusted if the previous boolean is true.
290: *>
291: *> err = 3 Reciprocal condition number: Estimated componentwise
292: *> reciprocal condition number. Compared with the threshold
293: *> sqrt(n) * slamch('Epsilon') to determine if the error
294: *> estimate is "guaranteed". These reciprocal condition
295: *> numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some
296: *> appropriately scaled matrix Z.
297: *> Let Z = S*(A*diag(x)), where x is the solution for the
298: *> current right-hand side and S scales each row of
299: *> A*diag(x) by a power of the radix so all absolute row
300: *> sums of Z are approximately 1.
301: *>
302: *> This subroutine is only responsible for setting the second field
303: *> above.
304: *> See Lapack Working Note 165 for further details and extra
305: *> cautions.
306: *> \endverbatim
307: *>
308: *> \param[in] RES
309: *> \verbatim
310: *> RES is DOUBLE PRECISION array, dimension (N)
311: *> Workspace to hold the intermediate residual.
312: *> \endverbatim
313: *>
314: *> \param[in] AYB
315: *> \verbatim
316: *> AYB is DOUBLE PRECISION array, dimension (N)
317: *> Workspace. This can be the same workspace passed for Y_TAIL.
318: *> \endverbatim
319: *>
320: *> \param[in] DY
321: *> \verbatim
322: *> DY is DOUBLE PRECISION array, dimension (N)
323: *> Workspace to hold the intermediate solution.
324: *> \endverbatim
325: *>
326: *> \param[in] Y_TAIL
327: *> \verbatim
328: *> Y_TAIL is DOUBLE PRECISION array, dimension (N)
329: *> Workspace to hold the trailing bits of the intermediate solution.
330: *> \endverbatim
331: *>
332: *> \param[in] RCOND
333: *> \verbatim
334: *> RCOND is DOUBLE PRECISION
335: *> Reciprocal scaled condition number. This is an estimate of the
336: *> reciprocal Skeel condition number of the matrix A after
337: *> equilibration (if done). If this is less than the machine
338: *> precision (in particular, if it is zero), the matrix is singular
339: *> to working precision. Note that the error may still be small even
340: *> if this number is very small and the matrix appears ill-
341: *> conditioned.
342: *> \endverbatim
343: *>
344: *> \param[in] ITHRESH
345: *> \verbatim
346: *> ITHRESH is INTEGER
347: *> The maximum number of residual computations allowed for
348: *> refinement. The default is 10. For 'aggressive' set to 100 to
349: *> permit convergence using approximate factorizations or
350: *> factorizations other than LU. If the factorization uses a
351: *> technique other than Gaussian elimination, the guarantees in
352: *> ERR_BNDS_NORM and ERR_BNDS_COMP may no longer be trustworthy.
353: *> \endverbatim
354: *>
355: *> \param[in] RTHRESH
356: *> \verbatim
357: *> RTHRESH is DOUBLE PRECISION
358: *> Determines when to stop refinement if the error estimate stops
359: *> decreasing. Refinement will stop when the next solution no longer
360: *> satisfies norm(dx_{i+1}) < RTHRESH * norm(dx_i) where norm(Z) is
361: *> the infinity norm of Z. RTHRESH satisfies 0 < RTHRESH <= 1. The
362: *> default value is 0.5. For 'aggressive' set to 0.9 to permit
363: *> convergence on extremely ill-conditioned matrices. See LAWN 165
364: *> for more details.
365: *> \endverbatim
366: *>
367: *> \param[in] DZ_UB
368: *> \verbatim
369: *> DZ_UB is DOUBLE PRECISION
370: *> Determines when to start considering componentwise convergence.
371: *> Componentwise convergence is only considered after each component
372: *> of the solution Y is stable, which we definte as the relative
373: *> change in each component being less than DZ_UB. The default value
374: *> is 0.25, requiring the first bit to be stable. See LAWN 165 for
375: *> more details.
376: *> \endverbatim
377: *>
378: *> \param[in] IGNORE_CWISE
379: *> \verbatim
380: *> IGNORE_CWISE is LOGICAL
381: *> If .TRUE. then ignore componentwise convergence. Default value
382: *> is .FALSE..
383: *> \endverbatim
384: *>
385: *> \param[out] INFO
386: *> \verbatim
387: *> INFO is INTEGER
388: *> = 0: Successful exit.
389: *> < 0: if INFO = -i, the ith argument to DGBTRS had an illegal
390: *> value
391: *> \endverbatim
392: *
393: * Authors:
394: * ========
395: *
396: *> \author Univ. of Tennessee
397: *> \author Univ. of California Berkeley
398: *> \author Univ. of Colorado Denver
399: *> \author NAG Ltd.
400: *
401: *> \date June 2017
402: *
403: *> \ingroup doubleGBcomputational
404: *
405: * =====================================================================
406: SUBROUTINE DLA_GBRFSX_EXTENDED( PREC_TYPE, TRANS_TYPE, N, KL, KU,
407: $ NRHS, AB, LDAB, AFB, LDAFB, IPIV,
408: $ COLEQU, C, B, LDB, Y, LDY,
409: $ BERR_OUT, N_NORMS, ERR_BNDS_NORM,
410: $ ERR_BNDS_COMP, RES, AYB, DY,
411: $ Y_TAIL, RCOND, ITHRESH, RTHRESH,
412: $ DZ_UB, IGNORE_CWISE, INFO )
413: *
414: * -- LAPACK computational routine (version 3.7.1) --
415: * -- LAPACK is a software package provided by Univ. of Tennessee, --
416: * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
417: * June 2017
418: *
419: * .. Scalar Arguments ..
420: INTEGER INFO, LDAB, LDAFB, LDB, LDY, N, KL, KU, NRHS,
421: $ PREC_TYPE, TRANS_TYPE, N_NORMS, ITHRESH
422: LOGICAL COLEQU, IGNORE_CWISE
423: DOUBLE PRECISION RTHRESH, DZ_UB
424: * ..
425: * .. Array Arguments ..
426: INTEGER IPIV( * )
427: DOUBLE PRECISION AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
428: $ Y( LDY, * ), RES(*), DY(*), Y_TAIL(*)
429: DOUBLE PRECISION C( * ), AYB(*), RCOND, BERR_OUT(*),
430: $ ERR_BNDS_NORM( NRHS, * ),
431: $ ERR_BNDS_COMP( NRHS, * )
432: * ..
433: *
434: * =====================================================================
435: *
436: * .. Local Scalars ..
437: CHARACTER TRANS
438: INTEGER CNT, I, J, M, X_STATE, Z_STATE, Y_PREC_STATE
439: DOUBLE PRECISION YK, DYK, YMIN, NORMY, NORMX, NORMDX, DXRAT,
440: $ DZRAT, PREVNORMDX, PREV_DZ_Z, DXRATMAX,
441: $ DZRATMAX, DX_X, DZ_Z, FINAL_DX_X, FINAL_DZ_Z,
442: $ EPS, HUGEVAL, INCR_THRESH
443: LOGICAL INCR_PREC
444: * ..
445: * .. Parameters ..
446: INTEGER UNSTABLE_STATE, WORKING_STATE, CONV_STATE,
447: $ NOPROG_STATE, BASE_RESIDUAL, EXTRA_RESIDUAL,
448: $ EXTRA_Y
449: PARAMETER ( UNSTABLE_STATE = 0, WORKING_STATE = 1,
450: $ CONV_STATE = 2, NOPROG_STATE = 3 )
451: PARAMETER ( BASE_RESIDUAL = 0, EXTRA_RESIDUAL = 1,
452: $ EXTRA_Y = 2 )
453: INTEGER FINAL_NRM_ERR_I, FINAL_CMP_ERR_I, BERR_I
454: INTEGER RCOND_I, NRM_RCOND_I, NRM_ERR_I, CMP_RCOND_I
455: INTEGER CMP_ERR_I, PIV_GROWTH_I
456: PARAMETER ( FINAL_NRM_ERR_I = 1, FINAL_CMP_ERR_I = 2,
457: $ BERR_I = 3 )
458: PARAMETER ( RCOND_I = 4, NRM_RCOND_I = 5, NRM_ERR_I = 6 )
459: PARAMETER ( CMP_RCOND_I = 7, CMP_ERR_I = 8,
460: $ PIV_GROWTH_I = 9 )
461: INTEGER LA_LINRX_ITREF_I, LA_LINRX_ITHRESH_I,
462: $ LA_LINRX_CWISE_I
463: PARAMETER ( LA_LINRX_ITREF_I = 1,
464: $ LA_LINRX_ITHRESH_I = 2 )
465: PARAMETER ( LA_LINRX_CWISE_I = 3 )
466: INTEGER LA_LINRX_TRUST_I, LA_LINRX_ERR_I,
467: $ LA_LINRX_RCOND_I
468: PARAMETER ( LA_LINRX_TRUST_I = 1, LA_LINRX_ERR_I = 2 )
469: PARAMETER ( LA_LINRX_RCOND_I = 3 )
470: * ..
471: * .. External Subroutines ..
472: EXTERNAL DAXPY, DCOPY, DGBTRS, DGBMV, BLAS_DGBMV_X,
473: $ BLAS_DGBMV2_X, DLA_GBAMV, DLA_WWADDW, DLAMCH,
474: $ CHLA_TRANSTYPE, DLA_LIN_BERR
475: DOUBLE PRECISION DLAMCH
476: CHARACTER CHLA_TRANSTYPE
477: * ..
478: * .. Intrinsic Functions ..
479: INTRINSIC ABS, MAX, MIN
480: * ..
481: * .. Executable Statements ..
482: *
483: IF (INFO.NE.0) RETURN
484: TRANS = CHLA_TRANSTYPE(TRANS_TYPE)
485: EPS = DLAMCH( 'Epsilon' )
486: HUGEVAL = DLAMCH( 'Overflow' )
487: * Force HUGEVAL to Inf
488: HUGEVAL = HUGEVAL * HUGEVAL
489: * Using HUGEVAL may lead to spurious underflows.
490: INCR_THRESH = DBLE( N ) * EPS
491: M = KL+KU+1
492:
493: DO J = 1, NRHS
494: Y_PREC_STATE = EXTRA_RESIDUAL
495: IF ( Y_PREC_STATE .EQ. EXTRA_Y ) THEN
496: DO I = 1, N
497: Y_TAIL( I ) = 0.0D+0
498: END DO
499: END IF
500:
501: DXRAT = 0.0D+0
502: DXRATMAX = 0.0D+0
503: DZRAT = 0.0D+0
504: DZRATMAX = 0.0D+0
505: FINAL_DX_X = HUGEVAL
506: FINAL_DZ_Z = HUGEVAL
507: PREVNORMDX = HUGEVAL
508: PREV_DZ_Z = HUGEVAL
509: DZ_Z = HUGEVAL
510: DX_X = HUGEVAL
511:
512: X_STATE = WORKING_STATE
513: Z_STATE = UNSTABLE_STATE
514: INCR_PREC = .FALSE.
515:
516: DO CNT = 1, ITHRESH
517: *
518: * Compute residual RES = B_s - op(A_s) * Y,
519: * op(A) = A, A**T, or A**H depending on TRANS (and type).
520: *
521: CALL DCOPY( N, B( 1, J ), 1, RES, 1 )
522: IF ( Y_PREC_STATE .EQ. BASE_RESIDUAL ) THEN
523: CALL DGBMV( TRANS, M, N, KL, KU, -1.0D+0, AB, LDAB,
524: $ Y( 1, J ), 1, 1.0D+0, RES, 1 )
525: ELSE IF ( Y_PREC_STATE .EQ. EXTRA_RESIDUAL ) THEN
526: CALL BLAS_DGBMV_X( TRANS_TYPE, N, N, KL, KU,
527: $ -1.0D+0, AB, LDAB, Y( 1, J ), 1, 1.0D+0, RES, 1,
528: $ PREC_TYPE )
529: ELSE
530: CALL BLAS_DGBMV2_X( TRANS_TYPE, N, N, KL, KU, -1.0D+0,
531: $ AB, LDAB, Y( 1, J ), Y_TAIL, 1, 1.0D+0, RES, 1,
532: $ PREC_TYPE )
533: END IF
534:
535: ! XXX: RES is no longer needed.
536: CALL DCOPY( N, RES, 1, DY, 1 )
537: CALL DGBTRS( TRANS, N, KL, KU, 1, AFB, LDAFB, IPIV, DY, N,
538: $ INFO )
539: *
540: * Calculate relative changes DX_X, DZ_Z and ratios DXRAT, DZRAT.
541: *
542: NORMX = 0.0D+0
543: NORMY = 0.0D+0
544: NORMDX = 0.0D+0
545: DZ_Z = 0.0D+0
546: YMIN = HUGEVAL
547:
548: DO I = 1, N
549: YK = ABS( Y( I, J ) )
550: DYK = ABS( DY( I ) )
551:
552: IF ( YK .NE. 0.0D+0 ) THEN
553: DZ_Z = MAX( DZ_Z, DYK / YK )
554: ELSE IF ( DYK .NE. 0.0D+0 ) THEN
555: DZ_Z = HUGEVAL
556: END IF
557:
558: YMIN = MIN( YMIN, YK )
559:
560: NORMY = MAX( NORMY, YK )
561:
562: IF ( COLEQU ) THEN
563: NORMX = MAX( NORMX, YK * C( I ) )
564: NORMDX = MAX( NORMDX, DYK * C( I ) )
565: ELSE
566: NORMX = NORMY
567: NORMDX = MAX( NORMDX, DYK )
568: END IF
569: END DO
570:
571: IF ( NORMX .NE. 0.0D+0 ) THEN
572: DX_X = NORMDX / NORMX
573: ELSE IF ( NORMDX .EQ. 0.0D+0 ) THEN
574: DX_X = 0.0D+0
575: ELSE
576: DX_X = HUGEVAL
577: END IF
578:
579: DXRAT = NORMDX / PREVNORMDX
580: DZRAT = DZ_Z / PREV_DZ_Z
581: *
582: * Check termination criteria.
583: *
584: IF ( .NOT.IGNORE_CWISE
585: $ .AND. YMIN*RCOND .LT. INCR_THRESH*NORMY
586: $ .AND. Y_PREC_STATE .LT. EXTRA_Y )
587: $ INCR_PREC = .TRUE.
588:
589: IF ( X_STATE .EQ. NOPROG_STATE .AND. DXRAT .LE. RTHRESH )
590: $ X_STATE = WORKING_STATE
591: IF ( X_STATE .EQ. WORKING_STATE ) THEN
592: IF ( DX_X .LE. EPS ) THEN
593: X_STATE = CONV_STATE
594: ELSE IF ( DXRAT .GT. RTHRESH ) THEN
595: IF ( Y_PREC_STATE .NE. EXTRA_Y ) THEN
596: INCR_PREC = .TRUE.
597: ELSE
598: X_STATE = NOPROG_STATE
599: END IF
600: ELSE
601: IF ( DXRAT .GT. DXRATMAX ) DXRATMAX = DXRAT
602: END IF
603: IF ( X_STATE .GT. WORKING_STATE ) FINAL_DX_X = DX_X
604: END IF
605:
606: IF ( Z_STATE .EQ. UNSTABLE_STATE .AND. DZ_Z .LE. DZ_UB )
607: $ Z_STATE = WORKING_STATE
608: IF ( Z_STATE .EQ. NOPROG_STATE .AND. DZRAT .LE. RTHRESH )
609: $ Z_STATE = WORKING_STATE
610: IF ( Z_STATE .EQ. WORKING_STATE ) THEN
611: IF ( DZ_Z .LE. EPS ) THEN
612: Z_STATE = CONV_STATE
613: ELSE IF ( DZ_Z .GT. DZ_UB ) THEN
614: Z_STATE = UNSTABLE_STATE
615: DZRATMAX = 0.0D+0
616: FINAL_DZ_Z = HUGEVAL
617: ELSE IF ( DZRAT .GT. RTHRESH ) THEN
618: IF ( Y_PREC_STATE .NE. EXTRA_Y ) THEN
619: INCR_PREC = .TRUE.
620: ELSE
621: Z_STATE = NOPROG_STATE
622: END IF
623: ELSE
624: IF ( DZRAT .GT. DZRATMAX ) DZRATMAX = DZRAT
625: END IF
626: IF ( Z_STATE .GT. WORKING_STATE ) FINAL_DZ_Z = DZ_Z
627: END IF
628: *
629: * Exit if both normwise and componentwise stopped working,
630: * but if componentwise is unstable, let it go at least two
631: * iterations.
632: *
633: IF ( X_STATE.NE.WORKING_STATE ) THEN
634: IF ( IGNORE_CWISE ) GOTO 666
635: IF ( Z_STATE.EQ.NOPROG_STATE .OR. Z_STATE.EQ.CONV_STATE )
636: $ GOTO 666
637: IF ( Z_STATE.EQ.UNSTABLE_STATE .AND. CNT.GT.1 ) GOTO 666
638: END IF
639:
640: IF ( INCR_PREC ) THEN
641: INCR_PREC = .FALSE.
642: Y_PREC_STATE = Y_PREC_STATE + 1
643: DO I = 1, N
644: Y_TAIL( I ) = 0.0D+0
645: END DO
646: END IF
647:
648: PREVNORMDX = NORMDX
649: PREV_DZ_Z = DZ_Z
650: *
651: * Update soluton.
652: *
653: IF (Y_PREC_STATE .LT. EXTRA_Y) THEN
654: CALL DAXPY( N, 1.0D+0, DY, 1, Y(1,J), 1 )
655: ELSE
656: CALL DLA_WWADDW( N, Y(1,J), Y_TAIL, DY )
657: END IF
658:
659: END DO
660: * Target of "IF (Z_STOP .AND. X_STOP)". Sun's f77 won't EXIT.
661: 666 CONTINUE
662: *
663: * Set final_* when cnt hits ithresh.
664: *
665: IF ( X_STATE .EQ. WORKING_STATE ) FINAL_DX_X = DX_X
666: IF ( Z_STATE .EQ. WORKING_STATE ) FINAL_DZ_Z = DZ_Z
667: *
668: * Compute error bounds.
669: *
670: IF ( N_NORMS .GE. 1 ) THEN
671: ERR_BNDS_NORM( J, LA_LINRX_ERR_I ) =
672: $ FINAL_DX_X / (1 - DXRATMAX)
673: END IF
674: IF (N_NORMS .GE. 2) THEN
675: ERR_BNDS_COMP( J, LA_LINRX_ERR_I ) =
676: $ FINAL_DZ_Z / (1 - DZRATMAX)
677: END IF
678: *
679: * Compute componentwise relative backward error from formula
680: * max(i) ( abs(R(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) )
681: * where abs(Z) is the componentwise absolute value of the matrix
682: * or vector Z.
683: *
684: * Compute residual RES = B_s - op(A_s) * Y,
685: * op(A) = A, A**T, or A**H depending on TRANS (and type).
686: *
687: CALL DCOPY( N, B( 1, J ), 1, RES, 1 )
688: CALL DGBMV(TRANS, N, N, KL, KU, -1.0D+0, AB, LDAB, Y(1,J),
689: $ 1, 1.0D+0, RES, 1 )
690:
691: DO I = 1, N
692: AYB( I ) = ABS( B( I, J ) )
693: END DO
694: *
695: * Compute abs(op(A_s))*abs(Y) + abs(B_s).
696: *
697: CALL DLA_GBAMV( TRANS_TYPE, N, N, KL, KU, 1.0D+0,
698: $ AB, LDAB, Y(1, J), 1, 1.0D+0, AYB, 1 )
699:
700: CALL DLA_LIN_BERR( N, N, 1, RES, AYB, BERR_OUT( J ) )
701: *
702: * End of loop for each RHS
703: *
704: END DO
705: *
706: RETURN
707: END
CVSweb interface <joel.bertrand@systella.fr>