zpot02.c
Go to the documentation of this file.
00001 /* zpot02.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 doublecomplex c_b1 = {1.,0.};
00019 static integer c__1 = 1;
00020 
00021 /* Subroutine */ int zpot02_(char *uplo, integer *n, integer *nrhs, 
00022         doublecomplex *a, integer *lda, doublecomplex *x, integer *ldx, 
00023         doublecomplex *b, integer *ldb, doublereal *rwork, doublereal *resid)
00024 {
00025     /* System generated locals */
00026     integer a_dim1, a_offset, b_dim1, b_offset, x_dim1, x_offset, i__1;
00027     doublereal d__1, d__2;
00028     doublecomplex z__1;
00029 
00030     /* Local variables */
00031     integer j;
00032     doublereal eps, anorm, bnorm;
00033     extern /* Subroutine */ int zhemm_(char *, char *, integer *, integer *, 
00034             doublecomplex *, doublecomplex *, integer *, doublecomplex *, 
00035             integer *, doublecomplex *, doublecomplex *, integer *);
00036     doublereal xnorm;
00037     extern doublereal dlamch_(char *), zlanhe_(char *, char *, 
00038             integer *, doublecomplex *, integer *, doublereal *), dzasum_(integer *, doublecomplex *, integer *);
00039 
00040 
00041 /*  -- LAPACK test routine (version 3.1) -- */
00042 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00043 /*     November 2006 */
00044 
00045 /*     .. Scalar Arguments .. */
00046 /*     .. */
00047 /*     .. Array Arguments .. */
00048 /*     .. */
00049 
00050 /*  Purpose */
00051 /*  ======= */
00052 
00053 /*  ZPOT02 computes the residual for the solution of a Hermitian system */
00054 /*  of linear equations  A*x = b: */
00055 
00056 /*     RESID = norm(B - A*X) / ( norm(A) * norm(X) * EPS ), */
00057 
00058 /*  where EPS is the machine epsilon. */
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*16 array, dimension (LDA,N) */
00077 /*          The original Hermitian matrix A. */
00078 
00079 /*  LDA     (input) INTEGER */
00080 /*          The leading dimension of the array A.  LDA >= max(1,N) */
00081 
00082 /*  X       (input) COMPLEX*16 array, dimension (LDX,NRHS) */
00083 /*          The computed solution vectors for the system of linear */
00084 /*          equations. */
00085 
00086 /*  LDX     (input) INTEGER */
00087 /*          The leading dimension of the array X.   LDX >= max(1,N). */
00088 
00089 /*  B       (input/output) COMPLEX*16 array, dimension (LDB,NRHS) */
00090 /*          On entry, the right hand side vectors for the system of */
00091 /*          linear equations. */
00092 /*          On exit, B is overwritten with the difference B - A*X. */
00093 
00094 /*  LDB     (input) INTEGER */
00095 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00096 
00097 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (N) */
00098 
00099 /*  RESID   (output) DOUBLE PRECISION */
00100 /*          The maximum over the number of right hand sides of */
00101 /*          norm(B - A*X) / ( norm(A) * norm(X) * EPS ). */
00102 
00103 /*  ===================================================================== */
00104 
00105 /*     .. Parameters .. */
00106 /*     .. */
00107 /*     .. Local Scalars .. */
00108 /*     .. */
00109 /*     .. External Functions .. */
00110 /*     .. */
00111 /*     .. External Subroutines .. */
00112 /*     .. */
00113 /*     .. Intrinsic Functions .. */
00114 /*     .. */
00115 /*     .. Executable Statements .. */
00116 
00117 /*     Quick exit if N = 0 or NRHS = 0. */
00118 
00119     /* Parameter adjustments */
00120     a_dim1 = *lda;
00121     a_offset = 1 + a_dim1;
00122     a -= a_offset;
00123     x_dim1 = *ldx;
00124     x_offset = 1 + x_dim1;
00125     x -= x_offset;
00126     b_dim1 = *ldb;
00127     b_offset = 1 + b_dim1;
00128     b -= b_offset;
00129     --rwork;
00130 
00131     /* Function Body */
00132     if (*n <= 0 || *nrhs <= 0) {
00133         *resid = 0.;
00134         return 0;
00135     }
00136 
00137 /*     Exit with RESID = 1/EPS if ANORM = 0. */
00138 
00139     eps = dlamch_("Epsilon");
00140     anorm = zlanhe_("1", uplo, n, &a[a_offset], lda, &rwork[1]);
00141     if (anorm <= 0.) {
00142         *resid = 1. / eps;
00143         return 0;
00144     }
00145 
00146 /*     Compute  B - A*X */
00147 
00148     z__1.r = -1., z__1.i = -0.;
00149     zhemm_("Left", uplo, n, nrhs, &z__1, &a[a_offset], lda, &x[x_offset], ldx, 
00150              &c_b1, &b[b_offset], ldb);
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.;
00156     i__1 = *nrhs;
00157     for (j = 1; j <= i__1; ++j) {
00158         bnorm = dzasum_(n, &b[j * b_dim1 + 1], &c__1);
00159         xnorm = dzasum_(n, &x[j * x_dim1 + 1], &c__1);
00160         if (xnorm <= 0.) {
00161             *resid = 1. / eps;
00162         } else {
00163 /* Computing MAX */
00164             d__1 = *resid, d__2 = bnorm / anorm / xnorm / eps;
00165             *resid = max(d__1,d__2);
00166         }
00167 /* L10: */
00168     }
00169 
00170     return 0;
00171 
00172 /*     End of ZPOT02 */
00173 
00174 } /* zpot02_ */


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