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 zhpgst_(integer *itype, char *uplo, integer *n,
00022 doublecomplex *ap, doublecomplex *bp, integer *info)
00023 {
00024
00025 integer i__1, i__2, i__3, i__4;
00026 doublereal d__1, d__2;
00027 doublecomplex z__1, z__2, z__3;
00028
00029
00030 integer j, k, j1, k1, jj, kk;
00031 doublecomplex ct;
00032 doublereal ajj;
00033 integer j1j1;
00034 doublereal akk;
00035 integer k1k1;
00036 doublereal bjj, bkk;
00037 extern int zhpr2_(char *, integer *, doublecomplex *,
00038 doublecomplex *, integer *, doublecomplex *, integer *,
00039 doublecomplex *);
00040 extern logical lsame_(char *, char *);
00041 extern VOID zdotc_(doublecomplex *, integer *,
00042 doublecomplex *, integer *, doublecomplex *, integer *);
00043 logical upper;
00044 extern int zhpmv_(char *, integer *, doublecomplex *,
00045 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
00046 doublecomplex *, integer *), zaxpy_(integer *,
00047 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
00048 integer *), ztpmv_(char *, char *, char *, integer *,
00049 doublecomplex *, doublecomplex *, integer *), ztpsv_(char *, char *, char *, integer *, doublecomplex *
00050 , doublecomplex *, integer *), xerbla_(
00051 char *, integer *), zdscal_(integer *, doublereal *,
00052 doublecomplex *, integer *);
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 --bp;
00130 --ap;
00131
00132
00133 *info = 0;
00134 upper = lsame_(uplo, "U");
00135 if (*itype < 1 || *itype > 3) {
00136 *info = -1;
00137 } else if (! upper && ! lsame_(uplo, "L")) {
00138 *info = -2;
00139 } else if (*n < 0) {
00140 *info = -3;
00141 }
00142 if (*info != 0) {
00143 i__1 = -(*info);
00144 xerbla_("ZHPGST", &i__1);
00145 return 0;
00146 }
00147
00148 if (*itype == 1) {
00149 if (upper) {
00150
00151
00152
00153
00154
00155 jj = 0;
00156 i__1 = *n;
00157 for (j = 1; j <= i__1; ++j) {
00158 j1 = jj + 1;
00159 jj += j;
00160
00161
00162
00163 i__2 = jj;
00164 i__3 = jj;
00165 d__1 = ap[i__3].r;
00166 ap[i__2].r = d__1, ap[i__2].i = 0.;
00167 i__2 = jj;
00168 bjj = bp[i__2].r;
00169 ztpsv_(uplo, "Conjugate transpose", "Non-unit", &j, &bp[1], &
00170 ap[j1], &c__1);
00171 i__2 = j - 1;
00172 z__1.r = -1., z__1.i = -0.;
00173 zhpmv_(uplo, &i__2, &z__1, &ap[1], &bp[j1], &c__1, &c_b1, &ap[
00174 j1], &c__1);
00175 i__2 = j - 1;
00176 d__1 = 1. / bjj;
00177 zdscal_(&i__2, &d__1, &ap[j1], &c__1);
00178 i__2 = jj;
00179 i__3 = jj;
00180 i__4 = j - 1;
00181 zdotc_(&z__3, &i__4, &ap[j1], &c__1, &bp[j1], &c__1);
00182 z__2.r = ap[i__3].r - z__3.r, z__2.i = ap[i__3].i - z__3.i;
00183 z__1.r = z__2.r / bjj, z__1.i = z__2.i / bjj;
00184 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00185
00186 }
00187 } else {
00188
00189
00190
00191
00192
00193 kk = 1;
00194 i__1 = *n;
00195 for (k = 1; k <= i__1; ++k) {
00196 k1k1 = kk + *n - k + 1;
00197
00198
00199
00200 i__2 = kk;
00201 akk = ap[i__2].r;
00202 i__2 = kk;
00203 bkk = bp[i__2].r;
00204
00205 d__1 = bkk;
00206 akk /= d__1 * d__1;
00207 i__2 = kk;
00208 ap[i__2].r = akk, ap[i__2].i = 0.;
00209 if (k < *n) {
00210 i__2 = *n - k;
00211 d__1 = 1. / bkk;
00212 zdscal_(&i__2, &d__1, &ap[kk + 1], &c__1);
00213 d__1 = akk * -.5;
00214 ct.r = d__1, ct.i = 0.;
00215 i__2 = *n - k;
00216 zaxpy_(&i__2, &ct, &bp[kk + 1], &c__1, &ap[kk + 1], &c__1)
00217 ;
00218 i__2 = *n - k;
00219 z__1.r = -1., z__1.i = -0.;
00220 zhpr2_(uplo, &i__2, &z__1, &ap[kk + 1], &c__1, &bp[kk + 1]
00221 , &c__1, &ap[k1k1]);
00222 i__2 = *n - k;
00223 zaxpy_(&i__2, &ct, &bp[kk + 1], &c__1, &ap[kk + 1], &c__1)
00224 ;
00225 i__2 = *n - k;
00226 ztpsv_(uplo, "No transpose", "Non-unit", &i__2, &bp[k1k1],
00227 &ap[kk + 1], &c__1);
00228 }
00229 kk = k1k1;
00230
00231 }
00232 }
00233 } else {
00234 if (upper) {
00235
00236
00237
00238
00239
00240 kk = 0;
00241 i__1 = *n;
00242 for (k = 1; k <= i__1; ++k) {
00243 k1 = kk + 1;
00244 kk += k;
00245
00246
00247
00248 i__2 = kk;
00249 akk = ap[i__2].r;
00250 i__2 = kk;
00251 bkk = bp[i__2].r;
00252 i__2 = k - 1;
00253 ztpmv_(uplo, "No transpose", "Non-unit", &i__2, &bp[1], &ap[
00254 k1], &c__1);
00255 d__1 = akk * .5;
00256 ct.r = d__1, ct.i = 0.;
00257 i__2 = k - 1;
00258 zaxpy_(&i__2, &ct, &bp[k1], &c__1, &ap[k1], &c__1);
00259 i__2 = k - 1;
00260 zhpr2_(uplo, &i__2, &c_b1, &ap[k1], &c__1, &bp[k1], &c__1, &
00261 ap[1]);
00262 i__2 = k - 1;
00263 zaxpy_(&i__2, &ct, &bp[k1], &c__1, &ap[k1], &c__1);
00264 i__2 = k - 1;
00265 zdscal_(&i__2, &bkk, &ap[k1], &c__1);
00266 i__2 = kk;
00267
00268 d__2 = bkk;
00269 d__1 = akk * (d__2 * d__2);
00270 ap[i__2].r = d__1, ap[i__2].i = 0.;
00271
00272 }
00273 } else {
00274
00275
00276
00277
00278
00279 jj = 1;
00280 i__1 = *n;
00281 for (j = 1; j <= i__1; ++j) {
00282 j1j1 = jj + *n - j + 1;
00283
00284
00285
00286 i__2 = jj;
00287 ajj = ap[i__2].r;
00288 i__2 = jj;
00289 bjj = bp[i__2].r;
00290 i__2 = jj;
00291 d__1 = ajj * bjj;
00292 i__3 = *n - j;
00293 zdotc_(&z__2, &i__3, &ap[jj + 1], &c__1, &bp[jj + 1], &c__1);
00294 z__1.r = d__1 + z__2.r, z__1.i = z__2.i;
00295 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00296 i__2 = *n - j;
00297 zdscal_(&i__2, &bjj, &ap[jj + 1], &c__1);
00298 i__2 = *n - j;
00299 zhpmv_(uplo, &i__2, &c_b1, &ap[j1j1], &bp[jj + 1], &c__1, &
00300 c_b1, &ap[jj + 1], &c__1);
00301 i__2 = *n - j + 1;
00302 ztpmv_(uplo, "Conjugate transpose", "Non-unit", &i__2, &bp[jj]
00303 , &ap[jj], &c__1);
00304 jj = j1j1;
00305
00306 }
00307 }
00308 }
00309 return 0;
00310
00311
00312
00313 }