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


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