dgbt02.c
Go to the documentation of this file.
00001 /* dgbt02.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 static doublereal c_b8 = -1.;
00020 static doublereal c_b10 = 1.;
00021 
00022 /* Subroutine */ int dgbt02_(char *trans, integer *m, integer *n, integer *kl, 
00023          integer *ku, integer *nrhs, doublereal *a, integer *lda, doublereal *
00024         x, integer *ldx, doublereal *b, integer *ldb, doublereal *resid)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, b_dim1, b_offset, x_dim1, x_offset, i__1, i__2, 
00028             i__3;
00029     doublereal d__1, d__2;
00030 
00031     /* Local variables */
00032     integer j, i1, i2, n1, kd;
00033     doublereal eps;
00034     extern /* Subroutine */ int dgbmv_(char *, integer *, integer *, integer *
00035 , integer *, doublereal *, doublereal *, integer *, doublereal *, 
00036             integer *, doublereal *, doublereal *, integer *);
00037     extern logical lsame_(char *, char *);
00038     extern doublereal dasum_(integer *, doublereal *, integer *);
00039     doublereal anorm, bnorm, xnorm;
00040     extern doublereal dlamch_(char *);
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 /*  DGBT02 computes the residual for a solution of a banded system of */
00056 /*  equations  A*x = b  or  A'*x = b: */
00057 /*     RESID = norm( B - A*X ) / ( norm(A) * norm(X) * EPS). */
00058 /*  where EPS is the machine precision. */
00059 
00060 /*  Arguments */
00061 /*  ========= */
00062 
00063 /*  TRANS   (input) CHARACTER*1 */
00064 /*          Specifies the form of the system of equations: */
00065 /*          = 'N':  A *x = b */
00066 /*          = 'T':  A'*x = b, where A' is the transpose of A */
00067 /*          = 'C':  A'*x = b, where A' is the transpose of A */
00068 
00069 /*  M       (input) INTEGER */
00070 /*          The number of rows of the matrix A.  M >= 0. */
00071 
00072 /*  N       (input) INTEGER */
00073 /*          The number of columns of the matrix A.  N >= 0. */
00074 
00075 /*  KL      (input) INTEGER */
00076 /*          The number of subdiagonals within the band of A.  KL >= 0. */
00077 
00078 /*  KU      (input) INTEGER */
00079 /*          The number of superdiagonals within the band of A.  KU >= 0. */
00080 
00081 /*  NRHS    (input) INTEGER */
00082 /*          The number of columns of B.  NRHS >= 0. */
00083 
00084 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00085 /*          The original matrix A in band storage, stored in rows 1 to */
00086 /*          KL+KU+1. */
00087 
00088 /*  LDA     (input) INTEGER */
00089 /*          The leading dimension of the array A.  LDA >= max(1,KL+KU+1). */
00090 
00091 /*  X       (input) DOUBLE PRECISION array, dimension (LDX,NRHS) */
00092 /*          The computed solution vectors for the system of linear */
00093 /*          equations. */
00094 
00095 /*  LDX     (input) INTEGER */
00096 /*          The leading dimension of the array X.  If TRANS = 'N', */
00097 /*          LDX >= max(1,N); if TRANS = 'T' or 'C', LDX >= max(1,M). */
00098 
00099 /*  B       (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
00100 /*          On entry, the right hand side vectors for the system of */
00101 /*          linear equations. */
00102 /*          On exit, B is overwritten with the difference B - A*X. */
00103 
00104 /*  LDB     (input) INTEGER */
00105 /*          The leading dimension of the array B.  IF TRANS = 'N', */
00106 /*          LDB >= max(1,M); if TRANS = 'T' or 'C', LDB >= max(1,N). */
00107 
00108 /*  RESID   (output) DOUBLE PRECISION */
00109 /*          The maximum over the number of right hand sides of */
00110 /*          norm(B - A*X) / ( norm(A) * norm(X) * EPS ). */
00111 
00112 /*  ===================================================================== */
00113 
00114 /*     .. Parameters .. */
00115 /*     .. */
00116 /*     .. Local Scalars .. */
00117 /*     .. */
00118 /*     .. External Functions .. */
00119 /*     .. */
00120 /*     .. External Subroutines .. */
00121 /*     .. */
00122 /*     .. Intrinsic Functions .. */
00123 /*     .. */
00124 /*     .. Executable Statements .. */
00125 
00126 /*     Quick return if N = 0 pr NRHS = 0 */
00127 
00128     /* Parameter adjustments */
00129     a_dim1 = *lda;
00130     a_offset = 1 + a_dim1;
00131     a -= a_offset;
00132     x_dim1 = *ldx;
00133     x_offset = 1 + x_dim1;
00134     x -= x_offset;
00135     b_dim1 = *ldb;
00136     b_offset = 1 + b_dim1;
00137     b -= b_offset;
00138 
00139     /* Function Body */
00140     if (*m <= 0 || *n <= 0 || *nrhs <= 0) {
00141         *resid = 0.;
00142         return 0;
00143     }
00144 
00145 /*     Exit with RESID = 1/EPS if ANORM = 0. */
00146 
00147     eps = dlamch_("Epsilon");
00148     kd = *ku + 1;
00149     anorm = 0.;
00150     i__1 = *n;
00151     for (j = 1; j <= i__1; ++j) {
00152 /* Computing MAX */
00153         i__2 = kd + 1 - j;
00154         i1 = max(i__2,1);
00155 /* Computing MIN */
00156         i__2 = kd + *m - j, i__3 = *kl + kd;
00157         i2 = min(i__2,i__3);
00158 /* Computing MAX */
00159         i__2 = i2 - i1 + 1;
00160         d__1 = anorm, d__2 = dasum_(&i__2, &a[i1 + j * a_dim1], &c__1);
00161         anorm = max(d__1,d__2);
00162 /* L10: */
00163     }
00164     if (anorm <= 0.) {
00165         *resid = 1. / eps;
00166         return 0;
00167     }
00168 
00169     if (lsame_(trans, "T") || lsame_(trans, "C")) {
00170         n1 = *n;
00171     } else {
00172         n1 = *m;
00173     }
00174 
00175 /*     Compute  B - A*X (or  B - A'*X ) */
00176 
00177     i__1 = *nrhs;
00178     for (j = 1; j <= i__1; ++j) {
00179         dgbmv_(trans, m, n, kl, ku, &c_b8, &a[a_offset], lda, &x[j * x_dim1 + 
00180                 1], &c__1, &c_b10, &b[j * b_dim1 + 1], &c__1);
00181 /* L20: */
00182     }
00183 
00184 /*     Compute the maximum over the number of right hand sides of */
00185 /*        norm(B - A*X) / ( norm(A) * norm(X) * EPS ). */
00186 
00187     *resid = 0.;
00188     i__1 = *nrhs;
00189     for (j = 1; j <= i__1; ++j) {
00190         bnorm = dasum_(&n1, &b[j * b_dim1 + 1], &c__1);
00191         xnorm = dasum_(&n1, &x[j * x_dim1 + 1], &c__1);
00192         if (xnorm <= 0.) {
00193             *resid = 1. / eps;
00194         } else {
00195 /* Computing MAX */
00196             d__1 = *resid, d__2 = bnorm / anorm / xnorm / eps;
00197             *resid = max(d__1,d__2);
00198         }
00199 /* L30: */
00200     }
00201 
00202     return 0;
00203 
00204 /*     End of DGBT02 */
00205 
00206 } /* dgbt02_ */


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