sget04.c
Go to the documentation of this file.
00001 /* sget04.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 integer c__1 = 1;
00019 
00020 /* Subroutine */ int sget04_(integer *n, integer *nrhs, real *x, integer *ldx, 
00021          real *xact, integer *ldxact, real *rcond, real *resid)
00022 {
00023     /* System generated locals */
00024     integer x_dim1, x_offset, xact_dim1, xact_offset, i__1, i__2;
00025     real r__1, r__2, r__3;
00026 
00027     /* Local variables */
00028     integer i__, j, ix;
00029     real eps, xnorm, diffnm;
00030     extern doublereal slamch_(char *);
00031     extern integer isamax_(integer *, real *, integer *);
00032 
00033 
00034 /*  -- LAPACK test routine (version 3.1) -- */
00035 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00036 /*     November 2006 */
00037 
00038 /*     .. Scalar Arguments .. */
00039 /*     .. */
00040 /*     .. Array Arguments .. */
00041 /*     .. */
00042 
00043 /*  Purpose */
00044 /*  ======= */
00045 
00046 /*  SGET04 computes the difference between a computed solution and the */
00047 /*  true solution to a system of linear equations. */
00048 
00049 /*  RESID =  ( norm(X-XACT) * RCOND ) / ( norm(XACT) * EPS ), */
00050 /*  where RCOND is the reciprocal of the condition number and EPS is the */
00051 /*  machine epsilon. */
00052 
00053 /*  Arguments */
00054 /*  ========= */
00055 
00056 /*  N       (input) INTEGER */
00057 /*          The number of rows of the matrices X and XACT.  N >= 0. */
00058 
00059 /*  NRHS    (input) INTEGER */
00060 /*          The number of columns of the matrices X and XACT.  NRHS >= 0. */
00061 
00062 /*  X       (input) REAL array, dimension (LDX,NRHS) */
00063 /*          The computed solution vectors.  Each vector is stored as a */
00064 /*          column of the matrix X. */
00065 
00066 /*  LDX     (input) INTEGER */
00067 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00068 
00069 /*  XACT    (input) REAL array, dimension( LDX, NRHS ) */
00070 /*          The exact solution vectors.  Each vector is stored as a */
00071 /*          column of the matrix XACT. */
00072 
00073 /*  LDXACT  (input) INTEGER */
00074 /*          The leading dimension of the array XACT.  LDXACT >= max(1,N). */
00075 
00076 /*  RCOND   (input) REAL */
00077 /*          The reciprocal of the condition number of the coefficient */
00078 /*          matrix in the system of equations. */
00079 
00080 /*  RESID   (output) REAL */
00081 /*          The maximum over the NRHS solution vectors of */
00082 /*          ( norm(X-XACT) * RCOND ) / ( norm(XACT) * EPS ) */
00083 
00084 /*  ===================================================================== */
00085 
00086 /*     .. Parameters .. */
00087 /*     .. */
00088 /*     .. Local Scalars .. */
00089 /*     .. */
00090 /*     .. External Functions .. */
00091 /*     .. */
00092 /*     .. Intrinsic Functions .. */
00093 /*     .. */
00094 /*     .. Executable Statements .. */
00095 
00096 /*     Quick exit if N = 0 or NRHS = 0. */
00097 
00098     /* Parameter adjustments */
00099     x_dim1 = *ldx;
00100     x_offset = 1 + x_dim1;
00101     x -= x_offset;
00102     xact_dim1 = *ldxact;
00103     xact_offset = 1 + xact_dim1;
00104     xact -= xact_offset;
00105 
00106     /* Function Body */
00107     if (*n <= 0 || *nrhs <= 0) {
00108         *resid = 0.f;
00109         return 0;
00110     }
00111 
00112 /*     Exit with RESID = 1/EPS if RCOND is invalid. */
00113 
00114     eps = slamch_("Epsilon");
00115     if (*rcond < 0.f) {
00116         *resid = 1.f / eps;
00117         return 0;
00118     }
00119 
00120 /*     Compute the maximum of */
00121 /*        norm(X - XACT) / ( norm(XACT) * EPS ) */
00122 /*     over all the vectors X and XACT . */
00123 
00124     *resid = 0.f;
00125     i__1 = *nrhs;
00126     for (j = 1; j <= i__1; ++j) {
00127         ix = isamax_(n, &xact[j * xact_dim1 + 1], &c__1);
00128         xnorm = (r__1 = xact[ix + j * xact_dim1], dabs(r__1));
00129         diffnm = 0.f;
00130         i__2 = *n;
00131         for (i__ = 1; i__ <= i__2; ++i__) {
00132 /* Computing MAX */
00133             r__2 = diffnm, r__3 = (r__1 = x[i__ + j * x_dim1] - xact[i__ + j *
00134                      xact_dim1], dabs(r__1));
00135             diffnm = dmax(r__2,r__3);
00136 /* L10: */
00137         }
00138         if (xnorm <= 0.f) {
00139             if (diffnm > 0.f) {
00140                 *resid = 1.f / eps;
00141             }
00142         } else {
00143 /* Computing MAX */
00144             r__1 = *resid, r__2 = diffnm / xnorm * *rcond;
00145             *resid = dmax(r__1,r__2);
00146         }
00147 /* L20: */
00148     }
00149     if (*resid * eps < 1.f) {
00150         *resid /= eps;
00151     }
00152 
00153     return 0;
00154 
00155 /*     End of SGET04 */
00156 
00157 } /* sget04_ */


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