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


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