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 doublecomplex c_b1 = {0.,0.};
00019 static doublecomplex c_b2 = {1.,0.};
00020 static integer c__1 = 1;
00021
00022 int zlaqps_(integer *m, integer *n, integer *offset, integer
00023 *nb, integer *kb, doublecomplex *a, integer *lda, integer *jpvt,
00024 doublecomplex *tau, doublereal *vn1, doublereal *vn2, doublecomplex *
00025 auxv, doublecomplex *f, integer *ldf)
00026 {
00027
00028 integer a_dim1, a_offset, f_dim1, f_offset, i__1, i__2, i__3;
00029 doublereal d__1, d__2;
00030 doublecomplex z__1;
00031
00032
00033 double sqrt(doublereal);
00034 void d_cnjg(doublecomplex *, doublecomplex *);
00035 double z_abs(doublecomplex *);
00036 integer i_dnnt(doublereal *);
00037
00038
00039 integer j, k, rk;
00040 doublecomplex akk;
00041 integer pvt;
00042 doublereal temp, temp2, tol3z;
00043 integer itemp;
00044 extern int zgemm_(char *, char *, integer *, integer *,
00045 integer *, doublecomplex *, doublecomplex *, integer *,
00046 doublecomplex *, integer *, doublecomplex *, doublecomplex *,
00047 integer *), zgemv_(char *, integer *, integer *,
00048 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
00049 integer *, doublecomplex *, doublecomplex *, integer *),
00050 zswap_(integer *, doublecomplex *, integer *, doublecomplex *,
00051 integer *);
00052 extern doublereal dznrm2_(integer *, doublecomplex *, integer *), dlamch_(
00053 char *);
00054 extern integer idamax_(integer *, doublereal *, integer *);
00055 integer lsticc;
00056 extern int zlarfp_(integer *, doublecomplex *,
00057 doublecomplex *, integer *, doublecomplex *);
00058 integer lastrk;
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
00157
00158 a_dim1 = *lda;
00159 a_offset = 1 + a_dim1;
00160 a -= a_offset;
00161 --jpvt;
00162 --tau;
00163 --vn1;
00164 --vn2;
00165 --auxv;
00166 f_dim1 = *ldf;
00167 f_offset = 1 + f_dim1;
00168 f -= f_offset;
00169
00170
00171
00172 i__1 = *m, i__2 = *n + *offset;
00173 lastrk = min(i__1,i__2);
00174 lsticc = 0;
00175 k = 0;
00176 tol3z = sqrt(dlamch_("Epsilon"));
00177
00178
00179
00180 L10:
00181 if (k < *nb && lsticc == 0) {
00182 ++k;
00183 rk = *offset + k;
00184
00185
00186
00187 i__1 = *n - k + 1;
00188 pvt = k - 1 + idamax_(&i__1, &vn1[k], &c__1);
00189 if (pvt != k) {
00190 zswap_(m, &a[pvt * a_dim1 + 1], &c__1, &a[k * a_dim1 + 1], &c__1);
00191 i__1 = k - 1;
00192 zswap_(&i__1, &f[pvt + f_dim1], ldf, &f[k + f_dim1], ldf);
00193 itemp = jpvt[pvt];
00194 jpvt[pvt] = jpvt[k];
00195 jpvt[k] = itemp;
00196 vn1[pvt] = vn1[k];
00197 vn2[pvt] = vn2[k];
00198 }
00199
00200
00201
00202
00203 if (k > 1) {
00204 i__1 = k - 1;
00205 for (j = 1; j <= i__1; ++j) {
00206 i__2 = k + j * f_dim1;
00207 d_cnjg(&z__1, &f[k + j * f_dim1]);
00208 f[i__2].r = z__1.r, f[i__2].i = z__1.i;
00209
00210 }
00211 i__1 = *m - rk + 1;
00212 i__2 = k - 1;
00213 z__1.r = -1., z__1.i = -0.;
00214 zgemv_("No transpose", &i__1, &i__2, &z__1, &a[rk + a_dim1], lda,
00215 &f[k + f_dim1], ldf, &c_b2, &a[rk + k * a_dim1], &c__1);
00216 i__1 = k - 1;
00217 for (j = 1; j <= i__1; ++j) {
00218 i__2 = k + j * f_dim1;
00219 d_cnjg(&z__1, &f[k + j * f_dim1]);
00220 f[i__2].r = z__1.r, f[i__2].i = z__1.i;
00221
00222 }
00223 }
00224
00225
00226
00227 if (rk < *m) {
00228 i__1 = *m - rk + 1;
00229 zlarfp_(&i__1, &a[rk + k * a_dim1], &a[rk + 1 + k * a_dim1], &
00230 c__1, &tau[k]);
00231 } else {
00232 zlarfp_(&c__1, &a[rk + k * a_dim1], &a[rk + k * a_dim1], &c__1, &
00233 tau[k]);
00234 }
00235
00236 i__1 = rk + k * a_dim1;
00237 akk.r = a[i__1].r, akk.i = a[i__1].i;
00238 i__1 = rk + k * a_dim1;
00239 a[i__1].r = 1., a[i__1].i = 0.;
00240
00241
00242
00243
00244
00245 if (k < *n) {
00246 i__1 = *m - rk + 1;
00247 i__2 = *n - k;
00248 zgemv_("Conjugate transpose", &i__1, &i__2, &tau[k], &a[rk + (k +
00249 1) * a_dim1], lda, &a[rk + k * a_dim1], &c__1, &c_b1, &f[
00250 k + 1 + k * f_dim1], &c__1);
00251 }
00252
00253
00254
00255 i__1 = k;
00256 for (j = 1; j <= i__1; ++j) {
00257 i__2 = j + k * f_dim1;
00258 f[i__2].r = 0., f[i__2].i = 0.;
00259
00260 }
00261
00262
00263
00264
00265
00266 if (k > 1) {
00267 i__1 = *m - rk + 1;
00268 i__2 = k - 1;
00269 i__3 = k;
00270 z__1.r = -tau[i__3].r, z__1.i = -tau[i__3].i;
00271 zgemv_("Conjugate transpose", &i__1, &i__2, &z__1, &a[rk + a_dim1]
00272 , lda, &a[rk + k * a_dim1], &c__1, &c_b1, &auxv[1], &c__1);
00273
00274 i__1 = k - 1;
00275 zgemv_("No transpose", n, &i__1, &c_b2, &f[f_dim1 + 1], ldf, &
00276 auxv[1], &c__1, &c_b2, &f[k * f_dim1 + 1], &c__1);
00277 }
00278
00279
00280
00281
00282 if (k < *n) {
00283 i__1 = *n - k;
00284 z__1.r = -1., z__1.i = -0.;
00285 zgemm_("No transpose", "Conjugate transpose", &c__1, &i__1, &k, &
00286 z__1, &a[rk + a_dim1], lda, &f[k + 1 + f_dim1], ldf, &
00287 c_b2, &a[rk + (k + 1) * a_dim1], lda);
00288 }
00289
00290
00291
00292 if (rk < lastrk) {
00293 i__1 = *n;
00294 for (j = k + 1; j <= i__1; ++j) {
00295 if (vn1[j] != 0.) {
00296
00297
00298
00299
00300 temp = z_abs(&a[rk + j * a_dim1]) / vn1[j];
00301
00302 d__1 = 0., d__2 = (temp + 1.) * (1. - temp);
00303 temp = max(d__1,d__2);
00304
00305 d__1 = vn1[j] / vn2[j];
00306 temp2 = temp * (d__1 * d__1);
00307 if (temp2 <= tol3z) {
00308 vn2[j] = (doublereal) lsticc;
00309 lsticc = j;
00310 } else {
00311 vn1[j] *= sqrt(temp);
00312 }
00313 }
00314
00315 }
00316 }
00317
00318 i__1 = rk + k * a_dim1;
00319 a[i__1].r = akk.r, a[i__1].i = akk.i;
00320
00321
00322
00323 goto L10;
00324 }
00325 *kb = k;
00326 rk = *offset + *kb;
00327
00328
00329
00330
00331
00332
00333 i__1 = *n, i__2 = *m - *offset;
00334 if (*kb < min(i__1,i__2)) {
00335 i__1 = *m - rk;
00336 i__2 = *n - *kb;
00337 z__1.r = -1., z__1.i = -0.;
00338 zgemm_("No transpose", "Conjugate transpose", &i__1, &i__2, kb, &z__1,
00339 &a[rk + 1 + a_dim1], lda, &f[*kb + 1 + f_dim1], ldf, &c_b2, &
00340 a[rk + 1 + (*kb + 1) * a_dim1], lda);
00341 }
00342
00343
00344
00345 L60:
00346 if (lsticc > 0) {
00347 itemp = i_dnnt(&vn2[lsticc]);
00348 i__1 = *m - rk;
00349 vn1[lsticc] = dznrm2_(&i__1, &a[rk + 1 + lsticc * a_dim1], &c__1);
00350
00351
00352
00353
00354
00355 vn2[lsticc] = vn1[lsticc];
00356 lsticc = itemp;
00357 goto L60;
00358 }
00359
00360 return 0;
00361
00362
00363
00364 }