1 *> \brief <b> ZGTSV 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 ZGTSV + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgtsv.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgtsv.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgtsv.f">
21 * SUBROUTINE ZGTSV( N, NRHS, DL, D, DU, B, LDB, INFO )
23 * .. Scalar Arguments ..
24 * INTEGER INFO, LDB, N, NRHS
26 * .. Array Arguments ..
27 * COMPLEX*16 B( LDB, * ), D( * ), DL( * ), DU( * )
36 *> ZGTSV 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 COMPLEX*16 array, dimension (N-1)
66 *> On entry, DL must contain the (n-1) subdiagonal elements of
68 *> On exit, DL is overwritten by the (n-2) elements of the
69 *> second superdiagonal of the upper triangular matrix U from
70 *> the LU factorization of A, in DL(1), ..., DL(n-2).
75 *> D is COMPLEX*16 array, dimension (N)
76 *> On entry, D must contain the diagonal elements of A.
77 *> On exit, D is overwritten by the n diagonal elements of U.
82 *> DU is COMPLEX*16 array, dimension (N-1)
83 *> On entry, DU must contain the (n-1) superdiagonal elements
85 *> On exit, DU is overwritten by the (n-1) elements of the first
86 *> superdiagonal of U.
91 *> B is COMPLEX*16 array, dimension (LDB,NRHS)
92 *> On entry, the N-by-NRHS right hand side matrix B.
93 *> On exit, if INFO = 0, the N-by-NRHS solution matrix X.
99 *> The leading dimension of the array B. LDB >= max(1,N).
105 *> = 0: successful exit
106 *> < 0: if INFO = -i, the i-th argument had an illegal value
107 *> > 0: if INFO = i, U(i,i) is exactly zero, and the solution
108 *> has not been computed. The factorization has not been
109 *> completed unless i = N.
115 *> \author Univ. of Tennessee
116 *> \author Univ. of California Berkeley
117 *> \author Univ. of Colorado Denver
120 *> \date September 2012
122 *> \ingroup complex16GTsolve
124 * =====================================================================
125 SUBROUTINE ZGTSV( N, NRHS, DL, D, DU, B, LDB, INFO )
127 * -- LAPACK driver routine (version 3.4.2) --
128 * -- LAPACK is a software package provided by Univ. of Tennessee, --
129 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
132 * .. Scalar Arguments ..
133 INTEGER INFO, LDB, N, NRHS
135 * .. Array Arguments ..
136 COMPLEX*16 B( LDB, * ), D( * ), DL( * ), DU( * )
139 * =====================================================================
143 PARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ) )
145 * .. Local Scalars ..
147 COMPLEX*16 MULT, TEMP, ZDUM
149 * .. Intrinsic Functions ..
150 INTRINSIC ABS, DBLE, DIMAG, MAX
152 * .. External Subroutines ..
155 * .. Statement Functions ..
156 DOUBLE PRECISION CABS1
158 * .. Statement Function definitions ..
159 CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )
161 * .. Executable Statements ..
166 ELSE IF( NRHS.LT.0 ) THEN
168 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
172 CALL XERBLA( 'ZGTSV ', -INFO )
180 IF( DL( K ).EQ.ZERO ) THEN
182 * Subdiagonal is zero, no elimination is required.
184 IF( D( K ).EQ.ZERO ) THEN
186 * Diagonal is zero: set INFO = K and return; a unique
187 * solution can not be found.
192 ELSE IF( CABS1( D( K ) ).GE.CABS1( DL( K ) ) ) THEN
194 * No row interchange required
196 MULT = DL( K ) / D( K )
197 D( K+1 ) = D( K+1 ) - MULT*DU( K )
199 B( K+1, J ) = B( K+1, J ) - MULT*B( K, J )
205 * Interchange rows K and K+1
207 MULT = D( K ) / DL( K )
210 D( K+1 ) = DU( K ) - MULT*TEMP
211 IF( K.LT.( N-1 ) ) THEN
213 DU( K+1 ) = -MULT*DL( K )
218 B( K, J ) = B( K+1, J )
219 B( K+1, J ) = TEMP - MULT*B( K+1, J )
223 IF( D( N ).EQ.ZERO ) THEN
228 * Back solve with the matrix U from the factorization.
231 B( N, J ) = B( N, J ) / D( N )
233 $ B( N-1, J ) = ( B( N-1, J )-DU( N-1 )*B( N, J ) ) / D( N-1 )
234 DO 40 K = N - 2, 1, -1
235 B( K, J ) = ( B( K, J )-DU( K )*B( K+1, J )-DL( K )*
236 $ B( K+2, J ) ) / D( K )