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


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