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


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