LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
cptsvx.f
Go to the documentation of this file.
1*> \brief <b> CPTSVX computes the solution to system of linear equations A * X = B for PT matrices</b>
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download CPTSVX + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cptsvx.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cptsvx.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cptsvx.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE CPTSVX( FACT, N, NRHS, D, E, DF, EF, B, LDB, X, LDX,
20* RCOND, FERR, BERR, WORK, RWORK, INFO )
21*
22* .. Scalar Arguments ..
23* CHARACTER FACT
24* INTEGER INFO, LDB, LDX, N, NRHS
25* REAL RCOND
26* ..
27* .. Array Arguments ..
28* REAL BERR( * ), D( * ), DF( * ), FERR( * ),
29* $ RWORK( * )
30* COMPLEX B( LDB, * ), E( * ), EF( * ), WORK( * ),
31* $ X( LDX, * )
32* ..
33*
34*
35*> \par Purpose:
36* =============
37*>
38*> \verbatim
39*>
40*> CPTSVX uses the factorization A = L*D*L**H to compute the solution
41*> to a complex system of linear equations A*X = B, where A is an
42*> N-by-N Hermitian positive definite tridiagonal matrix and X and B
43*> are N-by-NRHS matrices.
44*>
45*> Error bounds on the solution and a condition estimate are also
46*> provided.
47*> \endverbatim
48*
49*> \par Description:
50* =================
51*>
52*> \verbatim
53*>
54*> The following steps are performed:
55*>
56*> 1. If FACT = 'N', the matrix A is factored as A = L*D*L**H, where L
57*> is a unit lower bidiagonal matrix and D is diagonal. The
58*> factorization can also be regarded as having the form
59*> A = U**H*D*U.
60*>
61*> 2. If the leading principal minor of order i is not positive,
62*> then the routine returns with INFO = i. Otherwise, the factored
63*> form of A is used to estimate the condition number of the matrix
64*> A. If the reciprocal of the condition number is less than machine
65*> precision, INFO = N+1 is returned as a warning, but the routine
66*> still goes on to solve for X and compute error bounds as
67*> described below.
68*>
69*> 3. The system of equations is solved for X using the factored form
70*> of A.
71*>
72*> 4. Iterative refinement is applied to improve the computed solution
73*> matrix and calculate error bounds and backward error estimates
74*> for it.
75*> \endverbatim
76*
77* Arguments:
78* ==========
79*
80*> \param[in] FACT
81*> \verbatim
82*> FACT is CHARACTER*1
83*> Specifies whether or not the factored form of the matrix
84*> A is supplied on entry.
85*> = 'F': On entry, DF and EF contain the factored form of A.
86*> D, E, DF, and EF will not be modified.
87*> = 'N': The matrix A will be copied to DF and EF and
88*> factored.
89*> \endverbatim
90*>
91*> \param[in] N
92*> \verbatim
93*> N is INTEGER
94*> The order of the matrix A. N >= 0.
95*> \endverbatim
96*>
97*> \param[in] NRHS
98*> \verbatim
99*> NRHS is INTEGER
100*> The number of right hand sides, i.e., the number of columns
101*> of the matrices B and X. NRHS >= 0.
102*> \endverbatim
103*>
104*> \param[in] D
105*> \verbatim
106*> D is REAL array, dimension (N)
107*> The n diagonal elements of the tridiagonal matrix A.
108*> \endverbatim
109*>
110*> \param[in] E
111*> \verbatim
112*> E is COMPLEX array, dimension (N-1)
113*> The (n-1) subdiagonal elements of the tridiagonal matrix A.
114*> \endverbatim
115*>
116*> \param[in,out] DF
117*> \verbatim
118*> DF is REAL array, dimension (N)
119*> If FACT = 'F', then DF is an input argument and on entry
120*> contains the n diagonal elements of the diagonal matrix D
121*> from the L*D*L**H factorization of A.
122*> If FACT = 'N', then DF is an output argument and on exit
123*> contains the n diagonal elements of the diagonal matrix D
124*> from the L*D*L**H factorization of A.
125*> \endverbatim
126*>
127*> \param[in,out] EF
128*> \verbatim
129*> EF is COMPLEX array, dimension (N-1)
130*> If FACT = 'F', then EF is an input argument and on entry
131*> contains the (n-1) subdiagonal elements of the unit
132*> bidiagonal factor L from the L*D*L**H factorization of A.
133*> If FACT = 'N', then EF is an output argument and on exit
134*> contains the (n-1) subdiagonal elements of the unit
135*> bidiagonal factor L from the L*D*L**H factorization of A.
136*> \endverbatim
137*>
138*> \param[in] B
139*> \verbatim
140*> B is COMPLEX array, dimension (LDB,NRHS)
141*> The N-by-NRHS right hand side matrix B.
142*> \endverbatim
143*>
144*> \param[in] LDB
145*> \verbatim
146*> LDB is INTEGER
147*> The leading dimension of the array B. LDB >= max(1,N).
148*> \endverbatim
149*>
150*> \param[out] X
151*> \verbatim
152*> X is COMPLEX array, dimension (LDX,NRHS)
153*> If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X.
154*> \endverbatim
155*>
156*> \param[in] LDX
157*> \verbatim
158*> LDX is INTEGER
159*> The leading dimension of the array X. LDX >= max(1,N).
160*> \endverbatim
161*>
162*> \param[out] RCOND
163*> \verbatim
164*> RCOND is REAL
165*> The reciprocal condition number of the matrix A. If RCOND
166*> is less than the machine precision (in particular, if
167*> RCOND = 0), the matrix is singular to working precision.
168*> This condition is indicated by a return code of INFO > 0.
169*> \endverbatim
170*>
171*> \param[out] FERR
172*> \verbatim
173*> FERR is REAL array, dimension (NRHS)
174*> The forward error bound for each solution vector
175*> X(j) (the j-th column of the solution matrix X).
176*> If XTRUE is the true solution corresponding to X(j), FERR(j)
177*> is an estimated upper bound for the magnitude of the largest
178*> element in (X(j) - XTRUE) divided by the magnitude of the
179*> largest element in X(j).
180*> \endverbatim
181*>
182*> \param[out] BERR
183*> \verbatim
184*> BERR is REAL array, dimension (NRHS)
185*> The componentwise relative backward error of each solution
186*> vector X(j) (i.e., the smallest relative change in any
187*> element of A or B that makes X(j) an exact solution).
188*> \endverbatim
189*>
190*> \param[out] WORK
191*> \verbatim
192*> WORK is COMPLEX array, dimension (N)
193*> \endverbatim
194*>
195*> \param[out] RWORK
196*> \verbatim
197*> RWORK is REAL array, dimension (N)
198*> \endverbatim
199*>
200*> \param[out] INFO
201*> \verbatim
202*> INFO is INTEGER
203*> = 0: successful exit
204*> < 0: if INFO = -i, the i-th argument had an illegal value
205*> > 0: if INFO = i, and i is
206*> <= N: the leading principal minor of order i of A
207*> is not positive, so the factorization could not
208*> be completed, and the solution has not been
209*> computed. RCOND = 0 is returned.
210*> = N+1: U is nonsingular, but RCOND is less than machine
211*> precision, meaning that the matrix is singular
212*> to working precision. Nevertheless, the
213*> solution and error bounds are computed because
214*> there are a number of situations where the
215*> computed solution can be more accurate than the
216*> value of RCOND would suggest.
217*> \endverbatim
218*
219* Authors:
220* ========
221*
222*> \author Univ. of Tennessee
223*> \author Univ. of California Berkeley
224*> \author Univ. of Colorado Denver
225*> \author NAG Ltd.
226*
227*> \ingroup ptsvx
228*
229* =====================================================================
230 SUBROUTINE cptsvx( FACT, N, NRHS, D, E, DF, EF, B, LDB, X, LDX,
231 $ RCOND, FERR, BERR, WORK, RWORK, INFO )
232*
233* -- LAPACK driver routine --
234* -- LAPACK is a software package provided by Univ. of Tennessee, --
235* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
236*
237* .. Scalar Arguments ..
238 CHARACTER FACT
239 INTEGER INFO, LDB, LDX, N, NRHS
240 REAL RCOND
241* ..
242* .. Array Arguments ..
243 REAL BERR( * ), D( * ), DF( * ), FERR( * ),
244 $ rwork( * )
245 COMPLEX B( LDB, * ), E( * ), EF( * ), WORK( * ),
246 $ x( ldx, * )
247* ..
248*
249* =====================================================================
250*
251* .. Parameters ..
252 REAL ZERO
253 parameter( zero = 0.0e+0 )
254* ..
255* .. Local Scalars ..
256 LOGICAL NOFACT
257 REAL ANORM
258* ..
259* .. External Functions ..
260 LOGICAL LSAME
261 REAL CLANHT, SLAMCH
262 EXTERNAL lsame, clanht, slamch
263* ..
264* .. External Subroutines ..
265 EXTERNAL ccopy, clacpy, cptcon, cptrfs, cpttrf,
266 $ cpttrs,
267 $ scopy, xerbla
268* ..
269* .. Intrinsic Functions ..
270 INTRINSIC max
271* ..
272* .. Executable Statements ..
273*
274* Test the input parameters.
275*
276 info = 0
277 nofact = lsame( fact, 'N' )
278 IF( .NOT.nofact .AND. .NOT.lsame( fact, 'F' ) ) THEN
279 info = -1
280 ELSE IF( n.LT.0 ) THEN
281 info = -2
282 ELSE IF( nrhs.LT.0 ) THEN
283 info = -3
284 ELSE IF( ldb.LT.max( 1, n ) ) THEN
285 info = -9
286 ELSE IF( ldx.LT.max( 1, n ) ) THEN
287 info = -11
288 END IF
289 IF( info.NE.0 ) THEN
290 CALL xerbla( 'CPTSVX', -info )
291 RETURN
292 END IF
293*
294 IF( nofact ) THEN
295*
296* Compute the L*D*L**H (or U**H*D*U) factorization of A.
297*
298 CALL scopy( n, d, 1, df, 1 )
299 IF( n.GT.1 )
300 $ CALL ccopy( n-1, e, 1, ef, 1 )
301 CALL cpttrf( n, df, ef, info )
302*
303* Return if INFO is non-zero.
304*
305 IF( info.GT.0 )THEN
306 rcond = zero
307 RETURN
308 END IF
309 END IF
310*
311* Compute the norm of the matrix A.
312*
313 anorm = clanht( '1', n, d, e )
314*
315* Compute the reciprocal of the condition number of A.
316*
317 CALL cptcon( n, df, ef, anorm, rcond, rwork, info )
318*
319* Compute the solution vectors X.
320*
321 CALL clacpy( 'Full', n, nrhs, b, ldb, x, ldx )
322 CALL cpttrs( 'Lower', n, nrhs, df, ef, x, ldx, info )
323*
324* Use iterative refinement to improve the computed solutions and
325* compute error bounds and backward error estimates for them.
326*
327 CALL cptrfs( 'Lower', n, nrhs, d, e, df, ef, b, ldb, x, ldx,
328 $ ferr,
329 $ berr, work, rwork, info )
330*
331* Set INFO = N+1 if the matrix is singular to working precision.
332*
333 IF( rcond.LT.slamch( 'Epsilon' ) )
334 $ info = n + 1
335*
336 RETURN
337*
338* End of CPTSVX
339*
340 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine scopy(n, sx, incx, sy, incy)
SCOPY
Definition scopy.f:82
subroutine ccopy(n, cx, incx, cy, incy)
CCOPY
Definition ccopy.f:81
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
Definition clacpy.f:101
subroutine cptcon(n, d, e, anorm, rcond, rwork, info)
CPTCON
Definition cptcon.f:117
subroutine cptrfs(uplo, n, nrhs, d, e, df, ef, b, ldb, x, ldx, ferr, berr, work, rwork, info)
CPTRFS
Definition cptrfs.f:181
subroutine cptsvx(fact, n, nrhs, d, e, df, ef, b, ldb, x, ldx, rcond, ferr, berr, work, rwork, info)
CPTSVX computes the solution to system of linear equations A * X = B for PT matrices
Definition cptsvx.f:232
subroutine cpttrf(n, d, e, info)
CPTTRF
Definition cpttrf.f:90
subroutine cpttrs(uplo, n, nrhs, d, e, b, ldb, info)
CPTTRS
Definition cpttrs.f:119