zget51.c
Go to the documentation of this file.
00001 /* zget51.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 doublecomplex c_b1 = {0.,0.};
00019 static doublecomplex c_b2 = {1.,0.};
00020 
00021 /* Subroutine */ int zget51_(integer *itype, integer *n, doublecomplex *a, 
00022         integer *lda, doublecomplex *b, integer *ldb, doublecomplex *u, 
00023         integer *ldu, doublecomplex *v, integer *ldv, doublecomplex *work, 
00024         doublereal *rwork, doublereal *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, i__3, i__4, i__5;
00029     doublereal d__1, d__2;
00030     doublecomplex z__1;
00031 
00032     /* Local variables */
00033     doublereal ulp;
00034     integer jcol;
00035     doublereal unfl;
00036     integer jrow, jdiag;
00037     doublereal anorm;
00038     extern /* Subroutine */ int zgemm_(char *, char *, integer *, integer *, 
00039             integer *, doublecomplex *, doublecomplex *, integer *, 
00040             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00041             integer *);
00042     doublereal wnorm;
00043     extern doublereal dlamch_(char *), zlange_(char *, integer *, 
00044             integer *, doublecomplex *, integer *, doublereal *);
00045     extern /* Subroutine */ int zlacpy_(char *, integer *, integer *, 
00046             doublecomplex *, integer *, doublecomplex *, integer *);
00047 
00048 
00049 /*  -- LAPACK test routine (version 3.1) -- */
00050 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00051 /*     November 2006 */
00052 
00053 /*     .. Scalar Arguments .. */
00054 /*     .. */
00055 /*     .. Array Arguments .. */
00056 /*     .. */
00057 
00058 /*  Purpose */
00059 /*  ======= */
00060 
00061 /*       ZGET51  generally checks a decomposition of the form */
00062 
00063 /*               A = U B V* */
00064 
00065 /*       where * means conjugate transpose and U and V are unitary. */
00066 
00067 /*       Specifically, if ITYPE=1 */
00068 
00069 /*               RESULT = | A - U B V* | / ( |A| n ulp ) */
00070 
00071 /*       If ITYPE=2, then: */
00072 
00073 /*               RESULT = | A - B | / ( |A| n ulp ) */
00074 
00075 /*       If ITYPE=3, then: */
00076 
00077 /*               RESULT = | I - UU* | / ( n ulp ) */
00078 
00079 /*  Arguments */
00080 /*  ========= */
00081 
00082 /*  ITYPE   (input) INTEGER */
00083 /*          Specifies the type of tests to be performed. */
00084 /*          =1: RESULT = | A - U B V* | / ( |A| n ulp ) */
00085 /*          =2: RESULT = | A - B | / ( |A| n ulp ) */
00086 /*          =3: RESULT = | I - UU* | / ( n ulp ) */
00087 
00088 /*  N       (input) INTEGER */
00089 /*          The size of the matrix.  If it is zero, ZGET51 does nothing. */
00090 /*          It must be at least zero. */
00091 
00092 /*  A       (input) COMPLEX*16 array, dimension (LDA, N) */
00093 /*          The original (unfactored) matrix. */
00094 
00095 /*  LDA     (input) INTEGER */
00096 /*          The leading dimension of A.  It must be at least 1 */
00097 /*          and at least N. */
00098 
00099 /*  B       (input) COMPLEX*16 array, dimension (LDB, N) */
00100 /*          The factored matrix. */
00101 
00102 /*  LDB     (input) INTEGER */
00103 /*          The leading dimension of B.  It must be at least 1 */
00104 /*          and at least N. */
00105 
00106 /*  U       (input) COMPLEX*16 array, dimension (LDU, N) */
00107 /*          The unitary matrix on the left-hand side in the */
00108 /*          decomposition. */
00109 /*          Not referenced if ITYPE=2 */
00110 
00111 /*  LDU     (input) INTEGER */
00112 /*          The leading dimension of U.  LDU must be at least N and */
00113 /*          at least 1. */
00114 
00115 /*  V       (input) COMPLEX*16 array, dimension (LDV, N) */
00116 /*          The unitary matrix on the left-hand side in the */
00117 /*          decomposition. */
00118 /*          Not referenced if ITYPE=2 */
00119 
00120 /*  LDV     (input) INTEGER */
00121 /*          The leading dimension of V.  LDV must be at least N and */
00122 /*          at least 1. */
00123 
00124 /*  WORK    (workspace) COMPLEX*16 array, dimension (2*N**2) */
00125 
00126 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (N) */
00127 
00128 /*  RESULT  (output) DOUBLE PRECISION */
00129 /*          The values computed by the test specified by ITYPE.  The */
00130 /*          value is currently limited to 1/ulp, to avoid overflow. */
00131 /*          Errors are flagged by RESULT=10/ulp. */
00132 
00133 /*  ===================================================================== */
00134 
00135 /*     .. Parameters .. */
00136 /*     .. */
00137 /*     .. Local Scalars .. */
00138 /*     .. */
00139 /*     .. External Functions .. */
00140 /*     .. */
00141 /*     .. External Subroutines .. */
00142 /*     .. */
00143 /*     .. Intrinsic Functions .. */
00144 /*     .. */
00145 /*     .. Executable Statements .. */
00146 
00147     /* Parameter adjustments */
00148     a_dim1 = *lda;
00149     a_offset = 1 + a_dim1;
00150     a -= a_offset;
00151     b_dim1 = *ldb;
00152     b_offset = 1 + b_dim1;
00153     b -= b_offset;
00154     u_dim1 = *ldu;
00155     u_offset = 1 + u_dim1;
00156     u -= u_offset;
00157     v_dim1 = *ldv;
00158     v_offset = 1 + v_dim1;
00159     v -= v_offset;
00160     --work;
00161     --rwork;
00162 
00163     /* Function Body */
00164     *result = 0.;
00165     if (*n <= 0) {
00166         return 0;
00167     }
00168 
00169 /*     Constants */
00170 
00171     unfl = dlamch_("Safe minimum");
00172     ulp = dlamch_("Epsilon") * dlamch_("Base");
00173 
00174 /*     Some Error Checks */
00175 
00176     if (*itype < 1 || *itype > 3) {
00177         *result = 10. / ulp;
00178         return 0;
00179     }
00180 
00181     if (*itype <= 2) {
00182 
00183 /*        Tests scaled by the norm(A) */
00184 
00185 /* Computing MAX */
00186         d__1 = zlange_("1", n, n, &a[a_offset], lda, &rwork[1]);
00187         anorm = max(d__1,unfl);
00188 
00189         if (*itype == 1) {
00190 
00191 /*           ITYPE=1: Compute W = A - UBV' */
00192 
00193             zlacpy_(" ", n, n, &a[a_offset], lda, &work[1], n);
00194 /* Computing 2nd power */
00195             i__1 = *n;
00196             zgemm_("N", "N", n, n, n, &c_b2, &u[u_offset], ldu, &b[b_offset], 
00197                     ldb, &c_b1, &work[i__1 * i__1 + 1], n);
00198 
00199             z__1.r = -1., z__1.i = -0.;
00200 /* Computing 2nd power */
00201             i__1 = *n;
00202             zgemm_("N", "C", n, n, n, &z__1, &work[i__1 * i__1 + 1], n, &v[
00203                     v_offset], ldv, &c_b2, &work[1], n);
00204 
00205         } else {
00206 
00207 /*           ITYPE=2: Compute W = A - B */
00208 
00209             zlacpy_(" ", n, n, &b[b_offset], ldb, &work[1], n);
00210 
00211             i__1 = *n;
00212             for (jcol = 1; jcol <= i__1; ++jcol) {
00213                 i__2 = *n;
00214                 for (jrow = 1; jrow <= i__2; ++jrow) {
00215                     i__3 = jrow + *n * (jcol - 1);
00216                     i__4 = jrow + *n * (jcol - 1);
00217                     i__5 = jrow + jcol * a_dim1;
00218                     z__1.r = work[i__4].r - a[i__5].r, z__1.i = work[i__4].i 
00219                             - a[i__5].i;
00220                     work[i__3].r = z__1.r, work[i__3].i = z__1.i;
00221 /* L10: */
00222                 }
00223 /* L20: */
00224             }
00225         }
00226 
00227 /*        Compute norm(W)/ ( ulp*norm(A) ) */
00228 
00229         wnorm = zlange_("1", n, n, &work[1], n, &rwork[1]);
00230 
00231         if (anorm > wnorm) {
00232             *result = wnorm / anorm / (*n * ulp);
00233         } else {
00234             if (anorm < 1.) {
00235 /* Computing MIN */
00236                 d__1 = wnorm, d__2 = *n * anorm;
00237                 *result = min(d__1,d__2) / anorm / (*n * ulp);
00238             } else {
00239 /* Computing MIN */
00240                 d__1 = wnorm / anorm, d__2 = (doublereal) (*n);
00241                 *result = min(d__1,d__2) / (*n * ulp);
00242             }
00243         }
00244 
00245     } else {
00246 
00247 /*        Tests not scaled by norm(A) */
00248 
00249 /*        ITYPE=3: Compute  UU' - I */
00250 
00251         zgemm_("N", "C", n, n, n, &c_b2, &u[u_offset], ldu, &u[u_offset], ldu, 
00252                  &c_b1, &work[1], n);
00253 
00254         i__1 = *n;
00255         for (jdiag = 1; jdiag <= i__1; ++jdiag) {
00256             i__2 = (*n + 1) * (jdiag - 1) + 1;
00257             i__3 = (*n + 1) * (jdiag - 1) + 1;
00258             z__1.r = work[i__3].r - 1., z__1.i = work[i__3].i - 0.;
00259             work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00260 /* L30: */
00261         }
00262 
00263 /* Computing MIN */
00264         d__1 = zlange_("1", n, n, &work[1], n, &rwork[1]), d__2 = (
00265                 doublereal) (*n);
00266         *result = min(d__1,d__2) / (*n * ulp);
00267     }
00268 
00269     return 0;
00270 
00271 /*     End of ZGET51 */
00272 
00273 } /* zget51_ */


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