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 doublereal c_b12 = -1.;
00020 static doublereal c_b14 = 1.;
00021
00022 int dsyrfs_(char *uplo, integer *n, integer *nrhs,
00023 doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *
00024 ipiv, doublereal *b, integer *ldb, doublereal *x, integer *ldx,
00025 doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork,
00026 integer *info)
00027 {
00028
00029 integer a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, x_dim1,
00030 x_offset, i__1, i__2, i__3;
00031 doublereal d__1, d__2, d__3;
00032
00033
00034 integer i__, j, k;
00035 doublereal s, xk;
00036 integer nz;
00037 doublereal eps;
00038 integer kase;
00039 doublereal safe1, safe2;
00040 extern logical lsame_(char *, char *);
00041 integer isave[3];
00042 extern int dcopy_(integer *, doublereal *, integer *,
00043 doublereal *, integer *), daxpy_(integer *, doublereal *,
00044 doublereal *, integer *, doublereal *, integer *);
00045 integer count;
00046 logical upper;
00047 extern int dsymv_(char *, integer *, doublereal *,
00048 doublereal *, integer *, doublereal *, integer *, doublereal *,
00049 doublereal *, integer *), dlacn2_(integer *, doublereal *,
00050 doublereal *, integer *, doublereal *, integer *, integer *);
00051 extern doublereal dlamch_(char *);
00052 doublereal safmin;
00053 extern int xerbla_(char *, integer *);
00054 doublereal lstres;
00055 extern int dsytrs_(char *, integer *, integer *,
00056 doublereal *, integer *, integer *, doublereal *, integer *,
00057 integer *);
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
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 a_dim1 = *lda;
00178 a_offset = 1 + a_dim1;
00179 a -= a_offset;
00180 af_dim1 = *ldaf;
00181 af_offset = 1 + af_dim1;
00182 af -= af_offset;
00183 --ipiv;
00184 b_dim1 = *ldb;
00185 b_offset = 1 + b_dim1;
00186 b -= b_offset;
00187 x_dim1 = *ldx;
00188 x_offset = 1 + x_dim1;
00189 x -= x_offset;
00190 --ferr;
00191 --berr;
00192 --work;
00193 --iwork;
00194
00195
00196 *info = 0;
00197 upper = lsame_(uplo, "U");
00198 if (! upper && ! lsame_(uplo, "L")) {
00199 *info = -1;
00200 } else if (*n < 0) {
00201 *info = -2;
00202 } else if (*nrhs < 0) {
00203 *info = -3;
00204 } else if (*lda < max(1,*n)) {
00205 *info = -5;
00206 } else if (*ldaf < max(1,*n)) {
00207 *info = -7;
00208 } else if (*ldb < max(1,*n)) {
00209 *info = -10;
00210 } else if (*ldx < max(1,*n)) {
00211 *info = -12;
00212 }
00213 if (*info != 0) {
00214 i__1 = -(*info);
00215 xerbla_("DSYRFS", &i__1);
00216 return 0;
00217 }
00218
00219
00220
00221 if (*n == 0 || *nrhs == 0) {
00222 i__1 = *nrhs;
00223 for (j = 1; j <= i__1; ++j) {
00224 ferr[j] = 0.;
00225 berr[j] = 0.;
00226
00227 }
00228 return 0;
00229 }
00230
00231
00232
00233 nz = *n + 1;
00234 eps = dlamch_("Epsilon");
00235 safmin = dlamch_("Safe minimum");
00236 safe1 = nz * safmin;
00237 safe2 = safe1 / eps;
00238
00239
00240
00241 i__1 = *nrhs;
00242 for (j = 1; j <= i__1; ++j) {
00243
00244 count = 1;
00245 lstres = 3.;
00246 L20:
00247
00248
00249
00250
00251
00252 dcopy_(n, &b[j * b_dim1 + 1], &c__1, &work[*n + 1], &c__1);
00253 dsymv_(uplo, n, &c_b12, &a[a_offset], lda, &x[j * x_dim1 + 1], &c__1,
00254 &c_b14, &work[*n + 1], &c__1);
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265 i__2 = *n;
00266 for (i__ = 1; i__ <= i__2; ++i__) {
00267 work[i__] = (d__1 = b[i__ + j * b_dim1], abs(d__1));
00268
00269 }
00270
00271
00272
00273 if (upper) {
00274 i__2 = *n;
00275 for (k = 1; k <= i__2; ++k) {
00276 s = 0.;
00277 xk = (d__1 = x[k + j * x_dim1], abs(d__1));
00278 i__3 = k - 1;
00279 for (i__ = 1; i__ <= i__3; ++i__) {
00280 work[i__] += (d__1 = a[i__ + k * a_dim1], abs(d__1)) * xk;
00281 s += (d__1 = a[i__ + k * a_dim1], abs(d__1)) * (d__2 = x[
00282 i__ + j * x_dim1], abs(d__2));
00283
00284 }
00285 work[k] = work[k] + (d__1 = a[k + k * a_dim1], abs(d__1)) *
00286 xk + s;
00287
00288 }
00289 } else {
00290 i__2 = *n;
00291 for (k = 1; k <= i__2; ++k) {
00292 s = 0.;
00293 xk = (d__1 = x[k + j * x_dim1], abs(d__1));
00294 work[k] += (d__1 = a[k + k * a_dim1], abs(d__1)) * xk;
00295 i__3 = *n;
00296 for (i__ = k + 1; i__ <= i__3; ++i__) {
00297 work[i__] += (d__1 = a[i__ + k * a_dim1], abs(d__1)) * xk;
00298 s += (d__1 = a[i__ + k * a_dim1], abs(d__1)) * (d__2 = x[
00299 i__ + j * x_dim1], abs(d__2));
00300
00301 }
00302 work[k] += s;
00303
00304 }
00305 }
00306 s = 0.;
00307 i__2 = *n;
00308 for (i__ = 1; i__ <= i__2; ++i__) {
00309 if (work[i__] > safe2) {
00310
00311 d__2 = s, d__3 = (d__1 = work[*n + i__], abs(d__1)) / work[
00312 i__];
00313 s = max(d__2,d__3);
00314 } else {
00315
00316 d__2 = s, d__3 = ((d__1 = work[*n + i__], abs(d__1)) + safe1)
00317 / (work[i__] + safe1);
00318 s = max(d__2,d__3);
00319 }
00320
00321 }
00322 berr[j] = s;
00323
00324
00325
00326
00327
00328
00329
00330 if (berr[j] > eps && berr[j] * 2. <= lstres && count <= 5) {
00331
00332
00333
00334 dsytrs_(uplo, n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[*n
00335 + 1], n, info);
00336 daxpy_(n, &c_b14, &work[*n + 1], &c__1, &x[j * x_dim1 + 1], &c__1)
00337 ;
00338 lstres = berr[j];
00339 ++count;
00340 goto L20;
00341 }
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365 i__2 = *n;
00366 for (i__ = 1; i__ <= i__2; ++i__) {
00367 if (work[i__] > safe2) {
00368 work[i__] = (d__1 = work[*n + i__], abs(d__1)) + nz * eps *
00369 work[i__];
00370 } else {
00371 work[i__] = (d__1 = work[*n + i__], abs(d__1)) + nz * eps *
00372 work[i__] + safe1;
00373 }
00374
00375 }
00376
00377 kase = 0;
00378 L100:
00379 dlacn2_(n, &work[(*n << 1) + 1], &work[*n + 1], &iwork[1], &ferr[j], &
00380 kase, isave);
00381 if (kase != 0) {
00382 if (kase == 1) {
00383
00384
00385
00386 dsytrs_(uplo, n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00387 *n + 1], n, info);
00388 i__2 = *n;
00389 for (i__ = 1; i__ <= i__2; ++i__) {
00390 work[*n + i__] = work[i__] * work[*n + i__];
00391
00392 }
00393 } else if (kase == 2) {
00394
00395
00396
00397 i__2 = *n;
00398 for (i__ = 1; i__ <= i__2; ++i__) {
00399 work[*n + i__] = work[i__] * work[*n + i__];
00400
00401 }
00402 dsytrs_(uplo, n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00403 *n + 1], n, info);
00404 }
00405 goto L100;
00406 }
00407
00408
00409
00410 lstres = 0.;
00411 i__2 = *n;
00412 for (i__ = 1; i__ <= i__2; ++i__) {
00413
00414 d__2 = lstres, d__3 = (d__1 = x[i__ + j * x_dim1], abs(d__1));
00415 lstres = max(d__2,d__3);
00416
00417 }
00418 if (lstres != 0.) {
00419 ferr[j] /= lstres;
00420 }
00421
00422
00423 }
00424
00425 return 0;
00426
00427
00428
00429 }