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


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