zget07.c
Go to the documentation of this file.
00001 /* zget07.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 zget07_(char *trans, integer *n, integer *nrhs, 
00021         doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, 
00022         doublecomplex *x, integer *ldx, doublecomplex *xact, integer *ldxact, 
00023         doublereal *ferr, logical *chkferr, doublereal *berr, doublereal *
00024         reslts)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_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;
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 /*  ZGET07 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 n by n matrix 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 / ( (n+1)*EPS + (*) ), where */
00071 /*              (*) = (n+1)*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i ) */
00072 
00073 /*  Arguments */
00074 /*  ========= */
00075 
00076 /*  TRANS   (input) CHARACTER*1 */
00077 /*          Specifies the form of the system of equations. */
00078 /*          = 'N':  A * X = B     (No transpose) */
00079 /*          = 'T':  A**T * X = B  (Transpose) */
00080 /*          = 'C':  A**H * X = B  (Conjugate transpose = Transpose) */
00081 
00082 /*  N       (input) INTEGER */
00083 /*          The number of rows of the matrices X and XACT.  N >= 0. */
00084 
00085 /*  NRHS    (input) INTEGER */
00086 /*          The number of columns of the matrices X and XACT.  NRHS >= 0. */
00087 
00088 /*  A       (input) COMPLEX*16 array, dimension (LDA,N) */
00089 /*          The original n by n matrix A. */
00090 
00091 /*  LDA     (input) INTEGER */
00092 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00093 
00094 /*  B       (input) COMPLEX*16 array, dimension (LDB,NRHS) */
00095 /*          The right hand side vectors for the system of linear */
00096 /*          equations. */
00097 
00098 /*  LDB     (input) INTEGER */
00099 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00100 
00101 /*  X       (input) COMPLEX*16 array, dimension (LDX,NRHS) */
00102 /*          The computed solution vectors.  Each vector is stored as a */
00103 /*          column of the matrix X. */
00104 
00105 /*  LDX     (input) INTEGER */
00106 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00107 
00108 /*  XACT    (input) COMPLEX*16 array, dimension (LDX,NRHS) */
00109 /*          The exact solution vectors.  Each vector is stored as a */
00110 /*          column of the matrix XACT. */
00111 
00112 /*  LDXACT  (input) INTEGER */
00113 /*          The leading dimension of the array XACT.  LDXACT >= max(1,N). */
00114 
00115 /*  FERR    (input) DOUBLE PRECISION array, dimension (NRHS) */
00116 /*          The estimated forward error bounds for each solution vector */
00117 /*          X.  If XTRUE is the true solution, FERR bounds the magnitude */
00118 /*          of the largest entry in (X - XTRUE) divided by the magnitude */
00119 /*          of the largest entry in X. */
00120 
00121 /*  CHKFERR (input) LOGICAL */
00122 /*          Set to .TRUE. to check FERR, .FALSE. not to check FERR. */
00123 /*          When the test system is ill-conditioned, the "true" */
00124 /*          solution in XACT may be incorrect. */
00125 
00126 /*  BERR    (input) DOUBLE PRECISION 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) DOUBLE PRECISION 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 / ( (n+1)*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     a_dim1 = *lda;
00156     a_offset = 1 + a_dim1;
00157     a -= a_offset;
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.;
00174         reslts[2] = 0.;
00175         return 0;
00176     }
00177 
00178     eps = dlamch_("Epsilon");
00179     unfl = dlamch_("Safe minimum");
00180     ovfl = 1. / unfl;
00181     notran = lsame_(trans, "N");
00182 
00183 /*     Test 1:  Compute the maximum of */
00184 /*        norm(X - XACT) / ( norm(X) * FERR ) */
00185 /*     over all the vectors X and XACT using the infinity-norm. */
00186 
00187     errbnd = 0.;
00188     if (*chkferr) {
00189         i__1 = *nrhs;
00190         for (j = 1; j <= i__1; ++j) {
00191             imax = izamax_(n, &x[j * x_dim1 + 1], &c__1);
00192 /* Computing MAX */
00193             i__2 = imax + j * x_dim1;
00194             d__3 = (d__1 = x[i__2].r, abs(d__1)) + (d__2 = d_imag(&x[imax + j 
00195                     * x_dim1]), abs(d__2));
00196             xnorm = max(d__3,unfl);
00197             diff = 0.;
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                 z__2.r = x[i__3].r - xact[i__4].r, z__2.i = x[i__3].i - xact[
00203                         i__4].i;
00204                 z__1.r = z__2.r, z__1.i = z__2.i;
00205 /* Computing MAX */
00206                 d__3 = diff, d__4 = (d__1 = z__1.r, abs(d__1)) + (d__2 = 
00207                         d_imag(&z__1), abs(d__2));
00208                 diff = max(d__3,d__4);
00209 /* L10: */
00210             }
00211 
00212             if (xnorm > 1.) {
00213                 goto L20;
00214             } else if (diff <= ovfl * xnorm) {
00215                 goto L20;
00216             } else {
00217                 errbnd = 1. / eps;
00218                 goto L30;
00219             }
00220 
00221 L20:
00222             if (diff / xnorm <= ferr[j]) {
00223 /* Computing MAX */
00224                 d__1 = errbnd, d__2 = diff / xnorm / ferr[j];
00225                 errbnd = max(d__1,d__2);
00226             } else {
00227                 errbnd = 1. / eps;
00228             }
00229 L30:
00230             ;
00231         }
00232     }
00233     reslts[1] = errbnd;
00234 
00235 /*     Test 2:  Compute the maximum of BERR / ( (n+1)*EPS + (*) ), where */
00236 /*     (*) = (n+1)*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         i__2 = *n;
00241         for (i__ = 1; i__ <= i__2; ++i__) {
00242             i__3 = i__ + k * b_dim1;
00243             tmp = (d__1 = b[i__3].r, abs(d__1)) + (d__2 = d_imag(&b[i__ + k * 
00244                     b_dim1]), abs(d__2));
00245             if (notran) {
00246                 i__3 = *n;
00247                 for (j = 1; j <= i__3; ++j) {
00248                     i__4 = i__ + j * a_dim1;
00249                     i__5 = j + k * x_dim1;
00250                     tmp += ((d__1 = a[i__4].r, abs(d__1)) + (d__2 = d_imag(&a[
00251                             i__ + j * a_dim1]), abs(d__2))) * ((d__3 = x[i__5]
00252                             .r, abs(d__3)) + (d__4 = d_imag(&x[j + k * x_dim1]
00253                             ), abs(d__4)));
00254 /* L40: */
00255                 }
00256             } else {
00257                 i__3 = *n;
00258                 for (j = 1; j <= i__3; ++j) {
00259                     i__4 = j + i__ * a_dim1;
00260                     i__5 = j + k * x_dim1;
00261                     tmp += ((d__1 = a[i__4].r, abs(d__1)) + (d__2 = d_imag(&a[
00262                             j + i__ * a_dim1]), abs(d__2))) * ((d__3 = x[i__5]
00263                             .r, abs(d__3)) + (d__4 = d_imag(&x[j + k * x_dim1]
00264                             ), abs(d__4)));
00265 /* L50: */
00266                 }
00267             }
00268             if (i__ == 1) {
00269                 axbi = tmp;
00270             } else {
00271                 axbi = min(axbi,tmp);
00272             }
00273 /* L60: */
00274         }
00275 /* Computing MAX */
00276         d__1 = axbi, d__2 = (*n + 1) * unfl;
00277         tmp = berr[k] / ((*n + 1) * eps + (*n + 1) * unfl / max(d__1,d__2));
00278         if (k == 1) {
00279             reslts[2] = tmp;
00280         } else {
00281             reslts[2] = max(reslts[2],tmp);
00282         }
00283 /* L70: */
00284     }
00285 
00286     return 0;
00287 
00288 /*     End of ZGET07 */
00289 
00290 } /* zget07_ */


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