spot02.c
Go to the documentation of this file.
00001 /* spot02.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 real c_b5 = -1.f;
00019 static real c_b6 = 1.f;
00020 static integer c__1 = 1;
00021 
00022 /* Subroutine */ int spot02_(char *uplo, integer *n, integer *nrhs, real *a, 
00023         integer *lda, real *x, integer *ldx, real *b, integer *ldb, real *
00024         rwork, real *resid)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, b_dim1, b_offset, x_dim1, x_offset, i__1;
00028     real r__1, r__2;
00029 
00030     /* Local variables */
00031     integer j;
00032     real eps, anorm, bnorm;
00033     extern doublereal sasum_(integer *, real *, integer *);
00034     real xnorm;
00035     extern /* Subroutine */ int ssymm_(char *, char *, integer *, integer *, 
00036             real *, real *, integer *, real *, integer *, real *, real *, 
00037             integer *);
00038     extern doublereal slamch_(char *), slansy_(char *, char *, 
00039             integer *, real *, integer *, real *);
00040 
00041 
00042 /*  -- LAPACK test routine (version 3.1) -- */
00043 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00044 /*     November 2006 */
00045 
00046 /*     .. Scalar Arguments .. */
00047 /*     .. */
00048 /*     .. Array Arguments .. */
00049 /*     .. */
00050 
00051 /*  Purpose */
00052 /*  ======= */
00053 
00054 /*  SPOT02 computes the residual for the solution of a symmetric system */
00055 /*  of linear equations  A*x = b: */
00056 
00057 /*     RESID = norm(B - A*X) / ( norm(A) * norm(X) * EPS ), */
00058 
00059 /*  where EPS is the machine epsilon. */
00060 
00061 /*  Arguments */
00062 /*  ========= */
00063 
00064 /*  UPLO    (input) CHARACTER*1 */
00065 /*          Specifies whether the upper or lower triangular part of the */
00066 /*          symmetric matrix A is stored: */
00067 /*          = 'U':  Upper triangular */
00068 /*          = 'L':  Lower triangular */
00069 
00070 /*  N       (input) INTEGER */
00071 /*          The number of rows and columns of the matrix A.  N >= 0. */
00072 
00073 /*  NRHS    (input) INTEGER */
00074 /*          The number of columns of B, the matrix of right hand sides. */
00075 /*          NRHS >= 0. */
00076 
00077 /*  A       (input) REAL array, dimension (LDA,N) */
00078 /*          The original symmetric matrix A. */
00079 
00080 /*  LDA     (input) INTEGER */
00081 /*          The leading dimension of the array A.  LDA >= max(1,N) */
00082 
00083 /*  X       (input) REAL 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) REAL 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) REAL array, dimension (N) */
00099 
00100 /*  RESID   (output) REAL */
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_dim1 = *lda;
00122     a_offset = 1 + a_dim1;
00123     a -= a_offset;
00124     x_dim1 = *ldx;
00125     x_offset = 1 + x_dim1;
00126     x -= x_offset;
00127     b_dim1 = *ldb;
00128     b_offset = 1 + b_dim1;
00129     b -= b_offset;
00130     --rwork;
00131 
00132     /* Function Body */
00133     if (*n <= 0 || *nrhs <= 0) {
00134         *resid = 0.f;
00135         return 0;
00136     }
00137 
00138 /*     Exit with RESID = 1/EPS if ANORM = 0. */
00139 
00140     eps = slamch_("Epsilon");
00141     anorm = slansy_("1", uplo, n, &a[a_offset], lda, &rwork[1]);
00142     if (anorm <= 0.f) {
00143         *resid = 1.f / eps;
00144         return 0;
00145     }
00146 
00147 /*     Compute  B - A*X */
00148 
00149     ssymm_("Left", uplo, n, nrhs, &c_b5, &a[a_offset], lda, &x[x_offset], ldx, 
00150              &c_b6, &b[b_offset], ldb);
00151 
00152 /*     Compute the maximum over the number of right hand sides of */
00153 /*        norm( B - A*X ) / ( norm(A) * norm(X) * EPS ) . */
00154 
00155     *resid = 0.f;
00156     i__1 = *nrhs;
00157     for (j = 1; j <= i__1; ++j) {
00158         bnorm = sasum_(n, &b[j * b_dim1 + 1], &c__1);
00159         xnorm = sasum_(n, &x[j * x_dim1 + 1], &c__1);
00160         if (xnorm <= 0.f) {
00161             *resid = 1.f / eps;
00162         } else {
00163 /* Computing MAX */
00164             r__1 = *resid, r__2 = bnorm / anorm / xnorm / eps;
00165             *resid = dmax(r__1,r__2);
00166         }
00167 /* L10: */
00168     }
00169 
00170     return 0;
00171 
00172 /*     End of SPOT02 */
00173 
00174 } /* spot02_ */


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