cppt05.c
Go to the documentation of this file.
00001 /* cppt05.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 cppt05_(char *uplo, integer *n, integer *nrhs, complex *
00021         ap, complex *b, integer *ldb, complex *x, integer *ldx, complex *xact, 
00022          integer *ldxact, real *ferr, real *berr, real *reslts)
00023 {
00024     /* System generated locals */
00025     integer b_dim1, b_offset, x_dim1, x_offset, xact_dim1, xact_offset, i__1, 
00026             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, jc;
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 /*  CPPT05 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 matrix in packed storage format. */
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 /*  AP      (input) COMPLEX array, dimension (N*(N+1)/2) */
00089 /*          The upper or lower triangle of the Hermitian matrix A, packed */
00090 /*          columnwise in a linear array.  The j-th column of A is stored */
00091 /*          in the array AP as follows: */
00092 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
00093 /*          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
00094 
00095 /*  B       (input) COMPLEX array, dimension (LDB,NRHS) */
00096 /*          The right hand side vectors for the system of linear */
00097 /*          equations. */
00098 
00099 /*  LDB     (input) INTEGER */
00100 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00101 
00102 /*  X       (input) COMPLEX array, dimension (LDX,NRHS) */
00103 /*          The computed solution vectors.  Each vector is stored as a */
00104 /*          column of the matrix X. */
00105 
00106 /*  LDX     (input) INTEGER */
00107 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00108 
00109 /*  XACT    (input) COMPLEX array, dimension (LDX,NRHS) */
00110 /*          The exact solution vectors.  Each vector is stored as a */
00111 /*          column of the matrix XACT. */
00112 
00113 /*  LDXACT  (input) INTEGER */
00114 /*          The leading dimension of the array XACT.  LDXACT >= max(1,N). */
00115 
00116 /*  FERR    (input) REAL array, dimension (NRHS) */
00117 /*          The estimated forward error bounds for each solution vector */
00118 /*          X.  If XTRUE is the true solution, FERR bounds the magnitude */
00119 /*          of the largest entry in (X - XTRUE) divided by the magnitude */
00120 /*          of the largest entry in X. */
00121 
00122 /*  BERR    (input) REAL array, dimension (NRHS) */
00123 /*          The componentwise relative backward error of each solution */
00124 /*          vector (i.e., the smallest relative change in any entry of A */
00125 /*          or B that makes X an exact solution). */
00126 
00127 /*  RESLTS  (output) REAL array, dimension (2) */
00128 /*          The maximum over the NRHS solution vectors of the ratios: */
00129 /*          RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR ) */
00130 /*          RESLTS(2) = BERR / ( (n+1)*EPS + (*) ) */
00131 
00132 /*  ===================================================================== */
00133 
00134 /*     .. Parameters .. */
00135 /*     .. */
00136 /*     .. Local Scalars .. */
00137 /*     .. */
00138 /*     .. External Functions .. */
00139 /*     .. */
00140 /*     .. Intrinsic Functions .. */
00141 /*     .. */
00142 /*     .. Statement Functions .. */
00143 /*     .. */
00144 /*     .. Statement Function definitions .. */
00145 /*     .. */
00146 /*     .. Executable Statements .. */
00147 
00148 /*     Quick exit if N = 0 or NRHS = 0. */
00149 
00150     /* Parameter adjustments */
00151     --ap;
00152     b_dim1 = *ldb;
00153     b_offset = 1 + b_dim1;
00154     b -= b_offset;
00155     x_dim1 = *ldx;
00156     x_offset = 1 + x_dim1;
00157     x -= x_offset;
00158     xact_dim1 = *ldxact;
00159     xact_offset = 1 + xact_dim1;
00160     xact -= xact_offset;
00161     --ferr;
00162     --berr;
00163     --reslts;
00164 
00165     /* Function Body */
00166     if (*n <= 0 || *nrhs <= 0) {
00167         reslts[1] = 0.f;
00168         reslts[2] = 0.f;
00169         return 0;
00170     }
00171 
00172     eps = slamch_("Epsilon");
00173     unfl = slamch_("Safe minimum");
00174     ovfl = 1.f / unfl;
00175     upper = lsame_(uplo, "U");
00176 
00177 /*     Test 1:  Compute the maximum of */
00178 /*        norm(X - XACT) / ( norm(X) * FERR ) */
00179 /*     over all the vectors X and XACT using the infinity-norm. */
00180 
00181     errbnd = 0.f;
00182     i__1 = *nrhs;
00183     for (j = 1; j <= i__1; ++j) {
00184         imax = icamax_(n, &x[j * x_dim1 + 1], &c__1);
00185 /* Computing MAX */
00186         i__2 = imax + j * x_dim1;
00187         r__3 = (r__1 = x[i__2].r, dabs(r__1)) + (r__2 = r_imag(&x[imax + j * 
00188                 x_dim1]), dabs(r__2));
00189         xnorm = dmax(r__3,unfl);
00190         diff = 0.f;
00191         i__2 = *n;
00192         for (i__ = 1; i__ <= i__2; ++i__) {
00193             i__3 = i__ + j * x_dim1;
00194             i__4 = i__ + j * xact_dim1;
00195             q__2.r = x[i__3].r - xact[i__4].r, q__2.i = x[i__3].i - xact[i__4]
00196                     .i;
00197             q__1.r = q__2.r, q__1.i = q__2.i;
00198 /* Computing MAX */
00199             r__3 = diff, r__4 = (r__1 = q__1.r, dabs(r__1)) + (r__2 = r_imag(&
00200                     q__1), dabs(r__2));
00201             diff = dmax(r__3,r__4);
00202 /* L10: */
00203         }
00204 
00205         if (xnorm > 1.f) {
00206             goto L20;
00207         } else if (diff <= ovfl * xnorm) {
00208             goto L20;
00209         } else {
00210             errbnd = 1.f / eps;
00211             goto L30;
00212         }
00213 
00214 L20:
00215         if (diff / xnorm <= ferr[j]) {
00216 /* Computing MAX */
00217             r__1 = errbnd, r__2 = diff / xnorm / ferr[j];
00218             errbnd = dmax(r__1,r__2);
00219         } else {
00220             errbnd = 1.f / eps;
00221         }
00222 L30:
00223         ;
00224     }
00225     reslts[1] = errbnd;
00226 
00227 /*     Test 2:  Compute the maximum of BERR / ( (n+1)*EPS + (*) ), where */
00228 /*     (*) = (n+1)*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i ) */
00229 
00230     i__1 = *nrhs;
00231     for (k = 1; k <= i__1; ++k) {
00232         i__2 = *n;
00233         for (i__ = 1; i__ <= i__2; ++i__) {
00234             i__3 = i__ + k * b_dim1;
00235             tmp = (r__1 = b[i__3].r, dabs(r__1)) + (r__2 = r_imag(&b[i__ + k *
00236                      b_dim1]), dabs(r__2));
00237             if (upper) {
00238                 jc = (i__ - 1) * i__ / 2;
00239                 i__3 = i__ - 1;
00240                 for (j = 1; j <= i__3; ++j) {
00241                     i__4 = jc + j;
00242                     i__5 = j + k * x_dim1;
00243                     tmp += ((r__1 = ap[i__4].r, dabs(r__1)) + (r__2 = r_imag(&
00244                             ap[jc + j]), dabs(r__2))) * ((r__3 = x[i__5].r, 
00245                             dabs(r__3)) + (r__4 = r_imag(&x[j + k * x_dim1]), 
00246                             dabs(r__4)));
00247 /* L40: */
00248                 }
00249                 i__3 = jc + i__;
00250                 i__4 = i__ + k * x_dim1;
00251                 tmp += (r__1 = ap[i__3].r, dabs(r__1)) * ((r__2 = x[i__4].r, 
00252                         dabs(r__2)) + (r__3 = r_imag(&x[i__ + k * x_dim1]), 
00253                         dabs(r__3)));
00254                 jc = jc + i__ + i__;
00255                 i__3 = *n;
00256                 for (j = i__ + 1; j <= i__3; ++j) {
00257                     i__4 = jc;
00258                     i__5 = j + k * x_dim1;
00259                     tmp += ((r__1 = ap[i__4].r, dabs(r__1)) + (r__2 = r_imag(&
00260                             ap[jc]), dabs(r__2))) * ((r__3 = x[i__5].r, dabs(
00261                             r__3)) + (r__4 = r_imag(&x[j + k * x_dim1]), dabs(
00262                             r__4)));
00263                     jc += j;
00264 /* L50: */
00265                 }
00266             } else {
00267                 jc = i__;
00268                 i__3 = i__ - 1;
00269                 for (j = 1; j <= i__3; ++j) {
00270                     i__4 = jc;
00271                     i__5 = j + k * x_dim1;
00272                     tmp += ((r__1 = ap[i__4].r, dabs(r__1)) + (r__2 = r_imag(&
00273                             ap[jc]), dabs(r__2))) * ((r__3 = x[i__5].r, dabs(
00274                             r__3)) + (r__4 = r_imag(&x[j + k * x_dim1]), dabs(
00275                             r__4)));
00276                     jc = jc + *n - j;
00277 /* L60: */
00278                 }
00279                 i__3 = jc;
00280                 i__4 = i__ + k * x_dim1;
00281                 tmp += (r__1 = ap[i__3].r, dabs(r__1)) * ((r__2 = x[i__4].r, 
00282                         dabs(r__2)) + (r__3 = r_imag(&x[i__ + k * x_dim1]), 
00283                         dabs(r__3)));
00284                 i__3 = *n;
00285                 for (j = i__ + 1; j <= i__3; ++j) {
00286                     i__4 = jc + j - i__;
00287                     i__5 = j + k * x_dim1;
00288                     tmp += ((r__1 = ap[i__4].r, dabs(r__1)) + (r__2 = r_imag(&
00289                             ap[jc + j - i__]), dabs(r__2))) * ((r__3 = x[i__5]
00290                             .r, dabs(r__3)) + (r__4 = r_imag(&x[j + k * 
00291                             x_dim1]), dabs(r__4)));
00292 /* L70: */
00293                 }
00294             }
00295             if (i__ == 1) {
00296                 axbi = tmp;
00297             } else {
00298                 axbi = dmin(axbi,tmp);
00299             }
00300 /* L80: */
00301         }
00302 /* Computing MAX */
00303         r__1 = axbi, r__2 = (*n + 1) * unfl;
00304         tmp = berr[k] / ((*n + 1) * eps + (*n + 1) * unfl / dmax(r__1,r__2));
00305         if (k == 1) {
00306             reslts[2] = tmp;
00307         } else {
00308             reslts[2] = dmax(reslts[2],tmp);
00309         }
00310 /* L90: */
00311     }
00312 
00313     return 0;
00314 
00315 /*     End of CPPT05 */
00316 
00317 } /* cppt05_ */


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