00001 /* DGETF2.F -- translated by f2c (version 19941215). 00002 You must link the resulting object file with the libraries: 00003 -lf2c -lm (in that order) 00004 */ 00005 00006 #include "f2c.h" 00007 00008 /* Table of constant values */ 00009 00010 static integer c__1 = 1; 00011 static doublereal c_b6 = -1.; 00012 00013 /* Subroutine */ int dgetf2_(m, n, a, lda, ipiv, info) 00014 integer *m, *n; 00015 doublereal *a; 00016 integer *lda, *ipiv, *info; 00017 { 00018 /* System generated locals */ 00019 integer a_dim1, a_offset, i__1, i__2, i__3; 00020 doublereal d__1; 00021 00022 /* Local variables */ 00023 extern /* Subroutine */ int dger_(); 00024 static integer j; 00025 extern /* Subroutine */ int dscal_(), dswap_(); 00026 static integer jp; 00027 extern integer idamax_(); 00028 extern /* Subroutine */ int xerbla_(); 00029 00030 00031 /* -- LAPACK routine (version 1.1) -- */ 00032 /* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */ 00033 /* Courant Institute, Argonne National Lab, and Rice University */ 00034 /* June 30, 1992 */ 00035 00036 /* .. Scalar Arguments .. */ 00037 /* .. */ 00038 /* .. Array Arguments .. */ 00039 /* .. */ 00040 00041 /* Purpose */ 00042 /* ======= */ 00043 00044 /* DGETF2 computes an LU factorization of a general m-by-n matrix A */ 00045 /* using partial pivoting with row interchanges. */ 00046 00047 /* The factorization has the form */ 00048 /* A = P * L * U */ 00049 /* where P is a permutation matrix, L is lower triangular with unit */ 00050 /* diagonal elements (lower trapezoidal if m > n), and U is upper */ 00051 /* triangular (upper trapezoidal if m < n). */ 00052 00053 /* This is the right-looking Level 2 BLAS version of the algorithm. */ 00054 00055 /* Arguments */ 00056 /* ========= */ 00057 00058 /* M (input) INTEGER */ 00059 /* The number of rows of the matrix A. M >= 0. */ 00060 00061 /* N (input) INTEGER */ 00062 /* The number of columns of the matrix A. N >= 0. */ 00063 00064 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ 00065 /* On entry, the m by n matrix to be factored. */ 00066 /* On exit, the factors L and U from the factorization */ 00067 /* A = P*L*U; the unit diagonal elements of L are not stored. */ 00068 00069 /* LDA (input) INTEGER */ 00070 /* The leading dimension of the array A. LDA >= max(1,M). */ 00071 00072 /* IPIV (output) INTEGER array, dimension (min(M,N)) */ 00073 /* The pivot indices; for 1 <= i <= min(M,N), row i of the */ 00074 /* matrix was interchanged with row IPIV(i). */ 00075 00076 /* INFO (output) INTEGER */ 00077 /* = 0: successful exit */ 00078 /* < 0: if INFO = -k, the k-th argument had an illegal value */ 00079 /* > 0: if INFO = k, U(k,k) is exactly zero. The factorization */ 00080 /* has been completed, but the factor U is exactly */ 00081 /* singular, and division by zero will occur if it is used 00082 */ 00083 /* to solve a system of equations. */ 00084 00085 /* ===================================================================== 00086 */ 00087 00088 /* .. Parameters .. */ 00089 /* .. */ 00090 /* .. Local Scalars .. */ 00091 /* .. */ 00092 /* .. External Functions .. */ 00093 /* .. */ 00094 /* .. External Subroutines .. */ 00095 /* .. */ 00096 /* .. Intrinsic Functions .. */ 00097 /* .. */ 00098 /* .. Executable Statements .. */ 00099 00100 /* Test the input parameters. */ 00101 00102 /* Parameter adjustments */ 00103 a_dim1 = *lda; 00104 a_offset = a_dim1 + 1; 00105 a -= a_offset; 00106 --ipiv; 00107 00108 /* Function Body */ 00109 *info = 0; 00110 if (*m < 0) { 00111 *info = -1; 00112 } else if (*n < 0) { 00113 *info = -2; 00114 } else if (*lda < max(1,*m)) { 00115 *info = -4; 00116 } 00117 if (*info != 0) { 00118 i__1 = -(*info); 00119 xerbla_("DGETF2", &i__1, 6L); 00120 return 0; 00121 } 00122 00123 /* Quick return if possible */ 00124 00125 if (*m == 0 || *n == 0) { 00126 return 0; 00127 } 00128 00129 i__1 = min(*m,*n); 00130 for (j = 1; j <= i__1; ++j) { 00131 00132 /* Find pivot and test for singularity. */ 00133 00134 i__2 = *m - j + 1; 00135 jp = j - 1 + idamax_(&i__2, &a[j + j * a_dim1], &c__1); 00136 ipiv[j] = jp; 00137 if (a[jp + j * a_dim1] != 0.) { 00138 00139 /* Apply the interchange to columns 1:N. */ 00140 00141 if (jp != j) { 00142 dswap_(n, &a[j + a_dim1], lda, &a[jp + a_dim1], lda); 00143 } 00144 00145 /* Compute elements J+1:M of J-th column. */ 00146 00147 if (j < *m) { 00148 i__2 = *m - j; 00149 d__1 = 1. / a[j + j * a_dim1]; 00150 dscal_(&i__2, &d__1, &a[j + 1 + j * a_dim1], &c__1); 00151 } 00152 00153 } else if (*info == 0) { 00154 00155 *info = j; 00156 } 00157 00158 if (j < min(*m,*n)) { 00159 00160 /* Update trailing submatrix. */ 00161 00162 i__2 = *m - j; 00163 i__3 = *n - j; 00164 dger_(&i__2, &i__3, &c_b6, &a[j + 1 + j * a_dim1], &c__1, &a[j + ( 00165 j + 1) * a_dim1], lda, &a[j + 1 + (j + 1) * a_dim1], lda); 00166 } 00167 /* L10: */ 00168 } 00169 return 0; 00170 00171 /* End of DGETF2 */ 00172 00173 } /* dgetf2_ */ 00174