ztbt03.c
Go to the documentation of this file.
00001 /* ztbt03.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 ztbt03_(char *uplo, char *trans, char *diag, integer *n, 
00021         integer *kd, integer *nrhs, doublecomplex *ab, integer *ldab, 
00022         doublereal *scale, doublereal *cnorm, doublereal *tscal, 
00023         doublecomplex *x, integer *ldx, doublecomplex *b, integer *ldb, 
00024         doublecomplex *work, 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     doublecomplex z__1;
00030 
00031     /* Builtin functions */
00032     double z_abs(doublecomplex *);
00033 
00034     /* Local variables */
00035     integer j, ix;
00036     doublereal eps, err;
00037     extern logical lsame_(char *, char *);
00038     doublereal xscal, tnorm;
00039     extern /* Subroutine */ int ztbmv_(char *, char *, char *, integer *, 
00040             integer *, doublecomplex *, integer *, doublecomplex *, integer *);
00041     doublereal xnorm;
00042     extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, 
00043             doublecomplex *, integer *), zaxpy_(integer *, doublecomplex *, 
00044             doublecomplex *, integer *, doublecomplex *, integer *);
00045     extern doublereal dlamch_(char *);
00046     extern /* Subroutine */ int zdscal_(integer *, doublereal *, 
00047             doublecomplex *, integer *);
00048     extern integer izamax_(integer *, doublecomplex *, integer *);
00049     doublereal smlnum;
00050 
00051 
00052 /*  -- LAPACK test routine (version 3.1) -- */
00053 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00054 /*     November 2006 */
00055 
00056 /*     .. Scalar Arguments .. */
00057 /*     .. */
00058 /*     .. Array Arguments .. */
00059 /*     .. */
00060 
00061 /*  Purpose */
00062 /*  ======= */
00063 
00064 /*  ZTBT03 computes the residual for the solution to a scaled triangular */
00065 /*  system of equations  A*x = s*b,  A**T *x = s*b,  or  A**H *x = s*b */
00066 /*  when A is a triangular band matrix.  Here A**T  denotes the transpose */
00067 /*  of A, A**H denotes the conjugate transpose of A, s is a scalar, and */
00068 /*  x and b are N by NRHS matrices.  The test ratio is the maximum over */
00069 /*  the number of right hand sides of */
00070 /*     norm(s*b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ), */
00071 /*  where op(A) denotes A, A**T, or A**H, and EPS is the machine epsilon. */
00072 
00073 /*  Arguments */
00074 /*  ========= */
00075 
00076 /*  UPLO    (input) CHARACTER*1 */
00077 /*          Specifies whether the matrix A is upper or lower triangular. */
00078 /*          = 'U':  Upper triangular */
00079 /*          = 'L':  Lower triangular */
00080 
00081 /*  TRANS   (input) CHARACTER*1 */
00082 /*          Specifies the operation applied to A. */
00083 /*          = 'N':  A *x = s*b     (No transpose) */
00084 /*          = 'T':  A**T *x = s*b  (Transpose) */
00085 /*          = 'C':  A**H *x = s*b  (Conjugate transpose) */
00086 
00087 /*  DIAG    (input) CHARACTER*1 */
00088 /*          Specifies whether or not the matrix A is unit triangular. */
00089 /*          = 'N':  Non-unit triangular */
00090 /*          = 'U':  Unit triangular */
00091 
00092 /*  N       (input) INTEGER */
00093 /*          The order of the matrix A.  N >= 0. */
00094 
00095 /*  KD      (input) INTEGER */
00096 /*          The number of superdiagonals or subdiagonals of the */
00097 /*          triangular band matrix A.  KD >= 0. */
00098 
00099 /*  NRHS    (input) INTEGER */
00100 /*          The number of right hand sides, i.e., the number of columns */
00101 /*          of the matrices X and B.  NRHS >= 0. */
00102 
00103 /*  AB      (input) COMPLEX*16 array, dimension (LDAB,N) */
00104 /*          The upper or lower triangular band matrix A, stored in the */
00105 /*          first kd+1 rows of the array. The j-th column of A is stored */
00106 /*          in the j-th column of the array AB as follows: */
00107 /*          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; */
00108 /*          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd). */
00109 
00110 /*  LDAB    (input) INTEGER */
00111 /*          The leading dimension of the array AB.  LDAB >= KD+1. */
00112 
00113 /*  SCALE   (input) DOUBLE PRECISION */
00114 /*          The scaling factor s used in solving the triangular system. */
00115 
00116 /*  CNORM   (input) DOUBLE PRECISION array, dimension (N) */
00117 /*          The 1-norms of the columns of A, not counting the diagonal. */
00118 
00119 /*  TSCAL   (input) DOUBLE PRECISION */
00120 /*          The scaling factor used in computing the 1-norms in CNORM. */
00121 /*          CNORM actually contains the column norms of TSCAL*A. */
00122 
00123 /*  X       (input) COMPLEX*16 array, dimension (LDX,NRHS) */
00124 /*          The computed solution vectors for the system of linear */
00125 /*          equations. */
00126 
00127 /*  LDX     (input) INTEGER */
00128 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00129 
00130 /*  B       (input) COMPLEX*16 array, dimension (LDB,NRHS) */
00131 /*          The right hand side vectors for the system of linear */
00132 /*          equations. */
00133 
00134 /*  LDB     (input) INTEGER */
00135 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00136 
00137 /*  WORK    (workspace) COMPLEX*16 array, dimension (N) */
00138 
00139 /*  RESID   (output) DOUBLE PRECISION */
00140 /*          The maximum over the number of right hand sides of */
00141 /*          norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ). */
00142 
00143 /*  ===================================================================== */
00144 
00145 
00146 /*     .. Parameters .. */
00147 /*     .. */
00148 /*     .. Local Scalars .. */
00149 /*     .. */
00150 /*     .. External Functions .. */
00151 /*     .. */
00152 /*     .. External Subroutines .. */
00153 /*     .. */
00154 /*     .. Intrinsic Functions .. */
00155 /*     .. */
00156 /*     .. Executable Statements .. */
00157 
00158 /*     Quick exit if N = 0 */
00159 
00160     /* Parameter adjustments */
00161     ab_dim1 = *ldab;
00162     ab_offset = 1 + ab_dim1;
00163     ab -= ab_offset;
00164     --cnorm;
00165     x_dim1 = *ldx;
00166     x_offset = 1 + x_dim1;
00167     x -= x_offset;
00168     b_dim1 = *ldb;
00169     b_offset = 1 + b_dim1;
00170     b -= b_offset;
00171     --work;
00172 
00173     /* Function Body */
00174     if (*n <= 0 || *nrhs <= 0) {
00175         *resid = 0.;
00176         return 0;
00177     }
00178     eps = dlamch_("Epsilon");
00179     smlnum = dlamch_("Safe minimum");
00180 
00181 /*     Compute the norm of the triangular matrix A using the column */
00182 /*     norms already computed by ZLATBS. */
00183 
00184     tnorm = 0.;
00185     if (lsame_(diag, "N")) {
00186         if (lsame_(uplo, "U")) {
00187             i__1 = *n;
00188             for (j = 1; j <= i__1; ++j) {
00189 /* Computing MAX */
00190                 d__1 = tnorm, d__2 = *tscal * z_abs(&ab[*kd + 1 + j * ab_dim1]
00191                         ) + cnorm[j];
00192                 tnorm = max(d__1,d__2);
00193 /* L10: */
00194             }
00195         } else {
00196             i__1 = *n;
00197             for (j = 1; j <= i__1; ++j) {
00198 /* Computing MAX */
00199                 d__1 = tnorm, d__2 = *tscal * z_abs(&ab[j * ab_dim1 + 1]) + 
00200                         cnorm[j];
00201                 tnorm = max(d__1,d__2);
00202 /* L20: */
00203             }
00204         }
00205     } else {
00206         i__1 = *n;
00207         for (j = 1; j <= i__1; ++j) {
00208 /* Computing MAX */
00209             d__1 = tnorm, d__2 = *tscal + cnorm[j];
00210             tnorm = max(d__1,d__2);
00211 /* L30: */
00212         }
00213     }
00214 
00215 /*     Compute the maximum over the number of right hand sides of */
00216 /*        norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ). */
00217 
00218     *resid = 0.;
00219     i__1 = *nrhs;
00220     for (j = 1; j <= i__1; ++j) {
00221         zcopy_(n, &x[j * x_dim1 + 1], &c__1, &work[1], &c__1);
00222         ix = izamax_(n, &work[1], &c__1);
00223 /* Computing MAX */
00224         d__1 = 1., d__2 = z_abs(&x[ix + j * x_dim1]);
00225         xnorm = max(d__1,d__2);
00226         xscal = 1. / xnorm / (doublereal) (*kd + 1);
00227         zdscal_(n, &xscal, &work[1], &c__1);
00228         ztbmv_(uplo, trans, diag, n, kd, &ab[ab_offset], ldab, &work[1], &
00229                 c__1);
00230         d__1 = -(*scale) * xscal;
00231         z__1.r = d__1, z__1.i = 0.;
00232         zaxpy_(n, &z__1, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1);
00233         ix = izamax_(n, &work[1], &c__1);
00234         err = *tscal * z_abs(&work[ix]);
00235         ix = izamax_(n, &x[j * x_dim1 + 1], &c__1);
00236         xnorm = z_abs(&x[ix + j * x_dim1]);
00237         if (err * smlnum <= xnorm) {
00238             if (xnorm > 0.) {
00239                 err /= xnorm;
00240             }
00241         } else {
00242             if (err > 0.) {
00243                 err = 1. / eps;
00244             }
00245         }
00246         if (err * smlnum <= tnorm) {
00247             if (tnorm > 0.) {
00248                 err /= tnorm;
00249             }
00250         } else {
00251             if (err > 0.) {
00252                 err = 1. / eps;
00253             }
00254         }
00255         *resid = max(*resid,err);
00256 /* L40: */
00257     }
00258 
00259     return 0;
00260 
00261 /*     End of ZTBT03 */
00262 
00263 } /* ztbt03_ */


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