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_b8 = -1.;
00020 static doublereal c_b9 = 1.;
00021 static doublereal c_b16 = 0.;
00022
00023 int dlaqps_(integer *m, integer *n, integer *offset, integer
00024 *nb, integer *kb, doublereal *a, integer *lda, integer *jpvt,
00025 doublereal *tau, doublereal *vn1, doublereal *vn2, doublereal *auxv,
00026 doublereal *f, integer *ldf)
00027 {
00028
00029 integer a_dim1, a_offset, f_dim1, f_offset, i__1, i__2;
00030 doublereal d__1, d__2;
00031
00032
00033 double sqrt(doublereal);
00034 integer i_dnnt(doublereal *);
00035
00036
00037 integer j, k, rk;
00038 doublereal akk;
00039 integer pvt;
00040 doublereal temp;
00041 extern doublereal dnrm2_(integer *, doublereal *, integer *);
00042 doublereal temp2, tol3z;
00043 extern int dgemm_(char *, char *, integer *, integer *,
00044 integer *, doublereal *, doublereal *, integer *, doublereal *,
00045 integer *, doublereal *, doublereal *, integer *),
00046 dgemv_(char *, integer *, integer *, doublereal *, doublereal *,
00047 integer *, doublereal *, integer *, doublereal *, doublereal *,
00048 integer *);
00049 integer itemp;
00050 extern int dswap_(integer *, doublereal *, integer *,
00051 doublereal *, integer *);
00052 extern doublereal dlamch_(char *);
00053 extern integer idamax_(integer *, doublereal *, integer *);
00054 extern int dlarfp_(integer *, doublereal *, doublereal *,
00055 integer *, doublereal *);
00056 integer lsticc, lastrk;
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(dlamch_("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 + idamax_(&i__1, &vn1[k], &c__1);
00192 if (pvt != k) {
00193 dswap_(m, &a[pvt * a_dim1 + 1], &c__1, &a[k * a_dim1 + 1], &c__1);
00194 i__1 = k - 1;
00195 dswap_(&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 = *m - rk + 1;
00208 i__2 = k - 1;
00209 dgemv_("No transpose", &i__1, &i__2, &c_b8, &a[rk + a_dim1], lda,
00210 &f[k + f_dim1], ldf, &c_b9, &a[rk + k * a_dim1], &c__1);
00211 }
00212
00213
00214
00215 if (rk < *m) {
00216 i__1 = *m - rk + 1;
00217 dlarfp_(&i__1, &a[rk + k * a_dim1], &a[rk + 1 + k * a_dim1], &
00218 c__1, &tau[k]);
00219 } else {
00220 dlarfp_(&c__1, &a[rk + k * a_dim1], &a[rk + k * a_dim1], &c__1, &
00221 tau[k]);
00222 }
00223
00224 akk = a[rk + k * a_dim1];
00225 a[rk + k * a_dim1] = 1.;
00226
00227
00228
00229
00230
00231 if (k < *n) {
00232 i__1 = *m - rk + 1;
00233 i__2 = *n - k;
00234 dgemv_("Transpose", &i__1, &i__2, &tau[k], &a[rk + (k + 1) *
00235 a_dim1], lda, &a[rk + k * a_dim1], &c__1, &c_b16, &f[k +
00236 1 + k * f_dim1], &c__1);
00237 }
00238
00239
00240
00241 i__1 = k;
00242 for (j = 1; j <= i__1; ++j) {
00243 f[j + k * f_dim1] = 0.;
00244
00245 }
00246
00247
00248
00249
00250
00251 if (k > 1) {
00252 i__1 = *m - rk + 1;
00253 i__2 = k - 1;
00254 d__1 = -tau[k];
00255 dgemv_("Transpose", &i__1, &i__2, &d__1, &a[rk + a_dim1], lda, &a[
00256 rk + k * a_dim1], &c__1, &c_b16, &auxv[1], &c__1);
00257
00258 i__1 = k - 1;
00259 dgemv_("No transpose", n, &i__1, &c_b9, &f[f_dim1 + 1], ldf, &
00260 auxv[1], &c__1, &c_b9, &f[k * f_dim1 + 1], &c__1);
00261 }
00262
00263
00264
00265
00266 if (k < *n) {
00267 i__1 = *n - k;
00268 dgemv_("No transpose", &i__1, &k, &c_b8, &f[k + 1 + f_dim1], ldf,
00269 &a[rk + a_dim1], lda, &c_b9, &a[rk + (k + 1) * a_dim1],
00270 lda);
00271 }
00272
00273
00274
00275 if (rk < lastrk) {
00276 i__1 = *n;
00277 for (j = k + 1; j <= i__1; ++j) {
00278 if (vn1[j] != 0.) {
00279
00280
00281
00282
00283 temp = (d__1 = a[rk + j * a_dim1], abs(d__1)) / vn1[j];
00284
00285 d__1 = 0., d__2 = (temp + 1.) * (1. - temp);
00286 temp = max(d__1,d__2);
00287
00288 d__1 = vn1[j] / vn2[j];
00289 temp2 = temp * (d__1 * d__1);
00290 if (temp2 <= tol3z) {
00291 vn2[j] = (doublereal) lsticc;
00292 lsticc = j;
00293 } else {
00294 vn1[j] *= sqrt(temp);
00295 }
00296 }
00297
00298 }
00299 }
00300
00301 a[rk + k * a_dim1] = akk;
00302
00303
00304
00305 goto L10;
00306 }
00307 *kb = k;
00308 rk = *offset + *kb;
00309
00310
00311
00312
00313
00314
00315 i__1 = *n, i__2 = *m - *offset;
00316 if (*kb < min(i__1,i__2)) {
00317 i__1 = *m - rk;
00318 i__2 = *n - *kb;
00319 dgemm_("No transpose", "Transpose", &i__1, &i__2, kb, &c_b8, &a[rk +
00320 1 + a_dim1], lda, &f[*kb + 1 + f_dim1], ldf, &c_b9, &a[rk + 1
00321 + (*kb + 1) * a_dim1], lda);
00322 }
00323
00324
00325
00326 L40:
00327 if (lsticc > 0) {
00328 itemp = i_dnnt(&vn2[lsticc]);
00329 i__1 = *m - rk;
00330 vn1[lsticc] = dnrm2_(&i__1, &a[rk + 1 + lsticc * a_dim1], &c__1);
00331
00332
00333
00334
00335
00336 vn2[lsticc] = vn1[lsticc];
00337 lsticc = itemp;
00338 goto L40;
00339 }
00340
00341 return 0;
00342
00343
00344
00345 }