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


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