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