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


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