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


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