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


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