cpot05.c
Go to the documentation of this file.
00001 /* cpot05.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 cpot05_(char *uplo, integer *n, integer *nrhs, complex *
00021         a, integer *lda, complex *b, integer *ldb, complex *x, integer *ldx, 
00022         complex *xact, integer *ldxact, real *ferr, real *berr, real *reslts)
00023 {
00024     /* System generated locals */
00025     integer a_dim1, a_offset, b_dim1, b_offset, x_dim1, x_offset, xact_dim1, 
00026             xact_offset, i__1, i__2, i__3, i__4, i__5;
00027     real r__1, r__2, r__3, r__4;
00028     complex q__1, q__2;
00029 
00030     /* Builtin functions */
00031     double r_imag(complex *);
00032 
00033     /* Local variables */
00034     integer i__, j, k;
00035     real eps, tmp, diff, axbi;
00036     integer imax;
00037     real unfl, ovfl;
00038     extern logical lsame_(char *, char *);
00039     logical upper;
00040     real xnorm;
00041     extern integer icamax_(integer *, complex *, integer *);
00042     extern doublereal slamch_(char *);
00043     real errbnd;
00044 
00045 
00046 /*  -- LAPACK test routine (version 3.1) -- */
00047 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00048 /*     November 2006 */
00049 
00050 /*     .. Scalar Arguments .. */
00051 /*     .. */
00052 /*     .. Array Arguments .. */
00053 /*     .. */
00054 
00055 /*  Purpose */
00056 /*  ======= */
00057 
00058 /*  CPOT05 tests the error bounds from iterative refinement for the */
00059 /*  computed solution to a system of equations A*X = B, where A is a */
00060 /*  Hermitian n by n matrix. */
00061 
00062 /*  RESLTS(1) = test of the error bound */
00063 /*            = norm(X - XACT) / ( norm(X) * FERR ) */
00064 
00065 /*  A large value is returned if this ratio is not less than one. */
00066 
00067 /*  RESLTS(2) = residual from the iterative refinement routine */
00068 /*            = the maximum of BERR / ( (n+1)*EPS + (*) ), where */
00069 /*              (*) = (n+1)*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i ) */
00070 
00071 /*  Arguments */
00072 /*  ========= */
00073 
00074 /*  UPLO    (input) CHARACTER*1 */
00075 /*          Specifies whether the upper or lower triangular part of the */
00076 /*          Hermitian matrix A is stored. */
00077 /*          = 'U':  Upper triangular */
00078 /*          = 'L':  Lower triangular */
00079 
00080 /*  N       (input) INTEGER */
00081 /*          The number of rows of the matrices X, B, and XACT, and the */
00082 /*          order of the matrix A.  N >= 0. */
00083 
00084 /*  NRHS    (input) INTEGER */
00085 /*          The number of columns of the matrices X, B, and XACT. */
00086 /*          NRHS >= 0. */
00087 
00088 /*  A       (input) COMPLEX array, dimension (LDA,N) */
00089 /*          The Hermitian matrix A.  If UPLO = 'U', the leading n by n */
00090 /*          upper triangular part of A contains the upper triangular part */
00091 /*          of the matrix A, and the strictly lower triangular part of A */
00092 /*          is not referenced.  If UPLO = 'L', the leading n by n lower */
00093 /*          triangular part of A contains the lower triangular part of */
00094 /*          the matrix A, and the strictly upper triangular part of A is */
00095 /*          not referenced. */
00096 
00097 /*  LDA     (input) INTEGER */
00098 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00099 
00100 /*  B       (input) COMPLEX array, dimension (LDB,NRHS) */
00101 /*          The right hand side vectors for the system of linear */
00102 /*          equations. */
00103 
00104 /*  LDB     (input) INTEGER */
00105 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00106 
00107 /*  X       (input) COMPLEX array, dimension (LDX,NRHS) */
00108 /*          The computed solution vectors.  Each vector is stored as a */
00109 /*          column of the matrix X. */
00110 
00111 /*  LDX     (input) INTEGER */
00112 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00113 
00114 /*  XACT    (input) COMPLEX array, dimension (LDX,NRHS) */
00115 /*          The exact solution vectors.  Each vector is stored as a */
00116 /*          column of the matrix XACT. */
00117 
00118 /*  LDXACT  (input) INTEGER */
00119 /*          The leading dimension of the array XACT.  LDXACT >= max(1,N). */
00120 
00121 /*  FERR    (input) REAL array, dimension (NRHS) */
00122 /*          The estimated forward error bounds for each solution vector */
00123 /*          X.  If XTRUE is the true solution, FERR bounds the magnitude */
00124 /*          of the largest entry in (X - XTRUE) divided by the magnitude */
00125 /*          of the largest entry in X. */
00126 
00127 /*  BERR    (input) REAL array, dimension (NRHS) */
00128 /*          The componentwise relative backward error of each solution */
00129 /*          vector (i.e., the smallest relative change in any entry of A */
00130 /*          or B that makes X an exact solution). */
00131 
00132 /*  RESLTS  (output) REAL array, dimension (2) */
00133 /*          The maximum over the NRHS solution vectors of the ratios: */
00134 /*          RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR ) */
00135 /*          RESLTS(2) = BERR / ( (n+1)*EPS + (*) ) */
00136 
00137 /*  ===================================================================== */
00138 
00139 /*     .. Parameters .. */
00140 /*     .. */
00141 /*     .. Local Scalars .. */
00142 /*     .. */
00143 /*     .. External Functions .. */
00144 /*     .. */
00145 /*     .. Intrinsic Functions .. */
00146 /*     .. */
00147 /*     .. Statement Functions .. */
00148 /*     .. */
00149 /*     .. Statement Function definitions .. */
00150 /*     .. */
00151 /*     .. Executable Statements .. */
00152 
00153 /*     Quick exit if N = 0 or NRHS = 0. */
00154 
00155     /* Parameter adjustments */
00156     a_dim1 = *lda;
00157     a_offset = 1 + a_dim1;
00158     a -= a_offset;
00159     b_dim1 = *ldb;
00160     b_offset = 1 + b_dim1;
00161     b -= b_offset;
00162     x_dim1 = *ldx;
00163     x_offset = 1 + x_dim1;
00164     x -= x_offset;
00165     xact_dim1 = *ldxact;
00166     xact_offset = 1 + xact_dim1;
00167     xact -= xact_offset;
00168     --ferr;
00169     --berr;
00170     --reslts;
00171 
00172     /* Function Body */
00173     if (*n <= 0 || *nrhs <= 0) {
00174         reslts[1] = 0.f;
00175         reslts[2] = 0.f;
00176         return 0;
00177     }
00178 
00179     eps = slamch_("Epsilon");
00180     unfl = slamch_("Safe minimum");
00181     ovfl = 1.f / unfl;
00182     upper = lsame_(uplo, "U");
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 / ( (n+1)*EPS + (*) ), where */
00235 /*     (*) = (n+1)*UNFL / (min_i (abs(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 (upper) {
00245                 i__3 = i__ - 1;
00246                 for (j = 1; j <= i__3; ++j) {
00247                     i__4 = j + i__ * 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[j + i__ * 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                 i__3 = i__ + i__ * a_dim1;
00256                 i__4 = i__ + k * x_dim1;
00257                 tmp += (r__1 = a[i__3].r, dabs(r__1)) * ((r__2 = x[i__4].r, 
00258                         dabs(r__2)) + (r__3 = r_imag(&x[i__ + k * x_dim1]), 
00259                         dabs(r__3)));
00260                 i__3 = *n;
00261                 for (j = i__ + 1; j <= i__3; ++j) {
00262                     i__4 = i__ + j * a_dim1;
00263                     i__5 = j + k * x_dim1;
00264                     tmp += ((r__1 = a[i__4].r, dabs(r__1)) + (r__2 = r_imag(&
00265                             a[i__ + j * a_dim1]), dabs(r__2))) * ((r__3 = x[
00266                             i__5].r, dabs(r__3)) + (r__4 = r_imag(&x[j + k * 
00267                             x_dim1]), dabs(r__4)));
00268 /* L50: */
00269                 }
00270             } else {
00271                 i__3 = i__ - 1;
00272                 for (j = 1; j <= i__3; ++j) {
00273                     i__4 = i__ + j * a_dim1;
00274                     i__5 = j + k * x_dim1;
00275                     tmp += ((r__1 = a[i__4].r, dabs(r__1)) + (r__2 = r_imag(&
00276                             a[i__ + j * a_dim1]), dabs(r__2))) * ((r__3 = x[
00277                             i__5].r, dabs(r__3)) + (r__4 = r_imag(&x[j + k * 
00278                             x_dim1]), dabs(r__4)));
00279 /* L60: */
00280                 }
00281                 i__3 = i__ + i__ * a_dim1;
00282                 i__4 = i__ + k * x_dim1;
00283                 tmp += (r__1 = a[i__3].r, dabs(r__1)) * ((r__2 = x[i__4].r, 
00284                         dabs(r__2)) + (r__3 = r_imag(&x[i__ + k * x_dim1]), 
00285                         dabs(r__3)));
00286                 i__3 = *n;
00287                 for (j = i__ + 1; j <= i__3; ++j) {
00288                     i__4 = j + i__ * a_dim1;
00289                     i__5 = j + k * x_dim1;
00290                     tmp += ((r__1 = a[i__4].r, dabs(r__1)) + (r__2 = r_imag(&
00291                             a[j + i__ * a_dim1]), dabs(r__2))) * ((r__3 = x[
00292                             i__5].r, dabs(r__3)) + (r__4 = r_imag(&x[j + k * 
00293                             x_dim1]), dabs(r__4)));
00294 /* L70: */
00295                 }
00296             }
00297             if (i__ == 1) {
00298                 axbi = tmp;
00299             } else {
00300                 axbi = dmin(axbi,tmp);
00301             }
00302 /* L80: */
00303         }
00304 /* Computing MAX */
00305         r__1 = axbi, r__2 = (*n + 1) * unfl;
00306         tmp = berr[k] / ((*n + 1) * eps + (*n + 1) * unfl / dmax(r__1,r__2));
00307         if (k == 1) {
00308             reslts[2] = tmp;
00309         } else {
00310             reslts[2] = dmax(reslts[2],tmp);
00311         }
00312 /* L90: */
00313     }
00314 
00315     return 0;
00316 
00317 /*     End of CPOT05 */
00318 
00319 } /* cpot05_ */


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