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


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