dgetrf.c
Go to the documentation of this file.
00001 /* dgetrf.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 integer c_n1 = -1;
00020 static doublereal c_b15 = 1.;
00021 static doublereal c_b18 = -1.;
00022 
00023 /* Subroutine */ int dgetrf_(integer *m, integer *n, doublereal *a, integer *
00024         lda, integer *ipiv, integer *info)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
00028 
00029     /* Local variables */
00030     integer i__, j, k, jb, nb;
00031     extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *, 
00032             integer *, doublereal *, doublereal *, integer *, doublereal *, 
00033             integer *, doublereal *, doublereal *, integer *);
00034     integer iinfo;
00035     extern /* Subroutine */ int dtrsm_(char *, char *, char *, char *, 
00036             integer *, integer *, doublereal *, doublereal *, integer *, 
00037             doublereal *, integer *), dgetf2_(
00038             integer *, integer *, doublereal *, integer *, integer *, integer 
00039             *), xerbla_(char *, integer *);
00040     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00041             integer *, integer *);
00042     extern /* Subroutine */ int dlaswp_(integer *, doublereal *, integer *, 
00043             integer *, integer *, integer *, integer *);
00044 
00045 
00046 /*  -- LAPACK routine (version 3.1) -- */
00047 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00048 /*     March 2008 */
00049 
00050 /*     .. Scalar Arguments .. */
00051 /*     .. */
00052 /*     .. Array Arguments .. */
00053 /*     .. */
00054 
00055 /*  Purpose */
00056 /*  ======= */
00057 
00058 /*  DGETRF computes an LU factorization of a general M-by-N matrix A */
00059 /*  using partial pivoting with row interchanges. */
00060 
00061 /*  The factorization has the form */
00062 /*     A = P * L * U */
00063 /*  where P is a permutation matrix, L is lower triangular with unit */
00064 /*  diagonal elements (lower trapezoidal if m > n), and U is upper */
00065 /*  triangular (upper trapezoidal if m < n). */
00066 
00067 /*  This is the left-looking Level 3 BLAS version of the algorithm. */
00068 
00069 /*  Arguments */
00070 /*  ========= */
00071 
00072 /*  M       (input) INTEGER */
00073 /*          The number of rows of the matrix A.  M >= 0. */
00074 
00075 /*  N       (input) INTEGER */
00076 /*          The number of columns of the matrix A.  N >= 0. */
00077 
00078 /*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
00079 /*          On entry, the M-by-N matrix to be factored. */
00080 /*          On exit, the factors L and U from the factorization */
00081 /*          A = P*L*U; the unit diagonal elements of L are not stored. */
00082 
00083 /*  LDA     (input) INTEGER */
00084 /*          The leading dimension of the array A.  LDA >= max(1,M). */
00085 
00086 /*  IPIV    (output) INTEGER array, dimension (min(M,N)) */
00087 /*          The pivot indices; for 1 <= i <= min(M,N), row i of the */
00088 /*          matrix was interchanged with row IPIV(i). */
00089 
00090 /*  INFO    (output) INTEGER */
00091 /*          = 0:  successful exit */
00092 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00093 /*          > 0:  if INFO = i, U(i,i) is exactly zero. The factorization */
00094 /*                has been completed, but the factor U is exactly */
00095 /*                singular, and division by zero will occur if it is used */
00096 /*                to solve a system of equations. */
00097 
00098 /*  ===================================================================== */
00099 
00100 /*     .. Parameters .. */
00101 /*     .. */
00102 /*     .. Local Scalars .. */
00103 /*     .. */
00104 /*     .. External Subroutines .. */
00105 /*     .. */
00106 /*     .. External Functions .. */
00107 /*     .. */
00108 /*     .. Intrinsic Functions .. */
00109 /*     .. */
00110 /*     .. Executable Statements .. */
00111 
00112 /*     Test the input parameters. */
00113 
00114     /* Parameter adjustments */
00115     a_dim1 = *lda;
00116     a_offset = 1 + a_dim1;
00117     a -= a_offset;
00118     --ipiv;
00119 
00120     /* Function Body */
00121     *info = 0;
00122     if (*m < 0) {
00123         *info = -1;
00124     } else if (*n < 0) {
00125         *info = -2;
00126     } else if (*lda < max(1,*m)) {
00127         *info = -4;
00128     }
00129     if (*info != 0) {
00130         i__1 = -(*info);
00131         xerbla_("DGETRF", &i__1);
00132         return 0;
00133     }
00134 
00135 /*     Quick return if possible */
00136 
00137     if (*m == 0 || *n == 0) {
00138         return 0;
00139     }
00140 
00141 /*     Determine the block size for this environment. */
00142 
00143     nb = ilaenv_(&c__1, "DGETRF", " ", m, n, &c_n1, &c_n1);
00144     if (nb <= 1 || nb >= min(*m,*n)) {
00145 
00146 /*        Use unblocked code. */
00147 
00148         dgetf2_(m, n, &a[a_offset], lda, &ipiv[1], info);
00149     } else {
00150 
00151 /*        Use blocked code. */
00152 
00153         i__1 = min(*m,*n);
00154         i__2 = nb;
00155         for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
00156 /* Computing MIN */
00157             i__3 = min(*m,*n) - j + 1;
00158             jb = min(i__3,nb);
00159 
00160 /*           Update before factoring the current panel */
00161 
00162             i__3 = j - nb;
00163             i__4 = nb;
00164             for (k = 1; i__4 < 0 ? k >= i__3 : k <= i__3; k += i__4) {
00165 
00166 /*              Apply interchanges to rows K:K+NB-1. */
00167 
00168                 i__5 = k + nb - 1;
00169                 dlaswp_(&jb, &a[j * a_dim1 + 1], lda, &k, &i__5, &ipiv[1], &
00170                         c__1);
00171 
00172 /*              Compute block row of U. */
00173 
00174                 dtrsm_("Left", "Lower", "No transpose", "Unit", &nb, &jb, &
00175                         c_b15, &a[k + k * a_dim1], lda, &a[k + j * a_dim1], 
00176                         lda);
00177 
00178 /*              Update trailing submatrix. */
00179 
00180                 i__5 = *m - k - nb + 1;
00181                 dgemm_("No transpose", "No transpose", &i__5, &jb, &nb, &
00182                         c_b18, &a[k + nb + k * a_dim1], lda, &a[k + j * 
00183                         a_dim1], lda, &c_b15, &a[k + nb + j * a_dim1], lda);
00184 /* L30: */
00185             }
00186 
00187 /*           Factor diagonal and subdiagonal blocks and test for exact */
00188 /*           singularity. */
00189 
00190             i__4 = *m - j + 1;
00191             dgetf2_(&i__4, &jb, &a[j + j * a_dim1], lda, &ipiv[j], &iinfo);
00192 
00193 /*           Adjust INFO and the pivot indices. */
00194 
00195             if (*info == 0 && iinfo > 0) {
00196                 *info = iinfo + j - 1;
00197             }
00198 /* Computing MIN */
00199             i__3 = *m, i__5 = j + jb - 1;
00200             i__4 = min(i__3,i__5);
00201             for (i__ = j; i__ <= i__4; ++i__) {
00202                 ipiv[i__] = j - 1 + ipiv[i__];
00203 /* L10: */
00204             }
00205 
00206 /* L20: */
00207         }
00208 
00209 /*        Apply interchanges to the left-overs */
00210 
00211         i__2 = min(*m,*n);
00212         i__1 = nb;
00213         for (k = 1; i__1 < 0 ? k >= i__2 : k <= i__2; k += i__1) {
00214             i__4 = k - 1;
00215 /* Computing MIN */
00216             i__5 = k + nb - 1, i__6 = min(*m,*n);
00217             i__3 = min(i__5,i__6);
00218             dlaswp_(&i__4, &a[a_dim1 + 1], lda, &k, &i__3, &ipiv[1], &c__1);
00219 /* L40: */
00220         }
00221 
00222 /*        Apply update to the M+1:N columns when N > M */
00223 
00224         if (*n > *m) {
00225             i__1 = *n - *m;
00226             dlaswp_(&i__1, &a[(*m + 1) * a_dim1 + 1], lda, &c__1, m, &ipiv[1], 
00227                      &c__1);
00228             i__1 = *m;
00229             i__2 = nb;
00230             for (k = 1; i__2 < 0 ? k >= i__1 : k <= i__1; k += i__2) {
00231 /* Computing MIN */
00232                 i__4 = *m - k + 1;
00233                 jb = min(i__4,nb);
00234 
00235                 i__4 = *n - *m;
00236                 dtrsm_("Left", "Lower", "No transpose", "Unit", &jb, &i__4, &
00237                         c_b15, &a[k + k * a_dim1], lda, &a[k + (*m + 1) * 
00238                         a_dim1], lda);
00239 
00240                 if (k + nb <= *m) {
00241                     i__4 = *m - k - nb + 1;
00242                     i__3 = *n - *m;
00243                     dgemm_("No transpose", "No transpose", &i__4, &i__3, &nb, 
00244                             &c_b18, &a[k + nb + k * a_dim1], lda, &a[k + (*m 
00245                             + 1) * a_dim1], lda, &c_b15, &a[k + nb + (*m + 1) 
00246                             * a_dim1], lda);
00247                 }
00248 /* L50: */
00249             }
00250         }
00251 
00252     }
00253     return 0;
00254 
00255 /*     End of DGETRF */
00256 
00257 } /* dgetrf_ */


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