zpot05.c
Go to the documentation of this file.
00001 /* zpot05.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 zpot05_(char *uplo, 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, doublereal *berr, doublereal *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     doublereal d__1, d__2, d__3, d__4;
00029     doublecomplex z__1, z__2;
00030 
00031     /* Builtin functions */
00032     double d_imag(doublecomplex *);
00033 
00034     /* Local variables */
00035     integer i__, j, k;
00036     doublereal eps, tmp, diff, axbi;
00037     integer imax;
00038     doublereal unfl, ovfl;
00039     extern logical lsame_(char *, char *);
00040     logical upper;
00041     doublereal xnorm;
00042     extern doublereal dlamch_(char *);
00043     doublereal errbnd;
00044     extern integer izamax_(integer *, doublecomplex *, integer *);
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 /*  ZPOT05 tests the error bounds from iterative refinement for the */
00060 /*  computed solution to a system of equations A*X = B, where A is a */
00061 /*  Hermitian n by n matrix. */
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(A)*abs(X) +abs(b))_i ) */
00071 
00072 /*  Arguments */
00073 /*  ========= */
00074 
00075 /*  UPLO    (input) CHARACTER*1 */
00076 /*          Specifies whether the upper or lower triangular part of the */
00077 /*          Hermitian matrix A is stored. */
00078 /*          = 'U':  Upper triangular */
00079 /*          = 'L':  Lower triangular */
00080 
00081 /*  N       (input) INTEGER */
00082 /*          The number of rows of the matrices X, B, and XACT, and the */
00083 /*          order of the matrix A.  N >= 0. */
00084 
00085 /*  NRHS    (input) INTEGER */
00086 /*          The number of columns of the matrices X, B, and XACT. */
00087 /*          NRHS >= 0. */
00088 
00089 /*  A       (input) COMPLEX*16 array, dimension (LDA,N) */
00090 /*          The Hermitian matrix A.  If UPLO = 'U', the leading n by n */
00091 /*          upper triangular part of A contains the upper triangular part */
00092 /*          of the matrix A, and the strictly lower triangular part of A */
00093 /*          is not referenced.  If UPLO = 'L', the leading n by n lower */
00094 /*          triangular part of A contains the lower triangular part of */
00095 /*          the matrix A, and the strictly upper triangular part of A is */
00096 /*          not referenced. */
00097 
00098 /*  LDA     (input) INTEGER */
00099 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00100 
00101 /*  B       (input) COMPLEX*16 array, dimension (LDB,NRHS) */
00102 /*          The right hand side vectors for the system of linear */
00103 /*          equations. */
00104 
00105 /*  LDB     (input) INTEGER */
00106 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00107 
00108 /*  X       (input) COMPLEX*16 array, dimension (LDX,NRHS) */
00109 /*          The computed solution vectors.  Each vector is stored as a */
00110 /*          column of the matrix X. */
00111 
00112 /*  LDX     (input) INTEGER */
00113 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00114 
00115 /*  XACT    (input) COMPLEX*16 array, dimension (LDX,NRHS) */
00116 /*          The exact solution vectors.  Each vector is stored as a */
00117 /*          column of the matrix XACT. */
00118 
00119 /*  LDXACT  (input) INTEGER */
00120 /*          The leading dimension of the array XACT.  LDXACT >= max(1,N). */
00121 
00122 /*  FERR    (input) DOUBLE PRECISION array, dimension (NRHS) */
00123 /*          The estimated forward error bounds for each solution vector */
00124 /*          X.  If XTRUE is the true solution, FERR bounds the magnitude */
00125 /*          of the largest entry in (X - XTRUE) divided by the magnitude */
00126 /*          of the largest entry in X. */
00127 
00128 /*  BERR    (input) DOUBLE PRECISION array, dimension (NRHS) */
00129 /*          The componentwise relative backward error of each solution */
00130 /*          vector (i.e., the smallest relative change in any entry of A */
00131 /*          or B that makes X an exact solution). */
00132 
00133 /*  RESLTS  (output) DOUBLE PRECISION array, dimension (2) */
00134 /*          The maximum over the NRHS solution vectors of the ratios: */
00135 /*          RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR ) */
00136 /*          RESLTS(2) = BERR / ( (n+1)*EPS + (*) ) */
00137 
00138 /*  ===================================================================== */
00139 
00140 /*     .. Parameters .. */
00141 /*     .. */
00142 /*     .. Local Scalars .. */
00143 /*     .. */
00144 /*     .. External Functions .. */
00145 /*     .. */
00146 /*     .. Intrinsic Functions .. */
00147 /*     .. */
00148 /*     .. Statement Functions .. */
00149 /*     .. */
00150 /*     .. Statement Function definitions .. */
00151 /*     .. */
00152 /*     .. Executable Statements .. */
00153 
00154 /*     Quick exit if N = 0 or NRHS = 0. */
00155 
00156     /* Parameter adjustments */
00157     a_dim1 = *lda;
00158     a_offset = 1 + a_dim1;
00159     a -= a_offset;
00160     b_dim1 = *ldb;
00161     b_offset = 1 + b_dim1;
00162     b -= b_offset;
00163     x_dim1 = *ldx;
00164     x_offset = 1 + x_dim1;
00165     x -= x_offset;
00166     xact_dim1 = *ldxact;
00167     xact_offset = 1 + xact_dim1;
00168     xact -= xact_offset;
00169     --ferr;
00170     --berr;
00171     --reslts;
00172 
00173     /* Function Body */
00174     if (*n <= 0 || *nrhs <= 0) {
00175         reslts[1] = 0.;
00176         reslts[2] = 0.;
00177         return 0;
00178     }
00179 
00180     eps = dlamch_("Epsilon");
00181     unfl = dlamch_("Safe minimum");
00182     ovfl = 1. / unfl;
00183     upper = lsame_(uplo, "U");
00184 
00185 /*     Test 1:  Compute the maximum of */
00186 /*        norm(X - XACT) / ( norm(X) * FERR ) */
00187 /*     over all the vectors X and XACT using the infinity-norm. */
00188 
00189     errbnd = 0.;
00190     i__1 = *nrhs;
00191     for (j = 1; j <= i__1; ++j) {
00192         imax = izamax_(n, &x[j * x_dim1 + 1], &c__1);
00193 /* Computing MAX */
00194         i__2 = imax + j * x_dim1;
00195         d__3 = (d__1 = x[i__2].r, abs(d__1)) + (d__2 = d_imag(&x[imax + j * 
00196                 x_dim1]), abs(d__2));
00197         xnorm = max(d__3,unfl);
00198         diff = 0.;
00199         i__2 = *n;
00200         for (i__ = 1; i__ <= i__2; ++i__) {
00201             i__3 = i__ + j * x_dim1;
00202             i__4 = i__ + j * xact_dim1;
00203             z__2.r = x[i__3].r - xact[i__4].r, z__2.i = x[i__3].i - xact[i__4]
00204                     .i;
00205             z__1.r = z__2.r, z__1.i = z__2.i;
00206 /* Computing MAX */
00207             d__3 = diff, d__4 = (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&
00208                     z__1), abs(d__2));
00209             diff = max(d__3,d__4);
00210 /* L10: */
00211         }
00212 
00213         if (xnorm > 1.) {
00214             goto L20;
00215         } else if (diff <= ovfl * xnorm) {
00216             goto L20;
00217         } else {
00218             errbnd = 1. / eps;
00219             goto L30;
00220         }
00221 
00222 L20:
00223         if (diff / xnorm <= ferr[j]) {
00224 /* Computing MAX */
00225             d__1 = errbnd, d__2 = diff / xnorm / ferr[j];
00226             errbnd = max(d__1,d__2);
00227         } else {
00228             errbnd = 1. / eps;
00229         }
00230 L30:
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(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 (upper) {
00246                 i__3 = i__ - 1;
00247                 for (j = 1; j <= i__3; ++j) {
00248                     i__4 = j + i__ * 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                             j + i__ * 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                 i__3 = i__ + i__ * a_dim1;
00257                 i__4 = i__ + k * x_dim1;
00258                 tmp += (d__1 = a[i__3].r, abs(d__1)) * ((d__2 = x[i__4].r, 
00259                         abs(d__2)) + (d__3 = d_imag(&x[i__ + k * x_dim1]), 
00260                         abs(d__3)));
00261                 i__3 = *n;
00262                 for (j = i__ + 1; j <= i__3; ++j) {
00263                     i__4 = i__ + j * a_dim1;
00264                     i__5 = j + k * x_dim1;
00265                     tmp += ((d__1 = a[i__4].r, abs(d__1)) + (d__2 = d_imag(&a[
00266                             i__ + j * a_dim1]), abs(d__2))) * ((d__3 = x[i__5]
00267                             .r, abs(d__3)) + (d__4 = d_imag(&x[j + k * x_dim1]
00268                             ), abs(d__4)));
00269 /* L50: */
00270                 }
00271             } else {
00272                 i__3 = i__ - 1;
00273                 for (j = 1; j <= i__3; ++j) {
00274                     i__4 = i__ + j * a_dim1;
00275                     i__5 = j + k * x_dim1;
00276                     tmp += ((d__1 = a[i__4].r, abs(d__1)) + (d__2 = d_imag(&a[
00277                             i__ + j * a_dim1]), abs(d__2))) * ((d__3 = x[i__5]
00278                             .r, abs(d__3)) + (d__4 = d_imag(&x[j + k * x_dim1]
00279                             ), abs(d__4)));
00280 /* L60: */
00281                 }
00282                 i__3 = i__ + i__ * a_dim1;
00283                 i__4 = i__ + k * x_dim1;
00284                 tmp += (d__1 = a[i__3].r, abs(d__1)) * ((d__2 = x[i__4].r, 
00285                         abs(d__2)) + (d__3 = d_imag(&x[i__ + k * x_dim1]), 
00286                         abs(d__3)));
00287                 i__3 = *n;
00288                 for (j = i__ + 1; j <= i__3; ++j) {
00289                     i__4 = j + i__ * a_dim1;
00290                     i__5 = j + k * x_dim1;
00291                     tmp += ((d__1 = a[i__4].r, abs(d__1)) + (d__2 = d_imag(&a[
00292                             j + i__ * a_dim1]), abs(d__2))) * ((d__3 = x[i__5]
00293                             .r, abs(d__3)) + (d__4 = d_imag(&x[j + k * x_dim1]
00294                             ), abs(d__4)));
00295 /* L70: */
00296                 }
00297             }
00298             if (i__ == 1) {
00299                 axbi = tmp;
00300             } else {
00301                 axbi = min(axbi,tmp);
00302             }
00303 /* L80: */
00304         }
00305 /* Computing MAX */
00306         d__1 = axbi, d__2 = (*n + 1) * unfl;
00307         tmp = berr[k] / ((*n + 1) * eps + (*n + 1) * unfl / max(d__1,d__2));
00308         if (k == 1) {
00309             reslts[2] = tmp;
00310         } else {
00311             reslts[2] = max(reslts[2],tmp);
00312         }
00313 /* L90: */
00314     }
00315 
00316     return 0;
00317 
00318 /*     End of ZPOT05 */
00319 
00320 } /* zpot05_ */


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