LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
sgttrf.f
Go to the documentation of this file.
1*> \brief \b SGTTRF
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download SGTTRF + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgttrf.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgttrf.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgttrf.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE SGTTRF( N, DL, D, DU, DU2, IPIV, INFO )
20*
21* .. Scalar Arguments ..
22* INTEGER INFO, N
23* ..
24* .. Array Arguments ..
25* INTEGER IPIV( * )
26* REAL D( * ), DL( * ), DU( * ), DU2( * )
27* ..
28*
29*
30*> \par Purpose:
31* =============
32*>
33*> \verbatim
34*>
35*> SGTTRF computes an LU factorization of a real tridiagonal matrix A
36*> using elimination with partial pivoting and row interchanges.
37*>
38*> The factorization has the form
39*> A = L * U
40*> where L is a product of permutation and unit lower bidiagonal
41*> matrices and U is upper triangular with nonzeros in only the main
42*> diagonal and first two superdiagonals.
43*> \endverbatim
44*
45* Arguments:
46* ==========
47*
48*> \param[in] N
49*> \verbatim
50*> N is INTEGER
51*> The order of the matrix A.
52*> \endverbatim
53*>
54*> \param[in,out] DL
55*> \verbatim
56*> DL is REAL array, dimension (N-1)
57*> On entry, DL must contain the (n-1) sub-diagonal elements of
58*> A.
59*>
60*> On exit, DL is overwritten by the (n-1) multipliers that
61*> define the matrix L from the LU factorization of A.
62*> \endverbatim
63*>
64*> \param[in,out] D
65*> \verbatim
66*> D is REAL array, dimension (N)
67*> On entry, D must contain the diagonal elements of A.
68*>
69*> On exit, D is overwritten by the n diagonal elements of the
70*> upper triangular matrix U from the LU factorization of A.
71*> \endverbatim
72*>
73*> \param[in,out] DU
74*> \verbatim
75*> DU is REAL array, dimension (N-1)
76*> On entry, DU must contain the (n-1) super-diagonal elements
77*> of A.
78*>
79*> On exit, DU is overwritten by the (n-1) elements of the first
80*> super-diagonal of U.
81*> \endverbatim
82*>
83*> \param[out] DU2
84*> \verbatim
85*> DU2 is REAL array, dimension (N-2)
86*> On exit, DU2 is overwritten by the (n-2) elements of the
87*> second super-diagonal of U.
88*> \endverbatim
89*>
90*> \param[out] IPIV
91*> \verbatim
92*> IPIV is INTEGER array, dimension (N)
93*> The pivot indices; for 1 <= i <= n, row i of the matrix was
94*> interchanged with row IPIV(i). IPIV(i) will always be either
95*> i or i+1; IPIV(i) = i indicates a row interchange was not
96*> required.
97*> \endverbatim
98*>
99*> \param[out] INFO
100*> \verbatim
101*> INFO is INTEGER
102*> = 0: successful exit
103*> < 0: if INFO = -k, the k-th argument had an illegal value
104*> > 0: if INFO = k, U(k,k) is exactly zero. The factorization
105*> has been completed, but the factor U is exactly
106*> singular, and division by zero will occur if it is used
107*> to solve a system of equations.
108*> \endverbatim
109*
110* Authors:
111* ========
112*
113*> \author Univ. of Tennessee
114*> \author Univ. of California Berkeley
115*> \author Univ. of Colorado Denver
116*> \author NAG Ltd.
117*
118*> \ingroup gttrf
119*
120* =====================================================================
121 SUBROUTINE sgttrf( N, DL, D, DU, DU2, IPIV, INFO )
122*
123* -- LAPACK computational routine --
124* -- LAPACK is a software package provided by Univ. of Tennessee, --
125* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
126*
127* .. Scalar Arguments ..
128 INTEGER INFO, N
129* ..
130* .. Array Arguments ..
131 INTEGER IPIV( * )
132 REAL D( * ), DL( * ), DU( * ), DU2( * )
133* ..
134*
135* =====================================================================
136*
137* .. Parameters ..
138 REAL ZERO
139 parameter( zero = 0.0e+0 )
140* ..
141* .. Local Scalars ..
142 INTEGER I
143 REAL FACT, TEMP
144* ..
145* .. Intrinsic Functions ..
146 INTRINSIC abs
147* ..
148* .. External Subroutines ..
149 EXTERNAL xerbla
150* ..
151* .. Executable Statements ..
152*
153 info = 0
154 IF( n.LT.0 ) THEN
155 info = -1
156 CALL xerbla( 'SGTTRF', -info )
157 RETURN
158 END IF
159*
160* Quick return if possible
161*
162 IF( n.EQ.0 )
163 $ RETURN
164*
165* Initialize IPIV(i) = i and DU2(I) = 0
166*
167 DO 10 i = 1, n
168 ipiv( i ) = i
169 10 CONTINUE
170 DO 20 i = 1, n - 2
171 du2( i ) = zero
172 20 CONTINUE
173*
174 DO 30 i = 1, n - 2
175 IF( abs( d( i ) ).GE.abs( dl( i ) ) ) THEN
176*
177* No row interchange required, eliminate DL(I)
178*
179 IF( d( i ).NE.zero ) THEN
180 fact = dl( i ) / d( i )
181 dl( i ) = fact
182 d( i+1 ) = d( i+1 ) - fact*du( i )
183 END IF
184 ELSE
185*
186* Interchange rows I and I+1, eliminate DL(I)
187*
188 fact = d( i ) / dl( i )
189 d( i ) = dl( i )
190 dl( i ) = fact
191 temp = du( i )
192 du( i ) = d( i+1 )
193 d( i+1 ) = temp - fact*d( i+1 )
194 du2( i ) = du( i+1 )
195 du( i+1 ) = -fact*du( i+1 )
196 ipiv( i ) = i + 1
197 END IF
198 30 CONTINUE
199 IF( n.GT.1 ) THEN
200 i = n - 1
201 IF( abs( d( i ) ).GE.abs( dl( i ) ) ) THEN
202 IF( d( i ).NE.zero ) THEN
203 fact = dl( i ) / d( i )
204 dl( i ) = fact
205 d( i+1 ) = d( i+1 ) - fact*du( i )
206 END IF
207 ELSE
208 fact = d( i ) / dl( i )
209 d( i ) = dl( i )
210 dl( i ) = fact
211 temp = du( i )
212 du( i ) = d( i+1 )
213 d( i+1 ) = temp - fact*d( i+1 )
214 ipiv( i ) = i + 1
215 END IF
216 END IF
217*
218* Check for a zero on the diagonal of U.
219*
220 DO 40 i = 1, n
221 IF( d( i ).EQ.zero ) THEN
222 info = i
223 GO TO 50
224 END IF
225 40 CONTINUE
226 50 CONTINUE
227*
228 RETURN
229*
230* End of SGTTRF
231*
232 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sgttrf(n, dl, d, du, du2, ipiv, info)
SGTTRF
Definition sgttrf.f:122