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


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