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


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