cget51.c
Go to the documentation of this file.
00001 /* cget51.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 complex c_b1 = {0.f,0.f};
00019 static complex c_b2 = {1.f,0.f};
00020 
00021 /* Subroutine */ int cget51_(integer *itype, integer *n, complex *a, integer *
00022         lda, complex *b, integer *ldb, complex *u, integer *ldu, complex *v, 
00023         integer *ldv, complex *work, real *rwork, real *result)
00024 {
00025     /* System generated locals */
00026     integer a_dim1, a_offset, b_dim1, b_offset, u_dim1, u_offset, v_dim1, 
00027             v_offset, i__1, i__2, i__3, i__4, i__5;
00028     real r__1, r__2;
00029     complex q__1;
00030 
00031     /* Local variables */
00032     real ulp;
00033     integer jcol;
00034     real unfl;
00035     integer jrow, jdiag;
00036     extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, 
00037             integer *, complex *, complex *, integer *, complex *, integer *, 
00038             complex *, complex *, integer *);
00039     real anorm, wnorm;
00040     extern doublereal clange_(char *, integer *, integer *, complex *, 
00041             integer *, real *), slamch_(char *);
00042     extern /* Subroutine */ int clacpy_(char *, integer *, integer *, complex 
00043             *, integer *, complex *, integer *);
00044 
00045 
00046 /*  -- LAPACK test routine (version 3.1) -- */
00047 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00048 /*     November 2006 */
00049 
00050 /*     .. Scalar Arguments .. */
00051 /*     .. */
00052 /*     .. Array Arguments .. */
00053 /*     .. */
00054 
00055 /*  Purpose */
00056 /*  ======= */
00057 
00058 /*       CGET51  generally checks a decomposition of the form */
00059 
00060 /*               A = U B V* */
00061 
00062 /*       where * means conjugate transpose and U and V are unitary. */
00063 
00064 /*       Specifically, if ITYPE=1 */
00065 
00066 /*               RESULT = | A - U B V* | / ( |A| n ulp ) */
00067 
00068 /*       If ITYPE=2, then: */
00069 
00070 /*               RESULT = | A - B | / ( |A| n ulp ) */
00071 
00072 /*       If ITYPE=3, then: */
00073 
00074 /*               RESULT = | I - UU* | / ( n ulp ) */
00075 
00076 /*  Arguments */
00077 /*  ========= */
00078 
00079 /*  ITYPE   (input) INTEGER */
00080 /*          Specifies the type of tests to be performed. */
00081 /*          =1: RESULT = | A - U B V* | / ( |A| n ulp ) */
00082 /*          =2: RESULT = | A - B | / ( |A| n ulp ) */
00083 /*          =3: RESULT = | I - UU* | / ( n ulp ) */
00084 
00085 /*  N       (input) INTEGER */
00086 /*          The size of the matrix.  If it is zero, CGET51 does nothing. */
00087 /*          It must be at least zero. */
00088 
00089 /*  A       (input) COMPLEX array, dimension (LDA, N) */
00090 /*          The original (unfactored) matrix. */
00091 
00092 /*  LDA     (input) INTEGER */
00093 /*          The leading dimension of A.  It must be at least 1 */
00094 /*          and at least N. */
00095 
00096 /*  B       (input) COMPLEX array, dimension (LDB, N) */
00097 /*          The factored matrix. */
00098 
00099 /*  LDB     (input) INTEGER */
00100 /*          The leading dimension of B.  It must be at least 1 */
00101 /*          and at least N. */
00102 
00103 /*  U       (input) COMPLEX array, dimension (LDU, N) */
00104 /*          The unitary matrix on the left-hand side in the */
00105 /*          decomposition. */
00106 /*          Not referenced if ITYPE=2 */
00107 
00108 /*  LDU     (input) INTEGER */
00109 /*          The leading dimension of U.  LDU must be at least N and */
00110 /*          at least 1. */
00111 
00112 /*  V       (input) COMPLEX array, dimension (LDV, N) */
00113 /*          The unitary matrix on the left-hand side in the */
00114 /*          decomposition. */
00115 /*          Not referenced if ITYPE=2 */
00116 
00117 /*  LDV     (input) INTEGER */
00118 /*          The leading dimension of V.  LDV must be at least N and */
00119 /*          at least 1. */
00120 
00121 /*  WORK    (workspace) COMPLEX array, dimension (2*N**2) */
00122 
00123 /*  RWORK   (workspace) REAL array, dimension (N) */
00124 
00125 /*  RESULT  (output) REAL */
00126 /*          The values computed by the test specified by ITYPE.  The */
00127 /*          value is currently limited to 1/ulp, to avoid overflow. */
00128 /*          Errors are flagged by RESULT=10/ulp. */
00129 
00130 /*  ===================================================================== */
00131 
00132 /*     .. Parameters .. */
00133 /*     .. */
00134 /*     .. Local Scalars .. */
00135 /*     .. */
00136 /*     .. External Functions .. */
00137 /*     .. */
00138 /*     .. External Subroutines .. */
00139 /*     .. */
00140 /*     .. Intrinsic Functions .. */
00141 /*     .. */
00142 /*     .. Executable Statements .. */
00143 
00144     /* Parameter adjustments */
00145     a_dim1 = *lda;
00146     a_offset = 1 + a_dim1;
00147     a -= a_offset;
00148     b_dim1 = *ldb;
00149     b_offset = 1 + b_dim1;
00150     b -= b_offset;
00151     u_dim1 = *ldu;
00152     u_offset = 1 + u_dim1;
00153     u -= u_offset;
00154     v_dim1 = *ldv;
00155     v_offset = 1 + v_dim1;
00156     v -= v_offset;
00157     --work;
00158     --rwork;
00159 
00160     /* Function Body */
00161     *result = 0.f;
00162     if (*n <= 0) {
00163         return 0;
00164     }
00165 
00166 /*     Constants */
00167 
00168     unfl = slamch_("Safe minimum");
00169     ulp = slamch_("Epsilon") * slamch_("Base");
00170 
00171 /*     Some Error Checks */
00172 
00173     if (*itype < 1 || *itype > 3) {
00174         *result = 10.f / ulp;
00175         return 0;
00176     }
00177 
00178     if (*itype <= 2) {
00179 
00180 /*        Tests scaled by the norm(A) */
00181 
00182 /* Computing MAX */
00183         r__1 = clange_("1", n, n, &a[a_offset], lda, &rwork[1]);
00184         anorm = dmax(r__1,unfl);
00185 
00186         if (*itype == 1) {
00187 
00188 /*           ITYPE=1: Compute W = A - UBV' */
00189 
00190             clacpy_(" ", n, n, &a[a_offset], lda, &work[1], n);
00191 /* Computing 2nd power */
00192             i__1 = *n;
00193             cgemm_("N", "N", n, n, n, &c_b2, &u[u_offset], ldu, &b[b_offset], 
00194                     ldb, &c_b1, &work[i__1 * i__1 + 1], n);
00195 
00196             q__1.r = -1.f, q__1.i = -0.f;
00197 /* Computing 2nd power */
00198             i__1 = *n;
00199             cgemm_("N", "C", n, n, n, &q__1, &work[i__1 * i__1 + 1], n, &v[
00200                     v_offset], ldv, &c_b2, &work[1], n);
00201 
00202         } else {
00203 
00204 /*           ITYPE=2: Compute W = A - B */
00205 
00206             clacpy_(" ", n, n, &b[b_offset], ldb, &work[1], n);
00207 
00208             i__1 = *n;
00209             for (jcol = 1; jcol <= i__1; ++jcol) {
00210                 i__2 = *n;
00211                 for (jrow = 1; jrow <= i__2; ++jrow) {
00212                     i__3 = jrow + *n * (jcol - 1);
00213                     i__4 = jrow + *n * (jcol - 1);
00214                     i__5 = jrow + jcol * a_dim1;
00215                     q__1.r = work[i__4].r - a[i__5].r, q__1.i = work[i__4].i 
00216                             - a[i__5].i;
00217                     work[i__3].r = q__1.r, work[i__3].i = q__1.i;
00218 /* L10: */
00219                 }
00220 /* L20: */
00221             }
00222         }
00223 
00224 /*        Compute norm(W)/ ( ulp*norm(A) ) */
00225 
00226         wnorm = clange_("1", n, n, &work[1], n, &rwork[1]);
00227 
00228         if (anorm > wnorm) {
00229             *result = wnorm / anorm / (*n * ulp);
00230         } else {
00231             if (anorm < 1.f) {
00232 /* Computing MIN */
00233                 r__1 = wnorm, r__2 = *n * anorm;
00234                 *result = dmin(r__1,r__2) / anorm / (*n * ulp);
00235             } else {
00236 /* Computing MIN */
00237                 r__1 = wnorm / anorm, r__2 = (real) (*n);
00238                 *result = dmin(r__1,r__2) / (*n * ulp);
00239             }
00240         }
00241 
00242     } else {
00243 
00244 /*        Tests not scaled by norm(A) */
00245 
00246 /*        ITYPE=3: Compute  UU' - I */
00247 
00248         cgemm_("N", "C", n, n, n, &c_b2, &u[u_offset], ldu, &u[u_offset], ldu, 
00249                  &c_b1, &work[1], n);
00250 
00251         i__1 = *n;
00252         for (jdiag = 1; jdiag <= i__1; ++jdiag) {
00253             i__2 = (*n + 1) * (jdiag - 1) + 1;
00254             i__3 = (*n + 1) * (jdiag - 1) + 1;
00255             q__1.r = work[i__3].r - 1.f, q__1.i = work[i__3].i - 0.f;
00256             work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00257 /* L30: */
00258         }
00259 
00260 /* Computing MIN */
00261         r__1 = clange_("1", n, n, &work[1], n, &rwork[1]), r__2 = (
00262                 real) (*n);
00263         *result = dmin(r__1,r__2) / (*n * ulp);
00264     }
00265 
00266     return 0;
00267 
00268 /*     End of CGET51 */
00269 
00270 } /* cget51_ */


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