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