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


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