dqrt17.c
Go to the documentation of this file.
00001 /* dqrt17.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 static integer c__13 = 13;
00020 static doublereal c_b13 = -1.;
00021 static doublereal c_b14 = 1.;
00022 static integer c__0 = 0;
00023 static doublereal c_b22 = 0.;
00024 
00025 doublereal dqrt17_(char *trans, integer *iresid, integer *m, integer *n, 
00026         integer *nrhs, doublereal *a, integer *lda, doublereal *x, integer *
00027         ldx, doublereal *b, integer *ldb, doublereal *c__, doublereal *work, 
00028         integer *lwork)
00029 {
00030     /* System generated locals */
00031     integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, x_dim1, 
00032             x_offset, i__1;
00033     doublereal ret_val;
00034 
00035     /* Local variables */
00036     doublereal err;
00037     integer iscl, info;
00038     extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *, 
00039             integer *, doublereal *, doublereal *, integer *, doublereal *, 
00040             integer *, doublereal *, doublereal *, integer *);
00041     extern logical lsame_(char *, char *);
00042     doublereal norma, normb;
00043     integer ncols;
00044     doublereal normx, rwork[1];
00045     integer nrows;
00046     extern doublereal dlamch_(char *), dlange_(char *, integer *, 
00047             integer *, doublereal *, integer *, doublereal *);
00048     extern /* Subroutine */ int dlascl_(char *, integer *, integer *, 
00049             doublereal *, doublereal *, integer *, integer *, doublereal *, 
00050             integer *, integer *), dlacpy_(char *, integer *, integer 
00051             *, doublereal *, integer *, doublereal *, integer *), 
00052             xerbla_(char *, integer *);
00053     doublereal bignum, smlnum, normrs;
00054 
00055 
00056 /*  -- LAPACK test routine (version 3.1) -- */
00057 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00058 /*     November 2006 */
00059 
00060 /*     .. Scalar Arguments .. */
00061 /*     .. */
00062 /*     .. Array Arguments .. */
00063 /*     .. */
00064 
00065 /*  Purpose */
00066 /*  ======= */
00067 
00068 /*  DQRT17 computes the ratio */
00069 
00070 /*     || R'*op(A) ||/(||A||*alpha*max(M,N,NRHS)*eps) */
00071 
00072 /*  where R = op(A)*X - B, op(A) is A or A', and */
00073 
00074 /*     alpha = ||B|| if IRESID = 1 (zero-residual problem) */
00075 /*     alpha = ||R|| if IRESID = 2 (otherwise). */
00076 
00077 /*  Arguments */
00078 /*  ========= */
00079 
00080 /*  TRANS   (input) CHARACTER*1 */
00081 /*          Specifies whether or not the transpose of A is used. */
00082 /*          = 'N':  No transpose, op(A) = A. */
00083 /*          = 'T':  Transpose, op(A) = A'. */
00084 
00085 /*  IRESID  (input) INTEGER */
00086 /*          IRESID = 1 indicates zero-residual problem. */
00087 /*          IRESID = 2 indicates non-zero residual. */
00088 
00089 /*  M       (input) INTEGER */
00090 /*          The number of rows of the matrix A. */
00091 /*          If TRANS = 'N', the number of rows of the matrix B. */
00092 /*          If TRANS = 'T', the number of rows of the matrix X. */
00093 
00094 /*  N       (input) INTEGER */
00095 /*          The number of columns of the matrix  A. */
00096 /*          If TRANS = 'N', the number of rows of the matrix X. */
00097 /*          If TRANS = 'T', the number of rows of the matrix B. */
00098 
00099 /*  NRHS    (input) INTEGER */
00100 /*          The number of columns of the matrices X and B. */
00101 
00102 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00103 /*          The m-by-n matrix A. */
00104 
00105 /*  LDA     (input) INTEGER */
00106 /*          The leading dimension of the array A. LDA >= M. */
00107 
00108 /*  X       (input) DOUBLE PRECISION array, dimension (LDX,NRHS) */
00109 /*          If TRANS = 'N', the n-by-nrhs matrix X. */
00110 /*          If TRANS = 'T', the m-by-nrhs matrix X. */
00111 
00112 /*  LDX     (input) INTEGER */
00113 /*          The leading dimension of the array X. */
00114 /*          If TRANS = 'N', LDX >= N. */
00115 /*          If TRANS = 'T', LDX >= M. */
00116 
00117 /*  B       (input) DOUBLE PRECISION array, dimension (LDB,NRHS) */
00118 /*          If TRANS = 'N', the m-by-nrhs matrix B. */
00119 /*          If TRANS = 'T', the n-by-nrhs matrix B. */
00120 
00121 /*  LDB     (input) INTEGER */
00122 /*          The leading dimension of the array B. */
00123 /*          If TRANS = 'N', LDB >= M. */
00124 /*          If TRANS = 'T', LDB >= N. */
00125 
00126 /*  C       (workspace) DOUBLE PRECISION array, dimension (LDB,NRHS) */
00127 
00128 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (LWORK) */
00129 
00130 /*  LWORK   (input) INTEGER */
00131 /*          The length of the array WORK.  LWORK >= NRHS*(M+N). */
00132 
00133 /*  ===================================================================== */
00134 
00135 /*     .. Parameters .. */
00136 /*     .. */
00137 /*     .. Local Scalars .. */
00138 /*     .. */
00139 /*     .. Local Arrays .. */
00140 /*     .. */
00141 /*     .. External Functions .. */
00142 /*     .. */
00143 /*     .. External Subroutines .. */
00144 /*     .. */
00145 /*     .. Intrinsic Functions .. */
00146 /*     .. */
00147 /*     .. Executable Statements .. */
00148 
00149     /* Parameter adjustments */
00150     a_dim1 = *lda;
00151     a_offset = 1 + a_dim1;
00152     a -= a_offset;
00153     x_dim1 = *ldx;
00154     x_offset = 1 + x_dim1;
00155     x -= x_offset;
00156     c_dim1 = *ldb;
00157     c_offset = 1 + c_dim1;
00158     c__ -= c_offset;
00159     b_dim1 = *ldb;
00160     b_offset = 1 + b_dim1;
00161     b -= b_offset;
00162     --work;
00163 
00164     /* Function Body */
00165     ret_val = 0.;
00166 
00167     if (lsame_(trans, "N")) {
00168         nrows = *m;
00169         ncols = *n;
00170     } else if (lsame_(trans, "T")) {
00171         nrows = *n;
00172         ncols = *m;
00173     } else {
00174         xerbla_("DQRT17", &c__1);
00175         return ret_val;
00176     }
00177 
00178     if (*lwork < ncols * *nrhs) {
00179         xerbla_("DQRT17", &c__13);
00180         return ret_val;
00181     }
00182 
00183     if (*m <= 0 || *n <= 0 || *nrhs <= 0) {
00184         return ret_val;
00185     }
00186 
00187     norma = dlange_("One-norm", m, n, &a[a_offset], lda, rwork);
00188     smlnum = dlamch_("Safe minimum") / dlamch_("Precision");
00189     bignum = 1. / smlnum;
00190     iscl = 0;
00191 
00192 /*     compute residual and scale it */
00193 
00194     dlacpy_("All", &nrows, nrhs, &b[b_offset], ldb, &c__[c_offset], ldb);
00195     dgemm_(trans, "No transpose", &nrows, nrhs, &ncols, &c_b13, &a[a_offset], 
00196             lda, &x[x_offset], ldx, &c_b14, &c__[c_offset], ldb);
00197     normrs = dlange_("Max", &nrows, nrhs, &c__[c_offset], ldb, rwork);
00198     if (normrs > smlnum) {
00199         iscl = 1;
00200         dlascl_("General", &c__0, &c__0, &normrs, &c_b14, &nrows, nrhs, &c__[
00201                 c_offset], ldb, &info);
00202     }
00203 
00204 /*     compute R'*A */
00205 
00206     dgemm_("Transpose", trans, nrhs, &ncols, &nrows, &c_b14, &c__[c_offset], 
00207             ldb, &a[a_offset], lda, &c_b22, &work[1], nrhs);
00208 
00209 /*     compute and properly scale error */
00210 
00211     err = dlange_("One-norm", nrhs, &ncols, &work[1], nrhs, rwork);
00212     if (norma != 0.) {
00213         err /= norma;
00214     }
00215 
00216     if (iscl == 1) {
00217         err *= normrs;
00218     }
00219 
00220     if (*iresid == 1) {
00221         normb = dlange_("One-norm", &nrows, nrhs, &b[b_offset], ldb, rwork);
00222         if (normb != 0.) {
00223             err /= normb;
00224         }
00225     } else {
00226         normx = dlange_("One-norm", &ncols, nrhs, &x[x_offset], ldx, rwork);
00227         if (normx != 0.) {
00228             err /= normx;
00229         }
00230     }
00231 
00232 /* Computing MAX */
00233     i__1 = max(*m,*n);
00234     ret_val = err / (dlamch_("Epsilon") * (doublereal) max(i__1,*
00235             nrhs));
00236     return ret_val;
00237 
00238 /*     End of DQRT17 */
00239 
00240 } /* dqrt17_ */


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