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