001:       SUBROUTINE SLA_SYRFSX_EXTENDED( PREC_TYPE, UPLO, N, NRHS, A, LDA,
002:      $                                AF, LDAF, IPIV, COLEQU, C, B, LDB,
003:      $                                Y, LDY, BERR_OUT, N_NORMS,
004:      $                                ERR_BNDS_NORM, ERR_BNDS_COMP, RES,
005:      $                                AYB, DY, Y_TAIL, RCOND, ITHRESH,
006:      $                                RTHRESH, DZ_UB, IGNORE_CWISE,
007:      $                                INFO )
008: *
009: *     -- LAPACK routine (version 3.2.1)                                 --
010: *     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and --
011: *     -- Jason Riedy of Univ. of California Berkeley.                 --
012: *     -- April 2009                                                   --
013: *
014: *     -- LAPACK is a software package provided by Univ. of Tennessee, --
015: *     -- Univ. of California Berkeley and NAG Ltd.                    --
016: *
017:       IMPLICIT NONE
018: *     ..
019: *     .. Scalar Arguments ..
020:       INTEGER            INFO, LDA, LDAF, LDB, LDY, N, NRHS, PREC_TYPE,
021:      $                   N_NORMS, ITHRESH
022:       CHARACTER          UPLO
023:       LOGICAL            COLEQU, IGNORE_CWISE
024:       REAL               RTHRESH, DZ_UB
025: *     ..
026: *     .. Array Arguments ..
027:       INTEGER            IPIV( * )
028:       REAL               A( LDA, * ), AF( LDAF, * ), B( LDB, * ),
029:      $                   Y( LDY, * ), RES( * ), DY( * ), Y_TAIL( * )
030:       REAL               C( * ), AYB( * ), RCOND, BERR_OUT( * ),
031:      $                   ERR_BNDS_NORM( NRHS, * ),
032:      $                   ERR_BNDS_COMP( NRHS, * )
033: *     ..
034: *
035: *  Purpose
036: *  =======
037: * 
038: *  SLA_SYRFSX_EXTENDED improves the computed solution to a system of
039: *  linear equations by performing extra-precise iterative refinement
040: *  and provides error bounds and backward error estimates for the solution.
041: *  This subroutine is called by SSYRFSX to perform iterative refinement.
042: *  In addition to normwise error bound, the code provides maximum
043: *  componentwise error bound if possible. See comments for ERR_BNDS_NORM
044: *  and ERR_BNDS_COMP for details of the error bounds. Note that this
045: *  subroutine is only resonsible for setting the second fields of
046: *  ERR_BNDS_NORM and ERR_BNDS_COMP.
047: *
048: *  Arguments
049: *  =========
050: *
051: *     PREC_TYPE      (input) INTEGER
052: *     Specifies the intermediate precision to be used in refinement.
053: *     The value is defined by ILAPREC(P) where P is a CHARACTER and
054: *     P    = 'S':  Single
055: *          = 'D':  Double
056: *          = 'I':  Indigenous
057: *          = 'X', 'E':  Extra
058: *
059: *     UPLO    (input) CHARACTER*1
060: *       = 'U':  Upper triangle of A is stored;
061: *       = 'L':  Lower triangle of A is stored.
062: *
063: *     N              (input) INTEGER
064: *     The number of linear equations, i.e., the order of the
065: *     matrix A.  N >= 0.
066: *
067: *     NRHS           (input) INTEGER
068: *     The number of right-hand-sides, i.e., the number of columns of the
069: *     matrix B.
070: *
071: *     A              (input) REAL array, dimension (LDA,N)
072: *     On entry, the N-by-N matrix A.
073: *
074: *     LDA            (input) INTEGER
075: *     The leading dimension of the array A.  LDA >= max(1,N).
076: *
077: *     AF             (input) REAL array, dimension (LDAF,N)
078: *     The block diagonal matrix D and the multipliers used to
079: *     obtain the factor U or L as computed by SSYTRF.
080: *
081: *     LDAF           (input) INTEGER
082: *     The leading dimension of the array AF.  LDAF >= max(1,N).
083: *
084: *     IPIV           (input) INTEGER array, dimension (N)
085: *     Details of the interchanges and the block structure of D
086: *     as determined by SSYTRF.
087: *
088: *     COLEQU         (input) LOGICAL
089: *     If .TRUE. then column equilibration was done to A before calling
090: *     this routine. This is needed to compute the solution and error
091: *     bounds correctly.
092: *
093: *     C              (input) REAL array, dimension (N)
094: *     The column scale factors for A. If COLEQU = .FALSE., C
095: *     is not accessed. If C is input, each element of C should be a power
096: *     of the radix to ensure a reliable solution and error estimates.
097: *     Scaling by powers of the radix does not cause rounding errors unless
098: *     the result underflows or overflows. Rounding errors during scaling
099: *     lead to refining with a matrix that is not equivalent to the
100: *     input matrix, producing error estimates that may not be
101: *     reliable.
102: *
103: *     B              (input) REAL array, dimension (LDB,NRHS)
104: *     The right-hand-side matrix B.
105: *
106: *     LDB            (input) INTEGER
107: *     The leading dimension of the array B.  LDB >= max(1,N).
108: *
109: *     Y              (input/output) REAL array, dimension (LDY,NRHS)
110: *     On entry, the solution matrix X, as computed by SSYTRS.
111: *     On exit, the improved solution matrix Y.
112: *
113: *     LDY            (input) INTEGER
114: *     The leading dimension of the array Y.  LDY >= max(1,N).
115: *
116: *     BERR_OUT       (output) REAL array, dimension (NRHS)
117: *     On exit, BERR_OUT(j) contains the componentwise relative backward
118: *     error for right-hand-side j from the formula
119: *         max(i) ( abs(RES(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) )
120: *     where abs(Z) is the componentwise absolute value of the matrix
121: *     or vector Z. This is computed by SLA_LIN_BERR.
122: *
123: *     N_NORMS        (input) INTEGER
124: *     Determines which error bounds to return (see ERR_BNDS_NORM
125: *     and ERR_BNDS_COMP).
126: *     If N_NORMS >= 1 return normwise error bounds.
127: *     If N_NORMS >= 2 return componentwise error bounds.
128: *
129: *     ERR_BNDS_NORM  (input/output) REAL array, dimension (NRHS, N_ERR_BNDS)
130: *     For each right-hand side, this array contains information about
131: *     various error bounds and condition numbers corresponding to the
132: *     normwise relative error, which is defined as follows:
133: *
134: *     Normwise relative error in the ith solution vector:
135: *             max_j (abs(XTRUE(j,i) - X(j,i)))
136: *            ------------------------------
137: *                  max_j abs(X(j,i))
138: *
139: *     The array is indexed by the type of error information as described
140: *     below. There currently are up to three pieces of information
141: *     returned.
142: *
143: *     The first index in ERR_BNDS_NORM(i,:) corresponds to the ith
144: *     right-hand side.
145: *
146: *     The second index in ERR_BNDS_NORM(:,err) contains the following
147: *     three fields:
148: *     err = 1 "Trust/don't trust" boolean. Trust the answer if the
149: *              reciprocal condition number is less than the threshold
150: *              sqrt(n) * slamch('Epsilon').
151: *
152: *     err = 2 "Guaranteed" error bound: The estimated forward error,
153: *              almost certainly within a factor of 10 of the true error
154: *              so long as the next entry is greater than the threshold
155: *              sqrt(n) * slamch('Epsilon'). This error bound should only
156: *              be trusted if the previous boolean is true.
157: *
158: *     err = 3  Reciprocal condition number: Estimated normwise
159: *              reciprocal condition number.  Compared with the threshold
160: *              sqrt(n) * slamch('Epsilon') to determine if the error
161: *              estimate is "guaranteed". These reciprocal condition
162: *              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some
163: *              appropriately scaled matrix Z.
164: *              Let Z = S*A, where S scales each row by a power of the
165: *              radix so all absolute row sums of Z are approximately 1.
166: *
167: *     This subroutine is only responsible for setting the second field
168: *     above.
169: *     See Lapack Working Note 165 for further details and extra
170: *     cautions.
171: *
172: *     ERR_BNDS_COMP  (input/output) REAL array, dimension (NRHS, N_ERR_BNDS)
173: *     For each right-hand side, this array contains information about
174: *     various error bounds and condition numbers corresponding to the
175: *     componentwise relative error, which is defined as follows:
176: *
177: *     Componentwise relative error in the ith solution vector:
178: *                    abs(XTRUE(j,i) - X(j,i))
179: *             max_j ----------------------
180: *                         abs(X(j,i))
181: *
182: *     The array is indexed by the right-hand side i (on which the
183: *     componentwise relative error depends), and the type of error
184: *     information as described below. There currently are up to three
185: *     pieces of information returned for each right-hand side. If
186: *     componentwise accuracy is not requested (PARAMS(3) = 0.0), then
187: *     ERR_BNDS_COMP is not accessed.  If N_ERR_BNDS .LT. 3, then at most
188: *     the first (:,N_ERR_BNDS) entries are returned.
189: *
190: *     The first index in ERR_BNDS_COMP(i,:) corresponds to the ith
191: *     right-hand side.
192: *
193: *     The second index in ERR_BNDS_COMP(:,err) contains the following
194: *     three fields:
195: *     err = 1 "Trust/don't trust" boolean. Trust the answer if the
196: *              reciprocal condition number is less than the threshold
197: *              sqrt(n) * slamch('Epsilon').
198: *
199: *     err = 2 "Guaranteed" error bound: The estimated forward error,
200: *              almost certainly within a factor of 10 of the true error
201: *              so long as the next entry is greater than the threshold
202: *              sqrt(n) * slamch('Epsilon'). This error bound should only
203: *              be trusted if the previous boolean is true.
204: *
205: *     err = 3  Reciprocal condition number: Estimated componentwise
206: *              reciprocal condition number.  Compared with the threshold
207: *              sqrt(n) * slamch('Epsilon') to determine if the error
208: *              estimate is "guaranteed". These reciprocal condition
209: *              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some
210: *              appropriately scaled matrix Z.
211: *              Let Z = S*(A*diag(x)), where x is the solution for the
212: *              current right-hand side and S scales each row of
213: *              A*diag(x) by a power of the radix so all absolute row
214: *              sums of Z are approximately 1.
215: *
216: *     This subroutine is only responsible for setting the second field
217: *     above.
218: *     See Lapack Working Note 165 for further details and extra
219: *     cautions.
220: *
221: *     RES            (input) REAL array, dimension (N)
222: *     Workspace to hold the intermediate residual.
223: *
224: *     AYB            (input) REAL array, dimension (N)
225: *     Workspace. This can be the same workspace passed for Y_TAIL.
226: *
227: *     DY             (input) REAL array, dimension (N)
228: *     Workspace to hold the intermediate solution.
229: *
230: *     Y_TAIL         (input) REAL array, dimension (N)
231: *     Workspace to hold the trailing bits of the intermediate solution.
232: *
233: *     RCOND          (input) REAL
234: *     Reciprocal scaled condition number.  This is an estimate of the
235: *     reciprocal Skeel condition number of the matrix A after
236: *     equilibration (if done).  If this is less than the machine
237: *     precision (in particular, if it is zero), the matrix is singular
238: *     to working precision.  Note that the error may still be small even
239: *     if this number is very small and the matrix appears ill-
240: *     conditioned.
241: *
242: *     ITHRESH        (input) INTEGER
243: *     The maximum number of residual computations allowed for
244: *     refinement. The default is 10. For 'aggressive' set to 100 to
245: *     permit convergence using approximate factorizations or
246: *     factorizations other than LU. If the factorization uses a
247: *     technique other than Gaussian elimination, the guarantees in
248: *     ERR_BNDS_NORM and ERR_BNDS_COMP may no longer be trustworthy.
249: *
250: *     RTHRESH        (input) REAL
251: *     Determines when to stop refinement if the error estimate stops
252: *     decreasing. Refinement will stop when the next solution no longer
253: *     satisfies norm(dx_{i+1}) < RTHRESH * norm(dx_i) where norm(Z) is
254: *     the infinity norm of Z. RTHRESH satisfies 0 < RTHRESH <= 1. The
255: *     default value is 0.5. For 'aggressive' set to 0.9 to permit
256: *     convergence on extremely ill-conditioned matrices. See LAWN 165
257: *     for more details.
258: *
259: *     DZ_UB          (input) REAL
260: *     Determines when to start considering componentwise convergence.
261: *     Componentwise convergence is only considered after each component
262: *     of the solution Y is stable, which we definte as the relative
263: *     change in each component being less than DZ_UB. The default value
264: *     is 0.25, requiring the first bit to be stable. See LAWN 165 for
265: *     more details.
266: *
267: *     IGNORE_CWISE   (input) LOGICAL
268: *     If .TRUE. then ignore componentwise convergence. Default value
269: *     is .FALSE..
270: *
271: *     INFO           (output) INTEGER
272: *       = 0:  Successful exit.
273: *       < 0:  if INFO = -i, the ith argument to SSYTRS had an illegal
274: *             value
275: *
276: *  =====================================================================
277: *
278: *     .. Local Scalars ..
279:       INTEGER            UPLO2, CNT, I, J, X_STATE, Z_STATE
280:       REAL               YK, DYK, YMIN, NORMY, NORMX, NORMDX, DXRAT,
281:      $                   DZRAT, PREVNORMDX, PREV_DZ_Z, DXRATMAX,
282:      $                   DZRATMAX, DX_X, DZ_Z, FINAL_DX_X, FINAL_DZ_Z,
283:      $                   EPS, HUGEVAL, INCR_THRESH
284:       LOGICAL            INCR_PREC
285: *     ..
286: *     .. Parameters ..
287:       INTEGER            UNSTABLE_STATE, WORKING_STATE, CONV_STATE,
288:      $                   NOPROG_STATE, Y_PREC_STATE, BASE_RESIDUAL,
289:      $                   EXTRA_RESIDUAL, EXTRA_Y
290:       PARAMETER          ( UNSTABLE_STATE = 0, WORKING_STATE = 1,
291:      $                   CONV_STATE = 2, NOPROG_STATE = 3 )
292:       PARAMETER          ( BASE_RESIDUAL = 0, EXTRA_RESIDUAL = 1,
293:      $                   EXTRA_Y = 2 )
294:       INTEGER            FINAL_NRM_ERR_I, FINAL_CMP_ERR_I, BERR_I
295:       INTEGER            RCOND_I, NRM_RCOND_I, NRM_ERR_I, CMP_RCOND_I
296:       INTEGER            CMP_ERR_I, PIV_GROWTH_I
297:       PARAMETER          ( FINAL_NRM_ERR_I = 1, FINAL_CMP_ERR_I = 2,
298:      $                   BERR_I = 3 )
299:       PARAMETER          ( RCOND_I = 4, NRM_RCOND_I = 5, NRM_ERR_I = 6 )
300:       PARAMETER          ( CMP_RCOND_I = 7, CMP_ERR_I = 8,
301:      $                   PIV_GROWTH_I = 9 )
302:       INTEGER            LA_LINRX_ITREF_I, LA_LINRX_ITHRESH_I,
303:      $                   LA_LINRX_CWISE_I
304:       PARAMETER          ( LA_LINRX_ITREF_I = 1,
305:      $                   LA_LINRX_ITHRESH_I = 2 )
306:       PARAMETER          ( LA_LINRX_CWISE_I = 3 )
307:       INTEGER            LA_LINRX_TRUST_I, LA_LINRX_ERR_I,
308:      $                   LA_LINRX_RCOND_I
309:       PARAMETER          ( LA_LINRX_TRUST_I = 1, LA_LINRX_ERR_I = 2 )
310:       PARAMETER          ( LA_LINRX_RCOND_I = 3 )
311: *     ..
312: *     .. External Functions ..
313:       LOGICAL            LSAME
314:       EXTERNAL           ILAUPLO
315:       INTEGER            ILAUPLO
316: *     ..
317: *     .. External Subroutines ..
318:       EXTERNAL           SAXPY, SCOPY, SSYTRS, SSYMV, BLAS_SSYMV_X,
319:      $                   BLAS_SSYMV2_X, SLA_SYAMV, SLA_WWADDW,
320:      $                   SLA_LIN_BERR
321:       REAL               SLAMCH
322: *     ..
323: *     .. Intrinsic Functions ..
324:       INTRINSIC          ABS, MAX, MIN
325: *     ..
326: *     .. Executable Statements ..
327: *
328:       IF ( INFO.NE.0 ) RETURN
329:       EPS = SLAMCH( 'Epsilon' )
330:       HUGEVAL = SLAMCH( 'Overflow' )
331: *     Force HUGEVAL to Inf
332:       HUGEVAL = HUGEVAL * HUGEVAL
333: *     Using HUGEVAL may lead to spurious underflows.
334:       INCR_THRESH = REAL( N )*EPS
335: 
336:       IF ( LSAME ( UPLO, 'L' ) ) THEN
337:          UPLO2 = ILAUPLO( 'L' )
338:       ELSE
339:          UPLO2 = ILAUPLO( 'U' )
340:       ENDIF
341: 
342:       DO J = 1, NRHS
343:          Y_PREC_STATE = EXTRA_RESIDUAL
344:          IF ( Y_PREC_STATE .EQ. EXTRA_Y ) THEN
345:             DO I = 1, N
346:                Y_TAIL( I ) = 0.0
347:             END DO
348:          END IF
349: 
350:          DXRAT = 0.0
351:          DXRATMAX = 0.0
352:          DZRAT = 0.0
353:          DZRATMAX = 0.0
354:          FINAL_DX_X = HUGEVAL
355:          FINAL_DZ_Z = HUGEVAL
356:          PREVNORMDX = HUGEVAL
357:          PREV_DZ_Z = HUGEVAL
358:          DZ_Z = HUGEVAL
359:          DX_X = HUGEVAL
360: 
361:          X_STATE = WORKING_STATE
362:          Z_STATE = UNSTABLE_STATE
363:          INCR_PREC = .FALSE.
364: 
365:          DO CNT = 1, ITHRESH
366: *
367: *        Compute residual RES = B_s - op(A_s) * Y,
368: *            op(A) = A, A**T, or A**H depending on TRANS (and type).
369: *
370:             CALL SCOPY( N, B( 1, J ), 1, RES, 1 )
371:             IF (Y_PREC_STATE .EQ. BASE_RESIDUAL) THEN
372:                CALL SSYMV( UPLO, N, -1.0, A, LDA, Y(1,J), 1,
373:      $              1.0, RES, 1 )
374:             ELSE IF (Y_PREC_STATE .EQ. EXTRA_RESIDUAL) THEN
375:                CALL BLAS_SSYMV_X( UPLO2, N, -1.0, A, LDA,
376:      $              Y( 1, J ), 1, 1.0, RES, 1, PREC_TYPE )
377:             ELSE
378:                CALL BLAS_SSYMV2_X(UPLO2, N, -1.0, A, LDA,
379:      $              Y(1, J), Y_TAIL, 1, 1.0, RES, 1, PREC_TYPE)
380:             END IF
381:             
382: !         XXX: RES is no longer needed.
383:             CALL SCOPY( N, RES, 1, DY, 1 )
384:             CALL SSYTRS( UPLO, N, NRHS, AF, LDAF, IPIV, DY, N, INFO )
385: *
386: *         Calculate relative changes DX_X, DZ_Z and ratios DXRAT, DZRAT.
387: *
388:             NORMX = 0.0
389:             NORMY = 0.0
390:             NORMDX = 0.0
391:             DZ_Z = 0.0
392:             YMIN = HUGEVAL
393:             
394:             DO I = 1, N
395:                YK = ABS( Y( I, J ) )
396:                DYK = ABS( DY( I ) )
397:                
398:                IF ( YK .NE. 0.0 ) THEN
399:                   DZ_Z = MAX( DZ_Z, DYK / YK )
400:                ELSE IF ( DYK .NE. 0.0 ) THEN
401:                   DZ_Z = HUGEVAL
402:                END IF
403: 
404:                YMIN = MIN( YMIN, YK )
405: 
406:                NORMY = MAX( NORMY, YK )
407: 
408:                IF ( COLEQU ) THEN
409:                   NORMX = MAX( NORMX, YK * C( I ) )
410:                   NORMDX = MAX( NORMDX, DYK * C( I ) )
411:                ELSE
412:                   NORMX = NORMY
413:                   NORMDX = MAX(NORMDX, DYK)
414:                END IF
415:             END DO
416: 
417:             IF ( NORMX .NE. 0.0 ) THEN
418:                DX_X = NORMDX / NORMX
419:             ELSE IF ( NORMDX .EQ. 0.0 ) THEN
420:                DX_X = 0.0
421:             ELSE
422:                DX_X = HUGEVAL
423:             END IF
424: 
425:             DXRAT = NORMDX / PREVNORMDX
426:             DZRAT = DZ_Z / PREV_DZ_Z
427: *
428: *         Check termination criteria.
429: *
430:             IF ( YMIN*RCOND .LT. INCR_THRESH*NORMY
431:      $           .AND. Y_PREC_STATE .LT. EXTRA_Y )
432:      $           INCR_PREC = .TRUE.
433: 
434:             IF ( X_STATE .EQ. NOPROG_STATE .AND. DXRAT .LE. RTHRESH )
435:      $           X_STATE = WORKING_STATE
436:             IF ( X_STATE .EQ. WORKING_STATE ) THEN
437:                IF ( DX_X .LE. EPS ) THEN
438:                   X_STATE = CONV_STATE
439:                ELSE IF ( DXRAT .GT. RTHRESH ) THEN
440:                   IF ( Y_PREC_STATE .NE. EXTRA_Y ) THEN
441:                      INCR_PREC = .TRUE.
442:                   ELSE
443:                      X_STATE = NOPROG_STATE
444:                   END IF
445:                ELSE
446:                   IF ( DXRAT .GT. DXRATMAX ) DXRATMAX = DXRAT
447:                END IF
448:                IF ( X_STATE .GT. WORKING_STATE ) FINAL_DX_X = DX_X
449:             END IF
450: 
451:             IF ( Z_STATE .EQ. UNSTABLE_STATE .AND. DZ_Z .LE. DZ_UB )
452:      $           Z_STATE = WORKING_STATE
453:             IF ( Z_STATE .EQ. NOPROG_STATE .AND. DZRAT .LE. RTHRESH )
454:      $           Z_STATE = WORKING_STATE
455:             IF ( Z_STATE .EQ. WORKING_STATE ) THEN
456:                IF ( DZ_Z .LE. EPS ) THEN
457:                   Z_STATE = CONV_STATE
458:                ELSE IF ( DZ_Z .GT. DZ_UB ) THEN
459:                   Z_STATE = UNSTABLE_STATE
460:                   DZRATMAX = 0.0
461:                   FINAL_DZ_Z = HUGEVAL
462:                ELSE IF ( DZRAT .GT. RTHRESH ) THEN
463:                   IF ( Y_PREC_STATE .NE. EXTRA_Y ) THEN
464:                      INCR_PREC = .TRUE.
465:                   ELSE
466:                      Z_STATE = NOPROG_STATE
467:                   END IF
468:                ELSE
469:                   IF ( DZRAT .GT. DZRATMAX ) DZRATMAX = DZRAT
470:                END IF
471:                IF ( Z_STATE .GT. WORKING_STATE ) FINAL_DZ_Z = DZ_Z
472:             END IF
473: 
474:             IF ( X_STATE.NE.WORKING_STATE.AND.
475:      $           ( IGNORE_CWISE.OR.Z_STATE.NE.WORKING_STATE ) )
476:      $           GOTO 666
477: 
478:             IF ( INCR_PREC ) THEN
479:                INCR_PREC = .FALSE.
480:                Y_PREC_STATE = Y_PREC_STATE + 1
481:                DO I = 1, N
482:                   Y_TAIL( I ) = 0.0
483:                END DO
484:             END IF
485: 
486:             PREVNORMDX = NORMDX
487:             PREV_DZ_Z = DZ_Z
488: *
489: *           Update soluton.
490: *
491:             IF (Y_PREC_STATE .LT. EXTRA_Y) THEN
492:                CALL SAXPY( N, 1.0, DY, 1, Y(1,J), 1 )
493:             ELSE
494:                CALL SLA_WWADDW( N, Y(1,J), Y_TAIL, DY )
495:             END IF
496:             
497:          END DO
498: *        Target of "IF (Z_STOP .AND. X_STOP)".  Sun's f77 won't EXIT.
499:  666     CONTINUE
500: *
501: *     Set final_* when cnt hits ithresh.
502: *
503:          IF ( X_STATE .EQ. WORKING_STATE ) FINAL_DX_X = DX_X
504:          IF ( Z_STATE .EQ. WORKING_STATE ) FINAL_DZ_Z = DZ_Z
505: *
506: *     Compute error bounds.
507: *
508:          IF ( N_NORMS .GE. 1 ) THEN
509:             ERR_BNDS_NORM( J, LA_LINRX_ERR_I ) =
510:      $           FINAL_DX_X / (1 - DXRATMAX)
511:          END IF
512:          IF ( N_NORMS .GE. 2 ) THEN
513:             ERR_BNDS_COMP( J, LA_LINRX_ERR_I ) =
514:      $           FINAL_DZ_Z / (1 - DZRATMAX)
515:          END IF
516: *
517: *     Compute componentwise relative backward error from formula
518: *         max(i) ( abs(R(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) )
519: *     where abs(Z) is the componentwise absolute value of the matrix
520: *     or vector Z.
521: *
522: *        Compute residual RES = B_s - op(A_s) * Y,
523: *            op(A) = A, A**T, or A**H depending on TRANS (and type).
524:          CALL SCOPY( N, B( 1, J ), 1, RES, 1 )
525:          CALL SSYMV( UPLO, N, -1.0, A, LDA, Y(1,J), 1, 1.0, RES, 1 )
526:          
527:          DO I = 1, N
528:             AYB( I ) = ABS( B( I, J ) )
529:          END DO
530: *
531: *     Compute abs(op(A_s))*abs(Y) + abs(B_s).
532: *
533:          CALL SLA_SYAMV( UPLO2, N, 1.0,
534:      $        A, LDA, Y(1, J), 1, 1.0, AYB, 1 )
535:          
536:          CALL SLA_LIN_BERR( N, N, 1, RES, AYB, BERR_OUT( J ) )
537: *
538: *     End of loop for each RHS.
539: *
540:       END DO
541: *
542:       RETURN
543:       END
544: