dtpt02.c
Go to the documentation of this file.
00001 /* dtpt02.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 doublereal c_b10 = -1.;
00020 
00021 /* Subroutine */ int dtpt02_(char *uplo, char *trans, char *diag, integer *n, 
00022         integer *nrhs, doublereal *ap, doublereal *x, integer *ldx, 
00023         doublereal *b, integer *ldb, doublereal *work, doublereal *resid)
00024 {
00025     /* System generated locals */
00026     integer b_dim1, b_offset, x_dim1, x_offset, i__1;
00027     doublereal d__1, d__2;
00028 
00029     /* Local variables */
00030     integer j;
00031     doublereal eps;
00032     extern logical lsame_(char *, char *);
00033     extern doublereal dasum_(integer *, doublereal *, integer *);
00034     doublereal anorm, bnorm;
00035     extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *, 
00036             doublereal *, integer *), daxpy_(integer *, doublereal *, 
00037             doublereal *, integer *, doublereal *, integer *), dtpmv_(char *, 
00038             char *, char *, integer *, doublereal *, doublereal *, integer *);
00039     doublereal xnorm;
00040     extern doublereal dlamch_(char *), dlantp_(char *, char *, char *, 
00041              integer *, doublereal *, doublereal *);
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 /*  DTPT02 computes the residual for the computed solution to a */
00057 /*  triangular system of linear equations  A*x = b  or  A'*x = b  when */
00058 /*  the triangular matrix A is stored in packed format.  Here A' is the */
00059 /*  transpose of A and x and b are N by NRHS matrices.  The test ratio is */
00060 /*  the maximum over 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 /*  NRHS    (input) INTEGER */
00087 /*          The number of right hand sides, i.e., the number of columns */
00088 /*          of the matrices X and B.  NRHS >= 0. */
00089 
00090 /*  AP      (input) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
00091 /*          The upper or lower triangular matrix A, packed columnwise in */
00092 /*          a linear array.  The j-th column of A is stored in the array */
00093 /*          AP as follows: */
00094 /*          if UPLO = 'U', AP((j-1)*j/2 + i) = A(i,j) for 1<=i<=j; */
00095 /*          if UPLO = 'L', */
00096 /*             AP((j-1)*(n-j) + j*(j+1)/2 + i-j) = A(i,j) for j<=i<=n. */
00097 
00098 /*  X       (input) DOUBLE PRECISION array, dimension (LDX,NRHS) */
00099 /*          The computed solution vectors for the system of linear */
00100 /*          equations. */
00101 
00102 /*  LDX     (input) INTEGER */
00103 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00104 
00105 /*  B       (input) DOUBLE PRECISION array, dimension (LDB,NRHS) */
00106 /*          The right hand side vectors for the system of linear */
00107 /*          equations. */
00108 
00109 /*  LDB     (input) INTEGER */
00110 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00111 
00112 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (N) */
00113 
00114 /*  RESID   (output) DOUBLE PRECISION */
00115 /*          The maximum over the number of right hand sides of */
00116 /*          norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ). */
00117 
00118 /*  ===================================================================== */
00119 
00120 /*     .. Parameters .. */
00121 /*     .. */
00122 /*     .. Local Scalars .. */
00123 /*     .. */
00124 /*     .. External Functions .. */
00125 /*     .. */
00126 /*     .. External Subroutines .. */
00127 /*     .. */
00128 /*     .. Intrinsic Functions .. */
00129 /*     .. */
00130 /*     .. Executable Statements .. */
00131 
00132 /*     Quick exit if N = 0 or NRHS = 0 */
00133 
00134     /* Parameter adjustments */
00135     --ap;
00136     x_dim1 = *ldx;
00137     x_offset = 1 + x_dim1;
00138     x -= x_offset;
00139     b_dim1 = *ldb;
00140     b_offset = 1 + b_dim1;
00141     b -= b_offset;
00142     --work;
00143 
00144     /* Function Body */
00145     if (*n <= 0 || *nrhs <= 0) {
00146         *resid = 0.;
00147         return 0;
00148     }
00149 
00150 /*     Compute the 1-norm of A or A'. */
00151 
00152     if (lsame_(trans, "N")) {
00153         anorm = dlantp_("1", uplo, diag, n, &ap[1], &work[1]);
00154     } else {
00155         anorm = dlantp_("I", uplo, diag, n, &ap[1], &work[1]);
00156     }
00157 
00158 /*     Exit with RESID = 1/EPS if ANORM = 0. */
00159 
00160     eps = dlamch_("Epsilon");
00161     if (anorm <= 0.) {
00162         *resid = 1. / eps;
00163         return 0;
00164     }
00165 
00166 /*     Compute the maximum over the number of right hand sides of */
00167 /*        norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ). */
00168 
00169     *resid = 0.;
00170     i__1 = *nrhs;
00171     for (j = 1; j <= i__1; ++j) {
00172         dcopy_(n, &x[j * x_dim1 + 1], &c__1, &work[1], &c__1);
00173         dtpmv_(uplo, trans, diag, n, &ap[1], &work[1], &c__1);
00174         daxpy_(n, &c_b10, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1);
00175         bnorm = dasum_(n, &work[1], &c__1);
00176         xnorm = dasum_(n, &x[j * x_dim1 + 1], &c__1);
00177         if (xnorm <= 0.) {
00178             *resid = 1. / eps;
00179         } else {
00180 /* Computing MAX */
00181             d__1 = *resid, d__2 = bnorm / anorm / xnorm / eps;
00182             *resid = max(d__1,d__2);
00183         }
00184 /* L10: */
00185     }
00186 
00187     return 0;
00188 
00189 /*     End of DTPT02 */
00190 
00191 } /* dtpt02_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:49