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