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 integer c__1 = 1;
00019 static real c_b9 = -1.f;
00020 static real c_b11 = 1.f;
00021
00022 int sspgst_(integer *itype, char *uplo, integer *n, real *ap,
00023 real *bp, integer *info)
00024 {
00025
00026 integer i__1, i__2;
00027 real r__1;
00028
00029
00030 integer j, k, j1, k1, jj, kk;
00031 real ct, ajj;
00032 integer j1j1;
00033 real akk;
00034 integer k1k1;
00035 real bjj, bkk;
00036 extern doublereal sdot_(integer *, real *, integer *, real *, integer *);
00037 extern int sspr2_(char *, integer *, real *, real *,
00038 integer *, real *, integer *, real *);
00039 extern logical lsame_(char *, char *);
00040 extern int sscal_(integer *, real *, real *, integer *);
00041 logical upper;
00042 extern int saxpy_(integer *, real *, real *, integer *,
00043 real *, integer *), sspmv_(char *, integer *, real *, real *,
00044 real *, integer *, real *, real *, integer *), stpmv_(
00045 char *, char *, char *, integer *, real *, real *, integer *), stpsv_(char *, char *, char *, integer *,
00046 real *, real *, integer *), xerbla_(char
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 --bp;
00123 --ap;
00124
00125
00126 *info = 0;
00127 upper = lsame_(uplo, "U");
00128 if (*itype < 1 || *itype > 3) {
00129 *info = -1;
00130 } else if (! upper && ! lsame_(uplo, "L")) {
00131 *info = -2;
00132 } else if (*n < 0) {
00133 *info = -3;
00134 }
00135 if (*info != 0) {
00136 i__1 = -(*info);
00137 xerbla_("SSPGST", &i__1);
00138 return 0;
00139 }
00140
00141 if (*itype == 1) {
00142 if (upper) {
00143
00144
00145
00146
00147
00148 jj = 0;
00149 i__1 = *n;
00150 for (j = 1; j <= i__1; ++j) {
00151 j1 = jj + 1;
00152 jj += j;
00153
00154
00155
00156 bjj = bp[jj];
00157 stpsv_(uplo, "Transpose", "Nonunit", &j, &bp[1], &ap[j1], &
00158 c__1);
00159 i__2 = j - 1;
00160 sspmv_(uplo, &i__2, &c_b9, &ap[1], &bp[j1], &c__1, &c_b11, &
00161 ap[j1], &c__1);
00162 i__2 = j - 1;
00163 r__1 = 1.f / bjj;
00164 sscal_(&i__2, &r__1, &ap[j1], &c__1);
00165 i__2 = j - 1;
00166 ap[jj] = (ap[jj] - sdot_(&i__2, &ap[j1], &c__1, &bp[j1], &
00167 c__1)) / bjj;
00168
00169 }
00170 } else {
00171
00172
00173
00174
00175
00176 kk = 1;
00177 i__1 = *n;
00178 for (k = 1; k <= i__1; ++k) {
00179 k1k1 = kk + *n - k + 1;
00180
00181
00182
00183 akk = ap[kk];
00184 bkk = bp[kk];
00185
00186 r__1 = bkk;
00187 akk /= r__1 * r__1;
00188 ap[kk] = akk;
00189 if (k < *n) {
00190 i__2 = *n - k;
00191 r__1 = 1.f / bkk;
00192 sscal_(&i__2, &r__1, &ap[kk + 1], &c__1);
00193 ct = akk * -.5f;
00194 i__2 = *n - k;
00195 saxpy_(&i__2, &ct, &bp[kk + 1], &c__1, &ap[kk + 1], &c__1)
00196 ;
00197 i__2 = *n - k;
00198 sspr2_(uplo, &i__2, &c_b9, &ap[kk + 1], &c__1, &bp[kk + 1]
00199 , &c__1, &ap[k1k1]);
00200 i__2 = *n - k;
00201 saxpy_(&i__2, &ct, &bp[kk + 1], &c__1, &ap[kk + 1], &c__1)
00202 ;
00203 i__2 = *n - k;
00204 stpsv_(uplo, "No transpose", "Non-unit", &i__2, &bp[k1k1],
00205 &ap[kk + 1], &c__1);
00206 }
00207 kk = k1k1;
00208
00209 }
00210 }
00211 } else {
00212 if (upper) {
00213
00214
00215
00216
00217
00218 kk = 0;
00219 i__1 = *n;
00220 for (k = 1; k <= i__1; ++k) {
00221 k1 = kk + 1;
00222 kk += k;
00223
00224
00225
00226 akk = ap[kk];
00227 bkk = bp[kk];
00228 i__2 = k - 1;
00229 stpmv_(uplo, "No transpose", "Non-unit", &i__2, &bp[1], &ap[
00230 k1], &c__1);
00231 ct = akk * .5f;
00232 i__2 = k - 1;
00233 saxpy_(&i__2, &ct, &bp[k1], &c__1, &ap[k1], &c__1);
00234 i__2 = k - 1;
00235 sspr2_(uplo, &i__2, &c_b11, &ap[k1], &c__1, &bp[k1], &c__1, &
00236 ap[1]);
00237 i__2 = k - 1;
00238 saxpy_(&i__2, &ct, &bp[k1], &c__1, &ap[k1], &c__1);
00239 i__2 = k - 1;
00240 sscal_(&i__2, &bkk, &ap[k1], &c__1);
00241
00242 r__1 = bkk;
00243 ap[kk] = akk * (r__1 * r__1);
00244
00245 }
00246 } else {
00247
00248
00249
00250
00251
00252 jj = 1;
00253 i__1 = *n;
00254 for (j = 1; j <= i__1; ++j) {
00255 j1j1 = jj + *n - j + 1;
00256
00257
00258
00259 ajj = ap[jj];
00260 bjj = bp[jj];
00261 i__2 = *n - j;
00262 ap[jj] = ajj * bjj + sdot_(&i__2, &ap[jj + 1], &c__1, &bp[jj
00263 + 1], &c__1);
00264 i__2 = *n - j;
00265 sscal_(&i__2, &bjj, &ap[jj + 1], &c__1);
00266 i__2 = *n - j;
00267 sspmv_(uplo, &i__2, &c_b11, &ap[j1j1], &bp[jj + 1], &c__1, &
00268 c_b11, &ap[jj + 1], &c__1);
00269 i__2 = *n - j + 1;
00270 stpmv_(uplo, "Transpose", "Non-unit", &i__2, &bp[jj], &ap[jj],
00271 &c__1);
00272 jj = j1j1;
00273
00274 }
00275 }
00276 }
00277 return 0;
00278
00279
00280
00281 }