sptt05.c
Go to the documentation of this file.
00001 /* sptt05.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static integer c__1 = 1;
00019 
00020 /* Subroutine */ int sptt05_(integer *n, integer *nrhs, real *d__, real *e, 
00021         real *b, integer *ldb, real *x, integer *ldx, real *xact, integer *
00022         ldxact, real *ferr, real *berr, real *reslts)
00023 {
00024     /* System generated locals */
00025     integer b_dim1, b_offset, x_dim1, x_offset, xact_dim1, xact_offset, i__1, 
00026             i__2;
00027     real r__1, r__2, r__3, r__4;
00028 
00029     /* Local variables */
00030     integer i__, j, k, nz;
00031     real eps, tmp, diff, axbi;
00032     integer imax;
00033     real unfl, ovfl, xnorm;
00034     extern doublereal slamch_(char *);
00035     real errbnd;
00036     extern integer isamax_(integer *, real *, integer *);
00037 
00038 
00039 /*  -- LAPACK test routine (version 3.1) -- */
00040 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00041 /*     November 2006 */
00042 
00043 /*     .. Scalar Arguments .. */
00044 /*     .. */
00045 /*     .. Array Arguments .. */
00046 /*     .. */
00047 
00048 /*  Purpose */
00049 /*  ======= */
00050 
00051 /*  SPTT05 tests the error bounds from iterative refinement for the */
00052 /*  computed solution to a system of equations A*X = B, where A is a */
00053 /*  symmetric tridiagonal matrix of order n. */
00054 
00055 /*  RESLTS(1) = test of the error bound */
00056 /*            = norm(X - XACT) / ( norm(X) * FERR ) */
00057 
00058 /*  A large value is returned if this ratio is not less than one. */
00059 
00060 /*  RESLTS(2) = residual from the iterative refinement routine */
00061 /*            = the maximum of BERR / ( NZ*EPS + (*) ), where */
00062 /*              (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i ) */
00063 /*              and NZ = max. number of nonzeros in any row of A, plus 1 */
00064 
00065 /*  Arguments */
00066 /*  ========= */
00067 
00068 /*  N       (input) INTEGER */
00069 /*          The number of rows of the matrices X, B, and XACT, and the */
00070 /*          order of the matrix A.  N >= 0. */
00071 
00072 /*  NRHS    (input) INTEGER */
00073 /*          The number of columns of the matrices X, B, and XACT. */
00074 /*          NRHS >= 0. */
00075 
00076 /*  D       (input) REAL array, dimension (N) */
00077 /*          The n diagonal elements of the tridiagonal matrix A. */
00078 
00079 /*  E       (input) REAL array, dimension (N-1) */
00080 /*          The (n-1) subdiagonal elements of the tridiagonal matrix A. */
00081 
00082 /*  B       (input) REAL array, dimension (LDB,NRHS) */
00083 /*          The right hand side vectors for the system of linear */
00084 /*          equations. */
00085 
00086 /*  LDB     (input) INTEGER */
00087 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00088 
00089 /*  X       (input) REAL array, dimension (LDX,NRHS) */
00090 /*          The computed solution vectors.  Each vector is stored as a */
00091 /*          column of the matrix X. */
00092 
00093 /*  LDX     (input) INTEGER */
00094 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00095 
00096 /*  XACT    (input) REAL array, dimension (LDX,NRHS) */
00097 /*          The exact solution vectors.  Each vector is stored as a */
00098 /*          column of the matrix XACT. */
00099 
00100 /*  LDXACT  (input) INTEGER */
00101 /*          The leading dimension of the array XACT.  LDXACT >= max(1,N). */
00102 
00103 /*  FERR    (input) REAL array, dimension (NRHS) */
00104 /*          The estimated forward error bounds for each solution vector */
00105 /*          X.  If XTRUE is the true solution, FERR bounds the magnitude */
00106 /*          of the largest entry in (X - XTRUE) divided by the magnitude */
00107 /*          of the largest entry in X. */
00108 
00109 /*  BERR    (input) REAL array, dimension (NRHS) */
00110 /*          The componentwise relative backward error of each solution */
00111 /*          vector (i.e., the smallest relative change in any entry of A */
00112 /*          or B that makes X an exact solution). */
00113 
00114 /*  RESLTS  (output) REAL array, dimension (2) */
00115 /*          The maximum over the NRHS solution vectors of the ratios: */
00116 /*          RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR ) */
00117 /*          RESLTS(2) = BERR / ( NZ*EPS + (*) ) */
00118 
00119 /*  ===================================================================== */
00120 
00121 /*     .. Parameters .. */
00122 /*     .. */
00123 /*     .. Local Scalars .. */
00124 /*     .. */
00125 /*     .. External Functions .. */
00126 /*     .. */
00127 /*     .. Intrinsic Functions .. */
00128 /*     .. */
00129 /*     .. Executable Statements .. */
00130 
00131 /*     Quick exit if N = 0 or NRHS = 0. */
00132 
00133     /* Parameter adjustments */
00134     --d__;
00135     --e;
00136     b_dim1 = *ldb;
00137     b_offset = 1 + b_dim1;
00138     b -= b_offset;
00139     x_dim1 = *ldx;
00140     x_offset = 1 + x_dim1;
00141     x -= x_offset;
00142     xact_dim1 = *ldxact;
00143     xact_offset = 1 + xact_dim1;
00144     xact -= xact_offset;
00145     --ferr;
00146     --berr;
00147     --reslts;
00148 
00149     /* Function Body */
00150     if (*n <= 0 || *nrhs <= 0) {
00151         reslts[1] = 0.f;
00152         reslts[2] = 0.f;
00153         return 0;
00154     }
00155 
00156     eps = slamch_("Epsilon");
00157     unfl = slamch_("Safe minimum");
00158     ovfl = 1.f / unfl;
00159     nz = 4;
00160 
00161 /*     Test 1:  Compute the maximum of */
00162 /*        norm(X - XACT) / ( norm(X) * FERR ) */
00163 /*     over all the vectors X and XACT using the infinity-norm. */
00164 
00165     errbnd = 0.f;
00166     i__1 = *nrhs;
00167     for (j = 1; j <= i__1; ++j) {
00168         imax = isamax_(n, &x[j * x_dim1 + 1], &c__1);
00169 /* Computing MAX */
00170         r__2 = (r__1 = x[imax + j * x_dim1], dabs(r__1));
00171         xnorm = dmax(r__2,unfl);
00172         diff = 0.f;
00173         i__2 = *n;
00174         for (i__ = 1; i__ <= i__2; ++i__) {
00175 /* Computing MAX */
00176             r__2 = diff, r__3 = (r__1 = x[i__ + j * x_dim1] - xact[i__ + j * 
00177                     xact_dim1], dabs(r__1));
00178             diff = dmax(r__2,r__3);
00179 /* L10: */
00180         }
00181 
00182         if (xnorm > 1.f) {
00183             goto L20;
00184         } else if (diff <= ovfl * xnorm) {
00185             goto L20;
00186         } else {
00187             errbnd = 1.f / eps;
00188             goto L30;
00189         }
00190 
00191 L20:
00192         if (diff / xnorm <= ferr[j]) {
00193 /* Computing MAX */
00194             r__1 = errbnd, r__2 = diff / xnorm / ferr[j];
00195             errbnd = dmax(r__1,r__2);
00196         } else {
00197             errbnd = 1.f / eps;
00198         }
00199 L30:
00200         ;
00201     }
00202     reslts[1] = errbnd;
00203 
00204 /*     Test 2:  Compute the maximum of BERR / ( NZ*EPS + (*) ), where */
00205 /*     (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i ) */
00206 
00207     i__1 = *nrhs;
00208     for (k = 1; k <= i__1; ++k) {
00209         if (*n == 1) {
00210             axbi = (r__1 = b[k * b_dim1 + 1], dabs(r__1)) + (r__2 = d__[1] * 
00211                     x[k * x_dim1 + 1], dabs(r__2));
00212         } else {
00213             axbi = (r__1 = b[k * b_dim1 + 1], dabs(r__1)) + (r__2 = d__[1] * 
00214                     x[k * x_dim1 + 1], dabs(r__2)) + (r__3 = e[1] * x[k * 
00215                     x_dim1 + 2], dabs(r__3));
00216             i__2 = *n - 1;
00217             for (i__ = 2; i__ <= i__2; ++i__) {
00218                 tmp = (r__1 = b[i__ + k * b_dim1], dabs(r__1)) + (r__2 = e[
00219                         i__ - 1] * x[i__ - 1 + k * x_dim1], dabs(r__2)) + (
00220                         r__3 = d__[i__] * x[i__ + k * x_dim1], dabs(r__3)) + (
00221                         r__4 = e[i__] * x[i__ + 1 + k * x_dim1], dabs(r__4));
00222                 axbi = dmin(axbi,tmp);
00223 /* L40: */
00224             }
00225             tmp = (r__1 = b[*n + k * b_dim1], dabs(r__1)) + (r__2 = e[*n - 1] 
00226                     * x[*n - 1 + k * x_dim1], dabs(r__2)) + (r__3 = d__[*n] * 
00227                     x[*n + k * x_dim1], dabs(r__3));
00228             axbi = dmin(axbi,tmp);
00229         }
00230 /* Computing MAX */
00231         r__1 = axbi, r__2 = nz * unfl;
00232         tmp = berr[k] / (nz * eps + nz * unfl / dmax(r__1,r__2));
00233         if (k == 1) {
00234             reslts[2] = tmp;
00235         } else {
00236             reslts[2] = dmax(reslts[2],tmp);
00237         }
00238 /* L50: */
00239     }
00240 
00241     return 0;
00242 
00243 /*     End of SPTT05 */
00244 
00245 } /* sptt05_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:13