001:       Subroutine CSYRFSX( UPLO, EQUED, N, NRHS, A, LDA, AF, LDAF, IPIV,
002:      $                    S, B, LDB, X, LDX, RCOND, BERR, N_ERR_BNDS,
003:      $                    ERR_BNDS_NORM, ERR_BNDS_COMP, NPARAMS, PARAMS,
004:      $                    WORK, RWORK, INFO )
005: *
006: *     -- LAPACK routine (version 3.2)                                 --
007: *     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and --
008: *     -- Jason Riedy of Univ. of California Berkeley.                 --
009: *     -- November 2008                                                --
010: *
011: *     -- LAPACK is a software package provided by Univ. of Tennessee, --
012: *     -- Univ. of California Berkeley and NAG Ltd.                    --
013: *
014:       IMPLICIT NONE
015: *     ..
016: *     .. Scalar Arguments ..
017:       CHARACTER          UPLO, EQUED
018:       INTEGER            INFO, LDA, LDAF, LDB, LDX, N, NRHS, NPARAMS,
019:      $                   N_ERR_BNDS
020:       REAL               RCOND
021: *     ..
022: *     .. Array Arguments ..
023:       INTEGER            IPIV( * )
024:       COMPLEX            A( LDA, * ), AF( LDAF, * ), B( LDB, * ),
025:      $                   X( LDX, * ), WORK( * )
026:       REAL               S( * ), PARAMS( * ), BERR( * ), RWORK( * ),
027:      $                   ERR_BNDS_NORM( NRHS, * ),
028:      $                   ERR_BNDS_COMP( NRHS, * )
029: *     ..
030: *
031: *     Purpose
032: *     =======
033: *
034: *     CSYRFSX improves the computed solution to a system of linear
035: *     equations when the coefficient matrix is symmetric indefinite, and
036: *     provides error bounds and backward error estimates for the
037: *     solution.  In addition to normwise error bound, the code provides
038: *     maximum componentwise error bound if possible.  See comments for
039: *     ERR_BNDS_N and ERR_BNDS_C for details of the error bounds.
040: *
041: *     The original system of linear equations may have been equilibrated
042: *     before calling this routine, as described by arguments EQUED and S
043: *     below. In this case, the solution and error bounds returned are
044: *     for the original unequilibrated system.
045: *
046: *     Arguments
047: *     =========
048: *
049: *     Some optional parameters are bundled in the PARAMS array.  These
050: *     settings determine how refinement is performed, but often the
051: *     defaults are acceptable.  If the defaults are acceptable, users
052: *     can pass NPARAMS = 0 which prevents the source code from accessing
053: *     the PARAMS argument.
054: *
055: *     UPLO    (input) CHARACTER*1
056: *       = 'U':  Upper triangle of A is stored;
057: *       = 'L':  Lower triangle of A is stored.
058: *
059: *     EQUED   (input) CHARACTER*1
060: *     Specifies the form of equilibration that was done to A
061: *     before calling this routine. This is needed to compute
062: *     the solution and error bounds correctly.
063: *       = 'N':  No equilibration
064: *       = 'Y':  Both row and column equilibration, i.e., A has been
065: *               replaced by diag(S) * A * diag(S).
066: *               The right hand side B has been changed accordingly.
067: *
068: *     N       (input) INTEGER
069: *     The order of the matrix A.  N >= 0.
070: *
071: *     NRHS    (input) INTEGER
072: *     The number of right hand sides, i.e., the number of columns
073: *     of the matrices B and X.  NRHS >= 0.
074: *
075: *     A       (input) COMPLEX array, dimension (LDA,N)
076: *     The symmetric matrix A.  If UPLO = 'U', the leading N-by-N
077: *     upper triangular part of A contains the upper triangular
078: *     part of the matrix A, and the strictly lower triangular
079: *     part of A is not referenced.  If UPLO = 'L', the leading
080: *     N-by-N lower triangular part of A contains the lower
081: *     triangular part of the matrix A, and the strictly upper
082: *     triangular part of A is not referenced.
083: *
084: *     LDA     (input) INTEGER
085: *     The leading dimension of the array A.  LDA >= max(1,N).
086: *
087: *     AF      (input) COMPLEX array, dimension (LDAF,N)
088: *     The factored form of the matrix A.  AF contains the block
089: *     diagonal matrix D and the multipliers used to obtain the
090: *     factor U or L from the factorization A = U*D*U**T or A =
091: *     L*D*L**T as computed by SSYTRF.
092: *
093: *     LDAF    (input) INTEGER
094: *     The leading dimension of the array AF.  LDAF >= max(1,N).
095: *
096: *     IPIV    (input) INTEGER array, dimension (N)
097: *     Details of the interchanges and the block structure of D
098: *     as determined by SSYTRF.
099: *
100: *     S       (input or output) REAL array, dimension (N)
101: *     The scale factors for A.  If EQUED = 'Y', A is multiplied on
102: *     the left and right by diag(S).  S is an input argument if FACT =
103: *     'F'; otherwise, S is an output argument.  If FACT = 'F' and EQUED
104: *     = 'Y', each element of S must be positive.  If S is output, each
105: *     element of S is a power of the radix. If S is input, each element
106: *     of S should be a power of the radix to ensure a reliable solution
107: *     and error estimates. Scaling by powers of the radix does not cause
108: *     rounding errors unless the result underflows or overflows.
109: *     Rounding errors during scaling lead to refining with a matrix that
110: *     is not equivalent to the input matrix, producing error estimates
111: *     that may not be reliable.
112: *
113: *     B       (input) COMPLEX array, dimension (LDB,NRHS)
114: *     The right hand side matrix B.
115: *
116: *     LDB     (input) INTEGER
117: *     The leading dimension of the array B.  LDB >= max(1,N).
118: *
119: *     X       (input/output) COMPLEX array, dimension (LDX,NRHS)
120: *     On entry, the solution matrix X, as computed by SGETRS.
121: *     On exit, the improved solution matrix X.
122: *
123: *     LDX     (input) INTEGER
124: *     The leading dimension of the array X.  LDX >= max(1,N).
125: *
126: *     RCOND   (output) REAL
127: *     Reciprocal scaled condition number.  This is an estimate of the
128: *     reciprocal Skeel condition number of the matrix A after
129: *     equilibration (if done).  If this is less than the machine
130: *     precision (in particular, if it is zero), the matrix is singular
131: *     to working precision.  Note that the error may still be small even
132: *     if this number is very small and the matrix appears ill-
133: *     conditioned.
134: *
135: *     BERR    (output) REAL array, dimension (NRHS)
136: *     Componentwise relative backward error.  This is the
137: *     componentwise relative backward error of each solution vector X(j)
138: *     (i.e., the smallest relative change in any element of A or B that
139: *     makes X(j) an exact solution).
140: *
141: *     N_ERR_BNDS (input) INTEGER
142: *     Number of error bounds to return for each right hand side
143: *     and each type (normwise or componentwise).  See ERR_BNDS_NORM and
144: *     ERR_BNDS_COMP below.
145: *
146: *     ERR_BNDS_NORM  (output) REAL array, dimension (NRHS, N_ERR_BNDS)
147: *     For each right-hand side, this array contains information about
148: *     various error bounds and condition numbers corresponding to the
149: *     normwise relative error, which is defined as follows:
150: *
151: *     Normwise relative error in the ith solution vector:
152: *             max_j (abs(XTRUE(j,i) - X(j,i)))
153: *            ------------------------------
154: *                  max_j abs(X(j,i))
155: *
156: *     The array is indexed by the type of error information as described
157: *     below. There currently are up to three pieces of information
158: *     returned.
159: *
160: *     The first index in ERR_BNDS_NORM(i,:) corresponds to the ith
161: *     right-hand side.
162: *
163: *     The second index in ERR_BNDS_NORM(:,err) contains the following
164: *     three fields:
165: *     err = 1 "Trust/don't trust" boolean. Trust the answer if the
166: *              reciprocal condition number is less than the threshold
167: *              sqrt(n) * slamch('Epsilon').
168: *
169: *     err = 2 "Guaranteed" error bound: The estimated forward error,
170: *              almost certainly within a factor of 10 of the true error
171: *              so long as the next entry is greater than the threshold
172: *              sqrt(n) * slamch('Epsilon'). This error bound should only
173: *              be trusted if the previous boolean is true.
174: *
175: *     err = 3  Reciprocal condition number: Estimated normwise
176: *              reciprocal condition number.  Compared with the threshold
177: *              sqrt(n) * slamch('Epsilon') to determine if the error
178: *              estimate is "guaranteed". These reciprocal condition
179: *              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some
180: *              appropriately scaled matrix Z.
181: *              Let Z = S*A, where S scales each row by a power of the
182: *              radix so all absolute row sums of Z are approximately 1.
183: *
184: *     See Lapack Working Note 165 for further details and extra
185: *     cautions.
186: *
187: *     ERR_BNDS_COMP  (output) REAL array, dimension (NRHS, N_ERR_BNDS)
188: *     For each right-hand side, this array contains information about
189: *     various error bounds and condition numbers corresponding to the
190: *     componentwise relative error, which is defined as follows:
191: *
192: *     Componentwise relative error in the ith solution vector:
193: *                    abs(XTRUE(j,i) - X(j,i))
194: *             max_j ----------------------
195: *                         abs(X(j,i))
196: *
197: *     The array is indexed by the right-hand side i (on which the
198: *     componentwise relative error depends), and the type of error
199: *     information as described below. There currently are up to three
200: *     pieces of information returned for each right-hand side. If
201: *     componentwise accuracy is not requested (PARAMS(3) = 0.0), then
202: *     ERR_BNDS_COMP is not accessed.  If N_ERR_BNDS .LT. 3, then at most
203: *     the first (:,N_ERR_BNDS) entries are returned.
204: *
205: *     The first index in ERR_BNDS_COMP(i,:) corresponds to the ith
206: *     right-hand side.
207: *
208: *     The second index in ERR_BNDS_COMP(:,err) contains the following
209: *     three fields:
210: *     err = 1 "Trust/don't trust" boolean. Trust the answer if the
211: *              reciprocal condition number is less than the threshold
212: *              sqrt(n) * slamch('Epsilon').
213: *
214: *     err = 2 "Guaranteed" error bound: The estimated forward error,
215: *              almost certainly within a factor of 10 of the true error
216: *              so long as the next entry is greater than the threshold
217: *              sqrt(n) * slamch('Epsilon'). This error bound should only
218: *              be trusted if the previous boolean is true.
219: *
220: *     err = 3  Reciprocal condition number: Estimated componentwise
221: *              reciprocal condition number.  Compared with the threshold
222: *              sqrt(n) * slamch('Epsilon') to determine if the error
223: *              estimate is "guaranteed". These reciprocal condition
224: *              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some
225: *              appropriately scaled matrix Z.
226: *              Let Z = S*(A*diag(x)), where x is the solution for the
227: *              current right-hand side and S scales each row of
228: *              A*diag(x) by a power of the radix so all absolute row
229: *              sums of Z are approximately 1.
230: *
231: *     See Lapack Working Note 165 for further details and extra
232: *     cautions.
233: *
234: *     NPARAMS (input) INTEGER
235: *     Specifies the number of parameters set in PARAMS.  If .LE. 0, the
236: *     PARAMS array is never referenced and default values are used.
237: *
238: *     PARAMS  (input / output) REAL array, dimension NPARAMS
239: *     Specifies algorithm parameters.  If an entry is .LT. 0.0, then
240: *     that entry will be filled with default value used for that
241: *     parameter.  Only positions up to NPARAMS are accessed; defaults
242: *     are used for higher-numbered parameters.
243: *
244: *       PARAMS(LA_LINRX_ITREF_I = 1) : Whether to perform iterative
245: *            refinement or not.
246: *         Default: 1.0
247: *            = 0.0 : No refinement is performed, and no error bounds are
248: *                    computed.
249: *            = 1.0 : Use the double-precision refinement algorithm,
250: *                    possibly with doubled-single computations if the
251: *                    compilation environment does not support DOUBLE
252: *                    PRECISION.
253: *              (other values are reserved for future use)
254: *
255: *       PARAMS(LA_LINRX_ITHRESH_I = 2) : Maximum number of residual
256: *            computations allowed for refinement.
257: *         Default: 10
258: *         Aggressive: Set to 100 to permit convergence using approximate
259: *                     factorizations or factorizations other than LU. If
260: *                     the factorization uses a technique other than
261: *                     Gaussian elimination, the guarantees in
262: *                     err_bnds_norm and err_bnds_comp may no longer be
263: *                     trustworthy.
264: *
265: *       PARAMS(LA_LINRX_CWISE_I = 3) : Flag determining if the code
266: *            will attempt to find a solution with small componentwise
267: *            relative error in the double-precision algorithm.  Positive
268: *            is true, 0.0 is false.
269: *         Default: 1.0 (attempt componentwise convergence)
270: *
271: *     WORK    (workspace) REAL array, dimension (4*N)
272: *
273: *     IWORK   (workspace) INTEGER array, dimension (N)
274: *
275: *     INFO    (output) INTEGER
276: *       = 0:  Successful exit. The solution to every right-hand side is
277: *         guaranteed.
278: *       < 0:  If INFO = -i, the i-th argument had an illegal value
279: *       > 0 and <= N:  U(INFO,INFO) is exactly zero.  The factorization
280: *         has been completed, but the factor U is exactly singular, so
281: *         the solution and error bounds could not be computed. RCOND = 0
282: *         is returned.
283: *       = N+J: The solution corresponding to the Jth right-hand side is
284: *         not guaranteed. The solutions corresponding to other right-
285: *         hand sides K with K > J may not be guaranteed as well, but
286: *         only the first such right-hand side is reported. If a small
287: *         componentwise error is not requested (PARAMS(3) = 0.0) then
288: *         the Jth right-hand side is the first with a normwise error
289: *         bound that is not guaranteed (the smallest J such
290: *         that ERR_BNDS_NORM(J,1) = 0.0). By default (PARAMS(3) = 1.0)
291: *         the Jth right-hand side is the first with either a normwise or
292: *         componentwise error bound that is not guaranteed (the smallest
293: *         J such that either ERR_BNDS_NORM(J,1) = 0.0 or
294: *         ERR_BNDS_COMP(J,1) = 0.0). See the definition of
295: *         ERR_BNDS_NORM(:,1) and ERR_BNDS_COMP(:,1). To get information
296: *         about all of the right-hand sides check ERR_BNDS_NORM or
297: *         ERR_BNDS_COMP.
298: *
299: *     ==================================================================
300: *
301: *     .. Parameters ..
302:       REAL               ZERO, ONE
303:       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
304:       REAL               ITREF_DEFAULT, ITHRESH_DEFAULT,
305:      $                   COMPONENTWISE_DEFAULT
306:       REAL               RTHRESH_DEFAULT, DZTHRESH_DEFAULT
307:       PARAMETER          ( ITREF_DEFAULT = 1.0 )
308:       PARAMETER          ( ITHRESH_DEFAULT = 10.0 )
309:       PARAMETER          ( COMPONENTWISE_DEFAULT = 1.0 )
310:       PARAMETER          ( RTHRESH_DEFAULT = 0.5 )
311:       PARAMETER          ( DZTHRESH_DEFAULT = 0.25 )
312:       INTEGER            LA_LINRX_ITREF_I, LA_LINRX_ITHRESH_I,
313:      $                   LA_LINRX_CWISE_I
314:       PARAMETER          ( LA_LINRX_ITREF_I = 1,
315:      $                   LA_LINRX_ITHRESH_I = 2 )
316:       PARAMETER          ( LA_LINRX_CWISE_I = 3 )
317:       INTEGER            LA_LINRX_TRUST_I, LA_LINRX_ERR_I,
318:      $                   LA_LINRX_RCOND_I
319:       PARAMETER          ( LA_LINRX_TRUST_I = 1, LA_LINRX_ERR_I = 2 )
320:       PARAMETER          ( LA_LINRX_RCOND_I = 3 )
321:       INTEGER            LA_LINRX_MAX_N_ERRS
322:       PARAMETER          ( LA_LINRX_MAX_N_ERRS = 3 )
323: *     ..
324: *     .. Local Scalars ..
325:       CHARACTER(1)       NORM
326:       LOGICAL            RCEQU
327:       INTEGER            J, PREC_TYPE, REF_TYPE
328:       INTEGER            N_NORMS
329:       REAL               ANORM, RCOND_TMP
330:       REAL               ILLRCOND_THRESH, ERR_LBND, CWISE_WRONG
331:       LOGICAL            IGNORE_CWISE
332:       INTEGER            ITHRESH
333:       REAL               RTHRESH, UNSTABLE_THRESH
334: *     ..
335: *     .. External Subroutines ..
336:       EXTERNAL           XERBLA, CSYCON, CLA_SYRFSX_EXTENDED
337: *     ..
338: *     .. Intrinsic Functions ..
339:       INTRINSIC          MAX, SQRT
340: *     ..
341: *     .. External Functions ..
342:       EXTERNAL           LSAME, BLAS_FPINFO_X, ILATRANS, ILAPREC
343:       EXTERNAL           SLAMCH, CLANSY, CLA_SYRCOND_X, CLA_SYRCOND_C
344:       REAL               SLAMCH, CLANSY, CLA_SYRCOND_X, CLA_SYRCOND_C
345:       LOGICAL            LSAME
346:       INTEGER            BLAS_FPINFO_X
347:       INTEGER            ILATRANS, ILAPREC
348: *     ..
349: *     .. Executable Statements ..
350: *
351: *     Check the input parameters.
352: *
353:       INFO = 0
354:       REF_TYPE = INT( ITREF_DEFAULT )
355:       IF ( NPARAMS .GE. LA_LINRX_ITREF_I ) THEN
356:          IF ( PARAMS( LA_LINRX_ITREF_I ) .LT. 0.0 ) THEN
357:             PARAMS( LA_LINRX_ITREF_I ) = ITREF_DEFAULT
358:          ELSE
359:             REF_TYPE = PARAMS( LA_LINRX_ITREF_I )
360:          END IF
361:       END IF
362: *
363: *     Set default parameters.
364: *
365:       ILLRCOND_THRESH = REAL( N ) * SLAMCH( 'Epsilon' )
366:       ITHRESH = INT( ITHRESH_DEFAULT )
367:       RTHRESH = RTHRESH_DEFAULT
368:       UNSTABLE_THRESH = DZTHRESH_DEFAULT
369:       IGNORE_CWISE = COMPONENTWISE_DEFAULT .EQ. 0.0
370: *
371:       IF ( NPARAMS.GE.LA_LINRX_ITHRESH_I ) THEN
372:          IF ( PARAMS( LA_LINRX_ITHRESH_I ).LT.0.0 ) THEN
373:             PARAMS( LA_LINRX_ITHRESH_I ) = ITHRESH
374:          ELSE
375:             ITHRESH = INT( PARAMS( LA_LINRX_ITHRESH_I ) )
376:          END IF
377:       END IF
378:       IF ( NPARAMS.GE.LA_LINRX_CWISE_I ) THEN
379:          IF ( PARAMS( LA_LINRX_CWISE_I ).LT.0.0 ) THEN
380:             IF ( IGNORE_CWISE ) THEN
381:                PARAMS( LA_LINRX_CWISE_I ) = 0.0
382:             ELSE
383:                PARAMS( LA_LINRX_CWISE_I ) = 1.0
384:             END IF
385:          ELSE
386:             IGNORE_CWISE = PARAMS( LA_LINRX_CWISE_I ) .EQ. 0.0
387:          END IF
388:       END IF
389:       IF ( REF_TYPE .EQ. 0 .OR. N_ERR_BNDS .EQ. 0 ) THEN
390:          N_NORMS = 0
391:       ELSE IF ( IGNORE_CWISE ) THEN
392:          N_NORMS = 1
393:       ELSE
394:          N_NORMS = 2
395:       END IF
396: *
397:       RCEQU = LSAME( EQUED, 'Y' )
398: *
399: *     Test input parameters.
400: *
401:       IF ( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
402:         INFO = -1
403:       ELSE IF( .NOT.RCEQU .AND. .NOT.LSAME( EQUED, 'N' ) ) THEN
404:         INFO = -2
405:       ELSE IF( N.LT.0 ) THEN
406:         INFO = -3
407:       ELSE IF( NRHS.LT.0 ) THEN
408:         INFO = -4
409:       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
410:         INFO = -6
411:       ELSE IF( LDAF.LT.MAX( 1, N ) ) THEN
412:         INFO = -8
413:       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
414:         INFO = -11
415:       ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
416:         INFO = -13
417:       END IF
418:       IF( INFO.NE.0 ) THEN
419:         CALL XERBLA( 'CSYRFSX', -INFO )
420:         RETURN
421:       END IF
422: *
423: *     Quick return if possible.
424: *
425:       IF( N.EQ.0 .OR. NRHS.EQ.0 ) THEN
426:          RCOND = 1.0
427:          DO J = 1, NRHS
428:             BERR( J ) = 0.0
429:             IF ( N_ERR_BNDS .GE. 1 ) THEN
430:                ERR_BNDS_NORM( J, LA_LINRX_TRUST_I ) = 1.0
431:                ERR_BNDS_COMP( J, LA_LINRX_TRUST_I ) = 1.0
432:             ELSE IF ( N_ERR_BNDS .GE. 2 ) THEN
433:                ERR_BNDS_NORM( J, LA_LINRX_ERR_I ) = 0.0
434:                ERR_BNDS_COMP( J, LA_LINRX_ERR_I ) = 0.0
435:             ELSE IF ( N_ERR_BNDS .GE. 3 ) THEN
436:                ERR_BNDS_NORM( J, LA_LINRX_RCOND_I ) = 1.0
437:                ERR_BNDS_COMP( J, LA_LINRX_RCOND_I ) = 1.0
438:             END IF
439:          END DO
440:          RETURN
441:       END IF
442: *
443: *     Default to failure.
444: *
445:       RCOND = 0.0
446:       DO J = 1, NRHS
447:          BERR( J ) = 1.0
448:          IF ( N_ERR_BNDS .GE. 1 ) THEN
449:             ERR_BNDS_NORM( J, LA_LINRX_TRUST_I ) = 1.0
450:             ERR_BNDS_COMP( J, LA_LINRX_TRUST_I ) = 1.0
451:          ELSE IF ( N_ERR_BNDS .GE. 2 ) THEN
452:             ERR_BNDS_NORM( J, LA_LINRX_ERR_I ) = 1.0
453:             ERR_BNDS_COMP( J, LA_LINRX_ERR_I ) = 1.0
454:          ELSE IF ( N_ERR_BNDS .GE. 3 ) THEN
455:             ERR_BNDS_NORM( J, LA_LINRX_RCOND_I ) = 0.0
456:             ERR_BNDS_COMP( J, LA_LINRX_RCOND_I ) = 0.0
457:          END IF
458:       END DO
459: *
460: *     Compute the norm of A and the reciprocal of the condition
461: *     number of A.
462: *
463:       NORM = 'I'
464:       ANORM = CLANSY( NORM, UPLO, N, A, LDA, WORK )
465:       CALL CSYCON( UPLO, N, AF, LDAF, IPIV, ANORM, RCOND, WORK,
466:      $     INFO )
467: *
468: *     Perform refinement on each right-hand side
469: *
470:       IF ( REF_TYPE .NE. 0 ) THEN
471: 
472:          PREC_TYPE = ILAPREC( 'D' )
473: 
474:          CALL CLA_SYRFSX_EXTENDED( PREC_TYPE, UPLO,  N,
475:      $        NRHS, A, LDA, AF, LDAF, IPIV, RCEQU, S, B,
476:      $        LDB, X, LDX, BERR, N_NORMS, ERR_BNDS_NORM, ERR_BNDS_COMP,
477:      $        WORK(N+1), RWORK, WORK(2*N+1), WORK(1), RCOND,
478:      $        ITHRESH, RTHRESH, UNSTABLE_THRESH, IGNORE_CWISE,
479:      $        INFO )
480:       END IF
481: 
482:       ERR_LBND = MAX( 10.0, SQRT( REAL( N ) ) ) * SLAMCH( 'Epsilon' )
483:       IF (N_ERR_BNDS .GE. 1 .AND. N_NORMS .GE. 1) THEN
484: *
485: *     Compute scaled normwise condition number cond(A*C).
486: *
487:          IF ( RCEQU ) THEN
488:             RCOND_TMP = CLA_SYRCOND_C( UPLO, N, A, LDA, AF, LDAF, IPIV,
489:      $           S, .TRUE., INFO, WORK, RWORK )
490:          ELSE
491:             RCOND_TMP = CLA_SYRCOND_C( UPLO, N, A, LDA, AF, LDAF, IPIV,
492:      $           S, .FALSE., INFO, WORK, RWORK )
493:          END IF
494:          DO J = 1, NRHS
495: *
496: *     Cap the error at 1.0.
497: *
498:             IF ( N_ERR_BNDS .GE. LA_LINRX_ERR_I
499:      $           .AND. ERR_BNDS_NORM( J, LA_LINRX_ERR_I ) .GT. 1.0 )
500:      $           ERR_BNDS_NORM( J, LA_LINRX_ERR_I ) = 1.0
501: *
502: *     Threshold the error (see LAWN).
503: *
504:             IF ( RCOND_TMP .LT. ILLRCOND_THRESH ) THEN
505:                ERR_BNDS_NORM( J, LA_LINRX_ERR_I ) = 1.0
506:                ERR_BNDS_NORM( J, LA_LINRX_TRUST_I ) = 0.0
507:                IF ( INFO .LE. N ) INFO = N + J
508:             ELSE IF ( ERR_BNDS_NORM( J, LA_LINRX_ERR_I ) .LT. ERR_LBND )
509:      $              THEN
510:                ERR_BNDS_NORM( J, LA_LINRX_ERR_I ) = ERR_LBND
511:                ERR_BNDS_NORM( J, LA_LINRX_TRUST_I ) = 1.0
512:             END IF
513: *
514: *     Save the condition number.
515: *
516:             IF ( N_ERR_BNDS .GE. LA_LINRX_RCOND_I ) THEN
517:                ERR_BNDS_NORM( J, LA_LINRX_RCOND_I ) = RCOND_TMP
518:             END IF
519:          END DO
520:       END IF
521: 
522:       IF ( N_ERR_BNDS .GE. 1 .AND. N_NORMS .GE. 2 ) THEN
523: *
524: *     Compute componentwise condition number cond(A*diag(Y(:,J))) for
525: *     each right-hand side using the current solution as an estimate of
526: *     the true solution.  If the componentwise error estimate is too
527: *     large, then the solution is a lousy estimate of truth and the
528: *     estimated RCOND may be too optimistic.  To avoid misleading users,
529: *     the inverse condition number is set to 0.0 when the estimated
530: *     cwise error is at least CWISE_WRONG.
531: *
532:          CWISE_WRONG = SQRT( SLAMCH( 'Epsilon' ) )
533:          DO J = 1, NRHS
534:             IF ( ERR_BNDS_COMP( J, LA_LINRX_ERR_I ) .LT. CWISE_WRONG )
535:      $     THEN
536:                RCOND_TMP = CLA_SYRCOND_X( UPLO, N, A, LDA, AF, LDAF,
537:      $         IPIV, X(1,J), INFO, WORK, RWORK )
538:             ELSE
539:                RCOND_TMP = 0.0
540:             END IF
541: *
542: *     Cap the error at 1.0.
543: *
544:             IF ( N_ERR_BNDS .GE. LA_LINRX_ERR_I
545:      $           .AND. ERR_BNDS_COMP( J, LA_LINRX_ERR_I ) .GT. 1.0 )
546:      $           ERR_BNDS_COMP( J, LA_LINRX_ERR_I ) = 1.0
547: 
548: *
549: *     Threshold the error (see LAWN).
550: *
551:             IF ( RCOND_TMP .LT. ILLRCOND_THRESH ) THEN
552:                ERR_BNDS_COMP( J, LA_LINRX_ERR_I ) = 1.0
553:                ERR_BNDS_COMP( J, LA_LINRX_TRUST_I ) = 0.0
554:                IF ( PARAMS( LA_LINRX_CWISE_I ) .EQ. 1.0
555:      $              .AND. INFO.LT.N + J ) INFO = N + J
556:             ELSE IF ( ERR_BNDS_COMP( J, LA_LINRX_ERR_I )
557:      $              .LT. ERR_LBND ) THEN
558:                ERR_BNDS_COMP( J, LA_LINRX_ERR_I ) = ERR_LBND
559:                ERR_BNDS_COMP( J, LA_LINRX_TRUST_I ) = 1.0
560:             END IF
561: *
562: *     Save the condition number.
563: *
564:             IF ( N_ERR_BNDS .GE. LA_LINRX_RCOND_I ) THEN
565:                ERR_BNDS_COMP( J, LA_LINRX_RCOND_I ) = RCOND_TMP
566:             END IF
567: 
568:          END DO
569:       END IF
570: *
571:       RETURN
572: *
573: *     End of CSYRFSX
574: *
575:       END
576: