zpot06.c
Go to the documentation of this file.
00001 /* zpot06.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 doublecomplex c_b2 = {-1.,0.};
00020 static integer c__1 = 1;
00021 
00022 /* Subroutine */ int zpot06_(char *uplo, integer *n, integer *nrhs, 
00023         doublecomplex *a, integer *lda, doublecomplex *x, integer *ldx, 
00024         doublecomplex *b, integer *ldb, doublereal *rwork, doublereal *resid)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, b_dim1, b_offset, x_dim1, x_offset, i__1, i__2;
00028     doublereal d__1, d__2;
00029 
00030     /* Builtin functions */
00031     double d_imag(doublecomplex *);
00032 
00033     /* Local variables */
00034     integer j;
00035     doublereal eps;
00036     integer ifail;
00037     doublereal anorm, bnorm;
00038     extern /* Subroutine */ int zhemm_(char *, char *, integer *, integer *, 
00039             doublecomplex *, doublecomplex *, integer *, doublecomplex *, 
00040             integer *, doublecomplex *, doublecomplex *, integer *);
00041     doublereal xnorm;
00042     extern doublereal dlamch_(char *);
00043     extern integer izamax_(integer *, doublecomplex *, integer *);
00044     extern doublereal zlansy_(char *, char *, integer *, doublecomplex *, 
00045             integer *, doublereal *);
00046 
00047 
00048 /*  -- LAPACK test routine (version 3.1.2) -- */
00049 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00050 /*     May 2007 */
00051 
00052 /*     .. Scalar Arguments .. */
00053 /*     .. */
00054 /*     .. Array Arguments .. */
00055 /*     .. */
00056 
00057 /*  Purpose */
00058 /*  ======= */
00059 
00060 /*  ZPOT06 computes the residual for a solution of a system of linear */
00061 /*  equations  A*x = b : */
00062 /*     RESID = norm(B - A*X,inf) / ( norm(A,inf) * norm(X,inf) * EPS ), */
00063 /*  where EPS is the machine epsilon. */
00064 
00065 /*  Arguments */
00066 /*  ========= */
00067 
00068 /*  UPLO    (input) CHARACTER*1 */
00069 /*          Specifies whether the upper or lower triangular part of the */
00070 /*          symmetric matrix A is stored: */
00071 /*          = 'U':  Upper triangular */
00072 /*          = 'L':  Lower triangular */
00073 
00074 /*  N       (input) INTEGER */
00075 /*          The number of rows and columns of the matrix A.  N >= 0. */
00076 
00077 /*  NRHS    (input) INTEGER */
00078 /*          The number of columns of B, the matrix of right hand sides. */
00079 /*          NRHS >= 0. */
00080 
00081 /*  A       (input) COMPLEX*16 array, dimension (LDA,N) */
00082 /*          The original M x N matrix A. */
00083 
00084 /*  LDA     (input) INTEGER */
00085 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00086 
00087 /*  X       (input) COMPLEX*16 array, dimension (LDX,NRHS) */
00088 /*          The computed solution vectors for the system of linear */
00089 /*          equations. */
00090 
00091 /*  LDX     (input) INTEGER */
00092 /*          The leading dimension of the array X.  If TRANS = 'N', */
00093 /*          LDX >= max(1,N); if TRANS = 'T' or 'C', LDX >= max(1,N). */
00094 
00095 /*  B       (input/output) COMPLEX*16 array, dimension (LDB,NRHS) */
00096 /*          On entry, the right hand side vectors for the system of */
00097 /*          linear equations. */
00098 /*          On exit, B is overwritten with the difference B - A*X. */
00099 
00100 /*  LDB     (input) INTEGER */
00101 /*          The leading dimension of the array B.  IF TRANS = 'N', */
00102 /*          LDB >= max(1,M); if TRANS = 'T' or 'C', LDB >= max(1,N). */
00103 
00104 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (N) */
00105 
00106 /*  RESID   (output) DOUBLE PRECISION */
00107 /*          The maximum over the number of right hand sides of */
00108 /*          norm(B - A*X) / ( norm(A) * norm(X) * EPS ). */
00109 
00110 /*  ===================================================================== */
00111 
00112 /*     .. Parameters .. */
00113 /*     .. */
00114 /*     .. Local Scalars .. */
00115 /*     .. */
00116 /*     .. External Functions .. */
00117 /*     .. */
00118 /*     .. External Subroutines .. */
00119 /*     .. */
00120 /*     .. Intrinsic Functions .. */
00121 /*     .. */
00122 /*     .. Statement Functions .. */
00123 /*     .. */
00124 /*     .. Statement Function definitions .. */
00125 /*     .. */
00126 /*     .. */
00127 /*     .. Executable Statements .. */
00128 
00129 /*     Quick exit if N = 0 or NRHS = 0 */
00130 
00131     /* Parameter adjustments */
00132     a_dim1 = *lda;
00133     a_offset = 1 + a_dim1;
00134     a -= a_offset;
00135     x_dim1 = *ldx;
00136     x_offset = 1 + x_dim1;
00137     x -= x_offset;
00138     b_dim1 = *ldb;
00139     b_offset = 1 + b_dim1;
00140     b -= b_offset;
00141     --rwork;
00142 
00143     /* Function Body */
00144     if (*n <= 0 || *nrhs == 0) {
00145         *resid = 0.;
00146         return 0;
00147     }
00148 
00149 /*     Exit with RESID = 1/EPS if ANORM = 0. */
00150 
00151     eps = dlamch_("Epsilon");
00152     anorm = zlansy_("I", uplo, n, &a[a_offset], lda, &rwork[1]);
00153     if (anorm <= 0.) {
00154         *resid = 1. / eps;
00155         return 0;
00156     }
00157 
00158 /*     Compute  B - A*X  and store in B. */
00159     ifail = 0;
00160 
00161     zhemm_("Left", uplo, n, nrhs, &c_b2, &a[a_offset], lda, &x[x_offset], ldx, 
00162              &c_b1, &b[b_offset], ldb);
00163 
00164 /*     Compute the maximum over the number of right hand sides of */
00165 /*        norm(B - A*X) / ( norm(A) * norm(X) * EPS ) . */
00166 
00167     *resid = 0.;
00168     i__1 = *nrhs;
00169     for (j = 1; j <= i__1; ++j) {
00170         i__2 = izamax_(n, &b[j * b_dim1 + 1], &c__1) + j * b_dim1;
00171         bnorm = (d__1 = b[i__2].r, abs(d__1)) + (d__2 = d_imag(&b[izamax_(n, &
00172                 b[j * b_dim1 + 1], &c__1) + j * b_dim1]), abs(d__2));
00173         i__2 = izamax_(n, &x[j * x_dim1 + 1], &c__1) + j * x_dim1;
00174         xnorm = (d__1 = x[i__2].r, abs(d__1)) + (d__2 = d_imag(&x[izamax_(n, &
00175                 x[j * x_dim1 + 1], &c__1) + j * x_dim1]), abs(d__2));
00176         if (xnorm <= 0.) {
00177             *resid = 1. / eps;
00178         } else {
00179 /* Computing MAX */
00180             d__1 = *resid, d__2 = bnorm / anorm / xnorm / eps;
00181             *resid = max(d__1,d__2);
00182         }
00183 /* L10: */
00184     }
00185 
00186     return 0;
00187 
00188 /*     End of ZPOT06 */
00189 
00190 } /* zpot06_ */


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