cbdt02.c
Go to the documentation of this file.
00001 /* cbdt02.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 complex c_b7 = {-1.f,-0.f};
00020 static complex c_b10 = {1.f,0.f};
00021 
00022 /* Subroutine */ int cbdt02_(integer *m, integer *n, complex *b, integer *ldb, 
00023          complex *c__, integer *ldc, complex *u, integer *ldu, complex *work, 
00024         real *rwork, real *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;
00033     extern /* Subroutine */ int cgemv_(char *, integer *, integer *, complex *
00034 , complex *, integer *, complex *, integer *, complex *, complex *
00035 , integer *);
00036     real bnorm;
00037     extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, 
00038             complex *, integer *);
00039     extern doublereal clange_(char *, integer *, integer *, complex *, 
00040             integer *, real *), slamch_(char *);
00041     real realmn;
00042     extern doublereal scasum_(integer *, complex *, integer *);
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 /*  CBDT02 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) COMPLEX 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) COMPLEX 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) COMPLEX 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) COMPLEX array, dimension (M) */
00093 
00094 /*  RWORK   (workspace) REAL array, dimension (M) */
00095 
00096 /*  RESID   (output) REAL */
00097 /*          RESID = norm( B - U * C ) / ( max(m,n) * norm(B) * EPS ), */
00098 
00099 /* ====================================================================== */
00100 
00101 /*     .. Parameters .. */
00102 /*     .. */
00103 /*     .. Local Scalars .. */
00104 /*     .. */
00105 /*     .. External Functions .. */
00106 /*     .. */
00107 /*     .. External Subroutines .. */
00108 /*     .. */
00109 /*     .. Intrinsic Functions .. */
00110 /*     .. */
00111 /*     .. Executable Statements .. */
00112 
00113 /*     Quick return if possible */
00114 
00115     /* Parameter adjustments */
00116     b_dim1 = *ldb;
00117     b_offset = 1 + b_dim1;
00118     b -= b_offset;
00119     c_dim1 = *ldc;
00120     c_offset = 1 + c_dim1;
00121     c__ -= c_offset;
00122     u_dim1 = *ldu;
00123     u_offset = 1 + u_dim1;
00124     u -= u_offset;
00125     --work;
00126     --rwork;
00127 
00128     /* Function Body */
00129     *resid = 0.f;
00130     if (*m <= 0 || *n <= 0) {
00131         return 0;
00132     }
00133     realmn = (real) max(*m,*n);
00134     eps = slamch_("Precision");
00135 
00136 /*     Compute norm( B - U * C ) */
00137 
00138     i__1 = *n;
00139     for (j = 1; j <= i__1; ++j) {
00140         ccopy_(m, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1);
00141         cgemv_("No transpose", m, m, &c_b7, &u[u_offset], ldu, &c__[j * 
00142                 c_dim1 + 1], &c__1, &c_b10, &work[1], &c__1);
00143 /* Computing MAX */
00144         r__1 = *resid, r__2 = scasum_(m, &work[1], &c__1);
00145         *resid = dmax(r__1,r__2);
00146 /* L10: */
00147     }
00148 
00149 /*     Compute norm of B. */
00150 
00151     bnorm = clange_("1", m, n, &b[b_offset], ldb, &rwork[1]);
00152 
00153     if (bnorm <= 0.f) {
00154         if (*resid != 0.f) {
00155             *resid = 1.f / eps;
00156         }
00157     } else {
00158         if (bnorm >= *resid) {
00159             *resid = *resid / bnorm / (realmn * eps);
00160         } else {
00161             if (bnorm < 1.f) {
00162 /* Computing MIN */
00163                 r__1 = *resid, r__2 = realmn * bnorm;
00164                 *resid = dmin(r__1,r__2) / bnorm / (realmn * eps);
00165             } else {
00166 /* Computing MIN */
00167                 r__1 = *resid / bnorm;
00168                 *resid = dmin(r__1,realmn) / (realmn * eps);
00169             }
00170         }
00171     }
00172     return 0;
00173 
00174 /*     End of CBDT02 */
00175 
00176 } /* cbdt02_ */


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