LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
cgetf2.f
Go to the documentation of this file.
00001 *> \brief \b CGETF2
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download CGETF2 + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgetf2.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgetf2.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgetf2.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE CGETF2( M, N, A, LDA, IPIV, INFO )
00022 * 
00023 *       .. Scalar Arguments ..
00024 *       INTEGER            INFO, LDA, M, N
00025 *       ..
00026 *       .. Array Arguments ..
00027 *       INTEGER            IPIV( * )
00028 *       COMPLEX            A( LDA, * )
00029 *       ..
00030 *  
00031 *
00032 *> \par Purpose:
00033 *  =============
00034 *>
00035 *> \verbatim
00036 *>
00037 *> CGETF2 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 COMPLEX 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 complexGEcomputational
00107 *
00108 *  =====================================================================
00109       SUBROUTINE CGETF2( 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       COMPLEX            A( LDA, * )
00122 *     ..
00123 *
00124 *  =====================================================================
00125 *
00126 *     .. Parameters ..
00127       COMPLEX            ONE, ZERO
00128       PARAMETER          ( ONE = ( 1.0E+0, 0.0E+0 ),
00129      $                   ZERO = ( 0.0E+0, 0.0E+0 ) )
00130 *     ..
00131 *     .. Local Scalars ..
00132       REAL               SFMIN
00133       INTEGER            I, J, JP
00134 *     ..
00135 *     .. External Functions ..
00136       REAL               SLAMCH
00137       INTEGER            ICAMAX
00138       EXTERNAL           SLAMCH, ICAMAX
00139 *     ..
00140 *     .. External Subroutines ..
00141       EXTERNAL           CGERU, CSCAL, CSWAP, XERBLA
00142 *     ..
00143 *     .. Intrinsic Functions ..
00144       INTRINSIC          MAX, MIN
00145 *     ..
00146 *     .. Executable Statements ..
00147 *
00148 *     Test the input parameters.
00149 *
00150       INFO = 0
00151       IF( M.LT.0 ) THEN
00152          INFO = -1
00153       ELSE IF( N.LT.0 ) THEN
00154          INFO = -2
00155       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
00156          INFO = -4
00157       END IF
00158       IF( INFO.NE.0 ) THEN
00159          CALL XERBLA( 'CGETF2', -INFO )
00160          RETURN
00161       END IF
00162 *
00163 *     Quick return if possible
00164 *
00165       IF( M.EQ.0 .OR. N.EQ.0 )
00166      $   RETURN
00167 *
00168 *     Compute machine safe minimum
00169 *
00170       SFMIN = SLAMCH('S') 
00171 *
00172       DO 10 J = 1, MIN( M, N )
00173 *
00174 *        Find pivot and test for singularity.
00175 *
00176          JP = J - 1 + ICAMAX( M-J+1, A( J, J ), 1 )
00177          IPIV( J ) = JP
00178          IF( A( JP, J ).NE.ZERO ) THEN
00179 *
00180 *           Apply the interchange to columns 1:N.
00181 *
00182             IF( JP.NE.J )
00183      $         CALL CSWAP( N, A( J, 1 ), LDA, A( JP, 1 ), LDA )
00184 *
00185 *           Compute elements J+1:M of J-th column.
00186 *
00187             IF( J.LT.M ) THEN
00188                IF( ABS(A( J, J )) .GE. SFMIN ) THEN
00189                   CALL CSCAL( M-J, ONE / A( J, J ), A( J+1, J ), 1 )
00190                ELSE
00191                   DO 20 I = 1, M-J
00192                      A( J+I, J ) = A( J+I, J ) / A( J, J )
00193    20             CONTINUE
00194                END IF
00195             END IF
00196 *
00197          ELSE IF( INFO.EQ.0 ) THEN
00198 *
00199             INFO = J
00200          END IF
00201 *
00202          IF( J.LT.MIN( M, N ) ) THEN
00203 *
00204 *           Update trailing submatrix.
00205 *
00206             CALL CGERU( M-J, N-J, -ONE, A( J+1, J ), 1, A( J, J+1 ),
00207      $                  LDA, A( J+1, J+1 ), LDA )
00208          END IF
00209    10 CONTINUE
00210       RETURN
00211 *
00212 *     End of CGETF2
00213 *
00214       END
 All Files Functions