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 complex c_b1 = {1.f,0.f};
00019 static integer c__1 = 1;
00020 static integer c_n1 = -1;
00021
00022 int cgetrf_(integer *m, integer *n, complex *a, integer *lda,
00023 integer *ipiv, integer *info)
00024 {
00025
00026 integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
00027 complex q__1;
00028
00029
00030 integer i__, j, k, jb, nb;
00031 extern int cgemm_(char *, char *, integer *, integer *,
00032 integer *, complex *, complex *, integer *, complex *, integer *,
00033 complex *, complex *, integer *);
00034 integer iinfo;
00035 extern int ctrsm_(char *, char *, char *, char *,
00036 integer *, integer *, complex *, complex *, integer *, complex *,
00037 integer *), cgetf2_(integer *,
00038 integer *, complex *, integer *, integer *, integer *), xerbla_(
00039 char *, integer *);
00040 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
00041 integer *, integer *);
00042 extern int claswp_(integer *, complex *, integer *,
00043 integer *, integer *, integer *, integer *);
00044
00045
00046
00047
00048
00049
00050
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 a_dim1 = *lda;
00116 a_offset = 1 + a_dim1;
00117 a -= a_offset;
00118 --ipiv;
00119
00120
00121 *info = 0;
00122 if (*m < 0) {
00123 *info = -1;
00124 } else if (*n < 0) {
00125 *info = -2;
00126 } else if (*lda < max(1,*m)) {
00127 *info = -4;
00128 }
00129 if (*info != 0) {
00130 i__1 = -(*info);
00131 xerbla_("CGETRF", &i__1);
00132 return 0;
00133 }
00134
00135
00136
00137 if (*m == 0 || *n == 0) {
00138 return 0;
00139 }
00140
00141
00142
00143 nb = ilaenv_(&c__1, "CGETRF", " ", m, n, &c_n1, &c_n1);
00144 if (nb <= 1 || nb >= min(*m,*n)) {
00145
00146
00147
00148 cgetf2_(m, n, &a[a_offset], lda, &ipiv[1], info);
00149 } else {
00150
00151
00152
00153 i__1 = min(*m,*n);
00154 i__2 = nb;
00155 for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
00156
00157 i__3 = min(*m,*n) - j + 1;
00158 jb = min(i__3,nb);
00159
00160
00161
00162
00163 i__3 = j - nb;
00164 i__4 = nb;
00165 for (k = 1; i__4 < 0 ? k >= i__3 : k <= i__3; k += i__4) {
00166
00167
00168
00169 i__5 = k + nb - 1;
00170 claswp_(&jb, &a[j * a_dim1 + 1], lda, &k, &i__5, &ipiv[1], &
00171 c__1);
00172
00173
00174
00175 ctrsm_("Left", "Lower", "No transpose", "Unit", &nb, &jb, &
00176 c_b1, &a[k + k * a_dim1], lda, &a[k + j * a_dim1],
00177 lda);
00178
00179
00180
00181 i__5 = *m - k - nb + 1;
00182 q__1.r = -1.f, q__1.i = -0.f;
00183 cgemm_("No transpose", "No transpose", &i__5, &jb, &nb, &q__1,
00184 &a[k + nb + k * a_dim1], lda, &a[k + j * a_dim1],
00185 lda, &c_b1, &a[k + nb + j * a_dim1], lda);
00186
00187 }
00188
00189
00190
00191
00192 i__4 = *m - j + 1;
00193 cgetf2_(&i__4, &jb, &a[j + j * a_dim1], lda, &ipiv[j], &iinfo);
00194
00195
00196
00197 if (*info == 0 && iinfo > 0) {
00198 *info = iinfo + j - 1;
00199 }
00200
00201 i__3 = *m, i__5 = j + jb - 1;
00202 i__4 = min(i__3,i__5);
00203 for (i__ = j; i__ <= i__4; ++i__) {
00204 ipiv[i__] = j - 1 + ipiv[i__];
00205
00206 }
00207
00208
00209 }
00210
00211
00212
00213 i__2 = min(*m,*n);
00214 i__1 = nb;
00215 for (k = 1; i__1 < 0 ? k >= i__2 : k <= i__2; k += i__1) {
00216 i__4 = k - 1;
00217
00218 i__5 = k + nb - 1, i__6 = min(*m,*n);
00219 i__3 = min(i__5,i__6);
00220 claswp_(&i__4, &a[a_dim1 + 1], lda, &k, &i__3, &ipiv[1], &c__1);
00221
00222 }
00223
00224
00225
00226 if (*n > *m) {
00227 i__1 = *n - *m;
00228 claswp_(&i__1, &a[(*m + 1) * a_dim1 + 1], lda, &c__1, m, &ipiv[1],
00229 &c__1);
00230 i__1 = *m;
00231 i__2 = nb;
00232 for (k = 1; i__2 < 0 ? k >= i__1 : k <= i__1; k += i__2) {
00233
00234 i__4 = *m - k + 1;
00235 jb = min(i__4,nb);
00236
00237 i__4 = *n - *m;
00238 ctrsm_("Left", "Lower", "No transpose", "Unit", &jb, &i__4, &
00239 c_b1, &a[k + k * a_dim1], lda, &a[k + (*m + 1) *
00240 a_dim1], lda);
00241
00242 if (k + nb <= *m) {
00243 i__4 = *m - k - nb + 1;
00244 i__3 = *n - *m;
00245 q__1.r = -1.f, q__1.i = -0.f;
00246 cgemm_("No transpose", "No transpose", &i__4, &i__3, &nb,
00247 &q__1, &a[k + nb + k * a_dim1], lda, &a[k + (*m +
00248 1) * a_dim1], lda, &c_b1, &a[k + nb + (*m + 1) *
00249 a_dim1], lda);
00250 }
00251
00252 }
00253 }
00254
00255 }
00256 return 0;
00257
00258
00259
00260 }