cget07.c
Go to the documentation of this file.
00001 /* cget07.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 cget07_(char *trans, integer *n, integer *nrhs, complex *
00021         a, integer *lda, complex *b, integer *ldb, complex *x, integer *ldx, 
00022         complex *xact, integer *ldxact, real *ferr, logical *chkferr, real *
00023         berr, real *reslts)
00024 {
00025     /* System generated locals */
00026     integer a_dim1, a_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;
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 /*  CGET07 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 n by n matrix and op(A) = A or A**T, depending on TRANS. */
00062 
00063 /*  RESLTS(1) = test of the error bound */
00064 /*            = norm(X - XACT) / ( norm(X) * FERR ) */
00065 
00066 /*  A large value is returned if this ratio is not less than one. */
00067 
00068 /*  RESLTS(2) = residual from the iterative refinement routine */
00069 /*            = the maximum of BERR / ( (n+1)*EPS + (*) ), where */
00070 /*              (*) = (n+1)*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i ) */
00071 
00072 /*  Arguments */
00073 /*  ========= */
00074 
00075 /*  TRANS   (input) CHARACTER*1 */
00076 /*          Specifies the form of the system of equations. */
00077 /*          = 'N':  A * X = B     (No transpose) */
00078 /*          = 'T':  A**T * X = B  (Transpose) */
00079 /*          = 'C':  A**H * X = B  (Conjugate transpose = Transpose) */
00080 
00081 /*  N       (input) INTEGER */
00082 /*          The number of rows of the matrices X and XACT.  N >= 0. */
00083 
00084 /*  NRHS    (input) INTEGER */
00085 /*          The number of columns of the matrices X and XACT.  NRHS >= 0. */
00086 
00087 /*  A       (input) COMPLEX array, dimension (LDA,N) */
00088 /*          The original n by n matrix A. */
00089 
00090 /*  LDA     (input) INTEGER */
00091 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00092 
00093 /*  B       (input) COMPLEX array, dimension (LDB,NRHS) */
00094 /*          The right hand side vectors for the system of linear */
00095 /*          equations. */
00096 
00097 /*  LDB     (input) INTEGER */
00098 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00099 
00100 /*  X       (input) COMPLEX array, dimension (LDX,NRHS) */
00101 /*          The computed solution vectors.  Each vector is stored as a */
00102 /*          column of the matrix X. */
00103 
00104 /*  LDX     (input) INTEGER */
00105 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00106 
00107 /*  XACT    (input) COMPLEX array, dimension (LDX,NRHS) */
00108 /*          The exact solution vectors.  Each vector is stored as a */
00109 /*          column of the matrix XACT. */
00110 
00111 /*  LDXACT  (input) INTEGER */
00112 /*          The leading dimension of the array XACT.  LDXACT >= max(1,N). */
00113 
00114 /*  FERR    (input) REAL array, dimension (NRHS) */
00115 /*          The estimated forward error bounds for each solution vector */
00116 /*          X.  If XTRUE is the true solution, FERR bounds the magnitude */
00117 /*          of the largest entry in (X - XTRUE) divided by the magnitude */
00118 /*          of the largest entry in X. */
00119 
00120 /*  CHKFERR (input) LOGICAL */
00121 /*          Set to .TRUE. to check FERR, .FALSE. not to check FERR. */
00122 /*          When the test system is ill-conditioned, the "true" */
00123 /*          solution in XACT may be incorrect. */
00124 
00125 /*  BERR    (input) REAL array, dimension (NRHS) */
00126 /*          The componentwise relative backward error of each solution */
00127 /*          vector (i.e., the smallest relative change in any entry of A */
00128 /*          or B that makes X an exact solution). */
00129 
00130 /*  RESLTS  (output) REAL array, dimension (2) */
00131 /*          The maximum over the NRHS solution vectors of the ratios: */
00132 /*          RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR ) */
00133 /*          RESLTS(2) = BERR / ( (n+1)*EPS + (*) ) */
00134 
00135 /*  ===================================================================== */
00136 
00137 /*     .. Parameters .. */
00138 /*     .. */
00139 /*     .. Local Scalars .. */
00140 /*     .. */
00141 /*     .. External Functions .. */
00142 /*     .. */
00143 /*     .. Intrinsic Functions .. */
00144 /*     .. */
00145 /*     .. Statement Functions .. */
00146 /*     .. */
00147 /*     .. Statement Function definitions .. */
00148 /*     .. */
00149 /*     .. Executable Statements .. */
00150 
00151 /*     Quick exit if N = 0 or NRHS = 0. */
00152 
00153     /* Parameter adjustments */
00154     a_dim1 = *lda;
00155     a_offset = 1 + a_dim1;
00156     a -= a_offset;
00157     b_dim1 = *ldb;
00158     b_offset = 1 + b_dim1;
00159     b -= b_offset;
00160     x_dim1 = *ldx;
00161     x_offset = 1 + x_dim1;
00162     x -= x_offset;
00163     xact_dim1 = *ldxact;
00164     xact_offset = 1 + xact_dim1;
00165     xact -= xact_offset;
00166     --ferr;
00167     --berr;
00168     --reslts;
00169 
00170     /* Function Body */
00171     if (*n <= 0 || *nrhs <= 0) {
00172         reslts[1] = 0.f;
00173         reslts[2] = 0.f;
00174         return 0;
00175     }
00176 
00177     eps = slamch_("Epsilon");
00178     unfl = slamch_("Safe minimum");
00179     ovfl = 1.f / unfl;
00180     notran = lsame_(trans, "N");
00181 
00182 /*     Test 1:  Compute the maximum of */
00183 /*        norm(X - XACT) / ( norm(X) * FERR ) */
00184 /*     over all the vectors X and XACT using the infinity-norm. */
00185 
00186     errbnd = 0.f;
00187     if (*chkferr) {
00188         i__1 = *nrhs;
00189         for (j = 1; j <= i__1; ++j) {
00190             imax = icamax_(n, &x[j * x_dim1 + 1], &c__1);
00191 /* Computing MAX */
00192             i__2 = imax + j * x_dim1;
00193             r__3 = (r__1 = x[i__2].r, dabs(r__1)) + (r__2 = r_imag(&x[imax + 
00194                     j * x_dim1]), dabs(r__2));
00195             xnorm = dmax(r__3,unfl);
00196             diff = 0.f;
00197             i__2 = *n;
00198             for (i__ = 1; i__ <= i__2; ++i__) {
00199                 i__3 = i__ + j * x_dim1;
00200                 i__4 = i__ + j * xact_dim1;
00201                 q__2.r = x[i__3].r - xact[i__4].r, q__2.i = x[i__3].i - xact[
00202                         i__4].i;
00203                 q__1.r = q__2.r, q__1.i = q__2.i;
00204 /* Computing MAX */
00205                 r__3 = diff, r__4 = (r__1 = q__1.r, dabs(r__1)) + (r__2 = 
00206                         r_imag(&q__1), dabs(r__2));
00207                 diff = dmax(r__3,r__4);
00208 /* L10: */
00209             }
00210 
00211             if (xnorm > 1.f) {
00212                 goto L20;
00213             } else if (diff <= ovfl * xnorm) {
00214                 goto L20;
00215             } else {
00216                 errbnd = 1.f / eps;
00217                 goto L30;
00218             }
00219 
00220 L20:
00221             if (diff / xnorm <= ferr[j]) {
00222 /* Computing MAX */
00223                 r__1 = errbnd, r__2 = diff / xnorm / ferr[j];
00224                 errbnd = dmax(r__1,r__2);
00225             } else {
00226                 errbnd = 1.f / eps;
00227             }
00228 L30:
00229             ;
00230         }
00231     }
00232     reslts[1] = errbnd;
00233 
00234 /*     Test 2:  Compute the maximum of BERR / ( (n+1)*EPS + (*) ), where */
00235 /*     (*) = (n+1)*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         i__2 = *n;
00240         for (i__ = 1; i__ <= i__2; ++i__) {
00241             i__3 = i__ + k * b_dim1;
00242             tmp = (r__1 = b[i__3].r, dabs(r__1)) + (r__2 = r_imag(&b[i__ + k *
00243                      b_dim1]), dabs(r__2));
00244             if (notran) {
00245                 i__3 = *n;
00246                 for (j = 1; j <= i__3; ++j) {
00247                     i__4 = i__ + j * a_dim1;
00248                     i__5 = j + k * x_dim1;
00249                     tmp += ((r__1 = a[i__4].r, dabs(r__1)) + (r__2 = r_imag(&
00250                             a[i__ + j * a_dim1]), dabs(r__2))) * ((r__3 = x[
00251                             i__5].r, dabs(r__3)) + (r__4 = r_imag(&x[j + k * 
00252                             x_dim1]), dabs(r__4)));
00253 /* L40: */
00254                 }
00255             } else {
00256                 i__3 = *n;
00257                 for (j = 1; j <= i__3; ++j) {
00258                     i__4 = j + i__ * a_dim1;
00259                     i__5 = j + k * x_dim1;
00260                     tmp += ((r__1 = a[i__4].r, dabs(r__1)) + (r__2 = r_imag(&
00261                             a[j + i__ * a_dim1]), dabs(r__2))) * ((r__3 = x[
00262                             i__5].r, dabs(r__3)) + (r__4 = r_imag(&x[j + k * 
00263                             x_dim1]), dabs(r__4)));
00264 /* L50: */
00265                 }
00266             }
00267             if (i__ == 1) {
00268                 axbi = tmp;
00269             } else {
00270                 axbi = dmin(axbi,tmp);
00271             }
00272 /* L60: */
00273         }
00274 /* Computing MAX */
00275         r__1 = axbi, r__2 = (*n + 1) * unfl;
00276         tmp = berr[k] / ((*n + 1) * eps + (*n + 1) * unfl / dmax(r__1,r__2));
00277         if (k == 1) {
00278             reslts[2] = tmp;
00279         } else {
00280             reslts[2] = dmax(reslts[2],tmp);
00281         }
00282 /* L70: */
00283     }
00284 
00285     return 0;
00286 
00287 /*     End of CGET07 */
00288 
00289 } /* cget07_ */


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