stpt02.c
Go to the documentation of this file.
00001 /* stpt02.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 real c_b10 = -1.f;
00020 
00021 /* Subroutine */ int stpt02_(char *uplo, char *trans, char *diag, integer *n, 
00022         integer *nrhs, real *ap, real *x, integer *ldx, real *b, integer *ldb, 
00023          real *work, real *resid)
00024 {
00025     /* System generated locals */
00026     integer b_dim1, b_offset, x_dim1, x_offset, i__1;
00027     real r__1, r__2;
00028 
00029     /* Local variables */
00030     integer j;
00031     real eps;
00032     extern logical lsame_(char *, char *);
00033     real anorm, bnorm;
00034     extern doublereal sasum_(integer *, real *, integer *);
00035     extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *, 
00036             integer *);
00037     real xnorm;
00038     extern /* Subroutine */ int saxpy_(integer *, real *, real *, integer *, 
00039             real *, integer *), stpmv_(char *, char *, char *, integer *, 
00040             real *, real *, integer *);
00041     extern doublereal slamch_(char *), slantp_(char *, char *, char *, 
00042              integer *, real *, real *);
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 /*  STPT02 computes the residual for the computed solution to a */
00058 /*  triangular system of linear equations  A*x = b  or  A'*x = b  when */
00059 /*  the triangular matrix A is stored in packed format.  Here A' is the */
00060 /*  transpose of A and x and b are N by NRHS matrices.  The test ratio is */
00061 /*  the maximum over the number of right hand sides of */
00062 /*     norm(b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ), */
00063 /*  where op(A) denotes A or A' and EPS is the machine epsilon. */
00064 
00065 /*  Arguments */
00066 /*  ========= */
00067 
00068 /*  UPLO    (input) CHARACTER*1 */
00069 /*          Specifies whether the matrix A is upper or lower triangular. */
00070 /*          = 'U':  Upper triangular */
00071 /*          = 'L':  Lower triangular */
00072 
00073 /*  TRANS   (input) CHARACTER*1 */
00074 /*          Specifies the operation applied to A. */
00075 /*          = 'N':  A *x = b  (No transpose) */
00076 /*          = 'T':  A'*x = b  (Transpose) */
00077 /*          = 'C':  A'*x = b  (Conjugate transpose = Transpose) */
00078 
00079 /*  DIAG    (input) CHARACTER*1 */
00080 /*          Specifies whether or not the matrix A is unit triangular. */
00081 /*          = 'N':  Non-unit triangular */
00082 /*          = 'U':  Unit triangular */
00083 
00084 /*  N       (input) INTEGER */
00085 /*          The order of the matrix A.  N >= 0. */
00086 
00087 /*  NRHS    (input) INTEGER */
00088 /*          The number of right hand sides, i.e., the number of columns */
00089 /*          of the matrices X and B.  NRHS >= 0. */
00090 
00091 /*  AP      (input) REAL array, dimension (N*(N+1)/2) */
00092 /*          The upper or lower triangular matrix A, packed columnwise in */
00093 /*          a linear array.  The j-th column of A is stored in the array */
00094 /*          AP as follows: */
00095 /*          if UPLO = 'U', AP((j-1)*j/2 + i) = A(i,j) for 1<=i<=j; */
00096 /*          if UPLO = 'L', */
00097 /*             AP((j-1)*(n-j) + j*(j+1)/2 + i-j) = A(i,j) for j<=i<=n. */
00098 
00099 /*  X       (input) REAL array, dimension (LDX,NRHS) */
00100 /*          The computed solution vectors for the system of linear */
00101 /*          equations. */
00102 
00103 /*  LDX     (input) INTEGER */
00104 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00105 
00106 /*  B       (input) REAL array, dimension (LDB,NRHS) */
00107 /*          The right hand side vectors for the system of linear */
00108 /*          equations. */
00109 
00110 /*  LDB     (input) INTEGER */
00111 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00112 
00113 /*  WORK    (workspace) REAL array, dimension (N) */
00114 
00115 /*  RESID   (output) REAL */
00116 /*          The maximum over the number of right hand sides of */
00117 /*          norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ). */
00118 
00119 /*  ===================================================================== */
00120 
00121 /*     .. Parameters .. */
00122 /*     .. */
00123 /*     .. Local Scalars .. */
00124 /*     .. */
00125 /*     .. External Functions .. */
00126 /*     .. */
00127 /*     .. External Subroutines .. */
00128 /*     .. */
00129 /*     .. Intrinsic Functions .. */
00130 /*     .. */
00131 /*     .. Executable Statements .. */
00132 
00133 /*     Quick exit if N = 0 or NRHS = 0 */
00134 
00135     /* Parameter adjustments */
00136     --ap;
00137     x_dim1 = *ldx;
00138     x_offset = 1 + x_dim1;
00139     x -= x_offset;
00140     b_dim1 = *ldb;
00141     b_offset = 1 + b_dim1;
00142     b -= b_offset;
00143     --work;
00144 
00145     /* Function Body */
00146     if (*n <= 0 || *nrhs <= 0) {
00147         *resid = 0.f;
00148         return 0;
00149     }
00150 
00151 /*     Compute the 1-norm of A or A'. */
00152 
00153     if (lsame_(trans, "N")) {
00154         anorm = slantp_("1", uplo, diag, n, &ap[1], &work[1]);
00155     } else {
00156         anorm = slantp_("I", uplo, diag, n, &ap[1], &work[1]);
00157     }
00158 
00159 /*     Exit with RESID = 1/EPS if ANORM = 0. */
00160 
00161     eps = slamch_("Epsilon");
00162     if (anorm <= 0.f) {
00163         *resid = 1.f / eps;
00164         return 0;
00165     }
00166 
00167 /*     Compute the maximum over the number of right hand sides of */
00168 /*        norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ). */
00169 
00170     *resid = 0.f;
00171     i__1 = *nrhs;
00172     for (j = 1; j <= i__1; ++j) {
00173         scopy_(n, &x[j * x_dim1 + 1], &c__1, &work[1], &c__1);
00174         stpmv_(uplo, trans, diag, n, &ap[1], &work[1], &c__1);
00175         saxpy_(n, &c_b10, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1);
00176         bnorm = sasum_(n, &work[1], &c__1);
00177         xnorm = sasum_(n, &x[j * x_dim1 + 1], &c__1);
00178         if (xnorm <= 0.f) {
00179             *resid = 1.f / eps;
00180         } else {
00181 /* Computing MAX */
00182             r__1 = *resid, r__2 = bnorm / anorm / xnorm / eps;
00183             *resid = dmax(r__1,r__2);
00184         }
00185 /* L10: */
00186     }
00187 
00188     return 0;
00189 
00190 /*     End of STPT02 */
00191 
00192 } /* stpt02_ */


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