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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:08