00001 SUBROUTINE ZGETF2( M, N, A, LDA, IPIV, INFO ) 00002 * 00003 * -- LAPACK routine (version 3.0) -- 00004 * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., 00005 * Courant Institute, Argonne National Lab, and Rice University 00006 * September 30, 1994 00007 * 00008 * .. Scalar Arguments .. 00009 INTEGER INFO, LDA, M, N 00010 * .. 00011 * .. Array Arguments .. 00012 INTEGER IPIV( * ) 00013 COMPLEX*16 A( LDA, * ) 00014 * .. 00015 * 00016 * Purpose 00017 * ======= 00018 * 00019 * ZGETF2 computes an LU factorization of a general m-by-n matrix A 00020 * using partial pivoting with row interchanges. 00021 * 00022 * The factorization has the form 00023 * A = P * L * U 00024 * where P is a permutation matrix, L is lower triangular with unit 00025 * diagonal elements (lower trapezoidal if m > n), and U is upper 00026 * triangular (upper trapezoidal if m < n). 00027 * 00028 * This is the right-looking Level 2 BLAS version of the algorithm. 00029 * 00030 * Arguments 00031 * ========= 00032 * 00033 * M (input) INTEGER 00034 * The number of rows of the matrix A. M >= 0. 00035 * 00036 * N (input) INTEGER 00037 * The number of columns of the matrix A. N >= 0. 00038 * 00039 * A (input/output) COMPLEX*16 array, dimension (LDA,N) 00040 * On entry, the m by n matrix to be factored. 00041 * On exit, the factors L and U from the factorization 00042 * A = P*L*U; the unit diagonal elements of L are not stored. 00043 * 00044 * LDA (input) INTEGER 00045 * The leading dimension of the array A. LDA >= max(1,M). 00046 * 00047 * IPIV (output) INTEGER array, dimension (min(M,N)) 00048 * The pivot indices; for 1 <= i <= min(M,N), row i of the 00049 * matrix was interchanged with row IPIV(i). 00050 * 00051 * INFO (output) INTEGER 00052 * = 0: successful exit 00053 * < 0: if INFO = -k, the k-th argument had an illegal value 00054 * > 0: if INFO = k, U(k,k) is exactly zero. The factorization 00055 * has been completed, but the factor U is exactly 00056 * singular, and division by zero will occur if it is used 00057 * to solve a system of equations. 00058 * 00059 * ===================================================================== 00060 * 00061 * .. Parameters .. 00062 COMPLEX*16 ONE, ZERO 00063 PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ), 00064 $ ZERO = ( 0.0D+0, 0.0D+0 ) ) 00065 * .. 00066 * .. Local Scalars .. 00067 INTEGER J, JP 00068 * .. 00069 * .. External Functions .. 00070 INTEGER IZAMAX 00071 EXTERNAL IZAMAX 00072 * .. 00073 * .. External Subroutines .. 00074 EXTERNAL XERBLA, ZGERU, ZSCAL, ZSWAP 00075 * .. 00076 * .. Intrinsic Functions .. 00077 INTRINSIC MAX, MIN 00078 * .. 00079 * .. Executable Statements .. 00080 * 00081 * Test the input parameters. 00082 * 00083 INFO = 0 00084 IF( M.LT.0 ) THEN 00085 INFO = -1 00086 ELSE IF( N.LT.0 ) THEN 00087 INFO = -2 00088 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN 00089 INFO = -4 00090 END IF 00091 IF( INFO.NE.0 ) THEN 00092 CALL XERBLA( 'ZGETF2', -INFO ) 00093 RETURN 00094 END IF 00095 * 00096 * Quick return if possible 00097 * 00098 IF( M.EQ.0 .OR. N.EQ.0 ) 00099 $ RETURN 00100 * 00101 DO 10 J = 1, MIN( M, N ) 00102 * 00103 * Find pivot and test for singularity. 00104 * 00105 JP = J - 1 + IZAMAX( M-J+1, A( J, J ), 1 ) 00106 IPIV( J ) = JP 00107 IF( A( JP, J ).NE.ZERO ) THEN 00108 * 00109 * Apply the interchange to columns 1:N. 00110 * 00111 IF( JP.NE.J ) 00112 $ CALL ZSWAP( N, A( J, 1 ), LDA, A( JP, 1 ), LDA ) 00113 * 00114 * Compute elements J+1:M of J-th column. 00115 * 00116 IF( J.LT.M ) 00117 $ CALL ZSCAL( M-J, ONE / A( J, J ), A( J+1, J ), 1 ) 00118 * 00119 ELSE IF( INFO.EQ.0 ) THEN 00120 * 00121 INFO = J 00122 END IF 00123 * 00124 IF( J.LT.MIN( M, N ) ) THEN 00125 * 00126 * Update trailing submatrix. 00127 * 00128 CALL ZGERU( M-J, N-J, -ONE, A( J+1, J ), 1, A( J, J+1 ), 00129 $ LDA, A( J+1, J+1 ), LDA ) 00130 END IF 00131 10 CONTINUE 00132 RETURN 00133 * 00134 * End of ZGETF2 00135 * 00136 END