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