LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
sgetf2.f
Go to the documentation of this file.
00001 *> \brief \b SGETF2
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download SGETF2 + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgetf2.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgetf2.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgetf2.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE SGETF2( M, N, A, LDA, IPIV, INFO )
00022 * 
00023 *       .. Scalar Arguments ..
00024 *       INTEGER            INFO, LDA, M, N
00025 *       ..
00026 *       .. Array Arguments ..
00027 *       INTEGER            IPIV( * )
00028 *       REAL               A( LDA, * )
00029 *       ..
00030 *  
00031 *
00032 *> \par Purpose:
00033 *  =============
00034 *>
00035 *> \verbatim
00036 *>
00037 *> SGETF2 computes an LU factorization of a general m-by-n matrix A
00038 *> using partial pivoting with row interchanges.
00039 *>
00040 *> The factorization has the form
00041 *>    A = P * L * U
00042 *> where P is a permutation matrix, L is lower triangular with unit
00043 *> diagonal elements (lower trapezoidal if m > n), and U is upper
00044 *> triangular (upper trapezoidal if m < n).
00045 *>
00046 *> This is the right-looking Level 2 BLAS version of the algorithm.
00047 *> \endverbatim
00048 *
00049 *  Arguments:
00050 *  ==========
00051 *
00052 *> \param[in] M
00053 *> \verbatim
00054 *>          M is INTEGER
00055 *>          The number of rows of the matrix A.  M >= 0.
00056 *> \endverbatim
00057 *>
00058 *> \param[in] N
00059 *> \verbatim
00060 *>          N is INTEGER
00061 *>          The number of columns of the matrix A.  N >= 0.
00062 *> \endverbatim
00063 *>
00064 *> \param[in,out] A
00065 *> \verbatim
00066 *>          A is REAL array, dimension (LDA,N)
00067 *>          On entry, the m by n matrix to be factored.
00068 *>          On exit, the factors L and U from the factorization
00069 *>          A = P*L*U; the unit diagonal elements of L are not stored.
00070 *> \endverbatim
00071 *>
00072 *> \param[in] LDA
00073 *> \verbatim
00074 *>          LDA is INTEGER
00075 *>          The leading dimension of the array A.  LDA >= max(1,M).
00076 *> \endverbatim
00077 *>
00078 *> \param[out] IPIV
00079 *> \verbatim
00080 *>          IPIV is INTEGER array, dimension (min(M,N))
00081 *>          The pivot indices; for 1 <= i <= min(M,N), row i of the
00082 *>          matrix was interchanged with row IPIV(i).
00083 *> \endverbatim
00084 *>
00085 *> \param[out] INFO
00086 *> \verbatim
00087 *>          INFO is INTEGER
00088 *>          = 0: successful exit
00089 *>          < 0: if INFO = -k, the k-th argument had an illegal value
00090 *>          > 0: if INFO = k, U(k,k) is exactly zero. The factorization
00091 *>               has been completed, but the factor U is exactly
00092 *>               singular, and division by zero will occur if it is used
00093 *>               to solve a system of equations.
00094 *> \endverbatim
00095 *
00096 *  Authors:
00097 *  ========
00098 *
00099 *> \author Univ. of Tennessee 
00100 *> \author Univ. of California Berkeley 
00101 *> \author Univ. of Colorado Denver 
00102 *> \author NAG Ltd. 
00103 *
00104 *> \date November 2011
00105 *
00106 *> \ingroup realGEcomputational
00107 *
00108 *  =====================================================================
00109       SUBROUTINE SGETF2( M, N, A, LDA, IPIV, INFO )
00110 *
00111 *  -- LAPACK computational routine (version 3.4.0) --
00112 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00113 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00114 *     November 2011
00115 *
00116 *     .. Scalar Arguments ..
00117       INTEGER            INFO, LDA, M, N
00118 *     ..
00119 *     .. Array Arguments ..
00120       INTEGER            IPIV( * )
00121       REAL               A( LDA, * )
00122 *     ..
00123 *
00124 *  =====================================================================
00125 *
00126 *     .. Parameters ..
00127       REAL               ONE, ZERO
00128       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
00129 *     ..
00130 *     .. Local Scalars ..
00131       REAL               SFMIN
00132       INTEGER            I, J, JP
00133 *     ..
00134 *     .. External Functions ..
00135       REAL               SLAMCH
00136       INTEGER            ISAMAX
00137       EXTERNAL           SLAMCH, ISAMAX
00138 *     ..
00139 *     .. External Subroutines ..
00140       EXTERNAL           SGER, SSCAL, SSWAP, XERBLA
00141 *     ..
00142 *     .. Intrinsic Functions ..
00143       INTRINSIC          MAX, MIN
00144 *     ..
00145 *     .. Executable Statements ..
00146 *
00147 *     Test the input parameters.
00148 *
00149       INFO = 0
00150       IF( M.LT.0 ) THEN
00151          INFO = -1
00152       ELSE IF( N.LT.0 ) THEN
00153          INFO = -2
00154       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
00155          INFO = -4
00156       END IF
00157       IF( INFO.NE.0 ) THEN
00158          CALL XERBLA( 'SGETF2', -INFO )
00159          RETURN
00160       END IF
00161 *
00162 *     Quick return if possible
00163 *
00164       IF( M.EQ.0 .OR. N.EQ.0 )
00165      $   RETURN
00166 *
00167 *     Compute machine safe minimum 
00168 * 
00169       SFMIN = SLAMCH('S')
00170 *
00171       DO 10 J = 1, MIN( M, N )
00172 *
00173 *        Find pivot and test for singularity.
00174 *
00175          JP = J - 1 + ISAMAX( M-J+1, A( J, J ), 1 )
00176          IPIV( J ) = JP
00177          IF( A( JP, J ).NE.ZERO ) THEN
00178 *
00179 *           Apply the interchange to columns 1:N.
00180 *
00181             IF( JP.NE.J )
00182      $         CALL SSWAP( N, A( J, 1 ), LDA, A( JP, 1 ), LDA )
00183 *
00184 *           Compute elements J+1:M of J-th column.
00185 *
00186             IF( J.LT.M ) THEN 
00187                IF( ABS(A( J, J )) .GE. SFMIN ) THEN 
00188                   CALL SSCAL( M-J, ONE / A( J, J ), A( J+1, J ), 1 ) 
00189                ELSE 
00190                  DO 20 I = 1, M-J 
00191                     A( J+I, J ) = A( J+I, J ) / A( J, J ) 
00192    20            CONTINUE 
00193                END IF 
00194             END IF 
00195 *
00196          ELSE IF( INFO.EQ.0 ) THEN
00197 *
00198             INFO = J
00199          END IF
00200 *
00201          IF( J.LT.MIN( M, N ) ) THEN
00202 *
00203 *           Update trailing submatrix.
00204 *
00205             CALL SGER( M-J, N-J, -ONE, A( J+1, J ), 1, A( J, J+1 ), LDA,
00206      $                 A( J+1, J+1 ), LDA )
00207          END IF
00208    10 CONTINUE
00209       RETURN
00210 *
00211 *     End of SGETF2
00212 *
00213       END
 All Files Functions