sbdt02.c
Go to the documentation of this file.
00001 /* sbdt02.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 real c_b7 = -1.f;
00020 static real c_b9 = 1.f;
00021 
00022 /* Subroutine */ int sbdt02_(integer *m, integer *n, real *b, integer *ldb, 
00023         real *c__, integer *ldc, real *u, integer *ldu, real *work, real *
00024         resid)
00025 {
00026     /* System generated locals */
00027     integer b_dim1, b_offset, c_dim1, c_offset, u_dim1, u_offset, i__1;
00028     real r__1, r__2;
00029 
00030     /* Local variables */
00031     integer j;
00032     real eps, bnorm;
00033     extern /* Subroutine */ int sgemv_(char *, integer *, integer *, real *, 
00034             real *, integer *, real *, integer *, real *, real *, integer *);
00035     extern doublereal sasum_(integer *, real *, integer *);
00036     extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *, 
00037             integer *);
00038     extern doublereal slamch_(char *), slange_(char *, integer *, 
00039             integer *, real *, integer *, real *);
00040     real realmn;
00041 
00042 
00043 /*  -- LAPACK test routine (version 3.1) -- */
00044 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00045 /*     November 2006 */
00046 
00047 /*     .. Scalar Arguments .. */
00048 /*     .. */
00049 /*     .. Array Arguments .. */
00050 /*     .. */
00051 
00052 /*  Purpose */
00053 /*  ======= */
00054 
00055 /*  SBDT02 tests the change of basis C = U' * B by computing the residual */
00056 
00057 /*     RESID = norm( B - U * C ) / ( max(m,n) * norm(B) * EPS ), */
00058 
00059 /*  where B and C are M by N matrices, U is an M by M orthogonal matrix, */
00060 /*  and EPS is the machine precision. */
00061 
00062 /*  Arguments */
00063 /*  ========= */
00064 
00065 /*  M       (input) INTEGER */
00066 /*          The number of rows of the matrices B and C and the order of */
00067 /*          the matrix Q. */
00068 
00069 /*  N       (input) INTEGER */
00070 /*          The number of columns of the matrices B and C. */
00071 
00072 /*  B       (input) REAL array, dimension (LDB,N) */
00073 /*          The m by n matrix B. */
00074 
00075 /*  LDB     (input) INTEGER */
00076 /*          The leading dimension of the array B.  LDB >= max(1,M). */
00077 
00078 /*  C       (input) REAL array, dimension (LDC,N) */
00079 /*          The m by n matrix C, assumed to contain U' * B. */
00080 
00081 /*  LDC     (input) INTEGER */
00082 /*          The leading dimension of the array C.  LDC >= max(1,M). */
00083 
00084 /*  U       (input) REAL array, dimension (LDU,M) */
00085 /*          The m by m orthogonal matrix U. */
00086 
00087 /*  LDU     (input) INTEGER */
00088 /*          The leading dimension of the array U.  LDU >= max(1,M). */
00089 
00090 /*  WORK    (workspace) REAL array, dimension (M) */
00091 
00092 /*  RESID   (output) REAL */
00093 /*          RESID = norm( B - U * C ) / ( max(m,n) * norm(B) * EPS ), */
00094 
00095 /* ====================================================================== */
00096 
00097 /*     .. Parameters .. */
00098 /*     .. */
00099 /*     .. Local Scalars .. */
00100 /*     .. */
00101 /*     .. External Functions .. */
00102 /*     .. */
00103 /*     .. External Subroutines .. */
00104 /*     .. */
00105 /*     .. Intrinsic Functions .. */
00106 /*     .. */
00107 /*     .. Executable Statements .. */
00108 
00109 /*     Quick return if possible */
00110 
00111     /* Parameter adjustments */
00112     b_dim1 = *ldb;
00113     b_offset = 1 + b_dim1;
00114     b -= b_offset;
00115     c_dim1 = *ldc;
00116     c_offset = 1 + c_dim1;
00117     c__ -= c_offset;
00118     u_dim1 = *ldu;
00119     u_offset = 1 + u_dim1;
00120     u -= u_offset;
00121     --work;
00122 
00123     /* Function Body */
00124     *resid = 0.f;
00125     if (*m <= 0 || *n <= 0) {
00126         return 0;
00127     }
00128     realmn = (real) max(*m,*n);
00129     eps = slamch_("Precision");
00130 
00131 /*     Compute norm( B - U * C ) */
00132 
00133     i__1 = *n;
00134     for (j = 1; j <= i__1; ++j) {
00135         scopy_(m, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1);
00136         sgemv_("No transpose", m, m, &c_b7, &u[u_offset], ldu, &c__[j * 
00137                 c_dim1 + 1], &c__1, &c_b9, &work[1], &c__1);
00138 /* Computing MAX */
00139         r__1 = *resid, r__2 = sasum_(m, &work[1], &c__1);
00140         *resid = dmax(r__1,r__2);
00141 /* L10: */
00142     }
00143 
00144 /*     Compute norm of B. */
00145 
00146     bnorm = slange_("1", m, n, &b[b_offset], ldb, &work[1]);
00147 
00148     if (bnorm <= 0.f) {
00149         if (*resid != 0.f) {
00150             *resid = 1.f / eps;
00151         }
00152     } else {
00153         if (bnorm >= *resid) {
00154             *resid = *resid / bnorm / (realmn * eps);
00155         } else {
00156             if (bnorm < 1.f) {
00157 /* Computing MIN */
00158                 r__1 = *resid, r__2 = realmn * bnorm;
00159                 *resid = dmin(r__1,r__2) / bnorm / (realmn * eps);
00160             } else {
00161 /* Computing MIN */
00162                 r__1 = *resid / bnorm;
00163                 *resid = dmin(r__1,realmn) / (realmn * eps);
00164             }
00165         }
00166     }
00167     return 0;
00168 
00169 /*     End of SBDT02 */
00170 
00171 } /* sbdt02_ */


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