annotate ext/clapack/src/dgetf2.c @ 211:a41bea655151 msvc

Rename FFT back again, now we have our own project
author Chris Cannam
date Mon, 05 Feb 2018 17:40:13 +0000
parents 45330e0d2819
children
rev   line source
Chris@202 1 /* dgetf2.f -- translated by f2c (version 20061008).
Chris@202 2 You must link the resulting object file with libf2c:
Chris@202 3 on Microsoft Windows system, link with libf2c.lib;
Chris@202 4 on Linux or Unix systems, link with .../path/to/libf2c.a -lm
Chris@202 5 or, if you install libf2c.a in a standard place, with -lf2c -lm
Chris@202 6 -- in that order, at the end of the command line, as in
Chris@202 7 cc *.o -lf2c -lm
Chris@202 8 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
Chris@202 9
Chris@202 10 http://www.netlib.org/f2c/libf2c.zip
Chris@202 11 */
Chris@202 12
Chris@202 13 #include "f2c.h"
Chris@202 14 #include "blaswrap.h"
Chris@202 15
Chris@202 16 /* Table of constant values */
Chris@202 17
Chris@202 18 static integer c__1 = 1;
Chris@202 19 static doublereal c_b8 = -1.;
Chris@202 20
Chris@202 21 /* Subroutine */ int dgetf2_(integer *m, integer *n, doublereal *a, integer *
Chris@202 22 lda, integer *ipiv, integer *info)
Chris@202 23 {
Chris@202 24 /* System generated locals */
Chris@202 25 integer a_dim1, a_offset, i__1, i__2, i__3;
Chris@202 26 doublereal d__1;
Chris@202 27
Chris@202 28 /* Local variables */
Chris@202 29 integer i__, j, jp;
Chris@202 30 extern /* Subroutine */ int dger_(integer *, integer *, doublereal *,
Chris@202 31 doublereal *, integer *, doublereal *, integer *, doublereal *,
Chris@202 32 integer *), dscal_(integer *, doublereal *, doublereal *, integer
Chris@202 33 *);
Chris@202 34 doublereal sfmin;
Chris@202 35 extern /* Subroutine */ int dswap_(integer *, doublereal *, integer *,
Chris@202 36 doublereal *, integer *);
Chris@202 37 extern doublereal dlamch_(char *);
Chris@202 38 extern integer idamax_(integer *, doublereal *, integer *);
Chris@202 39 extern /* Subroutine */ int xerbla_(char *, integer *);
Chris@202 40
Chris@202 41
Chris@202 42 /* -- LAPACK routine (version 3.2) -- */
Chris@202 43 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
Chris@202 44 /* November 2006 */
Chris@202 45
Chris@202 46 /* .. Scalar Arguments .. */
Chris@202 47 /* .. */
Chris@202 48 /* .. Array Arguments .. */
Chris@202 49 /* .. */
Chris@202 50
Chris@202 51 /* Purpose */
Chris@202 52 /* ======= */
Chris@202 53
Chris@202 54 /* DGETF2 computes an LU factorization of a general m-by-n matrix A */
Chris@202 55 /* using partial pivoting with row interchanges. */
Chris@202 56
Chris@202 57 /* The factorization has the form */
Chris@202 58 /* A = P * L * U */
Chris@202 59 /* where P is a permutation matrix, L is lower triangular with unit */
Chris@202 60 /* diagonal elements (lower trapezoidal if m > n), and U is upper */
Chris@202 61 /* triangular (upper trapezoidal if m < n). */
Chris@202 62
Chris@202 63 /* This is the right-looking Level 2 BLAS version of the algorithm. */
Chris@202 64
Chris@202 65 /* Arguments */
Chris@202 66 /* ========= */
Chris@202 67
Chris@202 68 /* M (input) INTEGER */
Chris@202 69 /* The number of rows of the matrix A. M >= 0. */
Chris@202 70
Chris@202 71 /* N (input) INTEGER */
Chris@202 72 /* The number of columns of the matrix A. N >= 0. */
Chris@202 73
Chris@202 74 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
Chris@202 75 /* On entry, the m by n matrix to be factored. */
Chris@202 76 /* On exit, the factors L and U from the factorization */
Chris@202 77 /* A = P*L*U; the unit diagonal elements of L are not stored. */
Chris@202 78
Chris@202 79 /* LDA (input) INTEGER */
Chris@202 80 /* The leading dimension of the array A. LDA >= max(1,M). */
Chris@202 81
Chris@202 82 /* IPIV (output) INTEGER array, dimension (min(M,N)) */
Chris@202 83 /* The pivot indices; for 1 <= i <= min(M,N), row i of the */
Chris@202 84 /* matrix was interchanged with row IPIV(i). */
Chris@202 85
Chris@202 86 /* INFO (output) INTEGER */
Chris@202 87 /* = 0: successful exit */
Chris@202 88 /* < 0: if INFO = -k, the k-th argument had an illegal value */
Chris@202 89 /* > 0: if INFO = k, U(k,k) is exactly zero. The factorization */
Chris@202 90 /* has been completed, but the factor U is exactly */
Chris@202 91 /* singular, and division by zero will occur if it is used */
Chris@202 92 /* to solve a system of equations. */
Chris@202 93
Chris@202 94 /* ===================================================================== */
Chris@202 95
Chris@202 96 /* .. Parameters .. */
Chris@202 97 /* .. */
Chris@202 98 /* .. Local Scalars .. */
Chris@202 99 /* .. */
Chris@202 100 /* .. External Functions .. */
Chris@202 101 /* .. */
Chris@202 102 /* .. External Subroutines .. */
Chris@202 103 /* .. */
Chris@202 104 /* .. Intrinsic Functions .. */
Chris@202 105 /* .. */
Chris@202 106 /* .. Executable Statements .. */
Chris@202 107
Chris@202 108 /* Test the input parameters. */
Chris@202 109
Chris@202 110 /* Parameter adjustments */
Chris@202 111 a_dim1 = *lda;
Chris@202 112 a_offset = 1 + a_dim1;
Chris@202 113 a -= a_offset;
Chris@202 114 --ipiv;
Chris@202 115
Chris@202 116 /* Function Body */
Chris@202 117 *info = 0;
Chris@202 118 if (*m < 0) {
Chris@202 119 *info = -1;
Chris@202 120 } else if (*n < 0) {
Chris@202 121 *info = -2;
Chris@202 122 } else if (*lda < max(1,*m)) {
Chris@202 123 *info = -4;
Chris@202 124 }
Chris@202 125 if (*info != 0) {
Chris@202 126 i__1 = -(*info);
Chris@202 127 xerbla_("DGETF2", &i__1);
Chris@202 128 return 0;
Chris@202 129 }
Chris@202 130
Chris@202 131 /* Quick return if possible */
Chris@202 132
Chris@202 133 if (*m == 0 || *n == 0) {
Chris@202 134 return 0;
Chris@202 135 }
Chris@202 136
Chris@202 137 /* Compute machine safe minimum */
Chris@202 138
Chris@202 139 sfmin = dlamch_("S");
Chris@202 140
Chris@202 141 i__1 = min(*m,*n);
Chris@202 142 for (j = 1; j <= i__1; ++j) {
Chris@202 143
Chris@202 144 /* Find pivot and test for singularity. */
Chris@202 145
Chris@202 146 i__2 = *m - j + 1;
Chris@202 147 jp = j - 1 + idamax_(&i__2, &a[j + j * a_dim1], &c__1);
Chris@202 148 ipiv[j] = jp;
Chris@202 149 if (a[jp + j * a_dim1] != 0.) {
Chris@202 150
Chris@202 151 /* Apply the interchange to columns 1:N. */
Chris@202 152
Chris@202 153 if (jp != j) {
Chris@202 154 dswap_(n, &a[j + a_dim1], lda, &a[jp + a_dim1], lda);
Chris@202 155 }
Chris@202 156
Chris@202 157 /* Compute elements J+1:M of J-th column. */
Chris@202 158
Chris@202 159 if (j < *m) {
Chris@202 160 if ((d__1 = a[j + j * a_dim1], abs(d__1)) >= sfmin) {
Chris@202 161 i__2 = *m - j;
Chris@202 162 d__1 = 1. / a[j + j * a_dim1];
Chris@202 163 dscal_(&i__2, &d__1, &a[j + 1 + j * a_dim1], &c__1);
Chris@202 164 } else {
Chris@202 165 i__2 = *m - j;
Chris@202 166 for (i__ = 1; i__ <= i__2; ++i__) {
Chris@202 167 a[j + i__ + j * a_dim1] /= a[j + j * a_dim1];
Chris@202 168 /* L20: */
Chris@202 169 }
Chris@202 170 }
Chris@202 171 }
Chris@202 172
Chris@202 173 } else if (*info == 0) {
Chris@202 174
Chris@202 175 *info = j;
Chris@202 176 }
Chris@202 177
Chris@202 178 if (j < min(*m,*n)) {
Chris@202 179
Chris@202 180 /* Update trailing submatrix. */
Chris@202 181
Chris@202 182 i__2 = *m - j;
Chris@202 183 i__3 = *n - j;
Chris@202 184 dger_(&i__2, &i__3, &c_b8, &a[j + 1 + j * a_dim1], &c__1, &a[j + (
Chris@202 185 j + 1) * a_dim1], lda, &a[j + 1 + (j + 1) * a_dim1], lda);
Chris@202 186 }
Chris@202 187 /* L10: */
Chris@202 188 }
Chris@202 189 return 0;
Chris@202 190
Chris@202 191 /* End of DGETF2 */
Chris@202 192
Chris@202 193 } /* dgetf2_ */