1 *> \brief <b> SPTSVX computes the solution to system of linear equations A * X = B for PT matrices</b>
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SPTSVX + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sptsvx.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sptsvx.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sptsvx.f">
21 * SUBROUTINE SPTSVX( FACT, N, NRHS, D, E, DF, EF, B, LDB, X, LDX,
22 * RCOND, FERR, BERR, WORK, INFO )
24 * .. Scalar Arguments ..
26 * INTEGER INFO, LDB, LDX, N, NRHS
29 * .. Array Arguments ..
30 * REAL B( LDB, * ), BERR( * ), D( * ), DF( * ),
31 * $ E( * ), EF( * ), FERR( * ), WORK( * ),
41 *> SPTSVX uses the factorization A = L*D*L**T to compute the solution
42 *> to a real system of linear equations A*X = B, where A is an N-by-N
43 *> symmetric positive definite tridiagonal matrix and X and B are
44 *> N-by-NRHS matrices.
46 *> Error bounds on the solution and a condition estimate are also
55 *> The following steps are performed:
57 *> 1. If FACT = 'N', the matrix A is factored as A = L*D*L**T, where L
58 *> is a unit lower bidiagonal matrix and D is diagonal. The
59 *> factorization can also be regarded as having the form
62 *> 2. If the leading i-by-i principal minor is not positive definite,
63 *> then the routine returns with INFO = i. Otherwise, the factored
64 *> form of A is used to estimate the condition number of the matrix
65 *> A. If the reciprocal of the condition number is less than machine
66 *> precision, INFO = N+1 is returned as a warning, but the routine
67 *> still goes on to solve for X and compute error bounds as
70 *> 3. The system of equations is solved for X using the factored form
73 *> 4. Iterative refinement is applied to improve the computed solution
74 *> matrix and calculate error bounds and backward error estimates
83 *> FACT is CHARACTER*1
84 *> Specifies whether or not the factored form of A has been
86 *> = 'F': On entry, DF and EF contain the factored form of A.
87 *> D, E, DF, and EF will not be modified.
88 *> = 'N': The matrix A will be copied to DF and EF and
95 *> The order of the matrix A. N >= 0.
101 *> The number of right hand sides, i.e., the number of columns
102 *> of the matrices B and X. NRHS >= 0.
107 *> D is REAL array, dimension (N)
108 *> The n diagonal elements of the tridiagonal matrix A.
113 *> E is REAL array, dimension (N-1)
114 *> The (n-1) subdiagonal elements of the tridiagonal matrix A.
119 *> DF is REAL array, dimension (N)
120 *> If FACT = 'F', then DF is an input argument and on entry
121 *> contains the n diagonal elements of the diagonal matrix D
122 *> from the L*D*L**T factorization of A.
123 *> If FACT = 'N', then DF is an output argument and on exit
124 *> contains the n diagonal elements of the diagonal matrix D
125 *> from the L*D*L**T factorization of A.
130 *> EF is REAL array, dimension (N-1)
131 *> If FACT = 'F', then EF is an input argument and on entry
132 *> contains the (n-1) subdiagonal elements of the unit
133 *> bidiagonal factor L from the L*D*L**T factorization of A.
134 *> If FACT = 'N', then EF is an output argument and on exit
135 *> contains the (n-1) subdiagonal elements of the unit
136 *> bidiagonal factor L from the L*D*L**T factorization of A.
141 *> B is REAL array, dimension (LDB,NRHS)
142 *> The N-by-NRHS right hand side matrix B.
148 *> The leading dimension of the array B. LDB >= max(1,N).
153 *> X is REAL array, dimension (LDX,NRHS)
154 *> If INFO = 0 of INFO = N+1, the N-by-NRHS solution matrix X.
160 *> The leading dimension of the array X. LDX >= max(1,N).
166 *> The reciprocal condition number of the matrix A. If RCOND
167 *> is less than the machine precision (in particular, if
168 *> RCOND = 0), the matrix is singular to working precision.
169 *> This condition is indicated by a return code of INFO > 0.
174 *> FERR is REAL array, dimension (NRHS)
175 *> The forward error bound for each solution vector
176 *> X(j) (the j-th column of the solution matrix X).
177 *> If XTRUE is the true solution corresponding to X(j), FERR(j)
178 *> is an estimated upper bound for the magnitude of the largest
179 *> element in (X(j) - XTRUE) divided by the magnitude of the
180 *> largest element in X(j).
185 *> BERR is REAL array, dimension (NRHS)
186 *> The componentwise relative backward error of each solution
187 *> vector X(j) (i.e., the smallest relative change in any
188 *> element of A or B that makes X(j) an exact solution).
193 *> WORK is REAL array, dimension (2*N)
199 *> = 0: successful exit
200 *> < 0: if INFO = -i, the i-th argument had an illegal value
201 *> > 0: if INFO = i, and i is
202 *> <= N: the leading minor of order i of A is
203 *> not positive definite, so the factorization
204 *> could not be completed, and the solution has not
205 *> been computed. RCOND = 0 is returned.
206 *> = N+1: U is nonsingular, but RCOND is less than machine
207 *> precision, meaning that the matrix is singular
208 *> to working precision. Nevertheless, the
209 *> solution and error bounds are computed because
210 *> there are a number of situations where the
211 *> computed solution can be more accurate than the
212 *> value of RCOND would suggest.
218 *> \author Univ. of Tennessee
219 *> \author Univ. of California Berkeley
220 *> \author Univ. of Colorado Denver
223 *> \date September 2012
225 *> \ingroup realPTsolve
227 * =====================================================================
228 SUBROUTINE SPTSVX( FACT, N, NRHS, D, E, DF, EF, B, LDB, X, LDX,
229 $ RCOND, FERR, BERR, WORK, INFO )
231 * -- LAPACK driver routine (version 3.4.2) --
232 * -- LAPACK is a software package provided by Univ. of Tennessee, --
233 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
236 * .. Scalar Arguments ..
238 INTEGER INFO, LDB, LDX, N, NRHS
241 * .. Array Arguments ..
242 REAL B( LDB, * ), BERR( * ), D( * ), DF( * ),
243 $ E( * ), EF( * ), FERR( * ), WORK( * ),
247 * =====================================================================
251 PARAMETER ( ZERO = 0.0E+0 )
253 * .. Local Scalars ..
257 * .. External Functions ..
260 EXTERNAL LSAME, SLAMCH, SLANST
262 * .. External Subroutines ..
263 EXTERNAL SCOPY, SLACPY, SPTCON, SPTRFS, SPTTRF, SPTTRS,
266 * .. Intrinsic Functions ..
269 * .. Executable Statements ..
271 * Test the input parameters.
274 NOFACT = LSAME( FACT, 'N' )
275 IF( .NOT.NOFACT .AND. .NOT.LSAME( FACT, 'F' ) ) THEN
277 ELSE IF( N.LT.0 ) THEN
279 ELSE IF( NRHS.LT.0 ) THEN
281 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
283 ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
287 CALL XERBLA( 'SPTSVX', -INFO )
293 * Compute the L*D*L**T (or U**T*D*U) factorization of A.
295 CALL SCOPY( N, D, 1, DF, 1 )
297 $ CALL SCOPY( N-1, E, 1, EF, 1 )
298 CALL SPTTRF( N, DF, EF, INFO )
300 * Return if INFO is non-zero.
308 * Compute the norm of the matrix A.
310 ANORM = SLANST( '1', N, D, E )
312 * Compute the reciprocal of the condition number of A.
314 CALL SPTCON( N, DF, EF, ANORM, RCOND, WORK, INFO )
316 * Compute the solution vectors X.
318 CALL SLACPY( 'Full', N, NRHS, B, LDB, X, LDX )
319 CALL SPTTRS( N, NRHS, DF, EF, X, LDX, INFO )
321 * Use iterative refinement to improve the computed solutions and
322 * compute error bounds and backward error estimates for them.
324 CALL SPTRFS( N, NRHS, D, E, DF, EF, B, LDB, X, LDX, FERR, BERR,
327 * Set INFO = N+1 if the matrix is singular to working precision.
329 IF( RCOND.LT.SLAMCH( 'Epsilon' ) )