sget02.c
Go to the documentation of this file.
00001 /* sget02.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_b7 = -1.f;
00019 static real c_b8 = 1.f;
00020 static integer c__1 = 1;
00021 
00022 /* Subroutine */ int sget02_(char *trans, integer *m, integer *n, integer *
00023         nrhs, real *a, integer *lda, real *x, integer *ldx, real *b, integer *
00024         ldb, real *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, n1, n2;
00032     real eps;
00033     extern logical lsame_(char *, char *);
00034     extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *, 
00035             integer *, real *, real *, integer *, real *, integer *, real *, 
00036             real *, integer *);
00037     real anorm, bnorm;
00038     extern doublereal sasum_(integer *, real *, integer *);
00039     real xnorm;
00040     extern doublereal slamch_(char *), slange_(char *, integer *, 
00041             integer *, real *, integer *, real *);
00042 
00043 
00044 /*  -- LAPACK test routine (version 3.1) -- */
00045 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00046 /*     November 2006 */
00047 
00048 /*     .. Scalar Arguments .. */
00049 /*     .. */
00050 /*     .. Array Arguments .. */
00051 /*     .. */
00052 
00053 /*  Purpose */
00054 /*  ======= */
00055 
00056 /*  SGET02 computes the residual for a solution of a system of linear */
00057 /*  equations  A*x = b  or  A'*x = b: */
00058 /*     RESID = norm(B - A*X) / ( norm(A) * norm(X) * EPS ), */
00059 /*  where EPS is the machine epsilon. */
00060 
00061 /*  Arguments */
00062 /*  ========= */
00063 
00064 /*  TRANS   (input) CHARACTER*1 */
00065 /*          Specifies the form of the system of equations: */
00066 /*          = 'N':  A *x = b */
00067 /*          = 'T':  A'*x = b, where A' is the transpose of A */
00068 /*          = 'C':  A'*x = b, where A' is the transpose of A */
00069 
00070 /*  M       (input) INTEGER */
00071 /*          The number of rows of the matrix A.  M >= 0. */
00072 
00073 /*  N       (input) INTEGER */
00074 /*          The number of columns of the matrix A.  N >= 0. */
00075 
00076 /*  NRHS    (input) INTEGER */
00077 /*          The number of columns of B, the matrix of right hand sides. */
00078 /*          NRHS >= 0. */
00079 
00080 /*  A       (input) REAL array, dimension (LDA,N) */
00081 /*          The original M x N matrix A. */
00082 
00083 /*  LDA     (input) INTEGER */
00084 /*          The leading dimension of the array A.  LDA >= max(1,M). */
00085 
00086 /*  X       (input) REAL array, dimension (LDX,NRHS) */
00087 /*          The computed solution vectors for the system of linear */
00088 /*          equations. */
00089 
00090 /*  LDX     (input) INTEGER */
00091 /*          The leading dimension of the array X.  If TRANS = 'N', */
00092 /*          LDX >= max(1,N); if TRANS = 'T' or 'C', LDX >= max(1,M). */
00093 
00094 /*  B       (input/output) REAL array, dimension (LDB,NRHS) */
00095 /*          On entry, the right hand side vectors for the system of */
00096 /*          linear equations. */
00097 /*          On exit, B is overwritten with the difference B - A*X. */
00098 
00099 /*  LDB     (input) INTEGER */
00100 /*          The leading dimension of the array B.  IF TRANS = 'N', */
00101 /*          LDB >= max(1,M); if TRANS = 'T' or 'C', LDB >= max(1,N). */
00102 
00103 /*  RWORK   (workspace) REAL array, dimension (M) */
00104 
00105 /*  RESID   (output) REAL */
00106 /*          The maximum over the number of right hand sides of */
00107 /*          norm(B - A*X) / ( norm(A) * norm(X) * EPS ). */
00108 
00109 /*  ===================================================================== */
00110 
00111 /*     .. Parameters .. */
00112 /*     .. */
00113 /*     .. Local Scalars .. */
00114 /*     .. */
00115 /*     .. External Functions .. */
00116 /*     .. */
00117 /*     .. External Subroutines .. */
00118 /*     .. */
00119 /*     .. Intrinsic Functions .. */
00120 /*     .. */
00121 /*     .. Executable Statements .. */
00122 
00123 /*     Quick exit if M = 0 or N = 0 or NRHS = 0 */
00124 
00125     /* Parameter adjustments */
00126     a_dim1 = *lda;
00127     a_offset = 1 + a_dim1;
00128     a -= a_offset;
00129     x_dim1 = *ldx;
00130     x_offset = 1 + x_dim1;
00131     x -= x_offset;
00132     b_dim1 = *ldb;
00133     b_offset = 1 + b_dim1;
00134     b -= b_offset;
00135     --rwork;
00136 
00137     /* Function Body */
00138     if (*m <= 0 || *n <= 0 || *nrhs == 0) {
00139         *resid = 0.f;
00140         return 0;
00141     }
00142 
00143     if (lsame_(trans, "T") || lsame_(trans, "C")) {
00144         n1 = *n;
00145         n2 = *m;
00146     } else {
00147         n1 = *m;
00148         n2 = *n;
00149     }
00150 
00151 /*     Exit with RESID = 1/EPS if ANORM = 0. */
00152 
00153     eps = slamch_("Epsilon");
00154     anorm = slange_("1", &n1, &n2, &a[a_offset], lda, &rwork[1]);
00155     if (anorm <= 0.f) {
00156         *resid = 1.f / eps;
00157         return 0;
00158     }
00159 
00160 /*     Compute  B - A*X  (or  B - A'*X ) and store in B. */
00161 
00162     sgemm_(trans, "No transpose", &n1, nrhs, &n2, &c_b7, &a[a_offset], lda, &
00163             x[x_offset], ldx, &c_b8, &b[b_offset], ldb)
00164             ;
00165 
00166 /*     Compute the maximum over the number of right hand sides of */
00167 /*        norm(B - A*X) / ( norm(A) * norm(X) * EPS ) . */
00168 
00169     *resid = 0.f;
00170     i__1 = *nrhs;
00171     for (j = 1; j <= i__1; ++j) {
00172         bnorm = sasum_(&n1, &b[j * b_dim1 + 1], &c__1);
00173         xnorm = sasum_(&n2, &x[j * x_dim1 + 1], &c__1);
00174         if (xnorm <= 0.f) {
00175             *resid = 1.f / eps;
00176         } else {
00177 /* Computing MAX */
00178             r__1 = *resid, r__2 = bnorm / anorm / xnorm / eps;
00179             *resid = dmax(r__1,r__2);
00180         }
00181 /* L10: */
00182     }
00183 
00184     return 0;
00185 
00186 /*     End of SGET02 */
00187 
00188 } /* sget02_ */


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