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