LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
sgbtf2.f
Go to the documentation of this file.
00001 *> \brief \b SGBTF2
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download SGBTF2 + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgbtf2.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgbtf2.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgbtf2.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE SGBTF2( M, N, KL, KU, AB, LDAB, IPIV, INFO )
00022 * 
00023 *       .. Scalar Arguments ..
00024 *       INTEGER            INFO, KL, KU, LDAB, M, N
00025 *       ..
00026 *       .. Array Arguments ..
00027 *       INTEGER            IPIV( * )
00028 *       REAL               AB( LDAB, * )
00029 *       ..
00030 *  
00031 *
00032 *> \par Purpose:
00033 *  =============
00034 *>
00035 *> \verbatim
00036 *>
00037 *> SGBTF2 computes an LU factorization of a real m-by-n band matrix A
00038 *> using partial pivoting with row interchanges.
00039 *>
00040 *> This is the unblocked version of the algorithm, calling Level 2 BLAS.
00041 *> \endverbatim
00042 *
00043 *  Arguments:
00044 *  ==========
00045 *
00046 *> \param[in] M
00047 *> \verbatim
00048 *>          M is INTEGER
00049 *>          The number of rows of the matrix A.  M >= 0.
00050 *> \endverbatim
00051 *>
00052 *> \param[in] N
00053 *> \verbatim
00054 *>          N is INTEGER
00055 *>          The number of columns of the matrix A.  N >= 0.
00056 *> \endverbatim
00057 *>
00058 *> \param[in] KL
00059 *> \verbatim
00060 *>          KL is INTEGER
00061 *>          The number of subdiagonals within the band of A.  KL >= 0.
00062 *> \endverbatim
00063 *>
00064 *> \param[in] KU
00065 *> \verbatim
00066 *>          KU is INTEGER
00067 *>          The number of superdiagonals within the band of A.  KU >= 0.
00068 *> \endverbatim
00069 *>
00070 *> \param[in,out] AB
00071 *> \verbatim
00072 *>          AB is REAL array, dimension (LDAB,N)
00073 *>          On entry, the matrix A in band storage, in rows KL+1 to
00074 *>          2*KL+KU+1; rows 1 to KL of the array need not be set.
00075 *>          The j-th column of A is stored in the j-th column of the
00076 *>          array AB as follows:
00077 *>          AB(kl+ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl)
00078 *>
00079 *>          On exit, details of the factorization: U is stored as an
00080 *>          upper triangular band matrix with KL+KU superdiagonals in
00081 *>          rows 1 to KL+KU+1, and the multipliers used during the
00082 *>          factorization are stored in rows KL+KU+2 to 2*KL+KU+1.
00083 *>          See below for further details.
00084 *> \endverbatim
00085 *>
00086 *> \param[in] LDAB
00087 *> \verbatim
00088 *>          LDAB is INTEGER
00089 *>          The leading dimension of the array AB.  LDAB >= 2*KL+KU+1.
00090 *> \endverbatim
00091 *>
00092 *> \param[out] IPIV
00093 *> \verbatim
00094 *>          IPIV is INTEGER array, dimension (min(M,N))
00095 *>          The pivot indices; for 1 <= i <= min(M,N), row i of the
00096 *>          matrix was interchanged with row IPIV(i).
00097 *> \endverbatim
00098 *>
00099 *> \param[out] INFO
00100 *> \verbatim
00101 *>          INFO is INTEGER
00102 *>          = 0: successful exit
00103 *>          < 0: if INFO = -i, the i-th argument had an illegal value
00104 *>          > 0: if INFO = +i, U(i,i) is exactly zero. The factorization
00105 *>               has been completed, but the factor U is exactly
00106 *>               singular, and division by zero will occur if it is used
00107 *>               to solve a system of equations.
00108 *> \endverbatim
00109 *
00110 *  Authors:
00111 *  ========
00112 *
00113 *> \author Univ. of Tennessee 
00114 *> \author Univ. of California Berkeley 
00115 *> \author Univ. of Colorado Denver 
00116 *> \author NAG Ltd. 
00117 *
00118 *> \date November 2011
00119 *
00120 *> \ingroup realGBcomputational
00121 *
00122 *> \par Further Details:
00123 *  =====================
00124 *>
00125 *> \verbatim
00126 *>
00127 *>  The band storage scheme is illustrated by the following example, when
00128 *>  M = N = 6, KL = 2, KU = 1:
00129 *>
00130 *>  On entry:                       On exit:
00131 *>
00132 *>      *    *    *    +    +    +       *    *    *   u14  u25  u36
00133 *>      *    *    +    +    +    +       *    *   u13  u24  u35  u46
00134 *>      *   a12  a23  a34  a45  a56      *   u12  u23  u34  u45  u56
00135 *>     a11  a22  a33  a44  a55  a66     u11  u22  u33  u44  u55  u66
00136 *>     a21  a32  a43  a54  a65   *      m21  m32  m43  m54  m65   *
00137 *>     a31  a42  a53  a64   *    *      m31  m42  m53  m64   *    *
00138 *>
00139 *>  Array elements marked * are not used by the routine; elements marked
00140 *>  + need not be set on entry, but are required by the routine to store
00141 *>  elements of U, because of fill-in resulting from the row
00142 *>  interchanges.
00143 *> \endverbatim
00144 *>
00145 *  =====================================================================
00146       SUBROUTINE SGBTF2( M, N, KL, KU, AB, LDAB, IPIV, INFO )
00147 *
00148 *  -- LAPACK computational routine (version 3.4.0) --
00149 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00150 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00151 *     November 2011
00152 *
00153 *     .. Scalar Arguments ..
00154       INTEGER            INFO, KL, KU, LDAB, M, N
00155 *     ..
00156 *     .. Array Arguments ..
00157       INTEGER            IPIV( * )
00158       REAL               AB( LDAB, * )
00159 *     ..
00160 *
00161 *  =====================================================================
00162 *
00163 *     .. Parameters ..
00164       REAL               ONE, ZERO
00165       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
00166 *     ..
00167 *     .. Local Scalars ..
00168       INTEGER            I, J, JP, JU, KM, KV
00169 *     ..
00170 *     .. External Functions ..
00171       INTEGER            ISAMAX
00172       EXTERNAL           ISAMAX
00173 *     ..
00174 *     .. External Subroutines ..
00175       EXTERNAL           SGER, SSCAL, SSWAP, XERBLA
00176 *     ..
00177 *     .. Intrinsic Functions ..
00178       INTRINSIC          MAX, MIN
00179 *     ..
00180 *     .. Executable Statements ..
00181 *
00182 *     KV is the number of superdiagonals in the factor U, allowing for
00183 *     fill-in.
00184 *
00185       KV = KU + KL
00186 *
00187 *     Test the input parameters.
00188 *
00189       INFO = 0
00190       IF( M.LT.0 ) THEN
00191          INFO = -1
00192       ELSE IF( N.LT.0 ) THEN
00193          INFO = -2
00194       ELSE IF( KL.LT.0 ) THEN
00195          INFO = -3
00196       ELSE IF( KU.LT.0 ) THEN
00197          INFO = -4
00198       ELSE IF( LDAB.LT.KL+KV+1 ) THEN
00199          INFO = -6
00200       END IF
00201       IF( INFO.NE.0 ) THEN
00202          CALL XERBLA( 'SGBTF2', -INFO )
00203          RETURN
00204       END IF
00205 *
00206 *     Quick return if possible
00207 *
00208       IF( M.EQ.0 .OR. N.EQ.0 )
00209      $   RETURN
00210 *
00211 *     Gaussian elimination with partial pivoting
00212 *
00213 *     Set fill-in elements in columns KU+2 to KV to zero.
00214 *
00215       DO 20 J = KU + 2, MIN( KV, N )
00216          DO 10 I = KV - J + 2, KL
00217             AB( I, J ) = ZERO
00218    10    CONTINUE
00219    20 CONTINUE
00220 *
00221 *     JU is the index of the last column affected by the current stage
00222 *     of the factorization.
00223 *
00224       JU = 1
00225 *
00226       DO 40 J = 1, MIN( M, N )
00227 *
00228 *        Set fill-in elements in column J+KV to zero.
00229 *
00230          IF( J+KV.LE.N ) THEN
00231             DO 30 I = 1, KL
00232                AB( I, J+KV ) = ZERO
00233    30       CONTINUE
00234          END IF
00235 *
00236 *        Find pivot and test for singularity. KM is the number of
00237 *        subdiagonal elements in the current column.
00238 *
00239          KM = MIN( KL, M-J )
00240          JP = ISAMAX( KM+1, AB( KV+1, J ), 1 )
00241          IPIV( J ) = JP + J - 1
00242          IF( AB( KV+JP, J ).NE.ZERO ) THEN
00243             JU = MAX( JU, MIN( J+KU+JP-1, N ) )
00244 *
00245 *           Apply interchange to columns J to JU.
00246 *
00247             IF( JP.NE.1 )
00248      $         CALL SSWAP( JU-J+1, AB( KV+JP, J ), LDAB-1,
00249      $                     AB( KV+1, J ), LDAB-1 )
00250 *
00251             IF( KM.GT.0 ) THEN
00252 *
00253 *              Compute multipliers.
00254 *
00255                CALL SSCAL( KM, ONE / AB( KV+1, J ), AB( KV+2, J ), 1 )
00256 *
00257 *              Update trailing submatrix within the band.
00258 *
00259                IF( JU.GT.J )
00260      $            CALL SGER( KM, JU-J, -ONE, AB( KV+2, J ), 1,
00261      $                       AB( KV, J+1 ), LDAB-1, AB( KV+1, J+1 ),
00262      $                       LDAB-1 )
00263             END IF
00264          ELSE
00265 *
00266 *           If pivot is zero, set INFO to the index of the pivot
00267 *           unless a zero pivot has already been found.
00268 *
00269             IF( INFO.EQ.0 )
00270      $         INFO = J
00271          END IF
00272    40 CONTINUE
00273       RETURN
00274 *
00275 *     End of SGBTF2
00276 *
00277       END
 All Files Functions