dptt02.c
Go to the documentation of this file.
00001 /* dptt02.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 doublereal c_b4 = -1.;
00019 static doublereal c_b5 = 1.;
00020 static integer c__1 = 1;
00021 
00022 /* Subroutine */ int dptt02_(integer *n, integer *nrhs, doublereal *d__, 
00023         doublereal *e, doublereal *x, integer *ldx, doublereal *b, integer *
00024         ldb, doublereal *resid)
00025 {
00026     /* System generated locals */
00027     integer b_dim1, b_offset, x_dim1, x_offset, i__1;
00028     doublereal d__1, d__2;
00029 
00030     /* Local variables */
00031     integer j;
00032     doublereal eps;
00033     extern doublereal dasum_(integer *, doublereal *, integer *);
00034     doublereal anorm, bnorm, xnorm;
00035     extern doublereal dlamch_(char *);
00036     extern /* Subroutine */ int dlaptm_(integer *, integer *, doublereal *, 
00037             doublereal *, doublereal *, doublereal *, integer *, doublereal *, 
00038              doublereal *, integer *);
00039     extern doublereal dlanst_(char *, integer *, doublereal *, doublereal *);
00040 
00041 
00042 /*  -- LAPACK test routine (version 3.1) -- */
00043 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00044 /*     November 2006 */
00045 
00046 /*     .. Scalar Arguments .. */
00047 /*     .. */
00048 /*     .. Array Arguments .. */
00049 /*     .. */
00050 
00051 /*  Purpose */
00052 /*  ======= */
00053 
00054 /*  DPTT02 computes the residual for the solution to a symmetric */
00055 /*  tridiagonal system of equations: */
00056 /*     RESID = norm(B - A*X) / (norm(A) * norm(X) * EPS), */
00057 /*  where EPS is the machine epsilon. */
00058 
00059 /*  Arguments */
00060 /*  ========= */
00061 
00062 /*  N       (input) INTEGTER */
00063 /*          The order of the matrix A. */
00064 
00065 /*  NRHS    (input) INTEGER */
00066 /*          The number of right hand sides, i.e., the number of columns */
00067 /*          of the matrices B and X.  NRHS >= 0. */
00068 
00069 /*  D       (input) DOUBLE PRECISION array, dimension (N) */
00070 /*          The n diagonal elements of the tridiagonal matrix A. */
00071 
00072 /*  E       (input) DOUBLE PRECISION array, dimension (N-1) */
00073 /*          The (n-1) subdiagonal elements of the tridiagonal matrix A. */
00074 
00075 /*  X       (input) DOUBLE PRECISION array, dimension (LDX,NRHS) */
00076 /*          The n by nrhs matrix of solution vectors X. */
00077 
00078 /*  LDX     (input) INTEGER */
00079 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00080 
00081 /*  B       (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
00082 /*          On entry, the n by nrhs matrix of right hand side vectors B. */
00083 /*          On exit, B is overwritten with the difference B - A*X. */
00084 
00085 /*  LDB     (input) INTEGER */
00086 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00087 
00088 /*  RESID   (output) DOUBLE PRECISION */
00089 /*          norm(B - A*X) / (norm(A) * norm(X) * EPS) */
00090 
00091 /*  ===================================================================== */
00092 
00093 /*     .. Parameters .. */
00094 /*     .. */
00095 /*     .. Local Scalars .. */
00096 /*     .. */
00097 /*     .. External Functions .. */
00098 /*     .. */
00099 /*     .. Intrinsic Functions .. */
00100 /*     .. */
00101 /*     .. External Subroutines .. */
00102 /*     .. */
00103 /*     .. Executable Statements .. */
00104 
00105 /*     Quick return if possible */
00106 
00107     /* Parameter adjustments */
00108     --d__;
00109     --e;
00110     x_dim1 = *ldx;
00111     x_offset = 1 + x_dim1;
00112     x -= x_offset;
00113     b_dim1 = *ldb;
00114     b_offset = 1 + b_dim1;
00115     b -= b_offset;
00116 
00117     /* Function Body */
00118     if (*n <= 0) {
00119         *resid = 0.;
00120         return 0;
00121     }
00122 
00123 /*     Compute the 1-norm of the tridiagonal matrix A. */
00124 
00125     anorm = dlanst_("1", n, &d__[1], &e[1]);
00126 
00127 /*     Exit with RESID = 1/EPS if ANORM = 0. */
00128 
00129     eps = dlamch_("Epsilon");
00130     if (anorm <= 0.) {
00131         *resid = 1. / eps;
00132         return 0;
00133     }
00134 
00135 /*     Compute B - A*X. */
00136 
00137     dlaptm_(n, nrhs, &c_b4, &d__[1], &e[1], &x[x_offset], ldx, &c_b5, &b[
00138             b_offset], ldb);
00139 
00140 /*     Compute the maximum over the number of right hand sides of */
00141 /*        norm(B - A*X) / ( norm(A) * norm(X) * EPS ). */
00142 
00143     *resid = 0.;
00144     i__1 = *nrhs;
00145     for (j = 1; j <= i__1; ++j) {
00146         bnorm = dasum_(n, &b[j * b_dim1 + 1], &c__1);
00147         xnorm = dasum_(n, &x[j * x_dim1 + 1], &c__1);
00148         if (xnorm <= 0.) {
00149             *resid = 1. / eps;
00150         } else {
00151 /* Computing MAX */
00152             d__1 = *resid, d__2 = bnorm / anorm / xnorm / eps;
00153             *resid = max(d__1,d__2);
00154         }
00155 /* L10: */
00156     }
00157 
00158     return 0;
00159 
00160 /*     End of DPTT02 */
00161 
00162 } /* dptt02_ */


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