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_b2 = {1.f,0.f};
00019 static integer c__1 = 1;
00020 static integer c_n1 = -1;
00021 static integer c__3 = 3;
00022 static integer c__2 = 2;
00023 static integer c__65 = 65;
00024
00025 int cgehrd_(integer *n, integer *ilo, integer *ihi, complex *
00026 a, integer *lda, complex *tau, complex *work, integer *lwork, integer
00027 *info)
00028 {
00029
00030 integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
00031 complex q__1;
00032
00033
00034 integer i__, j;
00035 complex t[4160] ;
00036 integer ib;
00037 complex ei;
00038 integer nb, nh, nx, iws;
00039 extern int cgemm_(char *, char *, integer *, integer *,
00040 integer *, complex *, complex *, integer *, complex *, integer *,
00041 complex *, complex *, integer *);
00042 integer nbmin, iinfo;
00043 extern int ctrmm_(char *, char *, char *, char *,
00044 integer *, integer *, complex *, complex *, integer *, complex *,
00045 integer *), caxpy_(integer *,
00046 complex *, complex *, integer *, complex *, integer *), cgehd2_(
00047 integer *, integer *, integer *, complex *, integer *, complex *,
00048 complex *, integer *), clahr2_(integer *, integer *, integer *,
00049 complex *, integer *, complex *, complex *, integer *, complex *,
00050 integer *), clarfb_(char *, char *, char *, char *, integer *,
00051 integer *, integer *, complex *, integer *, complex *, integer *,
00052 complex *, integer *, complex *, integer *), xerbla_(char *, integer *);
00053 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
00054 integer *, integer *);
00055 integer ldwork, lwkopt;
00056 logical lquery;
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
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 a_dim1 = *lda;
00178 a_offset = 1 + a_dim1;
00179 a -= a_offset;
00180 --tau;
00181 --work;
00182
00183
00184 *info = 0;
00185
00186 i__1 = 64, i__2 = ilaenv_(&c__1, "CGEHRD", " ", n, ilo, ihi, &c_n1);
00187 nb = min(i__1,i__2);
00188 lwkopt = *n * nb;
00189 work[1].r = (real) lwkopt, work[1].i = 0.f;
00190 lquery = *lwork == -1;
00191 if (*n < 0) {
00192 *info = -1;
00193 } else if (*ilo < 1 || *ilo > max(1,*n)) {
00194 *info = -2;
00195 } else if (*ihi < min(*ilo,*n) || *ihi > *n) {
00196 *info = -3;
00197 } else if (*lda < max(1,*n)) {
00198 *info = -5;
00199 } else if (*lwork < max(1,*n) && ! lquery) {
00200 *info = -8;
00201 }
00202 if (*info != 0) {
00203 i__1 = -(*info);
00204 xerbla_("CGEHRD", &i__1);
00205 return 0;
00206 } else if (lquery) {
00207 return 0;
00208 }
00209
00210
00211
00212 i__1 = *ilo - 1;
00213 for (i__ = 1; i__ <= i__1; ++i__) {
00214 i__2 = i__;
00215 tau[i__2].r = 0.f, tau[i__2].i = 0.f;
00216
00217 }
00218 i__1 = *n - 1;
00219 for (i__ = max(1,*ihi); i__ <= i__1; ++i__) {
00220 i__2 = i__;
00221 tau[i__2].r = 0.f, tau[i__2].i = 0.f;
00222
00223 }
00224
00225
00226
00227 nh = *ihi - *ilo + 1;
00228 if (nh <= 1) {
00229 work[1].r = 1.f, work[1].i = 0.f;
00230 return 0;
00231 }
00232
00233
00234
00235
00236 i__1 = 64, i__2 = ilaenv_(&c__1, "CGEHRD", " ", n, ilo, ihi, &c_n1);
00237 nb = min(i__1,i__2);
00238 nbmin = 2;
00239 iws = 1;
00240 if (nb > 1 && nb < nh) {
00241
00242
00243
00244
00245
00246 i__1 = nb, i__2 = ilaenv_(&c__3, "CGEHRD", " ", n, ilo, ihi, &c_n1);
00247 nx = max(i__1,i__2);
00248 if (nx < nh) {
00249
00250
00251
00252 iws = *n * nb;
00253 if (*lwork < iws) {
00254
00255
00256
00257
00258
00259
00260 i__1 = 2, i__2 = ilaenv_(&c__2, "CGEHRD", " ", n, ilo, ihi, &
00261 c_n1);
00262 nbmin = max(i__1,i__2);
00263 if (*lwork >= *n * nbmin) {
00264 nb = *lwork / *n;
00265 } else {
00266 nb = 1;
00267 }
00268 }
00269 }
00270 }
00271 ldwork = *n;
00272
00273 if (nb < nbmin || nb >= nh) {
00274
00275
00276
00277 i__ = *ilo;
00278
00279 } else {
00280
00281
00282
00283 i__1 = *ihi - 1 - nx;
00284 i__2 = nb;
00285 for (i__ = *ilo; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
00286
00287 i__3 = nb, i__4 = *ihi - i__;
00288 ib = min(i__3,i__4);
00289
00290
00291
00292
00293
00294 clahr2_(ihi, &i__, &ib, &a[i__ * a_dim1 + 1], lda, &tau[i__], t, &
00295 c__65, &work[1], &ldwork);
00296
00297
00298
00299
00300
00301 i__3 = i__ + ib + (i__ + ib - 1) * a_dim1;
00302 ei.r = a[i__3].r, ei.i = a[i__3].i;
00303 i__3 = i__ + ib + (i__ + ib - 1) * a_dim1;
00304 a[i__3].r = 1.f, a[i__3].i = 0.f;
00305 i__3 = *ihi - i__ - ib + 1;
00306 q__1.r = -1.f, q__1.i = -0.f;
00307 cgemm_("No transpose", "Conjugate transpose", ihi, &i__3, &ib, &
00308 q__1, &work[1], &ldwork, &a[i__ + ib + i__ * a_dim1], lda,
00309 &c_b2, &a[(i__ + ib) * a_dim1 + 1], lda);
00310 i__3 = i__ + ib + (i__ + ib - 1) * a_dim1;
00311 a[i__3].r = ei.r, a[i__3].i = ei.i;
00312
00313
00314
00315
00316 i__3 = ib - 1;
00317 ctrmm_("Right", "Lower", "Conjugate transpose", "Unit", &i__, &
00318 i__3, &c_b2, &a[i__ + 1 + i__ * a_dim1], lda, &work[1], &
00319 ldwork);
00320 i__3 = ib - 2;
00321 for (j = 0; j <= i__3; ++j) {
00322 q__1.r = -1.f, q__1.i = -0.f;
00323 caxpy_(&i__, &q__1, &work[ldwork * j + 1], &c__1, &a[(i__ + j
00324 + 1) * a_dim1 + 1], &c__1);
00325
00326 }
00327
00328
00329
00330
00331 i__3 = *ihi - i__;
00332 i__4 = *n - i__ - ib + 1;
00333 clarfb_("Left", "Conjugate transpose", "Forward", "Columnwise", &
00334 i__3, &i__4, &ib, &a[i__ + 1 + i__ * a_dim1], lda, t, &
00335 c__65, &a[i__ + 1 + (i__ + ib) * a_dim1], lda, &work[1], &
00336 ldwork);
00337
00338 }
00339 }
00340
00341
00342
00343 cgehd2_(n, &i__, ihi, &a[a_offset], lda, &tau[1], &work[1], &iinfo);
00344 work[1].r = (real) iws, work[1].i = 0.f;
00345
00346 return 0;
00347
00348
00349
00350 }