stbt02.c
Go to the documentation of this file.
00001 /* stbt02.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 real c_b10 = -1.f;
00020 
00021 /* Subroutine */ int stbt02_(char *uplo, char *trans, char *diag, integer *n, 
00022         integer *kd, integer *nrhs, real *ab, integer *ldab, real *x, integer 
00023         *ldx, real *b, integer *ldb, real *work, real *resid)
00024 {
00025     /* System generated locals */
00026     integer ab_dim1, ab_offset, b_dim1, b_offset, x_dim1, x_offset, i__1;
00027     real r__1, r__2;
00028 
00029     /* Local variables */
00030     integer j;
00031     real eps;
00032     extern logical lsame_(char *, char *);
00033     real anorm, bnorm;
00034     extern doublereal sasum_(integer *, real *, integer *);
00035     extern /* Subroutine */ int stbmv_(char *, char *, char *, integer *, 
00036             integer *, real *, integer *, real *, integer *), scopy_(integer *, real *, integer *, real *, integer *);
00037     real xnorm;
00038     extern /* Subroutine */ int saxpy_(integer *, real *, real *, integer *, 
00039             real *, integer *);
00040     extern doublereal slamch_(char *), slantb_(char *, char *, char *, 
00041              integer *, 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 /*  STBT02 computes the residual for the computed solution to a */
00057 /*  triangular system of linear equations  A*x = b  or  A' *x = b when */
00058 /*  A is a triangular band matrix.  Here A' is the transpose of A and */
00059 /*  x and b are N by NRHS matrices.  The test ratio is the maximum over */
00060 /*  the number of right hand sides of */
00061 /*     norm(b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ), */
00062 /*  where op(A) denotes A or A' and EPS is the machine epsilon. */
00063 
00064 /*  Arguments */
00065 /*  ========= */
00066 
00067 /*  UPLO    (input) CHARACTER*1 */
00068 /*          Specifies whether the matrix A is upper or lower triangular. */
00069 /*          = 'U':  Upper triangular */
00070 /*          = 'L':  Lower triangular */
00071 
00072 /*  TRANS   (input) CHARACTER*1 */
00073 /*          Specifies the operation applied to A. */
00074 /*          = 'N':  A *x = b  (No transpose) */
00075 /*          = 'T':  A'*x = b  (Transpose) */
00076 /*          = 'C':  A'*x = b  (Conjugate transpose = Transpose) */
00077 
00078 /*  DIAG    (input) CHARACTER*1 */
00079 /*          Specifies whether or not the matrix A is unit triangular. */
00080 /*          = 'N':  Non-unit triangular */
00081 /*          = 'U':  Unit triangular */
00082 
00083 /*  N       (input) INTEGER */
00084 /*          The order of the matrix A.  N >= 0. */
00085 
00086 /*  KD      (input) INTEGER */
00087 /*          The number of superdiagonals or subdiagonals of the */
00088 /*          triangular band matrix A.  KD >= 0. */
00089 
00090 /*  NRHS    (input) INTEGER */
00091 /*          The number of right hand sides, i.e., the number of columns */
00092 /*          of the matrices X and B.  NRHS >= 0. */
00093 
00094 /*  AB      (input) REAL array, dimension (LDAB,N) */
00095 /*          The upper or lower triangular band matrix A, stored in the */
00096 /*          first kd+1 rows of the array. The j-th column of A is stored */
00097 /*          in the j-th column of the array AB as follows: */
00098 /*          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; */
00099 /*          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd). */
00100 
00101 /*  LDAB    (input) INTEGER */
00102 /*          The leading dimension of the array AB.  LDAB >= KD+1. */
00103 
00104 /*  X       (input) REAL array, dimension (LDX,NRHS) */
00105 /*          The computed solution vectors for the system of linear */
00106 /*          equations. */
00107 
00108 /*  LDX     (input) INTEGER */
00109 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00110 
00111 /*  B       (input) REAL array, dimension (LDB,NRHS) */
00112 /*          The right hand side vectors for the system of linear */
00113 /*          equations. */
00114 
00115 /*  LDB     (input) INTEGER */
00116 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00117 
00118 /*  WORK    (workspace) REAL array, dimension (N) */
00119 
00120 /*  RESID   (output) REAL */
00121 /*          The maximum over the number of right hand sides of */
00122 /*          norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ). */
00123 
00124 /*  ===================================================================== */
00125 
00126 /*     .. Parameters .. */
00127 /*     .. */
00128 /*     .. Local Scalars .. */
00129 /*     .. */
00130 /*     .. External Functions .. */
00131 /*     .. */
00132 /*     .. External Subroutines .. */
00133 /*     .. */
00134 /*     .. Intrinsic Functions .. */
00135 /*     .. */
00136 /*     .. Executable Statements .. */
00137 
00138 /*     Quick exit if N = 0 or NRHS = 0 */
00139 
00140     /* Parameter adjustments */
00141     ab_dim1 = *ldab;
00142     ab_offset = 1 + ab_dim1;
00143     ab -= ab_offset;
00144     x_dim1 = *ldx;
00145     x_offset = 1 + x_dim1;
00146     x -= x_offset;
00147     b_dim1 = *ldb;
00148     b_offset = 1 + b_dim1;
00149     b -= b_offset;
00150     --work;
00151 
00152     /* Function Body */
00153     if (*n <= 0 || *nrhs <= 0) {
00154         *resid = 0.f;
00155         return 0;
00156     }
00157 
00158 /*     Compute the 1-norm of A or A'. */
00159 
00160     if (lsame_(trans, "N")) {
00161         anorm = slantb_("1", uplo, diag, n, kd, &ab[ab_offset], ldab, &work[1]
00162 );
00163     } else {
00164         anorm = slantb_("I", uplo, diag, n, kd, &ab[ab_offset], ldab, &work[1]
00165 );
00166     }
00167 
00168 /*     Exit with RESID = 1/EPS if ANORM = 0. */
00169 
00170     eps = slamch_("Epsilon");
00171     if (anorm <= 0.f) {
00172         *resid = 1.f / eps;
00173         return 0;
00174     }
00175 
00176 /*     Compute the maximum over the number of right hand sides of */
00177 /*        norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ). */
00178 
00179     *resid = 0.f;
00180     i__1 = *nrhs;
00181     for (j = 1; j <= i__1; ++j) {
00182         scopy_(n, &x[j * x_dim1 + 1], &c__1, &work[1], &c__1);
00183         stbmv_(uplo, trans, diag, n, kd, &ab[ab_offset], ldab, &work[1], &
00184                 c__1);
00185         saxpy_(n, &c_b10, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1);
00186         bnorm = sasum_(n, &work[1], &c__1);
00187         xnorm = sasum_(n, &x[j * x_dim1 + 1], &c__1);
00188         if (xnorm <= 0.f) {
00189             *resid = 1.f / eps;
00190         } else {
00191 /* Computing MAX */
00192             r__1 = *resid, r__2 = bnorm / anorm / xnorm / eps;
00193             *resid = dmax(r__1,r__2);
00194         }
00195 /* L10: */
00196     }
00197 
00198     return 0;
00199 
00200 /*     End of STBT02 */
00201 
00202 } /* stbt02_ */


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