LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
dgtts2.f
Go to the documentation of this file.
1 *> \brief \b DGTTS2 solves a system of linear equations with a tridiagonal matrix using the LU factorization computed by sgttrf.
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 *> \htmlonly
9 *> Download DGTTS2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgtts2.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgtts2.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgtts2.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * SUBROUTINE DGTTS2( ITRANS, N, NRHS, DL, D, DU, DU2, IPIV, B, LDB )
22 *
23 * .. Scalar Arguments ..
24 * INTEGER ITRANS, LDB, N, NRHS
25 * ..
26 * .. Array Arguments ..
27 * INTEGER IPIV( * )
28 * DOUBLE PRECISION B( LDB, * ), D( * ), DL( * ), DU( * ), DU2( * )
29 * ..
30 *
31 *
32 *> \par Purpose:
33 * =============
34 *>
35 *> \verbatim
36 *>
37 *> DGTTS2 solves one of the systems of equations
38 *> A*X = B or A**T*X = B,
39 *> with a tridiagonal matrix A using the LU factorization computed
40 *> by DGTTRF.
41 *> \endverbatim
42 *
43 * Arguments:
44 * ==========
45 *
46 *> \param[in] ITRANS
47 *> \verbatim
48 *> ITRANS is INTEGER
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**T* X = B (Conjugate transpose = Transpose)
53 *> \endverbatim
54 *>
55 *> \param[in] N
56 *> \verbatim
57 *> N is INTEGER
58 *> The order of the matrix A.
59 *> \endverbatim
60 *>
61 *> \param[in] NRHS
62 *> \verbatim
63 *> NRHS is INTEGER
64 *> The number of right hand sides, i.e., the number of columns
65 *> of the matrix B. NRHS >= 0.
66 *> \endverbatim
67 *>
68 *> \param[in] DL
69 *> \verbatim
70 *> DL is DOUBLE PRECISION array, dimension (N-1)
71 *> The (n-1) multipliers that define the matrix L from the
72 *> LU factorization of A.
73 *> \endverbatim
74 *>
75 *> \param[in] D
76 *> \verbatim
77 *> D is DOUBLE PRECISION array, dimension (N)
78 *> The n diagonal elements of the upper triangular matrix U from
79 *> the LU factorization of A.
80 *> \endverbatim
81 *>
82 *> \param[in] DU
83 *> \verbatim
84 *> DU is DOUBLE PRECISION array, dimension (N-1)
85 *> The (n-1) elements of the first super-diagonal of U.
86 *> \endverbatim
87 *>
88 *> \param[in] DU2
89 *> \verbatim
90 *> DU2 is DOUBLE PRECISION array, dimension (N-2)
91 *> The (n-2) elements of the second super-diagonal of U.
92 *> \endverbatim
93 *>
94 *> \param[in] IPIV
95 *> \verbatim
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
100 *> required.
101 *> \endverbatim
102 *>
103 *> \param[in,out] B
104 *> \verbatim
105 *> B is DOUBLE PRECISION 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.
108 *> \endverbatim
109 *>
110 *> \param[in] LDB
111 *> \verbatim
112 *> LDB is INTEGER
113 *> The leading dimension of the array B. LDB >= max(1,N).
114 *> \endverbatim
115 *
116 * Authors:
117 * ========
118 *
119 *> \author Univ. of Tennessee
120 *> \author Univ. of California Berkeley
121 *> \author Univ. of Colorado Denver
122 *> \author NAG Ltd.
123 *
124 *> \date September 2012
125 *
126 *> \ingroup doubleGTcomputational
127 *
128 * =====================================================================
129  SUBROUTINE dgtts2( ITRANS, N, NRHS, DL, D, DU, DU2, IPIV, B, LDB )
130 *
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..--
134 * September 2012
135 *
136 * .. Scalar Arguments ..
137  INTEGER ITRANS, LDB, N, NRHS
138 * ..
139 * .. Array Arguments ..
140  INTEGER IPIV( * )
141  DOUBLE PRECISION B( ldb, * ), D( * ), DL( * ), DU( * ), DU2( * )
142 * ..
143 *
144 * =====================================================================
145 *
146 * .. Local Scalars ..
147  INTEGER I, IP, J
148  DOUBLE PRECISION TEMP
149 * ..
150 * .. Executable Statements ..
151 *
152 * Quick return if possible
153 *
154  IF( n.EQ.0 .OR. nrhs.EQ.0 )
155  $ RETURN
156 *
157  IF( itrans.EQ.0 ) THEN
158 *
159 * Solve A*X = B using the LU factorization of A,
160 * overwriting each right hand side vector with its solution.
161 *
162  IF( nrhs.LE.1 ) THEN
163  j = 1
164  10 CONTINUE
165 *
166 * Solve L*x = b.
167 *
168  DO 20 i = 1, n - 1
169  ip = ipiv( i )
170  temp = b( i+1-ip+i, j ) - dl( i )*b( ip, j )
171  b( i, j ) = b( ip, j )
172  b( i+1, j ) = temp
173  20 CONTINUE
174 *
175 * Solve U*x = b.
176 *
177  b( n, j ) = b( n, j ) / d( n )
178  IF( n.GT.1 )
179  $ b( n-1, j ) = ( b( n-1, j )-du( n-1 )*b( n, j ) ) /
180  $ d( n-1 )
181  DO 30 i = n - 2, 1, -1
182  b( i, j ) = ( b( i, j )-du( i )*b( i+1, j )-du2( i )*
183  $ b( i+2, j ) ) / d( i )
184  30 CONTINUE
185  IF( j.LT.nrhs ) THEN
186  j = j + 1
187  GO TO 10
188  END IF
189  ELSE
190  DO 60 j = 1, nrhs
191 *
192 * Solve L*x = b.
193 *
194  DO 40 i = 1, n - 1
195  IF( ipiv( i ).EQ.i ) THEN
196  b( i+1, j ) = b( i+1, j ) - dl( i )*b( i, j )
197  ELSE
198  temp = b( i, j )
199  b( i, j ) = b( i+1, j )
200  b( i+1, j ) = temp - dl( i )*b( i, j )
201  END IF
202  40 CONTINUE
203 *
204 * Solve U*x = b.
205 *
206  b( n, j ) = b( n, j ) / d( n )
207  IF( n.GT.1 )
208  $ b( n-1, j ) = ( b( n-1, j )-du( n-1 )*b( n, j ) ) /
209  $ d( n-1 )
210  DO 50 i = n - 2, 1, -1
211  b( i, j ) = ( b( i, j )-du( i )*b( i+1, j )-du2( i )*
212  $ b( i+2, j ) ) / d( i )
213  50 CONTINUE
214  60 CONTINUE
215  END IF
216  ELSE
217 *
218 * Solve A**T * X = B.
219 *
220  IF( nrhs.LE.1 ) THEN
221 *
222 * Solve U**T*x = b.
223 *
224  j = 1
225  70 CONTINUE
226  b( 1, j ) = b( 1, j ) / d( 1 )
227  IF( n.GT.1 )
228  $ b( 2, j ) = ( b( 2, j )-du( 1 )*b( 1, j ) ) / d( 2 )
229  DO 80 i = 3, n
230  b( i, j ) = ( b( i, j )-du( i-1 )*b( i-1, j )-du2( i-2 )*
231  $ b( i-2, j ) ) / d( i )
232  80 CONTINUE
233 *
234 * Solve L**T*x = b.
235 *
236  DO 90 i = n - 1, 1, -1
237  ip = ipiv( i )
238  temp = b( i, j ) - dl( i )*b( i+1, j )
239  b( i, j ) = b( ip, j )
240  b( ip, j ) = temp
241  90 CONTINUE
242  IF( j.LT.nrhs ) THEN
243  j = j + 1
244  GO TO 70
245  END IF
246 *
247  ELSE
248  DO 120 j = 1, nrhs
249 *
250 * Solve U**T*x = b.
251 *
252  b( 1, j ) = b( 1, j ) / d( 1 )
253  IF( n.GT.1 )
254  $ b( 2, j ) = ( b( 2, j )-du( 1 )*b( 1, j ) ) / d( 2 )
255  DO 100 i = 3, n
256  b( i, j ) = ( b( i, j )-du( i-1 )*b( i-1, j )-
257  $ du2( i-2 )*b( i-2, j ) ) / d( i )
258  100 CONTINUE
259  DO 110 i = n - 1, 1, -1
260  IF( ipiv( i ).EQ.i ) THEN
261  b( i, j ) = b( i, j ) - dl( i )*b( i+1, j )
262  ELSE
263  temp = b( i+1, j )
264  b( i+1, j ) = b( i, j ) - dl( i )*temp
265  b( i, j ) = temp
266  END IF
267  110 CONTINUE
268  120 CONTINUE
269  END IF
270  END IF
271 *
272 * End of DGTTS2
273 *
274  END
subroutine dgtts2(ITRANS, N, NRHS, DL, D, DU, DU2, IPIV, B, LDB)
DGTTS2 solves a system of linear equations with a tridiagonal matrix using the LU factorization compu...
Definition: dgtts2.f:130