001:SUBROUTINEDPTSVX( FACT, N, NRHS, D, E, DF, EF, B, LDB, X, LDX, 002: $ RCOND, FERR, BERR, WORK, INFO ) 003:*004:* -- LAPACK routine (version 3.2) --005:* -- LAPACK is a software package provided by Univ. of Tennessee, --006:* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--007:* November 2006008:*009:* .. Scalar Arguments ..010: CHARACTER FACT 011: INTEGER INFO, LDB, LDX, N, NRHS 012: DOUBLE PRECISION RCOND 013:* ..014:* .. Array Arguments ..015: DOUBLE PRECISIONB( LDB, * ),BERR( * ),D( * ),DF( * ), 016: $E( * ),EF( * ),FERR( * ),WORK( * ), 017: $X( LDX, * ) 018:* ..019:*020:* Purpose021:* =======022:*023:* DPTSVX uses the factorization A = L*D*L**T to compute the solution024:* to a real system of linear equations A*X = B, where A is an N-by-N025:* symmetric positive definite tridiagonal matrix and X and B are026:* N-by-NRHS matrices.027:*028:* Error bounds on the solution and a condition estimate are also029:* provided.030:*031:* Description032:* ===========033:*034:* The following steps are performed:035:*036:* 1. If FACT = 'N', the matrix A is factored as A = L*D*L**T, where L037:* is a unit lower bidiagonal matrix and D is diagonal. The038:* factorization can also be regarded as having the form039:* A = U**T*D*U.040:*041:* 2. If the leading i-by-i principal minor is not positive definite,042:* then the routine returns with INFO = i. Otherwise, the factored043:* form of A is used to estimate the condition number of the matrix044:* A. If the reciprocal of the condition number is less than machine045:* precision, INFO = N+1 is returned as a warning, but the routine046:* still goes on to solve for X and compute error bounds as047:* described below.048:*049:* 3. The system of equations is solved for X using the factored form050:* of A.051:*052:* 4. Iterative refinement is applied to improve the computed solution053:* matrix and calculate error bounds and backward error estimates054:* for it.055:*056:* Arguments057:* =========058:*059:* FACT (input) CHARACTER*1060:* Specifies whether or not the factored form of A has been061:* supplied on entry.062:* = 'F': On entry, DF and EF contain the factored form of A.063:* D, E, DF, and EF will not be modified.064:* = 'N': The matrix A will be copied to DF and EF and065:* factored.066:*067:* N (input) INTEGER068:* The order of the matrix A. N >= 0.069:*070:* NRHS (input) INTEGER071:* The number of right hand sides, i.e., the number of columns072:* of the matrices B and X. NRHS >= 0.073:*074:* D (input) DOUBLE PRECISION array, dimension (N)075:* The n diagonal elements of the tridiagonal matrix A.076:*077:* E (input) DOUBLE PRECISION array, dimension (N-1)078:* The (n-1) subdiagonal elements of the tridiagonal matrix A.079:*080:* DF (input or output) DOUBLE PRECISION array, dimension (N)081:* If FACT = 'F', then DF is an input argument and on entry082:* contains the n diagonal elements of the diagonal matrix D083:* from the L*D*L**T factorization of A.084:* If FACT = 'N', then DF is an output argument and on exit085:* contains the n diagonal elements of the diagonal matrix D086:* from the L*D*L**T factorization of A.087:*088:* EF (input or output) DOUBLE PRECISION array, dimension (N-1)089:* If FACT = 'F', then EF is an input argument and on entry090:* contains the (n-1) subdiagonal elements of the unit091:* bidiagonal factor L from the L*D*L**T factorization of A.092:* If FACT = 'N', then EF is an output argument and on exit093:* contains the (n-1) subdiagonal elements of the unit094:* bidiagonal factor L from the L*D*L**T factorization of A.095:*096:* B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)097:* The N-by-NRHS right hand side matrix B.098:*099:* LDB (input) INTEGER100:* The leading dimension of the array B. LDB >= max(1,N).101:*102:* X (output) DOUBLE PRECISION array, dimension (LDX,NRHS)103:* If INFO = 0 of INFO = N+1, the N-by-NRHS solution matrix X.104:*105:* LDX (input) INTEGER106:* The leading dimension of the array X. LDX >= max(1,N).107:*108:* RCOND (output) DOUBLE PRECISION109:* The reciprocal condition number of the matrix A. If RCOND110:* is less than the machine precision (in particular, if111:* RCOND = 0), the matrix is singular to working precision.112:* This condition is indicated by a return code of INFO > 0.113:*114:* FERR (output) DOUBLE PRECISION array, dimension (NRHS)115:* The forward error bound for each solution vector116:* X(j) (the j-th column of the solution matrix X).117:* If XTRUE is the true solution corresponding to X(j), FERR(j)118:* is an estimated upper bound for the magnitude of the largest119:* element in (X(j) - XTRUE) divided by the magnitude of the120:* largest element in X(j).121:*122:* BERR (output) DOUBLE PRECISION array, dimension (NRHS)123:* The componentwise relative backward error of each solution124:* vector X(j) (i.e., the smallest relative change in any125:* element of A or B that makes X(j) an exact solution).126:*127:* WORK (workspace) DOUBLE PRECISION array, dimension (2*N)128:*129:* INFO (output) INTEGER130:* = 0: successful exit131:* < 0: if INFO = -i, the i-th argument had an illegal value132:* > 0: if INFO = i, and i is133:* <= N: the leading minor of order i of A is134:* not positive definite, so the factorization135:* could not be completed, and the solution has not136:* been computed. RCOND = 0 is returned.137:* = N+1: U is nonsingular, but RCOND is less than machine138:* precision, meaning that the matrix is singular139:* to working precision. Nevertheless, the140:* solution and error bounds are computed because141:* there are a number of situations where the142:* computed solution can be more accurate than the143:* value of RCOND would suggest.144:*145:* =====================================================================146:*147:* .. Parameters ..148: DOUBLE PRECISION ZERO 149:PARAMETER( ZERO = 0.0D+0 ) 150:* ..151:* .. Local Scalars ..152:LOGICALNOFACT 153: DOUBLE PRECISION ANORM 154:* ..155:* .. External Functions ..156:LOGICALLSAME 157: DOUBLE PRECISION DLAMCH, DLANST 158:EXTERNALLSAME, DLAMCH, DLANST 159:* ..160:* .. External Subroutines ..161:EXTERNALDCOPY, DLACPY, DPTCON, DPTRFS, DPTTRF, DPTTRS, 162: $ XERBLA 163:* ..164:* .. Intrinsic Functions ..165:INTRINSICMAX 166:* ..167:* .. Executable Statements ..168:*169:* Test the input parameters.170:*171: INFO = 0 172: NOFACT =LSAME( FACT, 'N' ) 173:IF( .NOT.NOFACT .AND. .NOT.LSAME( FACT, 'F' ) )THEN174: INFO = -1 175:ELSEIF( N.LT.0 )THEN176: INFO = -2 177:ELSEIF( NRHS.LT.0 )THEN178: INFO = -3 179:ELSEIF( LDB.LT.MAX( 1, N ) )THEN180: INFO = -9 181:ELSEIF( LDX.LT.MAX( 1, N ) )THEN182: INFO = -11 183:ENDIF184:IF( INFO.NE.0 )THEN185:CALLXERBLA( 'DPTSVX', -INFO ) 186:RETURN187:ENDIF188:*189:IF( NOFACT )THEN190:*191:* Compute the L*D*L' (or U'*D*U) factorization of A.192:*193:CALLDCOPY( N, D, 1, DF, 1 ) 194:IF( N.GT.1 ) 195: $CALLDCOPY( N-1, E, 1, EF, 1 ) 196:CALLDPTTRF( N, DF, EF, INFO ) 197:*198:* Return if INFO is non-zero.199:*200:IF( INFO.GT.0 )THEN201: RCOND = ZERO 202:RETURN203:ENDIF204:ENDIF205:*206:* Compute the norm of the matrix A.207:*208: ANORM =DLANST( '1', N, D, E ) 209:*210:* Compute the reciprocal of the condition number of A.211:*212:CALLDPTCON( N, DF, EF, ANORM, RCOND, WORK, INFO ) 213:*214:* Compute the solution vectors X.215:*216:CALLDLACPY( 'Full', N, NRHS, B, LDB, X, LDX ) 217:CALLDPTTRS( N, NRHS, DF, EF, X, LDX, INFO ) 218:*219:* Use iterative refinement to improve the computed solutions and220:* compute error bounds and backward error estimates for them.221:*222:CALLDPTRFS( N, NRHS, D, E, DF, EF, B, LDB, X, LDX, FERR, BERR, 223: $ WORK, INFO ) 224:*225:* Set INFO = N+1 if the matrix is singular to working precision.226:*227:IF( RCOND.LT.DLAMCH( 'Epsilon' ) ) 228: $ INFO = N + 1 229:*230:RETURN231:*232:* End of DPTSVX233:*234:END235: