dgtt05.c
Go to the documentation of this file.
00001 /* dgtt05.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 dgtt05_(char *trans, integer *n, integer *nrhs, 
00021         doublereal *dl, doublereal *d__, doublereal *du, doublereal *b, 
00022         integer *ldb, doublereal *x, integer *ldx, doublereal *xact, integer *
00023         ldxact, doublereal *ferr, doublereal *berr, doublereal *reslts)
00024 {
00025     /* System generated locals */
00026     integer b_dim1, b_offset, x_dim1, x_offset, xact_dim1, xact_offset, i__1, 
00027             i__2;
00028     doublereal d__1, d__2, d__3, d__4;
00029 
00030     /* Local variables */
00031     integer i__, j, k, nz;
00032     doublereal eps, tmp, diff, axbi;
00033     integer imax;
00034     doublereal unfl, ovfl;
00035     extern logical lsame_(char *, char *);
00036     doublereal xnorm;
00037     extern doublereal dlamch_(char *);
00038     extern integer idamax_(integer *, doublereal *, integer *);
00039     doublereal errbnd;
00040     logical notran;
00041 
00042 
00043 /*  -- LAPACK test routine (version 3.1) -- */
00044 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00045 /*     November 2006 */
00046 
00047 /*     .. Scalar Arguments .. */
00048 /*     .. */
00049 /*     .. Array Arguments .. */
00050 /*     .. */
00051 
00052 /*  Purpose */
00053 /*  ======= */
00054 
00055 /*  DGTT05 tests the error bounds from iterative refinement for the */
00056 /*  computed solution to a system of equations A*X = B, where A is a */
00057 /*  general tridiagonal matrix of order n and op(A) = A or A**T, */
00058 /*  depending on TRANS. */
00059 
00060 /*  RESLTS(1) = test of the error bound */
00061 /*            = norm(X - XACT) / ( norm(X) * FERR ) */
00062 
00063 /*  A large value is returned if this ratio is not less than one. */
00064 
00065 /*  RESLTS(2) = residual from the iterative refinement routine */
00066 /*            = the maximum of BERR / ( NZ*EPS + (*) ), where */
00067 /*              (*) = NZ*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i ) */
00068 /*              and NZ = max. number of nonzeros in any row of A, plus 1 */
00069 
00070 /*  Arguments */
00071 /*  ========= */
00072 
00073 /*  TRANS   (input) CHARACTER*1 */
00074 /*          Specifies the form of the system of equations. */
00075 /*          = 'N':  A * X = B     (No transpose) */
00076 /*          = 'T':  A**T * X = B  (Transpose) */
00077 /*          = 'C':  A**H * X = B  (Conjugate transpose = Transpose) */
00078 
00079 /*  N       (input) INTEGER */
00080 /*          The number of rows of the matrices X and XACT.  N >= 0. */
00081 
00082 /*  NRHS    (input) INTEGER */
00083 /*          The number of columns of the matrices X and XACT.  NRHS >= 0. */
00084 
00085 /*  DL      (input) DOUBLE PRECISION array, dimension (N-1) */
00086 /*          The (n-1) sub-diagonal elements of A. */
00087 
00088 /*  D       (input) DOUBLE PRECISION array, dimension (N) */
00089 /*          The diagonal elements of A. */
00090 
00091 /*  DU      (input) DOUBLE PRECISION array, dimension (N-1) */
00092 /*          The (n-1) super-diagonal elements of A. */
00093 
00094 /*  B       (input) DOUBLE PRECISION array, dimension (LDB,NRHS) */
00095 /*          The right hand side vectors for the system of linear */
00096 /*          equations. */
00097 
00098 /*  LDB     (input) INTEGER */
00099 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00100 
00101 /*  X       (input) DOUBLE PRECISION array, dimension (LDX,NRHS) */
00102 /*          The computed solution vectors.  Each vector is stored as a */
00103 /*          column of the matrix X. */
00104 
00105 /*  LDX     (input) INTEGER */
00106 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00107 
00108 /*  XACT    (input) DOUBLE PRECISION array, dimension (LDX,NRHS) */
00109 /*          The exact solution vectors.  Each vector is stored as a */
00110 /*          column of the matrix XACT. */
00111 
00112 /*  LDXACT  (input) INTEGER */
00113 /*          The leading dimension of the array XACT.  LDXACT >= max(1,N). */
00114 
00115 /*  FERR    (input) DOUBLE PRECISION array, dimension (NRHS) */
00116 /*          The estimated forward error bounds for each solution vector */
00117 /*          X.  If XTRUE is the true solution, FERR bounds the magnitude */
00118 /*          of the largest entry in (X - XTRUE) divided by the magnitude */
00119 /*          of the largest entry in X. */
00120 
00121 /*  BERR    (input) DOUBLE PRECISION array, dimension (NRHS) */
00122 /*          The componentwise relative backward error of each solution */
00123 /*          vector (i.e., the smallest relative change in any entry of A */
00124 /*          or B that makes X an exact solution). */
00125 
00126 /*  RESLTS  (output) DOUBLE PRECISION array, dimension (2) */
00127 /*          The maximum over the NRHS solution vectors of the ratios: */
00128 /*          RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR ) */
00129 /*          RESLTS(2) = BERR / ( NZ*EPS + (*) ) */
00130 
00131 /*  ===================================================================== */
00132 
00133 /*     .. Parameters .. */
00134 /*     .. */
00135 /*     .. Local Scalars .. */
00136 /*     .. */
00137 /*     .. External Functions .. */
00138 /*     .. */
00139 /*     .. Intrinsic Functions .. */
00140 /*     .. */
00141 /*     .. Executable Statements .. */
00142 
00143 /*     Quick exit if N = 0 or NRHS = 0. */
00144 
00145     /* Parameter adjustments */
00146     --dl;
00147     --d__;
00148     --du;
00149     b_dim1 = *ldb;
00150     b_offset = 1 + b_dim1;
00151     b -= b_offset;
00152     x_dim1 = *ldx;
00153     x_offset = 1 + x_dim1;
00154     x -= x_offset;
00155     xact_dim1 = *ldxact;
00156     xact_offset = 1 + xact_dim1;
00157     xact -= xact_offset;
00158     --ferr;
00159     --berr;
00160     --reslts;
00161 
00162     /* Function Body */
00163     if (*n <= 0 || *nrhs <= 0) {
00164         reslts[1] = 0.;
00165         reslts[2] = 0.;
00166         return 0;
00167     }
00168 
00169     eps = dlamch_("Epsilon");
00170     unfl = dlamch_("Safe minimum");
00171     ovfl = 1. / unfl;
00172     notran = lsame_(trans, "N");
00173     nz = 4;
00174 
00175 /*     Test 1:  Compute the maximum of */
00176 /*        norm(X - XACT) / ( norm(X) * FERR ) */
00177 /*     over all the vectors X and XACT using the infinity-norm. */
00178 
00179     errbnd = 0.;
00180     i__1 = *nrhs;
00181     for (j = 1; j <= i__1; ++j) {
00182         imax = idamax_(n, &x[j * x_dim1 + 1], &c__1);
00183 /* Computing MAX */
00184         d__2 = (d__1 = x[imax + j * x_dim1], abs(d__1));
00185         xnorm = max(d__2,unfl);
00186         diff = 0.;
00187         i__2 = *n;
00188         for (i__ = 1; i__ <= i__2; ++i__) {
00189 /* Computing MAX */
00190             d__2 = diff, d__3 = (d__1 = x[i__ + j * x_dim1] - xact[i__ + j * 
00191                     xact_dim1], abs(d__1));
00192             diff = max(d__2,d__3);
00193 /* L10: */
00194         }
00195 
00196         if (xnorm > 1.) {
00197             goto L20;
00198         } else if (diff <= ovfl * xnorm) {
00199             goto L20;
00200         } else {
00201             errbnd = 1. / eps;
00202             goto L30;
00203         }
00204 
00205 L20:
00206         if (diff / xnorm <= ferr[j]) {
00207 /* Computing MAX */
00208             d__1 = errbnd, d__2 = diff / xnorm / ferr[j];
00209             errbnd = max(d__1,d__2);
00210         } else {
00211             errbnd = 1. / eps;
00212         }
00213 L30:
00214         ;
00215     }
00216     reslts[1] = errbnd;
00217 
00218 /*     Test 2:  Compute the maximum of BERR / ( NZ*EPS + (*) ), where */
00219 /*     (*) = NZ*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i ) */
00220 
00221     i__1 = *nrhs;
00222     for (k = 1; k <= i__1; ++k) {
00223         if (notran) {
00224             if (*n == 1) {
00225                 axbi = (d__1 = b[k * b_dim1 + 1], abs(d__1)) + (d__2 = d__[1] 
00226                         * x[k * x_dim1 + 1], abs(d__2));
00227             } else {
00228                 axbi = (d__1 = b[k * b_dim1 + 1], abs(d__1)) + (d__2 = d__[1] 
00229                         * x[k * x_dim1 + 1], abs(d__2)) + (d__3 = du[1] * x[k 
00230                         * x_dim1 + 2], abs(d__3));
00231                 i__2 = *n - 1;
00232                 for (i__ = 2; i__ <= i__2; ++i__) {
00233                     tmp = (d__1 = b[i__ + k * b_dim1], abs(d__1)) + (d__2 = 
00234                             dl[i__ - 1] * x[i__ - 1 + k * x_dim1], abs(d__2)) 
00235                             + (d__3 = d__[i__] * x[i__ + k * x_dim1], abs(
00236                             d__3)) + (d__4 = du[i__] * x[i__ + 1 + k * x_dim1]
00237                             , abs(d__4));
00238                     axbi = min(axbi,tmp);
00239 /* L40: */
00240                 }
00241                 tmp = (d__1 = b[*n + k * b_dim1], abs(d__1)) + (d__2 = dl[*n 
00242                         - 1] * x[*n - 1 + k * x_dim1], abs(d__2)) + (d__3 = 
00243                         d__[*n] * x[*n + k * x_dim1], abs(d__3));
00244                 axbi = min(axbi,tmp);
00245             }
00246         } else {
00247             if (*n == 1) {
00248                 axbi = (d__1 = b[k * b_dim1 + 1], abs(d__1)) + (d__2 = d__[1] 
00249                         * x[k * x_dim1 + 1], abs(d__2));
00250             } else {
00251                 axbi = (d__1 = b[k * b_dim1 + 1], abs(d__1)) + (d__2 = d__[1] 
00252                         * x[k * x_dim1 + 1], abs(d__2)) + (d__3 = dl[1] * x[k 
00253                         * x_dim1 + 2], abs(d__3));
00254                 i__2 = *n - 1;
00255                 for (i__ = 2; i__ <= i__2; ++i__) {
00256                     tmp = (d__1 = b[i__ + k * b_dim1], abs(d__1)) + (d__2 = 
00257                             du[i__ - 1] * x[i__ - 1 + k * x_dim1], abs(d__2)) 
00258                             + (d__3 = d__[i__] * x[i__ + k * x_dim1], abs(
00259                             d__3)) + (d__4 = dl[i__] * x[i__ + 1 + k * x_dim1]
00260                             , abs(d__4));
00261                     axbi = min(axbi,tmp);
00262 /* L50: */
00263                 }
00264                 tmp = (d__1 = b[*n + k * b_dim1], abs(d__1)) + (d__2 = du[*n 
00265                         - 1] * x[*n - 1 + k * x_dim1], abs(d__2)) + (d__3 = 
00266                         d__[*n] * x[*n + k * x_dim1], abs(d__3));
00267                 axbi = min(axbi,tmp);
00268             }
00269         }
00270 /* Computing MAX */
00271         d__1 = axbi, d__2 = nz * unfl;
00272         tmp = berr[k] / (nz * eps + nz * unfl / max(d__1,d__2));
00273         if (k == 1) {
00274             reslts[2] = tmp;
00275         } else {
00276             reslts[2] = max(reslts[2],tmp);
00277         }
00278 /* L60: */
00279     }
00280 
00281     return 0;
00282 
00283 /*     End of DGTT05 */
00284 
00285 } /* dgtt05_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:45