cppt02.c
Go to the documentation of this file.
00001 /* cppt02.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 complex c_b1 = {1.f,0.f};
00019 static integer c__1 = 1;
00020 
00021 /* Subroutine */ int cppt02_(char *uplo, integer *n, integer *nrhs, complex *
00022         a, complex *x, integer *ldx, complex *b, integer *ldb, real *rwork, 
00023         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     complex q__1;
00029 
00030     /* Local variables */
00031     integer j;
00032     real eps, anorm, bnorm;
00033     extern /* Subroutine */ int chpmv_(char *, integer *, complex *, complex *
00034 , complex *, integer *, complex *, complex *, integer *);
00035     real xnorm;
00036     extern doublereal clanhp_(char *, char *, integer *, complex *, real *), slamch_(char *), scasum_(integer *, 
00037             complex *, integer *);
00038 
00039 
00040 /*  -- LAPACK test routine (version 3.1) -- */
00041 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00042 /*     November 2006 */
00043 
00044 /*     .. Scalar Arguments .. */
00045 /*     .. */
00046 /*     .. Array Arguments .. */
00047 /*     .. */
00048 
00049 /*  Purpose */
00050 /*  ======= */
00051 
00052 /*  CPPT02 computes the residual in the solution of a Hermitian system */
00053 /*  of linear equations  A*x = b  when packed storage is used for the */
00054 /*  coefficient matrix.  The ratio computed is */
00055 
00056 /*     RESID = norm(B - A*X) / ( norm(A) * norm(X) * EPS), */
00057 
00058 /*  where EPS is the machine precision. */
00059 
00060 /*  Arguments */
00061 /*  ========= */
00062 
00063 /*  UPLO    (input) CHARACTER*1 */
00064 /*          Specifies whether the upper or lower triangular part of the */
00065 /*          Hermitian matrix A is stored: */
00066 /*          = 'U':  Upper triangular */
00067 /*          = 'L':  Lower triangular */
00068 
00069 /*  N       (input) INTEGER */
00070 /*          The number of rows and columns of the matrix A.  N >= 0. */
00071 
00072 /*  NRHS    (input) INTEGER */
00073 /*          The number of columns of B, the matrix of right hand sides. */
00074 /*          NRHS >= 0. */
00075 
00076 /*  A       (input) COMPLEX array, dimension (N*(N+1)/2) */
00077 /*          The original Hermitian matrix A, stored as a packed */
00078 /*          triangular matrix. */
00079 
00080 /*  X       (input) COMPLEX array, dimension (LDX,NRHS) */
00081 /*          The computed solution vectors for the system of linear */
00082 /*          equations. */
00083 
00084 /*  LDX     (input) INTEGER */
00085 /*          The leading dimension of the array X.   LDX >= max(1,N). */
00086 
00087 /*  B       (input/output) COMPLEX array, dimension (LDB,NRHS) */
00088 /*          On entry, the right hand side vectors for the system of */
00089 /*          linear equations. */
00090 /*          On exit, B is overwritten with the difference B - A*X. */
00091 
00092 /*  LDB     (input) INTEGER */
00093 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00094 
00095 /*  RWORK   (workspace) REAL array, dimension (N) */
00096 
00097 /*  RESID   (output) REAL */
00098 /*          The maximum over the number of right hand sides of */
00099 /*          norm(B - A*X) / ( norm(A) * norm(X) * EPS ). */
00100 
00101 /*  ===================================================================== */
00102 
00103 /*     .. Parameters .. */
00104 /*     .. */
00105 /*     .. Local Scalars .. */
00106 /*     .. */
00107 /*     .. External Functions .. */
00108 /*     .. */
00109 /*     .. External Subroutines .. */
00110 /*     .. */
00111 /*     .. Intrinsic Functions .. */
00112 /*     .. */
00113 /*     .. Executable Statements .. */
00114 
00115 /*     Quick exit if N = 0 or NRHS = 0. */
00116 
00117     /* Parameter adjustments */
00118     --a;
00119     x_dim1 = *ldx;
00120     x_offset = 1 + x_dim1;
00121     x -= x_offset;
00122     b_dim1 = *ldb;
00123     b_offset = 1 + b_dim1;
00124     b -= b_offset;
00125     --rwork;
00126 
00127     /* Function Body */
00128     if (*n <= 0 || *nrhs <= 0) {
00129         *resid = 0.f;
00130         return 0;
00131     }
00132 
00133 /*     Exit with RESID = 1/EPS if ANORM = 0. */
00134 
00135     eps = slamch_("Epsilon");
00136     anorm = clanhp_("1", uplo, n, &a[1], &rwork[1]);
00137     if (anorm <= 0.f) {
00138         *resid = 1.f / eps;
00139         return 0;
00140     }
00141 
00142 /*     Compute  B - A*X  for the matrix of right hand sides B. */
00143 
00144     i__1 = *nrhs;
00145     for (j = 1; j <= i__1; ++j) {
00146         q__1.r = -1.f, q__1.i = -0.f;
00147         chpmv_(uplo, n, &q__1, &a[1], &x[j * x_dim1 + 1], &c__1, &c_b1, &b[j *
00148                  b_dim1 + 1], &c__1);
00149 /* L10: */
00150     }
00151 
00152 /*     Compute the maximum over the number of right hand sides of */
00153 /*        norm( B - A*X ) / ( norm(A) * norm(X) * EPS ) . */
00154 
00155     *resid = 0.f;
00156     i__1 = *nrhs;
00157     for (j = 1; j <= i__1; ++j) {
00158         bnorm = scasum_(n, &b[j * b_dim1 + 1], &c__1);
00159         xnorm = scasum_(n, &x[j * x_dim1 + 1], &c__1);
00160         if (xnorm <= 0.f) {
00161             *resid = 1.f / eps;
00162         } else {
00163 /* Computing MAX */
00164             r__1 = *resid, r__2 = bnorm / anorm / xnorm / eps;
00165             *resid = dmax(r__1,r__2);
00166         }
00167 /* L20: */
00168     }
00169 
00170     return 0;
00171 
00172 /*     End of CPPT02 */
00173 
00174 } /* cppt02_ */


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