00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016
00017
00018 static integer c__1 = 1;
00019 static doublereal c_b12 = 1.;
00020 static doublereal c_b15 = -1.;
00021
00022 int dgetrf_(integer *m, integer *n, doublereal *a, integer *
00023 lda, integer *ipiv, integer *info)
00024 {
00025
00026 integer a_dim1, a_offset, i__1, i__2, i__3;
00027 doublereal d__1;
00028
00029
00030 integer i__, j, ipivstart, jpivstart, jp;
00031 doublereal tmp;
00032 extern int dscal_(integer *, doublereal *, doublereal *,
00033 integer *), dgemm_(char *, char *, integer *, integer *, integer *
00034 , doublereal *, doublereal *, integer *, doublereal *, integer *,
00035 doublereal *, doublereal *, integer *);
00036 integer kcols;
00037 doublereal sfmin;
00038 integer nstep;
00039 extern int dtrsm_(char *, char *, char *, char *,
00040 integer *, integer *, doublereal *, doublereal *, integer *,
00041 doublereal *, integer *);
00042 integer kahead;
00043 extern doublereal dlamch_(char *);
00044 extern integer idamax_(integer *, doublereal *, integer *);
00045 extern logical disnan_(doublereal *);
00046 extern int xerbla_(char *, integer *);
00047 integer npived;
00048 extern int dlaswp_(integer *, doublereal *, integer *,
00049 integer *, integer *, integer *, integer *);
00050 integer kstart, ntopiv;
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 a_dim1 = *lda;
00157 a_offset = 1 + a_dim1;
00158 a -= a_offset;
00159 --ipiv;
00160
00161
00162 *info = 0;
00163 if (*m < 0) {
00164 *info = -1;
00165 } else if (*n < 0) {
00166 *info = -2;
00167 } else if (*lda < max(1,*m)) {
00168 *info = -4;
00169 }
00170 if (*info != 0) {
00171 i__1 = -(*info);
00172 xerbla_("DGETRF", &i__1);
00173 return 0;
00174 }
00175
00176
00177
00178 if (*m == 0 || *n == 0) {
00179 return 0;
00180 }
00181
00182
00183
00184 sfmin = dlamch_("S");
00185
00186 nstep = min(*m,*n);
00187 i__1 = nstep;
00188 for (j = 1; j <= i__1; ++j) {
00189 kahead = j & -j;
00190 kstart = j + 1 - kahead;
00191
00192 i__2 = kahead, i__3 = *m - j;
00193 kcols = min(i__2,i__3);
00194
00195
00196
00197 i__2 = *m - j + 1;
00198 jp = j - 1 + idamax_(&i__2, &a[j + j * a_dim1], &c__1);
00199 ipiv[j] = jp;
00200
00201 if (jp != j) {
00202 tmp = a[j + j * a_dim1];
00203 a[j + j * a_dim1] = a[jp + j * a_dim1];
00204 a[jp + j * a_dim1] = tmp;
00205 }
00206
00207 ntopiv = 1;
00208 ipivstart = j;
00209 jpivstart = j - ntopiv;
00210 while(ntopiv < kahead) {
00211 dlaswp_(&ntopiv, &a[jpivstart * a_dim1 + 1], lda, &ipivstart, &j,
00212 &ipiv[1], &c__1);
00213 ipivstart -= ntopiv;
00214 ntopiv <<= 1;
00215 jpivstart -= ntopiv;
00216 }
00217
00218 dlaswp_(&kcols, &a[(j + 1) * a_dim1 + 1], lda, &kstart, &j, &ipiv[1],
00219 &c__1);
00220
00221 if (a[j + j * a_dim1] != 0. && ! disnan_(&a[j + j * a_dim1])) {
00222 if ((d__1 = a[j + j * a_dim1], abs(d__1)) >= sfmin) {
00223 i__2 = *m - j;
00224 d__1 = 1. / a[j + j * a_dim1];
00225 dscal_(&i__2, &d__1, &a[j + 1 + j * a_dim1], &c__1);
00226 } else {
00227 i__2 = *m - j;
00228 for (i__ = 1; i__ <= i__2; ++i__) {
00229 a[j + i__ + j * a_dim1] /= a[j + j * a_dim1];
00230 }
00231 }
00232 } else if (a[j + j * a_dim1] == 0. && *info == 0) {
00233 *info = j;
00234 }
00235
00236 dtrsm_("Left", "Lower", "No transpose", "Unit", &kahead, &kcols, &
00237 c_b12, &a[kstart + kstart * a_dim1], lda, &a[kstart + (j + 1)
00238 * a_dim1], lda);
00239
00240 i__2 = *m - j;
00241 dgemm_("No transpose", "No transpose", &i__2, &kcols, &kahead, &c_b15,
00242 &a[j + 1 + kstart * a_dim1], lda, &a[kstart + (j + 1) *
00243 a_dim1], lda, &c_b12, &a[j + 1 + (j + 1) * a_dim1], lda);
00244 }
00245
00246 npived = nstep & -nstep;
00247 j = nstep - npived;
00248 while(j > 0) {
00249 ntopiv = j & -j;
00250 i__1 = j + 1;
00251 dlaswp_(&ntopiv, &a[(j - ntopiv + 1) * a_dim1 + 1], lda, &i__1, &
00252 nstep, &ipiv[1], &c__1);
00253 j -= ntopiv;
00254 }
00255
00256 if (*m < *n) {
00257 i__1 = *n - *m;
00258 dlaswp_(&i__1, &a[(*m + kcols + 1) * a_dim1 + 1], lda, &c__1, m, &
00259 ipiv[1], &c__1);
00260 i__1 = *n - *m;
00261 dtrsm_("Left", "Lower", "No transpose", "Unit", m, &i__1, &c_b12, &a[
00262 a_offset], lda, &a[(*m + kcols + 1) * a_dim1 + 1], lda);
00263 }
00264 return 0;
00265
00266
00267
00268 }