zunt01.c
Go to the documentation of this file.
00001 /* zunt01.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_b7 = {0.,0.};
00019 static doublecomplex c_b8 = {1.,0.};
00020 static doublereal c_b10 = -1.;
00021 static doublereal c_b11 = 1.;
00022 static integer c__1 = 1;
00023 
00024 /* Subroutine */ int zunt01_(char *rowcol, integer *m, integer *n, 
00025         doublecomplex *u, integer *ldu, doublecomplex *work, integer *lwork, 
00026         doublereal *rwork, doublereal *resid)
00027 {
00028     /* System generated locals */
00029     integer u_dim1, u_offset, i__1, i__2;
00030     doublereal d__1, d__2, d__3, d__4;
00031     doublecomplex z__1, z__2;
00032 
00033     /* Builtin functions */
00034     double d_imag(doublecomplex *);
00035 
00036     /* Local variables */
00037     integer i__, j, k;
00038     doublereal eps;
00039     doublecomplex tmp;
00040     extern logical lsame_(char *, char *);
00041     integer mnmin;
00042     extern /* Double Complex */ VOID zdotc_(doublecomplex *, integer *, 
00043             doublecomplex *, integer *, doublecomplex *, integer *);
00044     extern /* Subroutine */ int zherk_(char *, char *, integer *, integer *, 
00045             doublereal *, doublecomplex *, integer *, doublereal *, 
00046             doublecomplex *, integer *);
00047     extern doublereal dlamch_(char *);
00048     integer ldwork;
00049     extern /* Subroutine */ int zlaset_(char *, integer *, integer *, 
00050             doublecomplex *, doublecomplex *, doublecomplex *, integer *);
00051     char transu[1];
00052     extern doublereal zlansy_(char *, char *, integer *, doublecomplex *, 
00053             integer *, doublereal *);
00054 
00055 
00056 /*  -- LAPACK test routine (version 3.1) -- */
00057 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00058 /*     November 2006 */
00059 
00060 /*     .. Scalar Arguments .. */
00061 /*     .. */
00062 /*     .. Array Arguments .. */
00063 /*     .. */
00064 
00065 /*  Purpose */
00066 /*  ======= */
00067 
00068 /*  ZUNT01 checks that the matrix U is unitary by computing the ratio */
00069 
00070 /*     RESID = norm( I - U*U' ) / ( n * EPS ), if ROWCOL = 'R', */
00071 /*  or */
00072 /*     RESID = norm( I - U'*U ) / ( m * EPS ), if ROWCOL = 'C'. */
00073 
00074 /*  Alternatively, if there isn't sufficient workspace to form */
00075 /*  I - U*U' or I - U'*U, the ratio is computed as */
00076 
00077 /*     RESID = abs( I - U*U' ) / ( n * EPS ), if ROWCOL = 'R', */
00078 /*  or */
00079 /*     RESID = abs( I - U'*U ) / ( m * EPS ), if ROWCOL = 'C'. */
00080 
00081 /*  where EPS is the machine precision.  ROWCOL is used only if m = n; */
00082 /*  if m > n, ROWCOL is assumed to be 'C', and if m < n, ROWCOL is */
00083 /*  assumed to be 'R'. */
00084 
00085 /*  Arguments */
00086 /*  ========= */
00087 
00088 /*  ROWCOL  (input) CHARACTER */
00089 /*          Specifies whether the rows or columns of U should be checked */
00090 /*          for orthogonality.  Used only if M = N. */
00091 /*          = 'R':  Check for orthogonal rows of U */
00092 /*          = 'C':  Check for orthogonal columns of U */
00093 
00094 /*  M       (input) INTEGER */
00095 /*          The number of rows of the matrix U. */
00096 
00097 /*  N       (input) INTEGER */
00098 /*          The number of columns of the matrix U. */
00099 
00100 /*  U       (input) COMPLEX*16 array, dimension (LDU,N) */
00101 /*          The unitary matrix U.  U is checked for orthogonal columns */
00102 /*          if m > n or if m = n and ROWCOL = 'C'.  U is checked for */
00103 /*          orthogonal rows if m < n or if m = n and ROWCOL = 'R'. */
00104 
00105 /*  LDU     (input) INTEGER */
00106 /*          The leading dimension of the array U.  LDU >= max(1,M). */
00107 
00108 /*  WORK    (workspace) COMPLEX*16 array, dimension (LWORK) */
00109 
00110 /*  LWORK   (input) INTEGER */
00111 /*          The length of the array WORK.  For best performance, LWORK */
00112 /*          should be at least N*N if ROWCOL = 'C' or M*M if */
00113 /*          ROWCOL = 'R', but the test will be done even if LWORK is 0. */
00114 
00115 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (min(M,N)) */
00116 /*          Used only if LWORK is large enough to use the Level 3 BLAS */
00117 /*          code. */
00118 
00119 /*  RESID   (output) DOUBLE PRECISION */
00120 /*          RESID = norm( I - U * U' ) / ( n * EPS ), if ROWCOL = 'R', or */
00121 /*          RESID = norm( I - U' * U ) / ( m * EPS ), if ROWCOL = 'C'. */
00122 
00123 /*  ===================================================================== */
00124 
00125 /*     .. Parameters .. */
00126 /*     .. */
00127 /*     .. Local Scalars .. */
00128 /*     .. */
00129 /*     .. External Functions .. */
00130 /*     .. */
00131 /*     .. External Subroutines .. */
00132 /*     .. */
00133 /*     .. Intrinsic Functions .. */
00134 /*     .. */
00135 /*     .. Statement Functions .. */
00136 /*     .. */
00137 /*     .. Statement Function definitions .. */
00138 /*     .. */
00139 /*     .. Executable Statements .. */
00140 
00141     /* Parameter adjustments */
00142     u_dim1 = *ldu;
00143     u_offset = 1 + u_dim1;
00144     u -= u_offset;
00145     --work;
00146     --rwork;
00147 
00148     /* Function Body */
00149     *resid = 0.;
00150 
00151 /*     Quick return if possible */
00152 
00153     if (*m <= 0 || *n <= 0) {
00154         return 0;
00155     }
00156 
00157     eps = dlamch_("Precision");
00158     if (*m < *n || *m == *n && lsame_(rowcol, "R")) {
00159         *(unsigned char *)transu = 'N';
00160         k = *n;
00161     } else {
00162         *(unsigned char *)transu = 'C';
00163         k = *m;
00164     }
00165     mnmin = min(*m,*n);
00166 
00167     if ((mnmin + 1) * mnmin <= *lwork) {
00168         ldwork = mnmin;
00169     } else {
00170         ldwork = 0;
00171     }
00172     if (ldwork > 0) {
00173 
00174 /*        Compute I - U*U' or I - U'*U. */
00175 
00176         zlaset_("Upper", &mnmin, &mnmin, &c_b7, &c_b8, &work[1], &ldwork);
00177         zherk_("Upper", transu, &mnmin, &k, &c_b10, &u[u_offset], ldu, &c_b11, 
00178                  &work[1], &ldwork);
00179 
00180 /*        Compute norm( I - U*U' ) / ( K * EPS ) . */
00181 
00182         *resid = zlansy_("1", "Upper", &mnmin, &work[1], &ldwork, &rwork[1]);
00183         *resid = *resid / (doublereal) k / eps;
00184     } else if (*(unsigned char *)transu == 'C') {
00185 
00186 /*        Find the maximum element in abs( I - U'*U ) / ( m * EPS ) */
00187 
00188         i__1 = *n;
00189         for (j = 1; j <= i__1; ++j) {
00190             i__2 = j;
00191             for (i__ = 1; i__ <= i__2; ++i__) {
00192                 if (i__ != j) {
00193                     tmp.r = 0., tmp.i = 0.;
00194                 } else {
00195                     tmp.r = 1., tmp.i = 0.;
00196                 }
00197                 zdotc_(&z__2, m, &u[i__ * u_dim1 + 1], &c__1, &u[j * u_dim1 + 
00198                         1], &c__1);
00199                 z__1.r = tmp.r - z__2.r, z__1.i = tmp.i - z__2.i;
00200                 tmp.r = z__1.r, tmp.i = z__1.i;
00201 /* Computing MAX */
00202                 d__3 = *resid, d__4 = (d__1 = tmp.r, abs(d__1)) + (d__2 = 
00203                         d_imag(&tmp), abs(d__2));
00204                 *resid = max(d__3,d__4);
00205 /* L10: */
00206             }
00207 /* L20: */
00208         }
00209         *resid = *resid / (doublereal) (*m) / eps;
00210     } else {
00211 
00212 /*        Find the maximum element in abs( I - U*U' ) / ( n * EPS ) */
00213 
00214         i__1 = *m;
00215         for (j = 1; j <= i__1; ++j) {
00216             i__2 = j;
00217             for (i__ = 1; i__ <= i__2; ++i__) {
00218                 if (i__ != j) {
00219                     tmp.r = 0., tmp.i = 0.;
00220                 } else {
00221                     tmp.r = 1., tmp.i = 0.;
00222                 }
00223                 zdotc_(&z__2, n, &u[j + u_dim1], ldu, &u[i__ + u_dim1], ldu);
00224                 z__1.r = tmp.r - z__2.r, z__1.i = tmp.i - z__2.i;
00225                 tmp.r = z__1.r, tmp.i = z__1.i;
00226 /* Computing MAX */
00227                 d__3 = *resid, d__4 = (d__1 = tmp.r, abs(d__1)) + (d__2 = 
00228                         d_imag(&tmp), abs(d__2));
00229                 *resid = max(d__3,d__4);
00230 /* L30: */
00231             }
00232 /* L40: */
00233         }
00234         *resid = *resid / (doublereal) (*n) / eps;
00235     }
00236     return 0;
00237 
00238 /*     End of ZUNT01 */
00239 
00240 } /* zunt01_ */


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