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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:45