comparison ext/clapack/src/dgetf2.c @ 202:45330e0d2819 clapack-included

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