ztpt02.c
Go to the documentation of this file.
00001 /* ztpt02.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 ztpt02_(char *uplo, char *trans, char *diag, integer *n, 
00022         integer *nrhs, doublecomplex *ap, doublecomplex *x, integer *ldx, 
00023         doublecomplex *b, integer *ldb, doublecomplex *work, doublereal *
00024         rwork, doublereal *resid)
00025 {
00026     /* System generated locals */
00027     integer 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, xnorm;
00035     extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, 
00036             doublecomplex *, integer *), zaxpy_(integer *, doublecomplex *, 
00037             doublecomplex *, integer *, doublecomplex *, integer *), ztpmv_(
00038             char *, char *, char *, integer *, doublecomplex *, doublecomplex 
00039             *, integer *);
00040     extern doublereal dlamch_(char *), dzasum_(integer *, 
00041             doublecomplex *, integer *), zlantp_(char *, char *, char *, 
00042             integer *, doublecomplex *, doublereal *);
00043 
00044 
00045 /*  -- LAPACK test routine (version 3.1) -- */
00046 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00047 /*     November 2006 */
00048 
00049 /*     .. Scalar Arguments .. */
00050 /*     .. */
00051 /*     .. Array Arguments .. */
00052 /*     .. */
00053 
00054 /*  Purpose */
00055 /*  ======= */
00056 
00057 /*  ZTPT02 computes the residual for the computed solution to a */
00058 /*  triangular system of linear equations  A*x = b,  A**T *x = b,  or */
00059 /*  A**H *x = b, when the triangular matrix A is stored in packed format. */
00060 /*  Here A**T denotes the transpose of A, A**H denotes the conjugate */
00061 /*  transpose of A, and x and b are N by NRHS matrices.  The test ratio */
00062 /*  is the maximum over the number of right hand sides of */
00063 /*  the maximum over 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 /*  NRHS    (input) INTEGER */
00090 /*          The number of right hand sides, i.e., the number of columns */
00091 /*          of the matrices X and B.  NRHS >= 0. */
00092 
00093 /*  AP      (input) COMPLEX*16 array, dimension (N*(N+1)/2) */
00094 /*          The upper or lower triangular matrix A, packed columnwise in */
00095 /*          a linear array.  The j-th column of A is stored in the array */
00096 /*          AP as follows: */
00097 /*          if UPLO = 'U', AP((j-1)*j/2 + i) = A(i,j) for 1<=i<=j; */
00098 /*          if UPLO = 'L', */
00099 /*             AP((j-1)*(n-j) + j*(j+1)/2 + i-j) = A(i,j) for j<=i<=n. */
00100 
00101 /*  X       (input) COMPLEX*16 array, dimension (LDX,NRHS) */
00102 /*          The computed solution vectors for the system of linear */
00103 /*          equations. */
00104 
00105 /*  LDX     (input) INTEGER */
00106 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00107 
00108 /*  B       (input) COMPLEX*16 array, dimension (LDB,NRHS) */
00109 /*          The right hand side vectors for the system of linear */
00110 /*          equations. */
00111 
00112 /*  LDB     (input) INTEGER */
00113 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00114 
00115 /*  WORK    (workspace) COMPLEX*16 array, dimension (N) */
00116 
00117 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (N) */
00118 
00119 /*  RESID   (output) DOUBLE PRECISION */
00120 /*          The maximum over the number of right hand sides of */
00121 /*          norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ). */
00122 
00123 /*  ===================================================================== */
00124 
00125 /*     .. Parameters .. */
00126 /*     .. */
00127 /*     .. Local Scalars .. */
00128 /*     .. */
00129 /*     .. External Functions .. */
00130 /*     .. */
00131 /*     .. External Subroutines .. */
00132 /*     .. */
00133 /*     .. Intrinsic Functions .. */
00134 /*     .. */
00135 /*     .. Executable Statements .. */
00136 
00137 /*     Quick exit if N = 0 or NRHS = 0 */
00138 
00139     /* Parameter adjustments */
00140     --ap;
00141     x_dim1 = *ldx;
00142     x_offset = 1 + x_dim1;
00143     x -= x_offset;
00144     b_dim1 = *ldb;
00145     b_offset = 1 + b_dim1;
00146     b -= b_offset;
00147     --work;
00148     --rwork;
00149 
00150     /* Function Body */
00151     if (*n <= 0 || *nrhs <= 0) {
00152         *resid = 0.;
00153         return 0;
00154     }
00155 
00156 /*     Compute the 1-norm of A or A**H. */
00157 
00158     if (lsame_(trans, "N")) {
00159         anorm = zlantp_("1", uplo, diag, n, &ap[1], &rwork[1]);
00160     } else {
00161         anorm = zlantp_("I", uplo, diag, n, &ap[1], &rwork[1]);
00162     }
00163 
00164 /*     Exit with RESID = 1/EPS if ANORM = 0. */
00165 
00166     eps = dlamch_("Epsilon");
00167     if (anorm <= 0.) {
00168         *resid = 1. / eps;
00169         return 0;
00170     }
00171 
00172 /*     Compute the maximum over the number of right hand sides of */
00173 /*        norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ). */
00174 
00175     *resid = 0.;
00176     i__1 = *nrhs;
00177     for (j = 1; j <= i__1; ++j) {
00178         zcopy_(n, &x[j * x_dim1 + 1], &c__1, &work[1], &c__1);
00179         ztpmv_(uplo, trans, diag, n, &ap[1], &work[1], &c__1);
00180         zaxpy_(n, &c_b12, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1);
00181         bnorm = dzasum_(n, &work[1], &c__1);
00182         xnorm = dzasum_(n, &x[j * x_dim1 + 1], &c__1);
00183         if (xnorm <= 0.) {
00184             *resid = 1. / eps;
00185         } else {
00186 /* Computing MAX */
00187             d__1 = *resid, d__2 = bnorm / anorm / xnorm / eps;
00188             *resid = max(d__1,d__2);
00189         }
00190 /* L10: */
00191     }
00192 
00193     return 0;
00194 
00195 /*     End of ZTPT02 */
00196 
00197 } /* ztpt02_ */


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