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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:28