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