zget04.c
Go to the documentation of this file.
00001 /* zget04.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 
00020 /* Subroutine */ int zget04_(integer *n, integer *nrhs, doublecomplex *x, 
00021         integer *ldx, doublecomplex *xact, integer *ldxact, doublereal *rcond, 
00022          doublereal *resid)
00023 {
00024     /* System generated locals */
00025     integer x_dim1, x_offset, xact_dim1, xact_offset, i__1, i__2, i__3, i__4;
00026     doublereal d__1, d__2, d__3, d__4;
00027     doublecomplex z__1, z__2;
00028 
00029     /* Builtin functions */
00030     double d_imag(doublecomplex *);
00031 
00032     /* Local variables */
00033     integer i__, j, ix;
00034     doublereal eps, xnorm;
00035     extern doublereal dlamch_(char *);
00036     doublereal diffnm;
00037     extern integer izamax_(integer *, doublecomplex *, 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 /*  ZGET04 computes the difference between a computed solution and the */
00053 /*  true solution to a system of linear equations. */
00054 
00055 /*  RESID =  ( norm(X-XACT) * RCOND ) / ( norm(XACT) * EPS ), */
00056 /*  where RCOND is the reciprocal of the condition number and EPS is the */
00057 /*  machine epsilon. */
00058 
00059 /*  Arguments */
00060 /*  ========= */
00061 
00062 /*  N       (input) INTEGER */
00063 /*          The number of rows of the matrices X and XACT.  N >= 0. */
00064 
00065 /*  NRHS    (input) INTEGER */
00066 /*          The number of columns of the matrices X and XACT.  NRHS >= 0. */
00067 
00068 /*  X       (input) COMPLEX*16 array, dimension (LDX,NRHS) */
00069 /*          The computed solution vectors.  Each vector is stored as a */
00070 /*          column of the matrix X. */
00071 
00072 /*  LDX     (input) INTEGER */
00073 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00074 
00075 /*  XACT    (input) COMPLEX*16 array, dimension (LDX,NRHS) */
00076 /*          The exact solution vectors.  Each vector is stored as a */
00077 /*          column of the matrix XACT. */
00078 
00079 /*  LDXACT  (input) INTEGER */
00080 /*          The leading dimension of the array XACT.  LDXACT >= max(1,N). */
00081 
00082 /*  RCOND   (input) DOUBLE PRECISION */
00083 /*          The reciprocal of the condition number of the coefficient */
00084 /*          matrix in the system of equations. */
00085 
00086 /*  RESID   (output) DOUBLE PRECISION */
00087 /*          The maximum over the NRHS solution vectors of */
00088 /*          ( norm(X-XACT) * RCOND ) / ( norm(XACT) * EPS ) */
00089 
00090 /*  ===================================================================== */
00091 
00092 /*     .. Parameters .. */
00093 /*     .. */
00094 /*     .. Local Scalars .. */
00095 /*     .. */
00096 /*     .. External Functions .. */
00097 /*     .. */
00098 /*     .. Intrinsic Functions .. */
00099 /*     .. */
00100 /*     .. Statement Functions .. */
00101 /*     .. */
00102 /*     .. Statement Function definitions .. */
00103 /*     .. */
00104 /*     .. Executable Statements .. */
00105 
00106 /*     Quick exit if N = 0 or NRHS = 0. */
00107 
00108     /* Parameter adjustments */
00109     x_dim1 = *ldx;
00110     x_offset = 1 + x_dim1;
00111     x -= x_offset;
00112     xact_dim1 = *ldxact;
00113     xact_offset = 1 + xact_dim1;
00114     xact -= xact_offset;
00115 
00116     /* Function Body */
00117     if (*n <= 0 || *nrhs <= 0) {
00118         *resid = 0.;
00119         return 0;
00120     }
00121 
00122 /*     Exit with RESID = 1/EPS if RCOND is invalid. */
00123 
00124     eps = dlamch_("Epsilon");
00125     if (*rcond < 0.) {
00126         *resid = 1. / eps;
00127         return 0;
00128     }
00129 
00130 /*     Compute the maximum of */
00131 /*        norm(X - XACT) / ( norm(XACT) * EPS ) */
00132 /*     over all the vectors X and XACT . */
00133 
00134     *resid = 0.;
00135     i__1 = *nrhs;
00136     for (j = 1; j <= i__1; ++j) {
00137         ix = izamax_(n, &xact[j * xact_dim1 + 1], &c__1);
00138         i__2 = ix + j * xact_dim1;
00139         xnorm = (d__1 = xact[i__2].r, abs(d__1)) + (d__2 = d_imag(&xact[ix + 
00140                 j * xact_dim1]), abs(d__2));
00141         diffnm = 0.;
00142         i__2 = *n;
00143         for (i__ = 1; i__ <= i__2; ++i__) {
00144             i__3 = i__ + j * x_dim1;
00145             i__4 = i__ + j * xact_dim1;
00146             z__2.r = x[i__3].r - xact[i__4].r, z__2.i = x[i__3].i - xact[i__4]
00147                     .i;
00148             z__1.r = z__2.r, z__1.i = z__2.i;
00149 /* Computing MAX */
00150             d__3 = diffnm, d__4 = (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(
00151                     &z__1), abs(d__2));
00152             diffnm = max(d__3,d__4);
00153 /* L10: */
00154         }
00155         if (xnorm <= 0.) {
00156             if (diffnm > 0.) {
00157                 *resid = 1. / eps;
00158             }
00159         } else {
00160 /* Computing MAX */
00161             d__1 = *resid, d__2 = diffnm / xnorm * *rcond;
00162             *resid = max(d__1,d__2);
00163         }
00164 /* L20: */
00165     }
00166     if (*resid * eps < 1.) {
00167         *resid /= eps;
00168     }
00169 
00170     return 0;
00171 
00172 /*     End of ZGET04 */
00173 
00174 } /* zget04_ */


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