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