sget51.c
Go to the documentation of this file.
00001 /* sget51.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 real c_b9 = 1.f;
00019 static real c_b10 = 0.f;
00020 static real c_b13 = -1.f;
00021 
00022 /* Subroutine */ int sget51_(integer *itype, integer *n, real *a, integer *
00023         lda, real *b, integer *ldb, real *u, integer *ldu, real *v, integer *
00024         ldv, real *work, real *result)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, b_dim1, b_offset, u_dim1, u_offset, v_dim1, 
00028             v_offset, i__1, i__2;
00029     real r__1, r__2;
00030 
00031     /* Local variables */
00032     real ulp;
00033     integer jcol;
00034     real unfl;
00035     integer jrow, jdiag;
00036     extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *, 
00037             integer *, real *, real *, integer *, real *, integer *, real *, 
00038             real *, integer *);
00039     real anorm, wnorm;
00040     extern doublereal slamch_(char *), slange_(char *, integer *, 
00041             integer *, real *, integer *, real *);
00042     extern /* Subroutine */ int slacpy_(char *, integer *, integer *, real *, 
00043             integer *, real *, 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 /*       SGET51  generally checks a decomposition of the form */
00059 
00060 /*               A = U B V' */
00061 
00062 /*       where ' means transpose and U and V are orthogonal. */
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, SGET51 does nothing. */
00087 /*          It must be at least zero. */
00088 
00089 /*  A       (input) REAL 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) REAL 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) REAL array, dimension (LDU, N) */
00104 /*          The orthogonal 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) REAL array, dimension (LDV, N) */
00113 /*          The orthogonal 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) REAL array, dimension (2*N**2) */
00122 
00123 /*  RESULT  (output) REAL */
00124 /*          The values computed by the test specified by ITYPE.  The */
00125 /*          value is currently limited to 1/ulp, to avoid overflow. */
00126 /*          Errors are flagged by RESULT=10/ulp. */
00127 
00128 /*  ===================================================================== */
00129 
00130 /*     .. Parameters .. */
00131 /*     .. */
00132 /*     .. Local Scalars .. */
00133 /*     .. */
00134 /*     .. External Functions .. */
00135 /*     .. */
00136 /*     .. External Subroutines .. */
00137 /*     .. */
00138 /*     .. Intrinsic Functions .. */
00139 /*     .. */
00140 /*     .. Executable Statements .. */
00141 
00142     /* Parameter adjustments */
00143     a_dim1 = *lda;
00144     a_offset = 1 + a_dim1;
00145     a -= a_offset;
00146     b_dim1 = *ldb;
00147     b_offset = 1 + b_dim1;
00148     b -= b_offset;
00149     u_dim1 = *ldu;
00150     u_offset = 1 + u_dim1;
00151     u -= u_offset;
00152     v_dim1 = *ldv;
00153     v_offset = 1 + v_dim1;
00154     v -= v_offset;
00155     --work;
00156 
00157     /* Function Body */
00158     *result = 0.f;
00159     if (*n <= 0) {
00160         return 0;
00161     }
00162 
00163 /*     Constants */
00164 
00165     unfl = slamch_("Safe minimum");
00166     ulp = slamch_("Epsilon") * slamch_("Base");
00167 
00168 /*     Some Error Checks */
00169 
00170     if (*itype < 1 || *itype > 3) {
00171         *result = 10.f / ulp;
00172         return 0;
00173     }
00174 
00175     if (*itype <= 2) {
00176 
00177 /*        Tests scaled by the norm(A) */
00178 
00179 /* Computing MAX */
00180         r__1 = slange_("1", n, n, &a[a_offset], lda, &work[1]);
00181         anorm = dmax(r__1,unfl);
00182 
00183         if (*itype == 1) {
00184 
00185 /*           ITYPE=1: Compute W = A - UBV' */
00186 
00187             slacpy_(" ", n, n, &a[a_offset], lda, &work[1], n);
00188 /* Computing 2nd power */
00189             i__1 = *n;
00190             sgemm_("N", "N", n, n, n, &c_b9, &u[u_offset], ldu, &b[b_offset], 
00191                     ldb, &c_b10, &work[i__1 * i__1 + 1], n);
00192 
00193 /* Computing 2nd power */
00194             i__1 = *n;
00195             sgemm_("N", "C", n, n, n, &c_b13, &work[i__1 * i__1 + 1], n, &v[
00196                     v_offset], ldv, &c_b9, &work[1], n);
00197 
00198         } else {
00199 
00200 /*           ITYPE=2: Compute W = A - B */
00201 
00202             slacpy_(" ", n, n, &b[b_offset], ldb, &work[1], n);
00203 
00204             i__1 = *n;
00205             for (jcol = 1; jcol <= i__1; ++jcol) {
00206                 i__2 = *n;
00207                 for (jrow = 1; jrow <= i__2; ++jrow) {
00208                     work[jrow + *n * (jcol - 1)] -= a[jrow + jcol * a_dim1];
00209 /* L10: */
00210                 }
00211 /* L20: */
00212             }
00213         }
00214 
00215 /*        Compute norm(W)/ ( ulp*norm(A) ) */
00216 
00217 /* Computing 2nd power */
00218         i__1 = *n;
00219         wnorm = slange_("1", n, n, &work[1], n, &work[i__1 * i__1 + 1]);
00220 
00221         if (anorm > wnorm) {
00222             *result = wnorm / anorm / (*n * ulp);
00223         } else {
00224             if (anorm < 1.f) {
00225 /* Computing MIN */
00226                 r__1 = wnorm, r__2 = *n * anorm;
00227                 *result = dmin(r__1,r__2) / anorm / (*n * ulp);
00228             } else {
00229 /* Computing MIN */
00230                 r__1 = wnorm / anorm, r__2 = (real) (*n);
00231                 *result = dmin(r__1,r__2) / (*n * ulp);
00232             }
00233         }
00234 
00235     } else {
00236 
00237 /*        Tests not scaled by norm(A) */
00238 
00239 /*        ITYPE=3: Compute  UU' - I */
00240 
00241         sgemm_("N", "C", n, n, n, &c_b9, &u[u_offset], ldu, &u[u_offset], ldu, 
00242                  &c_b10, &work[1], n);
00243 
00244         i__1 = *n;
00245         for (jdiag = 1; jdiag <= i__1; ++jdiag) {
00246             work[(*n + 1) * (jdiag - 1) + 1] += -1.f;
00247 /* L30: */
00248         }
00249 
00250 /* Computing MIN */
00251 /* Computing 2nd power */
00252         i__1 = *n;
00253         r__1 = slange_("1", n, n, &work[1], n, &work[i__1 * i__1 + 1]), r__2 = (real) (*n);
00254         *result = dmin(r__1,r__2) / (*n * ulp);
00255     }
00256 
00257     return 0;
00258 
00259 /*     End of SGET51 */
00260 
00261 } /* sget51_ */


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