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


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