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