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


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