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


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