spot05.c
Go to the documentation of this file.
00001 /* spot05.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 spot05_(char *uplo, integer *n, integer *nrhs, real *a, 
00021         integer *lda, real *b, integer *ldb, real *x, integer *ldx, real *
00022         xact, integer *ldxact, real *ferr, real *berr, real *reslts)
00023 {
00024     /* System generated locals */
00025     integer a_dim1, a_offset, b_dim1, b_offset, x_dim1, x_offset, xact_dim1, 
00026             xact_offset, i__1, i__2, i__3;
00027     real r__1, r__2, r__3;
00028 
00029     /* Local variables */
00030     integer i__, j, k;
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 /*  SPOT05 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 n by n matrix. */
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 /*  A       (input) REAL array, dimension (LDA,N) */
00085 /*          The symmetric matrix A.  If UPLO = 'U', the leading n by n */
00086 /*          upper triangular part of A contains the upper triangular part */
00087 /*          of the matrix A, and the strictly lower triangular part of A */
00088 /*          is not referenced.  If UPLO = 'L', the leading n by n lower */
00089 /*          triangular part of A contains the lower triangular part of */
00090 /*          the matrix A, and the strictly upper triangular part of A is */
00091 /*          not referenced. */
00092 
00093 /*  LDA     (input) INTEGER */
00094 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00095 
00096 /*  B       (input) REAL array, dimension (LDB,NRHS) */
00097 /*          The right hand side vectors for the system of linear */
00098 /*          equations. */
00099 
00100 /*  LDB     (input) INTEGER */
00101 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00102 
00103 /*  X       (input) REAL array, dimension (LDX,NRHS) */
00104 /*          The computed solution vectors.  Each vector is stored as a */
00105 /*          column of the matrix X. */
00106 
00107 /*  LDX     (input) INTEGER */
00108 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00109 
00110 /*  XACT    (input) REAL array, dimension (LDX,NRHS) */
00111 /*          The exact solution vectors.  Each vector is stored as a */
00112 /*          column of the matrix XACT. */
00113 
00114 /*  LDXACT  (input) INTEGER */
00115 /*          The leading dimension of the array XACT.  LDXACT >= max(1,N). */
00116 
00117 /*  FERR    (input) REAL array, dimension (NRHS) */
00118 /*          The estimated forward error bounds for each solution vector */
00119 /*          X.  If XTRUE is the true solution, FERR bounds the magnitude */
00120 /*          of the largest entry in (X - XTRUE) divided by the magnitude */
00121 /*          of the largest entry in X. */
00122 
00123 /*  BERR    (input) REAL array, dimension (NRHS) */
00124 /*          The componentwise relative backward error of each solution */
00125 /*          vector (i.e., the smallest relative change in any entry of A */
00126 /*          or B that makes X an exact solution). */
00127 
00128 /*  RESLTS  (output) REAL array, dimension (2) */
00129 /*          The maximum over the NRHS solution vectors of the ratios: */
00130 /*          RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR ) */
00131 /*          RESLTS(2) = BERR / ( (n+1)*EPS + (*) ) */
00132 
00133 /*  ===================================================================== */
00134 
00135 /*     .. Parameters .. */
00136 /*     .. */
00137 /*     .. Local Scalars .. */
00138 /*     .. */
00139 /*     .. External Functions .. */
00140 /*     .. */
00141 /*     .. Intrinsic Functions .. */
00142 /*     .. */
00143 /*     .. Executable Statements .. */
00144 
00145 /*     Quick exit if N = 0 or NRHS = 0. */
00146 
00147     /* Parameter adjustments */
00148     a_dim1 = *lda;
00149     a_offset = 1 + a_dim1;
00150     a -= a_offset;
00151     b_dim1 = *ldb;
00152     b_offset = 1 + b_dim1;
00153     b -= b_offset;
00154     x_dim1 = *ldx;
00155     x_offset = 1 + x_dim1;
00156     x -= x_offset;
00157     xact_dim1 = *ldxact;
00158     xact_offset = 1 + xact_dim1;
00159     xact -= xact_offset;
00160     --ferr;
00161     --berr;
00162     --reslts;
00163 
00164     /* Function Body */
00165     if (*n <= 0 || *nrhs <= 0) {
00166         reslts[1] = 0.f;
00167         reslts[2] = 0.f;
00168         return 0;
00169     }
00170 
00171     eps = slamch_("Epsilon");
00172     unfl = slamch_("Safe minimum");
00173     ovfl = 1.f / unfl;
00174     upper = lsame_(uplo, "U");
00175 
00176 /*     Test 1:  Compute the maximum of */
00177 /*        norm(X - XACT) / ( norm(X) * FERR ) */
00178 /*     over all the vectors X and XACT using the infinity-norm. */
00179 
00180     errbnd = 0.f;
00181     i__1 = *nrhs;
00182     for (j = 1; j <= i__1; ++j) {
00183         imax = isamax_(n, &x[j * x_dim1 + 1], &c__1);
00184 /* Computing MAX */
00185         r__2 = (r__1 = x[imax + j * x_dim1], dabs(r__1));
00186         xnorm = dmax(r__2,unfl);
00187         diff = 0.f;
00188         i__2 = *n;
00189         for (i__ = 1; i__ <= i__2; ++i__) {
00190 /* Computing MAX */
00191             r__2 = diff, r__3 = (r__1 = x[i__ + j * x_dim1] - xact[i__ + j * 
00192                     xact_dim1], dabs(r__1));
00193             diff = dmax(r__2,r__3);
00194 /* L10: */
00195         }
00196 
00197         if (xnorm > 1.f) {
00198             goto L20;
00199         } else if (diff <= ovfl * xnorm) {
00200             goto L20;
00201         } else {
00202             errbnd = 1.f / eps;
00203             goto L30;
00204         }
00205 
00206 L20:
00207         if (diff / xnorm <= ferr[j]) {
00208 /* Computing MAX */
00209             r__1 = errbnd, r__2 = diff / xnorm / ferr[j];
00210             errbnd = dmax(r__1,r__2);
00211         } else {
00212             errbnd = 1.f / eps;
00213         }
00214 L30:
00215         ;
00216     }
00217     reslts[1] = errbnd;
00218 
00219 /*     Test 2:  Compute the maximum of BERR / ( (n+1)*EPS + (*) ), where */
00220 /*     (*) = (n+1)*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i ) */
00221 
00222     i__1 = *nrhs;
00223     for (k = 1; k <= i__1; ++k) {
00224         i__2 = *n;
00225         for (i__ = 1; i__ <= i__2; ++i__) {
00226             tmp = (r__1 = b[i__ + k * b_dim1], dabs(r__1));
00227             if (upper) {
00228                 i__3 = i__;
00229                 for (j = 1; j <= i__3; ++j) {
00230                     tmp += (r__1 = a[j + i__ * a_dim1], dabs(r__1)) * (r__2 = 
00231                             x[j + k * x_dim1], dabs(r__2));
00232 /* L40: */
00233                 }
00234                 i__3 = *n;
00235                 for (j = i__ + 1; j <= i__3; ++j) {
00236                     tmp += (r__1 = a[i__ + j * a_dim1], dabs(r__1)) * (r__2 = 
00237                             x[j + k * x_dim1], dabs(r__2));
00238 /* L50: */
00239                 }
00240             } else {
00241                 i__3 = i__ - 1;
00242                 for (j = 1; j <= i__3; ++j) {
00243                     tmp += (r__1 = a[i__ + j * a_dim1], dabs(r__1)) * (r__2 = 
00244                             x[j + k * x_dim1], dabs(r__2));
00245 /* L60: */
00246                 }
00247                 i__3 = *n;
00248                 for (j = i__; j <= i__3; ++j) {
00249                     tmp += (r__1 = a[j + i__ * a_dim1], dabs(r__1)) * (r__2 = 
00250                             x[j + k * x_dim1], dabs(r__2));
00251 /* L70: */
00252                 }
00253             }
00254             if (i__ == 1) {
00255                 axbi = tmp;
00256             } else {
00257                 axbi = dmin(axbi,tmp);
00258             }
00259 /* L80: */
00260         }
00261 /* Computing MAX */
00262         r__1 = axbi, r__2 = (*n + 1) * unfl;
00263         tmp = berr[k] / ((*n + 1) * eps + (*n + 1) * unfl / dmax(r__1,r__2));
00264         if (k == 1) {
00265             reslts[2] = tmp;
00266         } else {
00267             reslts[2] = dmax(reslts[2],tmp);
00268         }
00269 /* L90: */
00270     }
00271 
00272     return 0;
00273 
00274 /*     End of SPOT05 */
00275 
00276 } /* spot05_ */


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