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


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