1 *> \brief <b> DGTSV computes the solution to system of linear equations A * X = B for GT matrices <b>
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download DGTSV + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgtsv.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgtsv.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgtsv.f">
21 * SUBROUTINE DGTSV( N, NRHS, DL, D, DU, B, LDB, INFO )
23 * .. Scalar Arguments ..
24 * INTEGER INFO, LDB, N, NRHS
26 * .. Array Arguments ..
27 * DOUBLE PRECISION B( LDB, * ), D( * ), DL( * ), DU( * )
36 *> DGTSV solves the equation
40 *> where A is an n by n tridiagonal matrix, by Gaussian elimination with
43 *> Note that the equation A**T*X = B may be solved by interchanging the
44 *> order of the arguments DU and DL.
53 *> The order of the matrix A. N >= 0.
59 *> The number of right hand sides, i.e., the number of columns
60 *> of the matrix B. NRHS >= 0.
65 *> DL is DOUBLE PRECISION array, dimension (N-1)
66 *> On entry, DL must contain the (n-1) sub-diagonal elements of
69 *> On exit, DL is overwritten by the (n-2) elements of the
70 *> second super-diagonal of the upper triangular matrix U from
71 *> the LU factorization of A, in DL(1), ..., DL(n-2).
76 *> D is DOUBLE PRECISION array, dimension (N)
77 *> On entry, D must contain the diagonal elements of A.
79 *> On exit, D is overwritten by the n diagonal elements of U.
84 *> DU is DOUBLE PRECISION array, dimension (N-1)
85 *> On entry, DU must contain the (n-1) super-diagonal elements
88 *> On exit, DU is overwritten by the (n-1) elements of the first
89 *> super-diagonal of U.
94 *> B is DOUBLE PRECISION array, dimension (LDB,NRHS)
95 *> On entry, the N by NRHS matrix of right hand side matrix B.
96 *> On exit, if INFO = 0, the N by NRHS solution matrix X.
102 *> The leading dimension of the array B. LDB >= max(1,N).
108 *> = 0: successful exit
109 *> < 0: if INFO = -i, the i-th argument had an illegal value
110 *> > 0: if INFO = i, U(i,i) is exactly zero, and the solution
111 *> has not been computed. The factorization has not been
112 *> completed unless i = N.
118 *> \author Univ. of Tennessee
119 *> \author Univ. of California Berkeley
120 *> \author Univ. of Colorado Denver
123 *> \date September 2012
125 *> \ingroup doubleGTsolve
127 * =====================================================================
128 SUBROUTINE DGTSV( N, NRHS, DL, D, DU, B, LDB, INFO )
130 * -- LAPACK driver routine (version 3.4.2) --
131 * -- LAPACK is a software package provided by Univ. of Tennessee, --
132 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
135 * .. Scalar Arguments ..
136 INTEGER INFO, LDB, N, NRHS
138 * .. Array Arguments ..
139 DOUBLE PRECISION B( LDB, * ), D( * ), DL( * ), DU( * )
142 * =====================================================================
145 DOUBLE PRECISION ZERO
146 PARAMETER ( ZERO = 0.0D+0 )
148 * .. Local Scalars ..
150 DOUBLE PRECISION FACT, TEMP
152 * .. Intrinsic Functions ..
155 * .. External Subroutines ..
158 * .. Executable Statements ..
163 ELSE IF( NRHS.LT.0 ) THEN
165 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
169 CALL XERBLA( 'DGTSV ', -INFO )
178 IF( ABS( D( I ) ).GE.ABS( DL( I ) ) ) THEN
180 * No row interchange required
182 IF( D( I ).NE.ZERO ) THEN
183 FACT = DL( I ) / D( I )
184 D( I+1 ) = D( I+1 ) - FACT*DU( I )
185 B( I+1, 1 ) = B( I+1, 1 ) - FACT*B( I, 1 )
193 * Interchange rows I and I+1
195 FACT = D( I ) / DL( I )
198 D( I+1 ) = DU( I ) - FACT*TEMP
200 DU( I+1 ) = -FACT*DL( I )
203 B( I, 1 ) = B( I+1, 1 )
204 B( I+1, 1 ) = TEMP - FACT*B( I+1, 1 )
209 IF( ABS( D( I ) ).GE.ABS( DL( I ) ) ) THEN
210 IF( D( I ).NE.ZERO ) THEN
211 FACT = DL( I ) / D( I )
212 D( I+1 ) = D( I+1 ) - FACT*DU( I )
213 B( I+1, 1 ) = B( I+1, 1 ) - FACT*B( I, 1 )
219 FACT = D( I ) / DL( I )
222 D( I+1 ) = DU( I ) - FACT*TEMP
225 B( I, 1 ) = B( I+1, 1 )
226 B( I+1, 1 ) = TEMP - FACT*B( I+1, 1 )
229 IF( D( N ).EQ.ZERO ) THEN
235 IF( ABS( D( I ) ).GE.ABS( DL( I ) ) ) THEN
237 * No row interchange required
239 IF( D( I ).NE.ZERO ) THEN
240 FACT = DL( I ) / D( I )
241 D( I+1 ) = D( I+1 ) - FACT*DU( I )
243 B( I+1, J ) = B( I+1, J ) - FACT*B( I, J )
252 * Interchange rows I and I+1
254 FACT = D( I ) / DL( I )
257 D( I+1 ) = DU( I ) - FACT*TEMP
259 DU( I+1 ) = -FACT*DL( I )
263 B( I, J ) = B( I+1, J )
264 B( I+1, J ) = TEMP - FACT*B( I+1, J )
270 IF( ABS( D( I ) ).GE.ABS( DL( I ) ) ) THEN
271 IF( D( I ).NE.ZERO ) THEN
272 FACT = DL( I ) / D( I )
273 D( I+1 ) = D( I+1 ) - FACT*DU( I )
275 B( I+1, J ) = B( I+1, J ) - FACT*B( I, J )
282 FACT = D( I ) / DL( I )
285 D( I+1 ) = DU( I ) - FACT*TEMP
289 B( I, J ) = B( I+1, J )
290 B( I+1, J ) = TEMP - FACT*B( I+1, J )
294 IF( D( N ).EQ.ZERO ) THEN
300 * Back solve with the matrix U from the factorization.
305 B( N, J ) = B( N, J ) / D( N )
307 $ B( N-1, J ) = ( B( N-1, J )-DU( N-1 )*B( N, J ) ) / D( N-1 )
308 DO 80 I = N - 2, 1, -1
309 B( I, J ) = ( B( I, J )-DU( I )*B( I+1, J )-DL( I )*
310 $ B( I+2, J ) ) / D( I )
318 B( N, J ) = B( N, J ) / D( N )
320 $ B( N-1, J ) = ( B( N-1, J )-DU( N-1 )*B( N, J ) ) /
322 DO 90 I = N - 2, 1, -1
323 B( I, J ) = ( B( I, J )-DU( I )*B( I+1, J )-DL( I )*
324 $ B( I+2, J ) ) / D( I )