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

◆ sgbtf2()

subroutine sgbtf2 ( integer  m,
integer  n,
integer  kl,
integer  ku,
real, dimension( ldab, * )  ab,
integer  ldab,
integer, dimension( * )  ipiv,
integer  info 
)

SGBTF2 computes the LU factorization of a general band matrix using the unblocked version of the algorithm.

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

Purpose:
 SGBTF2 computes an LU factorization of a real m-by-n band matrix A
 using partial pivoting with row interchanges.

 This is the unblocked version of the algorithm, calling Level 2 BLAS.
Parameters
[in]M
          M is INTEGER
          The number of rows of the matrix A.  M >= 0.
[in]N
          N is INTEGER
          The number of columns of the matrix A.  N >= 0.
[in]KL
          KL is INTEGER
          The number of subdiagonals within the band of A.  KL >= 0.
[in]KU
          KU is INTEGER
          The number of superdiagonals within the band of A.  KU >= 0.
[in,out]AB
          AB is REAL array, dimension (LDAB,N)
          On entry, the matrix A in band storage, in rows KL+1 to
          2*KL+KU+1; rows 1 to KL of the array need not be set.
          The j-th column of A is stored in the j-th column of the
          array AB as follows:
          AB(kl+ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl)

          On exit, details of the factorization: U is stored as an
          upper triangular band matrix with KL+KU superdiagonals in
          rows 1 to KL+KU+1, and the multipliers used during the
          factorization are stored in rows KL+KU+2 to 2*KL+KU+1.
          See below for further details.
[in]LDAB
          LDAB is INTEGER
          The leading dimension of the array AB.  LDAB >= 2*KL+KU+1.
[out]IPIV
          IPIV is INTEGER array, dimension (min(M,N))
          The pivot indices; for 1 <= i <= min(M,N), row i of the
          matrix was interchanged with row IPIV(i).
[out]INFO
          INFO is INTEGER
          = 0: successful exit
          < 0: if INFO = -i, the i-th argument had an illegal value
          > 0: if INFO = +i, U(i,i) is exactly zero. The factorization
               has been completed, but the factor U is exactly
               singular, and division by zero will occur if it is used
               to solve a system of equations.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
  The band storage scheme is illustrated by the following example, when
  M = N = 6, KL = 2, KU = 1:

  On entry:                       On exit:

      *    *    *    +    +    +       *    *    *   u14  u25  u36
      *    *    +    +    +    +       *    *   u13  u24  u35  u46
      *   a12  a23  a34  a45  a56      *   u12  u23  u34  u45  u56
     a11  a22  a33  a44  a55  a66     u11  u22  u33  u44  u55  u66
     a21  a32  a43  a54  a65   *      m21  m32  m43  m54  m65   *
     a31  a42  a53  a64   *    *      m31  m42  m53  m64   *    *

  Array elements marked * are not used by the routine; elements marked
  + need not be set on entry, but are required by the routine to store
  elements of U, because of fill-in resulting from the row
  interchanges.

Definition at line 144 of file sgbtf2.f.

145*
146* -- LAPACK computational routine --
147* -- LAPACK is a software package provided by Univ. of Tennessee, --
148* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
149*
150* .. Scalar Arguments ..
151 INTEGER INFO, KL, KU, LDAB, M, N
152* ..
153* .. Array Arguments ..
154 INTEGER IPIV( * )
155 REAL AB( LDAB, * )
156* ..
157*
158* =====================================================================
159*
160* .. Parameters ..
161 REAL ONE, ZERO
162 parameter( one = 1.0e+0, zero = 0.0e+0 )
163* ..
164* .. Local Scalars ..
165 INTEGER I, J, JP, JU, KM, KV
166* ..
167* .. External Functions ..
168 INTEGER ISAMAX
169 EXTERNAL isamax
170* ..
171* .. External Subroutines ..
172 EXTERNAL sger, sscal, sswap, xerbla
173* ..
174* .. Intrinsic Functions ..
175 INTRINSIC max, min
176* ..
177* .. Executable Statements ..
178*
179* KV is the number of superdiagonals in the factor U, allowing for
180* fill-in.
181*
182 kv = ku + kl
183*
184* Test the input parameters.
185*
186 info = 0
187 IF( m.LT.0 ) THEN
188 info = -1
189 ELSE IF( n.LT.0 ) THEN
190 info = -2
191 ELSE IF( kl.LT.0 ) THEN
192 info = -3
193 ELSE IF( ku.LT.0 ) THEN
194 info = -4
195 ELSE IF( ldab.LT.kl+kv+1 ) THEN
196 info = -6
197 END IF
198 IF( info.NE.0 ) THEN
199 CALL xerbla( 'SGBTF2', -info )
200 RETURN
201 END IF
202*
203* Quick return if possible
204*
205 IF( m.EQ.0 .OR. n.EQ.0 )
206 $ RETURN
207*
208* Gaussian elimination with partial pivoting
209*
210* Set fill-in elements in columns KU+2 to KV to zero.
211*
212 DO 20 j = ku + 2, min( kv, n )
213 DO 10 i = kv - j + 2, kl
214 ab( i, j ) = zero
215 10 CONTINUE
216 20 CONTINUE
217*
218* JU is the index of the last column affected by the current stage
219* of the factorization.
220*
221 ju = 1
222*
223 DO 40 j = 1, min( m, n )
224*
225* Set fill-in elements in column J+KV to zero.
226*
227 IF( j+kv.LE.n ) THEN
228 DO 30 i = 1, kl
229 ab( i, j+kv ) = zero
230 30 CONTINUE
231 END IF
232*
233* Find pivot and test for singularity. KM is the number of
234* subdiagonal elements in the current column.
235*
236 km = min( kl, m-j )
237 jp = isamax( km+1, ab( kv+1, j ), 1 )
238 ipiv( j ) = jp + j - 1
239 IF( ab( kv+jp, j ).NE.zero ) THEN
240 ju = max( ju, min( j+ku+jp-1, n ) )
241*
242* Apply interchange to columns J to JU.
243*
244 IF( jp.NE.1 )
245 $ CALL sswap( ju-j+1, ab( kv+jp, j ), ldab-1,
246 $ ab( kv+1, j ), ldab-1 )
247*
248 IF( km.GT.0 ) THEN
249*
250* Compute multipliers.
251*
252 CALL sscal( km, one / ab( kv+1, j ), ab( kv+2, j ), 1 )
253*
254* Update trailing submatrix within the band.
255*
256 IF( ju.GT.j )
257 $ CALL sger( km, ju-j, -one, ab( kv+2, j ), 1,
258 $ ab( kv, j+1 ), ldab-1, ab( kv+1, j+1 ),
259 $ ldab-1 )
260 END IF
261 ELSE
262*
263* If pivot is zero, set INFO to the index of the pivot
264* unless a zero pivot has already been found.
265*
266 IF( info.EQ.0 )
267 $ info = j
268 END IF
269 40 CONTINUE
270 RETURN
271*
272* End of SGBTF2
273*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sger(m, n, alpha, x, incx, y, incy, a, lda)
SGER
Definition sger.f:130
integer function isamax(n, sx, incx)
ISAMAX
Definition isamax.f:71
subroutine sscal(n, sa, sx, incx)
SSCAL
Definition sscal.f:79
subroutine sswap(n, sx, incx, sy, incy)
SSWAP
Definition sswap.f:82
Here is the call graph for this function:
Here is the caller graph for this function: