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