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


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