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 doublecomplex c_b1 = {1.,0.};
00019 static doublecomplex c_b2 = {.5,0.};
00020 static integer c__1 = 1;
00021 static integer c_n1 = -1;
00022 static doublereal c_b18 = 1.;
00023
00024 int zhegst_(integer *itype, char *uplo, integer *n,
00025 doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb,
00026 integer *info)
00027 {
00028
00029 integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3;
00030 doublecomplex z__1;
00031
00032
00033 integer k, kb, nb;
00034 extern logical lsame_(char *, char *);
00035 extern int zhemm_(char *, char *, integer *, integer *,
00036 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
00037 integer *, doublecomplex *, doublecomplex *, integer *);
00038 logical upper;
00039 extern int ztrmm_(char *, char *, char *, char *,
00040 integer *, integer *, doublecomplex *, doublecomplex *, integer *,
00041 doublecomplex *, integer *),
00042 ztrsm_(char *, char *, char *, char *, integer *, integer *,
00043 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
00044 integer *), zhegs2_(integer *,
00045 char *, integer *, doublecomplex *, integer *, doublecomplex *,
00046 integer *, integer *), zher2k_(char *, char *, integer *,
00047 integer *, doublecomplex *, doublecomplex *, integer *,
00048 doublecomplex *, integer *, doublereal *, doublecomplex *,
00049 integer *), xerbla_(char *, integer *);
00050 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
00051 integer *, integer *);
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 a_dim1 = *lda;
00137 a_offset = 1 + a_dim1;
00138 a -= a_offset;
00139 b_dim1 = *ldb;
00140 b_offset = 1 + b_dim1;
00141 b -= b_offset;
00142
00143
00144 *info = 0;
00145 upper = lsame_(uplo, "U");
00146 if (*itype < 1 || *itype > 3) {
00147 *info = -1;
00148 } else if (! upper && ! lsame_(uplo, "L")) {
00149 *info = -2;
00150 } else if (*n < 0) {
00151 *info = -3;
00152 } else if (*lda < max(1,*n)) {
00153 *info = -5;
00154 } else if (*ldb < max(1,*n)) {
00155 *info = -7;
00156 }
00157 if (*info != 0) {
00158 i__1 = -(*info);
00159 xerbla_("ZHEGST", &i__1);
00160 return 0;
00161 }
00162
00163
00164
00165 if (*n == 0) {
00166 return 0;
00167 }
00168
00169
00170
00171 nb = ilaenv_(&c__1, "ZHEGST", uplo, n, &c_n1, &c_n1, &c_n1);
00172
00173 if (nb <= 1 || nb >= *n) {
00174
00175
00176
00177 zhegs2_(itype, uplo, n, &a[a_offset], lda, &b[b_offset], ldb, info);
00178 } else {
00179
00180
00181
00182 if (*itype == 1) {
00183 if (upper) {
00184
00185
00186
00187 i__1 = *n;
00188 i__2 = nb;
00189 for (k = 1; i__2 < 0 ? k >= i__1 : k <= i__1; k += i__2) {
00190
00191 i__3 = *n - k + 1;
00192 kb = min(i__3,nb);
00193
00194
00195
00196 zhegs2_(itype, uplo, &kb, &a[k + k * a_dim1], lda, &b[k +
00197 k * b_dim1], ldb, info);
00198 if (k + kb <= *n) {
00199 i__3 = *n - k - kb + 1;
00200 ztrsm_("Left", uplo, "Conjugate transpose", "Non-unit"
00201 , &kb, &i__3, &c_b1, &b[k + k * b_dim1], ldb,
00202 &a[k + (k + kb) * a_dim1], lda);
00203 i__3 = *n - k - kb + 1;
00204 z__1.r = -.5, z__1.i = -0.;
00205 zhemm_("Left", uplo, &kb, &i__3, &z__1, &a[k + k *
00206 a_dim1], lda, &b[k + (k + kb) * b_dim1], ldb,
00207 &c_b1, &a[k + (k + kb) * a_dim1], lda);
00208 i__3 = *n - k - kb + 1;
00209 z__1.r = -1., z__1.i = -0.;
00210 zher2k_(uplo, "Conjugate transpose", &i__3, &kb, &
00211 z__1, &a[k + (k + kb) * a_dim1], lda, &b[k + (
00212 k + kb) * b_dim1], ldb, &c_b18, &a[k + kb + (
00213 k + kb) * a_dim1], lda)
00214 ;
00215 i__3 = *n - k - kb + 1;
00216 z__1.r = -.5, z__1.i = -0.;
00217 zhemm_("Left", uplo, &kb, &i__3, &z__1, &a[k + k *
00218 a_dim1], lda, &b[k + (k + kb) * b_dim1], ldb,
00219 &c_b1, &a[k + (k + kb) * a_dim1], lda);
00220 i__3 = *n - k - kb + 1;
00221 ztrsm_("Right", uplo, "No transpose", "Non-unit", &kb,
00222 &i__3, &c_b1, &b[k + kb + (k + kb) * b_dim1],
00223 ldb, &a[k + (k + kb) * a_dim1], lda);
00224 }
00225
00226 }
00227 } else {
00228
00229
00230
00231 i__2 = *n;
00232 i__1 = nb;
00233 for (k = 1; i__1 < 0 ? k >= i__2 : k <= i__2; k += i__1) {
00234
00235 i__3 = *n - k + 1;
00236 kb = min(i__3,nb);
00237
00238
00239
00240 zhegs2_(itype, uplo, &kb, &a[k + k * a_dim1], lda, &b[k +
00241 k * b_dim1], ldb, info);
00242 if (k + kb <= *n) {
00243 i__3 = *n - k - kb + 1;
00244 ztrsm_("Right", uplo, "Conjugate transpose", "Non-un"
00245 "it", &i__3, &kb, &c_b1, &b[k + k * b_dim1],
00246 ldb, &a[k + kb + k * a_dim1], lda);
00247 i__3 = *n - k - kb + 1;
00248 z__1.r = -.5, z__1.i = -0.;
00249 zhemm_("Right", uplo, &i__3, &kb, &z__1, &a[k + k *
00250 a_dim1], lda, &b[k + kb + k * b_dim1], ldb, &
00251 c_b1, &a[k + kb + k * a_dim1], lda);
00252 i__3 = *n - k - kb + 1;
00253 z__1.r = -1., z__1.i = -0.;
00254 zher2k_(uplo, "No transpose", &i__3, &kb, &z__1, &a[k
00255 + kb + k * a_dim1], lda, &b[k + kb + k *
00256 b_dim1], ldb, &c_b18, &a[k + kb + (k + kb) *
00257 a_dim1], lda);
00258 i__3 = *n - k - kb + 1;
00259 z__1.r = -.5, z__1.i = -0.;
00260 zhemm_("Right", uplo, &i__3, &kb, &z__1, &a[k + k *
00261 a_dim1], lda, &b[k + kb + k * b_dim1], ldb, &
00262 c_b1, &a[k + kb + k * a_dim1], lda);
00263 i__3 = *n - k - kb + 1;
00264 ztrsm_("Left", uplo, "No transpose", "Non-unit", &
00265 i__3, &kb, &c_b1, &b[k + kb + (k + kb) *
00266 b_dim1], ldb, &a[k + kb + k * a_dim1], lda);
00267 }
00268
00269 }
00270 }
00271 } else {
00272 if (upper) {
00273
00274
00275
00276 i__1 = *n;
00277 i__2 = nb;
00278 for (k = 1; i__2 < 0 ? k >= i__1 : k <= i__1; k += i__2) {
00279
00280 i__3 = *n - k + 1;
00281 kb = min(i__3,nb);
00282
00283
00284
00285 i__3 = k - 1;
00286 ztrmm_("Left", uplo, "No transpose", "Non-unit", &i__3, &
00287 kb, &c_b1, &b[b_offset], ldb, &a[k * a_dim1 + 1],
00288 lda);
00289 i__3 = k - 1;
00290 zhemm_("Right", uplo, &i__3, &kb, &c_b2, &a[k + k *
00291 a_dim1], lda, &b[k * b_dim1 + 1], ldb, &c_b1, &a[
00292 k * a_dim1 + 1], lda);
00293 i__3 = k - 1;
00294 zher2k_(uplo, "No transpose", &i__3, &kb, &c_b1, &a[k *
00295 a_dim1 + 1], lda, &b[k * b_dim1 + 1], ldb, &c_b18,
00296 &a[a_offset], lda);
00297 i__3 = k - 1;
00298 zhemm_("Right", uplo, &i__3, &kb, &c_b2, &a[k + k *
00299 a_dim1], lda, &b[k * b_dim1 + 1], ldb, &c_b1, &a[
00300 k * a_dim1 + 1], lda);
00301 i__3 = k - 1;
00302 ztrmm_("Right", uplo, "Conjugate transpose", "Non-unit", &
00303 i__3, &kb, &c_b1, &b[k + k * b_dim1], ldb, &a[k *
00304 a_dim1 + 1], lda);
00305 zhegs2_(itype, uplo, &kb, &a[k + k * a_dim1], lda, &b[k +
00306 k * b_dim1], ldb, info);
00307
00308 }
00309 } else {
00310
00311
00312
00313 i__2 = *n;
00314 i__1 = nb;
00315 for (k = 1; i__1 < 0 ? k >= i__2 : k <= i__2; k += i__1) {
00316
00317 i__3 = *n - k + 1;
00318 kb = min(i__3,nb);
00319
00320
00321
00322 i__3 = k - 1;
00323 ztrmm_("Right", uplo, "No transpose", "Non-unit", &kb, &
00324 i__3, &c_b1, &b[b_offset], ldb, &a[k + a_dim1],
00325 lda);
00326 i__3 = k - 1;
00327 zhemm_("Left", uplo, &kb, &i__3, &c_b2, &a[k + k * a_dim1]
00328 , lda, &b[k + b_dim1], ldb, &c_b1, &a[k + a_dim1],
00329 lda);
00330 i__3 = k - 1;
00331 zher2k_(uplo, "Conjugate transpose", &i__3, &kb, &c_b1, &
00332 a[k + a_dim1], lda, &b[k + b_dim1], ldb, &c_b18, &
00333 a[a_offset], lda);
00334 i__3 = k - 1;
00335 zhemm_("Left", uplo, &kb, &i__3, &c_b2, &a[k + k * a_dim1]
00336 , lda, &b[k + b_dim1], ldb, &c_b1, &a[k + a_dim1],
00337 lda);
00338 i__3 = k - 1;
00339 ztrmm_("Left", uplo, "Conjugate transpose", "Non-unit", &
00340 kb, &i__3, &c_b1, &b[k + k * b_dim1], ldb, &a[k +
00341 a_dim1], lda);
00342 zhegs2_(itype, uplo, &kb, &a[k + k * a_dim1], lda, &b[k +
00343 k * b_dim1], ldb, info);
00344
00345 }
00346 }
00347 }
00348 }
00349 return 0;
00350
00351
00352
00353 }