LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ sgtts2()

subroutine sgtts2 ( integer itrans,
integer n,
integer nrhs,
real, dimension( * ) dl,
real, dimension( * ) d,
real, dimension( * ) du,
real, dimension( * ) du2,
integer, dimension( * ) ipiv,
real, dimension( ldb, * ) b,
integer ldb )

SGTTS2 solves a system of linear equations with a tridiagonal matrix using the LU factorization computed by sgttrf.

Download SGTTS2 + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> SGTTS2 solves one of the systems of equations
!>    A*X = B  or  A**T*X = B,
!> with a tridiagonal matrix A using the LU factorization computed
!> by SGTTRF.
!> 
Parameters
[in]ITRANS
!>          ITRANS is INTEGER
!>          Specifies the form of the system of equations.
!>          = 0:  A * X = B  (No transpose)
!>          = 1:  A**T* X = B  (Transpose)
!>          = 2:  A**T* X = B  (Conjugate transpose = Transpose)
!> 
[in]N
!>          N is INTEGER
!>          The order of the matrix A.
!> 
[in]NRHS
!>          NRHS is INTEGER
!>          The number of right hand sides, i.e., the number of columns
!>          of the matrix B.  NRHS >= 0.
!> 
[in]DL
!>          DL is REAL array, dimension (N-1)
!>          The (n-1) multipliers that define the matrix L from the
!>          LU factorization of A.
!> 
[in]D
!>          D is REAL array, dimension (N)
!>          The n diagonal elements of the upper triangular matrix U from
!>          the LU factorization of A.
!> 
[in]DU
!>          DU is REAL array, dimension (N-1)
!>          The (n-1) elements of the first super-diagonal of U.
!> 
[in]DU2
!>          DU2 is REAL array, dimension (N-2)
!>          The (n-2) elements of the second super-diagonal of U.
!> 
[in]IPIV
!>          IPIV is INTEGER array, dimension (N)
!>          The pivot indices; for 1 <= i <= n, row i of the matrix was
!>          interchanged with row IPIV(i).  IPIV(i) will always be either
!>          i or i+1; IPIV(i) = i indicates a row interchange was not
!>          required.
!> 
[in,out]B
!>          B is REAL array, dimension (LDB,NRHS)
!>          On entry, the matrix of right hand side vectors B.
!>          On exit, B is overwritten by the solution vectors X.
!> 
[in]LDB
!>          LDB is INTEGER
!>          The leading dimension of the array B.  LDB >= max(1,N).
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 125 of file sgtts2.f.

127*
128* -- LAPACK computational routine --
129* -- LAPACK is a software package provided by Univ. of Tennessee, --
130* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
131*
132* .. Scalar Arguments ..
133 INTEGER ITRANS, LDB, N, NRHS
134* ..
135* .. Array Arguments ..
136 INTEGER IPIV( * )
137 REAL B( LDB, * ), D( * ), DL( * ), DU( * ), DU2( * )
138* ..
139*
140* =====================================================================
141*
142* .. Local Scalars ..
143 INTEGER I, IP, J
144 REAL TEMP
145* ..
146* .. Executable Statements ..
147*
148* Quick return if possible
149*
150 IF( n.EQ.0 .OR. nrhs.EQ.0 )
151 $ RETURN
152*
153 IF( itrans.EQ.0 ) THEN
154*
155* Solve A*X = B using the LU factorization of A,
156* overwriting each right hand side vector with its solution.
157*
158 IF( nrhs.LE.1 ) THEN
159 j = 1
160 10 CONTINUE
161*
162* Solve L*x = b.
163*
164 DO 20 i = 1, n - 1
165 ip = ipiv( i )
166 temp = b( i+1-ip+i, j ) - dl( i )*b( ip, j )
167 b( i, j ) = b( ip, j )
168 b( i+1, j ) = temp
169 20 CONTINUE
170*
171* Solve U*x = b.
172*
173 b( n, j ) = b( n, j ) / d( n )
174 IF( n.GT.1 )
175 $ b( n-1, j ) = ( b( n-1, j )-du( n-1 )*b( n, j ) ) /
176 $ d( n-1 )
177 DO 30 i = n - 2, 1, -1
178 b( i, j ) = ( b( i, j )-du( i )*b( i+1, j )-du2( i )*
179 $ b( i+2, j ) ) / d( i )
180 30 CONTINUE
181 IF( j.LT.nrhs ) THEN
182 j = j + 1
183 GO TO 10
184 END IF
185 ELSE
186 DO 60 j = 1, nrhs
187*
188* Solve L*x = b.
189*
190 DO 40 i = 1, n - 1
191 IF( ipiv( i ).EQ.i ) THEN
192 b( i+1, j ) = b( i+1, j ) - dl( i )*b( i, j )
193 ELSE
194 temp = b( i, j )
195 b( i, j ) = b( i+1, j )
196 b( i+1, j ) = temp - dl( i )*b( i, j )
197 END IF
198 40 CONTINUE
199*
200* Solve U*x = b.
201*
202 b( n, j ) = b( n, j ) / d( n )
203 IF( n.GT.1 )
204 $ b( n-1, j ) = ( b( n-1, j )-du( n-1 )*b( n, j ) ) /
205 $ d( n-1 )
206 DO 50 i = n - 2, 1, -1
207 b( i, j ) = ( b( i, j )-du( i )*b( i+1, j )-du2( i )*
208 $ b( i+2, j ) ) / d( i )
209 50 CONTINUE
210 60 CONTINUE
211 END IF
212 ELSE
213*
214* Solve A**T * X = B.
215*
216 IF( nrhs.LE.1 ) THEN
217*
218* Solve U**T*x = b.
219*
220 j = 1
221 70 CONTINUE
222 b( 1, j ) = b( 1, j ) / d( 1 )
223 IF( n.GT.1 )
224 $ b( 2, j ) = ( b( 2, j )-du( 1 )*b( 1, j ) ) / d( 2 )
225 DO 80 i = 3, n
226 b( i, j ) = ( b( i, j )-du( i-1 )*b( i-1, j )-du2( i-2 )*
227 $ b( i-2, j ) ) / d( i )
228 80 CONTINUE
229*
230* Solve L**T*x = b.
231*
232 DO 90 i = n - 1, 1, -1
233 ip = ipiv( i )
234 temp = b( i, j ) - dl( i )*b( i+1, j )
235 b( i, j ) = b( ip, j )
236 b( ip, j ) = temp
237 90 CONTINUE
238 IF( j.LT.nrhs ) THEN
239 j = j + 1
240 GO TO 70
241 END IF
242*
243 ELSE
244 DO 120 j = 1, nrhs
245*
246* Solve U**T*x = b.
247*
248 b( 1, j ) = b( 1, j ) / d( 1 )
249 IF( n.GT.1 )
250 $ b( 2, j ) = ( b( 2, j )-du( 1 )*b( 1, j ) ) / d( 2 )
251 DO 100 i = 3, n
252 b( i, j ) = ( b( i, j )-du( i-1 )*b( i-1, j )-
253 $ du2( i-2 )*b( i-2, j ) ) / d( i )
254 100 CONTINUE
255 DO 110 i = n - 1, 1, -1
256 IF( ipiv( i ).EQ.i ) THEN
257 b( i, j ) = b( i, j ) - dl( i )*b( i+1, j )
258 ELSE
259 temp = b( i+1, j )
260 b( i+1, j ) = b( i, j ) - dl( i )*temp
261 b( i, j ) = temp
262 END IF
263 110 CONTINUE
264 120 CONTINUE
265 END IF
266 END IF
267*
268* End of SGTTS2
269*
Here is the caller graph for this function: