zptt05.c
Go to the documentation of this file.
00001 /* zptt05.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 zptt05_(integer *n, integer *nrhs, doublereal *d__, 
00021         doublecomplex *e, doublecomplex *b, integer *ldb, doublecomplex *x, 
00022         integer *ldx, doublecomplex *xact, integer *ldxact, doublereal *ferr, 
00023         doublereal *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, i__4, i__5, i__6, i__7, i__8, i__9;
00028     doublereal d__1, d__2, d__3, d__4, d__5, d__6, d__7, d__8, d__9, d__10, 
00029             d__11, d__12;
00030     doublecomplex z__1, z__2;
00031 
00032     /* Builtin functions */
00033     double d_imag(doublecomplex *);
00034 
00035     /* Local variables */
00036     integer i__, j, k, nz;
00037     doublereal eps, tmp, diff, axbi;
00038     integer imax;
00039     doublereal unfl, ovfl, xnorm;
00040     extern doublereal dlamch_(char *);
00041     doublereal errbnd;
00042     extern integer izamax_(integer *, doublecomplex *, integer *);
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 /*  ZPTT05 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 /*  Hermitian tridiagonal matrix of order n. */
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 / ( NZ*EPS + (*) ), where */
00068 /*              (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i ) */
00069 /*              and NZ = max. number of nonzeros in any row of A, plus 1 */
00070 
00071 /*  Arguments */
00072 /*  ========= */
00073 
00074 /*  N       (input) INTEGER */
00075 /*          The number of rows of the matrices X, B, and XACT, and the */
00076 /*          order of the matrix A.  N >= 0. */
00077 
00078 /*  NRHS    (input) INTEGER */
00079 /*          The number of columns of the matrices X, B, and XACT. */
00080 /*          NRHS >= 0. */
00081 
00082 /*  D       (input) DOUBLE PRECISION array, dimension (N) */
00083 /*          The n diagonal elements of the tridiagonal matrix A. */
00084 
00085 /*  E       (input) COMPLEX*16 array, dimension (N-1) */
00086 /*          The (n-1) subdiagonal elements of the tridiagonal matrix A. */
00087 
00088 /*  B       (input) COMPLEX*16 array, dimension (LDB,NRHS) */
00089 /*          The right hand side vectors for the system of linear */
00090 /*          equations. */
00091 
00092 /*  LDB     (input) INTEGER */
00093 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00094 
00095 /*  X       (input) COMPLEX*16 array, dimension (LDX,NRHS) */
00096 /*          The computed solution vectors.  Each vector is stored as a */
00097 /*          column of the matrix X. */
00098 
00099 /*  LDX     (input) INTEGER */
00100 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00101 
00102 /*  XACT    (input) COMPLEX*16 array, dimension (LDX,NRHS) */
00103 /*          The exact solution vectors.  Each vector is stored as a */
00104 /*          column of the matrix XACT. */
00105 
00106 /*  LDXACT  (input) INTEGER */
00107 /*          The leading dimension of the array XACT.  LDXACT >= max(1,N). */
00108 
00109 /*  FERR    (input) DOUBLE PRECISION array, dimension (NRHS) */
00110 /*          The estimated forward error bounds for each solution vector */
00111 /*          X.  If XTRUE is the true solution, FERR bounds the magnitude */
00112 /*          of the largest entry in (X - XTRUE) divided by the magnitude */
00113 /*          of the largest entry in X. */
00114 
00115 /*  BERR    (input) DOUBLE PRECISION array, dimension (NRHS) */
00116 /*          The componentwise relative backward error of each solution */
00117 /*          vector (i.e., the smallest relative change in any entry of A */
00118 /*          or B that makes X an exact solution). */
00119 
00120 /*  RESLTS  (output) DOUBLE PRECISION array, dimension (2) */
00121 /*          The maximum over the NRHS solution vectors of the ratios: */
00122 /*          RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR ) */
00123 /*          RESLTS(2) = BERR / ( NZ*EPS + (*) ) */
00124 
00125 /*  ===================================================================== */
00126 
00127 /*     .. Parameters .. */
00128 /*     .. */
00129 /*     .. Local Scalars .. */
00130 /*     .. */
00131 /*     .. External Functions .. */
00132 /*     .. */
00133 /*     .. Intrinsic Functions .. */
00134 /*     .. */
00135 /*     .. Statement Functions .. */
00136 /*     .. */
00137 /*     .. Statement Function definitions .. */
00138 /*     .. */
00139 /*     .. Executable Statements .. */
00140 
00141 /*     Quick exit if N = 0 or NRHS = 0. */
00142 
00143     /* Parameter adjustments */
00144     --d__;
00145     --e;
00146     b_dim1 = *ldb;
00147     b_offset = 1 + b_dim1;
00148     b -= b_offset;
00149     x_dim1 = *ldx;
00150     x_offset = 1 + x_dim1;
00151     x -= x_offset;
00152     xact_dim1 = *ldxact;
00153     xact_offset = 1 + xact_dim1;
00154     xact -= xact_offset;
00155     --ferr;
00156     --berr;
00157     --reslts;
00158 
00159     /* Function Body */
00160     if (*n <= 0 || *nrhs <= 0) {
00161         reslts[1] = 0.;
00162         reslts[2] = 0.;
00163         return 0;
00164     }
00165 
00166     eps = dlamch_("Epsilon");
00167     unfl = dlamch_("Safe minimum");
00168     ovfl = 1. / unfl;
00169     nz = 4;
00170 
00171 /*     Test 1:  Compute the maximum of */
00172 /*        norm(X - XACT) / ( norm(X) * FERR ) */
00173 /*     over all the vectors X and XACT using the infinity-norm. */
00174 
00175     errbnd = 0.;
00176     i__1 = *nrhs;
00177     for (j = 1; j <= i__1; ++j) {
00178         imax = izamax_(n, &x[j * x_dim1 + 1], &c__1);
00179 /* Computing MAX */
00180         i__2 = imax + j * x_dim1;
00181         d__3 = (d__1 = x[i__2].r, abs(d__1)) + (d__2 = d_imag(&x[imax + j * 
00182                 x_dim1]), abs(d__2));
00183         xnorm = max(d__3,unfl);
00184         diff = 0.;
00185         i__2 = *n;
00186         for (i__ = 1; i__ <= i__2; ++i__) {
00187             i__3 = i__ + j * x_dim1;
00188             i__4 = i__ + j * xact_dim1;
00189             z__2.r = x[i__3].r - xact[i__4].r, z__2.i = x[i__3].i - xact[i__4]
00190                     .i;
00191             z__1.r = z__2.r, z__1.i = z__2.i;
00192 /* Computing MAX */
00193             d__3 = diff, d__4 = (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&
00194                     z__1), abs(d__2));
00195             diff = max(d__3,d__4);
00196 /* L10: */
00197         }
00198 
00199         if (xnorm > 1.) {
00200             goto L20;
00201         } else if (diff <= ovfl * xnorm) {
00202             goto L20;
00203         } else {
00204             errbnd = 1. / eps;
00205             goto L30;
00206         }
00207 
00208 L20:
00209         if (diff / xnorm <= ferr[j]) {
00210 /* Computing MAX */
00211             d__1 = errbnd, d__2 = diff / xnorm / ferr[j];
00212             errbnd = max(d__1,d__2);
00213         } else {
00214             errbnd = 1. / eps;
00215         }
00216 L30:
00217         ;
00218     }
00219     reslts[1] = errbnd;
00220 
00221 /*     Test 2:  Compute the maximum of BERR / ( NZ*EPS + (*) ), where */
00222 /*     (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i ) */
00223 
00224     i__1 = *nrhs;
00225     for (k = 1; k <= i__1; ++k) {
00226         if (*n == 1) {
00227             i__2 = k * x_dim1 + 1;
00228             z__2.r = d__[1] * x[i__2].r, z__2.i = d__[1] * x[i__2].i;
00229             z__1.r = z__2.r, z__1.i = z__2.i;
00230             i__3 = k * b_dim1 + 1;
00231             axbi = (d__1 = b[i__3].r, abs(d__1)) + (d__2 = d_imag(&b[k * 
00232                     b_dim1 + 1]), abs(d__2)) + ((d__3 = z__1.r, abs(d__3)) + (
00233                     d__4 = d_imag(&z__1), abs(d__4)));
00234         } else {
00235             i__2 = k * x_dim1 + 1;
00236             z__2.r = d__[1] * x[i__2].r, z__2.i = d__[1] * x[i__2].i;
00237             z__1.r = z__2.r, z__1.i = z__2.i;
00238             i__3 = k * b_dim1 + 1;
00239             i__4 = k * x_dim1 + 2;
00240             axbi = (d__1 = b[i__3].r, abs(d__1)) + (d__2 = d_imag(&b[k * 
00241                     b_dim1 + 1]), abs(d__2)) + ((d__3 = z__1.r, abs(d__3)) + (
00242                     d__4 = d_imag(&z__1), abs(d__4))) + ((d__5 = e[1].r, abs(
00243                     d__5)) + (d__6 = d_imag(&e[1]), abs(d__6))) * ((d__7 = x[
00244                     i__4].r, abs(d__7)) + (d__8 = d_imag(&x[k * x_dim1 + 2]), 
00245                     abs(d__8)));
00246             i__2 = *n - 1;
00247             for (i__ = 2; i__ <= i__2; ++i__) {
00248                 i__3 = i__;
00249                 i__4 = i__ + k * x_dim1;
00250                 z__2.r = d__[i__3] * x[i__4].r, z__2.i = d__[i__3] * x[i__4]
00251                         .i;
00252                 z__1.r = z__2.r, z__1.i = z__2.i;
00253                 i__5 = i__ + k * b_dim1;
00254                 i__6 = i__ - 1;
00255                 i__7 = i__ - 1 + k * x_dim1;
00256                 i__8 = i__;
00257                 i__9 = i__ + 1 + k * x_dim1;
00258                 tmp = (d__1 = b[i__5].r, abs(d__1)) + (d__2 = d_imag(&b[i__ + 
00259                         k * b_dim1]), abs(d__2)) + ((d__3 = e[i__6].r, abs(
00260                         d__3)) + (d__4 = d_imag(&e[i__ - 1]), abs(d__4))) * ((
00261                         d__5 = x[i__7].r, abs(d__5)) + (d__6 = d_imag(&x[i__ 
00262                         - 1 + k * x_dim1]), abs(d__6))) + ((d__7 = z__1.r, 
00263                         abs(d__7)) + (d__8 = d_imag(&z__1), abs(d__8))) + ((
00264                         d__9 = e[i__8].r, abs(d__9)) + (d__10 = d_imag(&e[i__]
00265                         ), abs(d__10))) * ((d__11 = x[i__9].r, abs(d__11)) + (
00266                         d__12 = d_imag(&x[i__ + 1 + k * x_dim1]), abs(d__12)))
00267                         ;
00268                 axbi = min(axbi,tmp);
00269 /* L40: */
00270             }
00271             i__2 = *n;
00272             i__3 = *n + k * x_dim1;
00273             z__2.r = d__[i__2] * x[i__3].r, z__2.i = d__[i__2] * x[i__3].i;
00274             z__1.r = z__2.r, z__1.i = z__2.i;
00275             i__4 = *n + k * b_dim1;
00276             i__5 = *n - 1;
00277             i__6 = *n - 1 + k * x_dim1;
00278             tmp = (d__1 = b[i__4].r, abs(d__1)) + (d__2 = d_imag(&b[*n + k * 
00279                     b_dim1]), abs(d__2)) + ((d__3 = e[i__5].r, abs(d__3)) + (
00280                     d__4 = d_imag(&e[*n - 1]), abs(d__4))) * ((d__5 = x[i__6]
00281                     .r, abs(d__5)) + (d__6 = d_imag(&x[*n - 1 + k * x_dim1]), 
00282                     abs(d__6))) + ((d__7 = z__1.r, abs(d__7)) + (d__8 = 
00283                     d_imag(&z__1), abs(d__8)));
00284             axbi = min(axbi,tmp);
00285         }
00286 /* Computing MAX */
00287         d__1 = axbi, d__2 = nz * unfl;
00288         tmp = berr[k] / (nz * eps + nz * unfl / max(d__1,d__2));
00289         if (k == 1) {
00290             reslts[2] = tmp;
00291         } else {
00292             reslts[2] = max(reslts[2],tmp);
00293         }
00294 /* L50: */
00295     }
00296 
00297     return 0;
00298 
00299 /*     End of ZPTT05 */
00300 
00301 } /* zptt05_ */


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