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


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