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_b16 = 1.f;
00021 static real c_b19 = -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;
00028 
00029     /* Local variables */
00030     integer i__, j, 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.2) -- */
00045 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00046 /*     November 2006 */
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 right-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 /*           Factor diagonal and subdiagonal blocks and test for exact */
00159 /*           singularity. */
00160 
00161             i__3 = *m - j + 1;
00162             sgetf2_(&i__3, &jb, &a[j + j * a_dim1], lda, &ipiv[j], &iinfo);
00163 
00164 /*           Adjust INFO and the pivot indices. */
00165 
00166             if (*info == 0 && iinfo > 0) {
00167                 *info = iinfo + j - 1;
00168             }
00169 /* Computing MIN */
00170             i__4 = *m, i__5 = j + jb - 1;
00171             i__3 = min(i__4,i__5);
00172             for (i__ = j; i__ <= i__3; ++i__) {
00173                 ipiv[i__] = j - 1 + ipiv[i__];
00174 /* L10: */
00175             }
00176 
00177 /*           Apply interchanges to columns 1:J-1. */
00178 
00179             i__3 = j - 1;
00180             i__4 = j + jb - 1;
00181             slaswp_(&i__3, &a[a_offset], lda, &j, &i__4, &ipiv[1], &c__1);
00182 
00183             if (j + jb <= *n) {
00184 
00185 /*              Apply interchanges to columns J+JB:N. */
00186 
00187                 i__3 = *n - j - jb + 1;
00188                 i__4 = j + jb - 1;
00189                 slaswp_(&i__3, &a[(j + jb) * a_dim1 + 1], lda, &j, &i__4, &
00190                         ipiv[1], &c__1);
00191 
00192 /*              Compute block row of U. */
00193 
00194                 i__3 = *n - j - jb + 1;
00195                 strsm_("Left", "Lower", "No transpose", "Unit", &jb, &i__3, &
00196                         c_b16, &a[j + j * a_dim1], lda, &a[j + (j + jb) * 
00197                         a_dim1], lda);
00198                 if (j + jb <= *m) {
00199 
00200 /*                 Update trailing submatrix. */
00201 
00202                     i__3 = *m - j - jb + 1;
00203                     i__4 = *n - j - jb + 1;
00204                     sgemm_("No transpose", "No transpose", &i__3, &i__4, &jb, 
00205                             &c_b19, &a[j + jb + j * a_dim1], lda, &a[j + (j + 
00206                             jb) * a_dim1], lda, &c_b16, &a[j + jb + (j + jb) *
00207                              a_dim1], lda);
00208                 }
00209             }
00210 /* L20: */
00211         }
00212     }
00213     return 0;
00214 
00215 /*     End of SGETRF */
00216 
00217 } /* sgetrf_ */


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