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