cgbt05.c
Go to the documentation of this file.
00001 /* cgbt05.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 cgbt05_(char *trans, integer *n, integer *kl, integer *
00021         ku, integer *nrhs, complex *ab, integer *ldab, complex *b, integer *
00022         ldb, complex *x, integer *ldx, complex *xact, integer *ldxact, real *
00023         ferr, real *berr, real *reslts)
00024 {
00025     /* System generated locals */
00026     integer ab_dim1, ab_offset, b_dim1, b_offset, x_dim1, x_offset, xact_dim1,
00027              xact_offset, i__1, i__2, i__3, i__4, i__5;
00028     real r__1, r__2, r__3, r__4;
00029     complex q__1, q__2;
00030 
00031     /* Builtin functions */
00032     double r_imag(complex *);
00033 
00034     /* Local variables */
00035     integer i__, j, k, nz;
00036     real eps, tmp, diff, axbi;
00037     integer imax;
00038     real unfl, ovfl;
00039     extern logical lsame_(char *, char *);
00040     real xnorm;
00041     extern integer icamax_(integer *, complex *, integer *);
00042     extern doublereal slamch_(char *);
00043     real errbnd;
00044     logical notran;
00045 
00046 
00047 /*  -- LAPACK test routine (version 3.1) -- */
00048 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00049 /*     November 2006 */
00050 
00051 /*     .. Scalar Arguments .. */
00052 /*     .. */
00053 /*     .. Array Arguments .. */
00054 /*     .. */
00055 
00056 /*  Purpose */
00057 /*  ======= */
00058 
00059 /*  CGBT05 tests the error bounds from iterative refinement for the */
00060 /*  computed solution to a system of equations op(A)*X = B, where A is a */
00061 /*  general band matrix of order n with kl subdiagonals and ku */
00062 /*  superdiagonals and op(A) = A or A**T, depending on TRANS. */
00063 
00064 /*  RESLTS(1) = test of the error bound */
00065 /*            = norm(X - XACT) / ( norm(X) * FERR ) */
00066 
00067 /*  A large value is returned if this ratio is not less than one. */
00068 
00069 /*  RESLTS(2) = residual from the iterative refinement routine */
00070 /*            = the maximum of BERR / ( NZ*EPS + (*) ), where */
00071 /*              (*) = NZ*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i ) */
00072 /*              and NZ = max. number of nonzeros in any row of A, plus 1 */
00073 
00074 /*  Arguments */
00075 /*  ========= */
00076 
00077 /*  TRANS   (input) CHARACTER*1 */
00078 /*          Specifies the form of the system of equations. */
00079 /*          = 'N':  A * X = B     (No transpose) */
00080 /*          = 'T':  A**T * X = B  (Transpose) */
00081 /*          = 'C':  A**H * X = B  (Conjugate transpose = Transpose) */
00082 
00083 /*  N       (input) INTEGER */
00084 /*          The number of rows of the matrices X, B, and XACT, and the */
00085 /*          order of the matrix A.  N >= 0. */
00086 
00087 /*  KL      (input) INTEGER */
00088 /*          The number of subdiagonals within the band of A.  KL >= 0. */
00089 
00090 /*  KU      (input) INTEGER */
00091 /*          The number of superdiagonals within the band of A.  KU >= 0. */
00092 
00093 /*  NRHS    (input) INTEGER */
00094 /*          The number of columns of the matrices X, B, and XACT. */
00095 /*          NRHS >= 0. */
00096 
00097 /*  AB      (input) COMPLEX array, dimension (LDAB,N) */
00098 /*          The original band matrix A, stored in rows 1 to KL+KU+1. */
00099 /*          The j-th column of A is stored in the j-th column of the */
00100 /*          array AB as follows: */
00101 /*          AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(n,j+kl). */
00102 
00103 /*  LDAB    (input) INTEGER */
00104 /*          The leading dimension of the array AB.  LDAB >= KL+KU+1. */
00105 
00106 /*  B       (input) COMPLEX array, dimension (LDB,NRHS) */
00107 /*          The right hand side vectors for the system of linear */
00108 /*          equations. */
00109 
00110 /*  LDB     (input) INTEGER */
00111 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00112 
00113 /*  X       (input) COMPLEX array, dimension (LDX,NRHS) */
00114 /*          The computed solution vectors.  Each vector is stored as a */
00115 /*          column of the matrix X. */
00116 
00117 /*  LDX     (input) INTEGER */
00118 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00119 
00120 /*  XACT    (input) COMPLEX array, dimension (LDX,NRHS) */
00121 /*          The exact solution vectors.  Each vector is stored as a */
00122 /*          column of the matrix XACT. */
00123 
00124 /*  LDXACT  (input) INTEGER */
00125 /*          The leading dimension of the array XACT.  LDXACT >= max(1,N). */
00126 
00127 /*  FERR    (input) REAL array, dimension (NRHS) */
00128 /*          The estimated forward error bounds for each solution vector */
00129 /*          X.  If XTRUE is the true solution, FERR bounds the magnitude */
00130 /*          of the largest entry in (X - XTRUE) divided by the magnitude */
00131 /*          of the largest entry in X. */
00132 
00133 /*  BERR    (input) REAL array, dimension (NRHS) */
00134 /*          The componentwise relative backward error of each solution */
00135 /*          vector (i.e., the smallest relative change in any entry of A */
00136 /*          or B that makes X an exact solution). */
00137 
00138 /*  RESLTS  (output) REAL array, dimension (2) */
00139 /*          The maximum over the NRHS solution vectors of the ratios: */
00140 /*          RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR ) */
00141 /*          RESLTS(2) = BERR / ( NZ*EPS + (*) ) */
00142 
00143 /*  ===================================================================== */
00144 
00145 /*     .. Parameters .. */
00146 /*     .. */
00147 /*     .. Local Scalars .. */
00148 /*     .. */
00149 /*     .. External Functions .. */
00150 /*     .. */
00151 /*     .. Intrinsic Functions .. */
00152 /*     .. */
00153 /*     .. Statement Functions .. */
00154 /*     .. */
00155 /*     .. Statement Function definitions .. */
00156 /*     .. */
00157 /*     .. Executable Statements .. */
00158 
00159 /*     Quick exit if N = 0 or NRHS = 0. */
00160 
00161     /* Parameter adjustments */
00162     ab_dim1 = *ldab;
00163     ab_offset = 1 + ab_dim1;
00164     ab -= ab_offset;
00165     b_dim1 = *ldb;
00166     b_offset = 1 + b_dim1;
00167     b -= b_offset;
00168     x_dim1 = *ldx;
00169     x_offset = 1 + x_dim1;
00170     x -= x_offset;
00171     xact_dim1 = *ldxact;
00172     xact_offset = 1 + xact_dim1;
00173     xact -= xact_offset;
00174     --ferr;
00175     --berr;
00176     --reslts;
00177 
00178     /* Function Body */
00179     if (*n <= 0 || *nrhs <= 0) {
00180         reslts[1] = 0.f;
00181         reslts[2] = 0.f;
00182         return 0;
00183     }
00184 
00185     eps = slamch_("Epsilon");
00186     unfl = slamch_("Safe minimum");
00187     ovfl = 1.f / unfl;
00188     notran = lsame_(trans, "N");
00189 /* Computing MIN */
00190     i__1 = *kl + *ku + 2, i__2 = *n + 1;
00191     nz = min(i__1,i__2);
00192 
00193 /*     Test 1:  Compute the maximum of */
00194 /*        norm(X - XACT) / ( norm(X) * FERR ) */
00195 /*     over all the vectors X and XACT using the infinity-norm. */
00196 
00197     errbnd = 0.f;
00198     i__1 = *nrhs;
00199     for (j = 1; j <= i__1; ++j) {
00200         imax = icamax_(n, &x[j * x_dim1 + 1], &c__1);
00201 /* Computing MAX */
00202         i__2 = imax + j * x_dim1;
00203         r__3 = (r__1 = x[i__2].r, dabs(r__1)) + (r__2 = r_imag(&x[imax + j * 
00204                 x_dim1]), dabs(r__2));
00205         xnorm = dmax(r__3,unfl);
00206         diff = 0.f;
00207         i__2 = *n;
00208         for (i__ = 1; i__ <= i__2; ++i__) {
00209             i__3 = i__ + j * x_dim1;
00210             i__4 = i__ + j * xact_dim1;
00211             q__2.r = x[i__3].r - xact[i__4].r, q__2.i = x[i__3].i - xact[i__4]
00212                     .i;
00213             q__1.r = q__2.r, q__1.i = q__2.i;
00214 /* Computing MAX */
00215             r__3 = diff, r__4 = (r__1 = q__1.r, dabs(r__1)) + (r__2 = r_imag(&
00216                     q__1), dabs(r__2));
00217             diff = dmax(r__3,r__4);
00218 /* L10: */
00219         }
00220 
00221         if (xnorm > 1.f) {
00222             goto L20;
00223         } else if (diff <= ovfl * xnorm) {
00224             goto L20;
00225         } else {
00226             errbnd = 1.f / eps;
00227             goto L30;
00228         }
00229 
00230 L20:
00231         if (diff / xnorm <= ferr[j]) {
00232 /* Computing MAX */
00233             r__1 = errbnd, r__2 = diff / xnorm / ferr[j];
00234             errbnd = dmax(r__1,r__2);
00235         } else {
00236             errbnd = 1.f / eps;
00237         }
00238 L30:
00239         ;
00240     }
00241     reslts[1] = errbnd;
00242 
00243 /*     Test 2:  Compute the maximum of BERR / ( NZ*EPS + (*) ), where */
00244 /*     (*) = NZ*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i ) */
00245 
00246     i__1 = *nrhs;
00247     for (k = 1; k <= i__1; ++k) {
00248         i__2 = *n;
00249         for (i__ = 1; i__ <= i__2; ++i__) {
00250             i__3 = i__ + k * b_dim1;
00251             tmp = (r__1 = b[i__3].r, dabs(r__1)) + (r__2 = r_imag(&b[i__ + k *
00252                      b_dim1]), dabs(r__2));
00253             if (notran) {
00254 /* Computing MAX */
00255                 i__3 = i__ - *kl;
00256 /* Computing MIN */
00257                 i__5 = i__ + *ku;
00258                 i__4 = min(i__5,*n);
00259                 for (j = max(i__3,1); j <= i__4; ++j) {
00260                     i__3 = *ku + 1 + i__ - j + j * ab_dim1;
00261                     i__5 = j + k * x_dim1;
00262                     tmp += ((r__1 = ab[i__3].r, dabs(r__1)) + (r__2 = r_imag(&
00263                             ab[*ku + 1 + i__ - j + j * ab_dim1]), dabs(r__2)))
00264                              * ((r__3 = x[i__5].r, dabs(r__3)) + (r__4 = 
00265                             r_imag(&x[j + k * x_dim1]), dabs(r__4)));
00266 /* L40: */
00267                 }
00268             } else {
00269 /* Computing MAX */
00270                 i__4 = i__ - *ku;
00271 /* Computing MIN */
00272                 i__5 = i__ + *kl;
00273                 i__3 = min(i__5,*n);
00274                 for (j = max(i__4,1); j <= i__3; ++j) {
00275                     i__4 = *ku + 1 + j - i__ + i__ * ab_dim1;
00276                     i__5 = j + k * x_dim1;
00277                     tmp += ((r__1 = ab[i__4].r, dabs(r__1)) + (r__2 = r_imag(&
00278                             ab[*ku + 1 + j - i__ + i__ * ab_dim1]), dabs(r__2)
00279                             )) * ((r__3 = x[i__5].r, dabs(r__3)) + (r__4 = 
00280                             r_imag(&x[j + k * x_dim1]), dabs(r__4)));
00281 /* L50: */
00282                 }
00283             }
00284             if (i__ == 1) {
00285                 axbi = tmp;
00286             } else {
00287                 axbi = dmin(axbi,tmp);
00288             }
00289 /* L60: */
00290         }
00291 /* Computing MAX */
00292         r__1 = axbi, r__2 = nz * unfl;
00293         tmp = berr[k] / (nz * eps + nz * unfl / dmax(r__1,r__2));
00294         if (k == 1) {
00295             reslts[2] = tmp;
00296         } else {
00297             reslts[2] = dmax(reslts[2],tmp);
00298         }
00299 /* L70: */
00300     }
00301 
00302     return 0;
00303 
00304 /*     End of CGBT05 */
00305 
00306 } /* cgbt05_ */


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