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


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