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


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