dpot06.c
Go to the documentation of this file.
00001 /* dpot06.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 dpot06_(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     integer ifail;
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 *);
00040     extern integer idamax_(integer *, doublereal *, integer *);
00041     extern doublereal dlansy_(char *, char *, integer *, doublereal *, 
00042             integer *, doublereal *);
00043 
00044 
00045 /*  -- LAPACK test routine (version 3.1.2) -- */
00046 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00047 /*     April 2007 */
00048 
00049 /*     .. Scalar Arguments .. */
00050 /*     .. */
00051 /*     .. Array Arguments .. */
00052 /*     .. */
00053 
00054 /*  Purpose */
00055 /*  ======= */
00056 
00057 /*  DPOT06 computes the residual for a solution of a system of linear */
00058 /*  equations  A*x = b : */
00059 /*     RESID = norm(B - A*X,inf) / ( norm(A,inf) * norm(X,inf) * EPS ), */
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 M x N 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.  If TRANS = 'N', */
00090 /*          LDX >= max(1,N); if TRANS = 'T' or 'C', LDX >= max(1,N). */
00091 
00092 /*  B       (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
00093 /*          On entry, the right hand side vectors for the system of */
00094 /*          linear equations. */
00095 /*          On exit, B is overwritten with the difference B - A*X. */
00096 
00097 /*  LDB     (input) INTEGER */
00098 /*          The leading dimension of the array B.  IF TRANS = 'N', */
00099 /*          LDB >= max(1,M); if TRANS = 'T' or 'C', LDB >= max(1,N). */
00100 
00101 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (N) */
00102 
00103 /*  RESID   (output) DOUBLE PRECISION */
00104 /*          The maximum over the number of right hand sides of */
00105 /*          norm(B - 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     a_dim1 = *lda;
00125     a_offset = 1 + a_dim1;
00126     a -= a_offset;
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     if (*n <= 0 || *nrhs == 0) {
00137         *resid = 0.;
00138         return 0;
00139     }
00140 
00141 /*     Exit with RESID = 1/EPS if ANORM = 0. */
00142 
00143     eps = dlamch_("Epsilon");
00144     anorm = dlansy_("I", uplo, n, &a[a_offset], lda, &rwork[1]);
00145     if (anorm <= 0.) {
00146         *resid = 1. / eps;
00147         return 0;
00148     }
00149 
00150 /*     Compute  B - A*X  and store in B. */
00151     ifail = 0;
00152 
00153     dsymm_("Left", uplo, n, nrhs, &c_b5, &a[a_offset], lda, &x[x_offset], ldx, 
00154              &c_b6, &b[b_offset], ldb);
00155 
00156 /*     Compute the maximum over the number of right hand sides of */
00157 /*        norm(B - A*X) / ( norm(A) * norm(X) * EPS ) . */
00158 
00159     *resid = 0.;
00160     i__1 = *nrhs;
00161     for (j = 1; j <= i__1; ++j) {
00162         bnorm = (d__1 = b[idamax_(n, &b[j * b_dim1 + 1], &c__1) + j * b_dim1],
00163                  abs(d__1));
00164         xnorm = (d__1 = x[idamax_(n, &x[j * x_dim1 + 1], &c__1) + j * x_dim1],
00165                  abs(d__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 DPOT06 */
00179 
00180 } /* dpot06_ */


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