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


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