1 *> \brief \b ZGTTS2 solves a system of linear equations with a tridiagonal matrix using the LU factorization computed by sgttrf.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download ZGTTS2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgtts2.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgtts2.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgtts2.f">
21 * SUBROUTINE ZGTTS2( ITRANS, N, NRHS, DL, D, DU, DU2, IPIV, B, LDB )
23 * .. Scalar Arguments ..
24 * INTEGER ITRANS, LDB, N, NRHS
26 * .. Array Arguments ..
28 * COMPLEX*16 B( LDB, * ), D( * ), DL( * ), DU( * ), DU2( * )
37 *> ZGTTS2 solves one of the systems of equations
38 *> A * X = B, A**T * X = B, or A**H * X = B,
39 *> with a tridiagonal matrix A using the LU factorization computed
49 *> Specifies the form of the system of equations.
50 *> = 0: A * X = B (No transpose)
51 *> = 1: A**T * X = B (Transpose)
52 *> = 2: A**H * X = B (Conjugate transpose)
58 *> The order of the matrix A.
64 *> The number of right hand sides, i.e., the number of columns
65 *> of the matrix B. NRHS >= 0.
70 *> DL is COMPLEX*16 array, dimension (N-1)
71 *> The (n-1) multipliers that define the matrix L from the
72 *> LU factorization of A.
77 *> D is COMPLEX*16 array, dimension (N)
78 *> The n diagonal elements of the upper triangular matrix U from
79 *> the LU factorization of A.
84 *> DU is COMPLEX*16 array, dimension (N-1)
85 *> The (n-1) elements of the first super-diagonal of U.
90 *> DU2 is COMPLEX*16 array, dimension (N-2)
91 *> The (n-2) elements of the second super-diagonal of U.
96 *> IPIV is INTEGER array, dimension (N)
97 *> The pivot indices; for 1 <= i <= n, row i of the matrix was
98 *> interchanged with row IPIV(i). IPIV(i) will always be either
99 *> i or i+1; IPIV(i) = i indicates a row interchange was not
105 *> B is COMPLEX*16 array, dimension (LDB,NRHS)
106 *> On entry, the matrix of right hand side vectors B.
107 *> On exit, B is overwritten by the solution vectors X.
113 *> The leading dimension of the array B. LDB >= max(1,N).
119 *> \author Univ. of Tennessee
120 *> \author Univ. of California Berkeley
121 *> \author Univ. of Colorado Denver
124 *> \date September 2012
126 *> \ingroup complex16GTcomputational
128 * =====================================================================
129 SUBROUTINE ZGTTS2( ITRANS, N, NRHS, DL, D, DU, DU2, IPIV, B, LDB )
131 * -- LAPACK computational routine (version 3.4.2) --
132 * -- LAPACK is a software package provided by Univ. of Tennessee, --
133 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
136 * .. Scalar Arguments ..
137 INTEGER ITRANS, LDB, N, NRHS
139 * .. Array Arguments ..
141 COMPLEX*16 B( LDB, * ), D( * ), DL( * ), DU( * ), DU2( * )
144 * =====================================================================
146 * .. Local Scalars ..
150 * .. Intrinsic Functions ..
153 * .. Executable Statements ..
155 * Quick return if possible
157 IF( N.EQ.0 .OR. NRHS.EQ.0 )
160 IF( ITRANS.EQ.0 ) THEN
162 * Solve A*X = B using the LU factorization of A,
163 * overwriting each right hand side vector with its solution.
172 IF( IPIV( I ).EQ.I ) THEN
173 B( I+1, J ) = B( I+1, J ) - DL( I )*B( I, J )
176 B( I, J ) = B( I+1, J )
177 B( I+1, J ) = TEMP - DL( I )*B( I, J )
183 B( N, J ) = B( N, J ) / D( N )
185 $ B( N-1, J ) = ( B( N-1, J )-DU( N-1 )*B( N, J ) ) /
187 DO 30 I = N - 2, 1, -1
188 B( I, J ) = ( B( I, J )-DU( I )*B( I+1, J )-DU2( I )*
189 $ B( I+2, J ) ) / D( I )
201 IF( IPIV( I ).EQ.I ) THEN
202 B( I+1, J ) = B( I+1, J ) - DL( I )*B( I, J )
205 B( I, J ) = B( I+1, J )
206 B( I+1, J ) = TEMP - DL( I )*B( I, J )
212 B( N, J ) = B( N, J ) / D( N )
214 $ B( N-1, J ) = ( B( N-1, J )-DU( N-1 )*B( N, J ) ) /
216 DO 50 I = N - 2, 1, -1
217 B( I, J ) = ( B( I, J )-DU( I )*B( I+1, J )-DU2( I )*
218 $ B( I+2, J ) ) / D( I )
222 ELSE IF( ITRANS.EQ.1 ) THEN
224 * Solve A**T * X = B.
230 * Solve U**T * x = b.
232 B( 1, J ) = B( 1, J ) / D( 1 )
234 $ B( 2, J ) = ( B( 2, J )-DU( 1 )*B( 1, J ) ) / D( 2 )
236 B( I, J ) = ( B( I, J )-DU( I-1 )*B( I-1, J )-DU2( I-2 )*
237 $ B( I-2, J ) ) / D( I )
240 * Solve L**T * x = b.
242 DO 90 I = N - 1, 1, -1
243 IF( IPIV( I ).EQ.I ) THEN
244 B( I, J ) = B( I, J ) - DL( I )*B( I+1, J )
247 B( I+1, J ) = B( I, J ) - DL( I )*TEMP
258 * Solve U**T * x = b.
260 B( 1, J ) = B( 1, J ) / D( 1 )
262 $ B( 2, J ) = ( B( 2, J )-DU( 1 )*B( 1, J ) ) / D( 2 )
264 B( I, J ) = ( B( I, J )-DU( I-1 )*B( I-1, J )-
265 $ DU2( I-2 )*B( I-2, J ) ) / D( I )
268 * Solve L**T * x = b.
270 DO 110 I = N - 1, 1, -1
271 IF( IPIV( I ).EQ.I ) THEN
272 B( I, J ) = B( I, J ) - DL( I )*B( I+1, J )
275 B( I+1, J ) = B( I, J ) - DL( I )*TEMP
283 * Solve A**H * X = B.
289 * Solve U**H * x = b.
291 B( 1, J ) = B( 1, J ) / DCONJG( D( 1 ) )
293 $ B( 2, J ) = ( B( 2, J )-DCONJG( DU( 1 ) )*B( 1, J ) ) /
296 B( I, J ) = ( B( I, J )-DCONJG( DU( I-1 ) )*B( I-1, J )-
297 $ DCONJG( DU2( I-2 ) )*B( I-2, J ) ) /
301 * Solve L**H * x = b.
303 DO 150 I = N - 1, 1, -1
304 IF( IPIV( I ).EQ.I ) THEN
305 B( I, J ) = B( I, J ) - DCONJG( DL( I ) )*B( I+1, J )
308 B( I+1, J ) = B( I, J ) - DCONJG( DL( I ) )*TEMP
319 * Solve U**H * x = b.
321 B( 1, J ) = B( 1, J ) / DCONJG( D( 1 ) )
323 $ B( 2, J ) = ( B( 2, J )-DCONJG( DU( 1 ) )*B( 1, J ) )
326 B( I, J ) = ( B( I, J )-DCONJG( DU( I-1 ) )*
327 $ B( I-1, J )-DCONJG( DU2( I-2 ) )*
328 $ B( I-2, J ) ) / DCONJG( D( I ) )
331 * Solve L**H * x = b.
333 DO 170 I = N - 1, 1, -1
334 IF( IPIV( I ).EQ.I ) THEN
335 B( I, J ) = B( I, J ) - DCONJG( DL( I ) )*
339 B( I+1, J ) = B( I, J ) - DCONJG( DL( I ) )*TEMP