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
00020 int zlaqp2_(integer *m, integer *n, integer *offset,
00021 doublecomplex *a, integer *lda, integer *jpvt, doublecomplex *tau,
00022 doublereal *vn1, doublereal *vn2, doublecomplex *work)
00023 {
00024
00025 integer a_dim1, a_offset, i__1, i__2, i__3;
00026 doublereal d__1;
00027 doublecomplex z__1;
00028
00029
00030 double sqrt(doublereal);
00031 void d_cnjg(doublecomplex *, doublecomplex *);
00032 double z_abs(doublecomplex *);
00033
00034
00035 integer i__, j, mn;
00036 doublecomplex aii;
00037 integer pvt;
00038 doublereal temp, temp2, tol3z;
00039 integer offpi, itemp;
00040 extern int zlarf_(char *, integer *, integer *,
00041 doublecomplex *, integer *, doublecomplex *, doublecomplex *,
00042 integer *, doublecomplex *), zswap_(integer *,
00043 doublecomplex *, integer *, doublecomplex *, integer *);
00044 extern doublereal dznrm2_(integer *, doublecomplex *, integer *), dlamch_(
00045 char *);
00046 extern integer idamax_(integer *, doublereal *, integer *);
00047 extern int zlarfp_(integer *, doublecomplex *,
00048 doublecomplex *, integer *, doublecomplex *);
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
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137 a_dim1 = *lda;
00138 a_offset = 1 + a_dim1;
00139 a -= a_offset;
00140 --jpvt;
00141 --tau;
00142 --vn1;
00143 --vn2;
00144 --work;
00145
00146
00147
00148 i__1 = *m - *offset;
00149 mn = min(i__1,*n);
00150 tol3z = sqrt(dlamch_("Epsilon"));
00151
00152
00153
00154 i__1 = mn;
00155 for (i__ = 1; i__ <= i__1; ++i__) {
00156
00157 offpi = *offset + i__;
00158
00159
00160
00161 i__2 = *n - i__ + 1;
00162 pvt = i__ - 1 + idamax_(&i__2, &vn1[i__], &c__1);
00163
00164 if (pvt != i__) {
00165 zswap_(m, &a[pvt * a_dim1 + 1], &c__1, &a[i__ * a_dim1 + 1], &
00166 c__1);
00167 itemp = jpvt[pvt];
00168 jpvt[pvt] = jpvt[i__];
00169 jpvt[i__] = itemp;
00170 vn1[pvt] = vn1[i__];
00171 vn2[pvt] = vn2[i__];
00172 }
00173
00174
00175
00176 if (offpi < *m) {
00177 i__2 = *m - offpi + 1;
00178 zlarfp_(&i__2, &a[offpi + i__ * a_dim1], &a[offpi + 1 + i__ *
00179 a_dim1], &c__1, &tau[i__]);
00180 } else {
00181 zlarfp_(&c__1, &a[*m + i__ * a_dim1], &a[*m + i__ * a_dim1], &
00182 c__1, &tau[i__]);
00183 }
00184
00185 if (i__ < *n) {
00186
00187
00188
00189 i__2 = offpi + i__ * a_dim1;
00190 aii.r = a[i__2].r, aii.i = a[i__2].i;
00191 i__2 = offpi + i__ * a_dim1;
00192 a[i__2].r = 1., a[i__2].i = 0.;
00193 i__2 = *m - offpi + 1;
00194 i__3 = *n - i__;
00195 d_cnjg(&z__1, &tau[i__]);
00196 zlarf_("Left", &i__2, &i__3, &a[offpi + i__ * a_dim1], &c__1, &
00197 z__1, &a[offpi + (i__ + 1) * a_dim1], lda, &work[1]);
00198 i__2 = offpi + i__ * a_dim1;
00199 a[i__2].r = aii.r, a[i__2].i = aii.i;
00200 }
00201
00202
00203
00204 i__2 = *n;
00205 for (j = i__ + 1; j <= i__2; ++j) {
00206 if (vn1[j] != 0.) {
00207
00208
00209
00210
00211
00212 d__1 = z_abs(&a[offpi + j * a_dim1]) / vn1[j];
00213 temp = 1. - d__1 * d__1;
00214 temp = max(temp,0.);
00215
00216 d__1 = vn1[j] / vn2[j];
00217 temp2 = temp * (d__1 * d__1);
00218 if (temp2 <= tol3z) {
00219 if (offpi < *m) {
00220 i__3 = *m - offpi;
00221 vn1[j] = dznrm2_(&i__3, &a[offpi + 1 + j * a_dim1], &
00222 c__1);
00223 vn2[j] = vn1[j];
00224 } else {
00225 vn1[j] = 0.;
00226 vn2[j] = 0.;
00227 }
00228 } else {
00229 vn1[j] *= sqrt(temp);
00230 }
00231 }
00232
00233 }
00234
00235
00236 }
00237
00238 return 0;
00239
00240
00241
00242 }