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


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