dort01.c
Go to the documentation of this file.
00001 /* dort01.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 doublereal c_b7 = 0.;
00019 static doublereal c_b8 = 1.;
00020 static doublereal c_b10 = -1.;
00021 static integer c__1 = 1;
00022 
00023 /* Subroutine */ int dort01_(char *rowcol, integer *m, integer *n, doublereal 
00024         *u, integer *ldu, doublereal *work, integer *lwork, doublereal *resid)
00025 {
00026     /* System generated locals */
00027     integer u_dim1, u_offset, i__1, i__2;
00028     doublereal d__1, d__2;
00029 
00030     /* Local variables */
00031     integer i__, j, k;
00032     doublereal eps, tmp;
00033     extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *, 
00034             integer *);
00035     extern logical lsame_(char *, char *);
00036     integer mnmin;
00037     extern /* Subroutine */ int dsyrk_(char *, char *, integer *, integer *, 
00038             doublereal *, doublereal *, integer *, doublereal *, doublereal *, 
00039              integer *);
00040     extern doublereal dlamch_(char *);
00041     extern /* Subroutine */ int dlaset_(char *, integer *, integer *, 
00042             doublereal *, doublereal *, doublereal *, integer *);
00043     extern doublereal dlansy_(char *, char *, integer *, doublereal *, 
00044             integer *, doublereal *);
00045     integer ldwork;
00046     char transu[1];
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 /*  DORT01 checks that the matrix U is orthogonal by computing the ratio */
00062 
00063 /*     RESID = norm( I - U*U' ) / ( n * EPS ), if ROWCOL = 'R', */
00064 /*  or */
00065 /*     RESID = norm( I - U'*U ) / ( m * EPS ), if ROWCOL = 'C'. */
00066 
00067 /*  Alternatively, if there isn't sufficient workspace to form */
00068 /*  I - U*U' or I - U'*U, the ratio is computed as */
00069 
00070 /*     RESID = abs( I - U*U' ) / ( n * EPS ), if ROWCOL = 'R', */
00071 /*  or */
00072 /*     RESID = abs( I - U'*U ) / ( m * EPS ), if ROWCOL = 'C'. */
00073 
00074 /*  where EPS is the machine precision.  ROWCOL is used only if m = n; */
00075 /*  if m > n, ROWCOL is assumed to be 'C', and if m < n, ROWCOL is */
00076 /*  assumed to be 'R'. */
00077 
00078 /*  Arguments */
00079 /*  ========= */
00080 
00081 /*  ROWCOL  (input) CHARACTER */
00082 /*          Specifies whether the rows or columns of U should be checked */
00083 /*          for orthogonality.  Used only if M = N. */
00084 /*          = 'R':  Check for orthogonal rows of U */
00085 /*          = 'C':  Check for orthogonal columns of U */
00086 
00087 /*  M       (input) INTEGER */
00088 /*          The number of rows of the matrix U. */
00089 
00090 /*  N       (input) INTEGER */
00091 /*          The number of columns of the matrix U. */
00092 
00093 /*  U       (input) DOUBLE PRECISION array, dimension (LDU,N) */
00094 /*          The orthogonal matrix U.  U is checked for orthogonal columns */
00095 /*          if m > n or if m = n and ROWCOL = 'C'.  U is checked for */
00096 /*          orthogonal rows if m < n or if m = n and ROWCOL = 'R'. */
00097 
00098 /*  LDU     (input) INTEGER */
00099 /*          The leading dimension of the array U.  LDU >= max(1,M). */
00100 
00101 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (LWORK) */
00102 
00103 /*  LWORK   (input) INTEGER */
00104 /*          The length of the array WORK.  For best performance, LWORK */
00105 /*          should be at least N*(N+1) if ROWCOL = 'C' or M*(M+1) if */
00106 /*          ROWCOL = 'R', but the test will be done even if LWORK is 0. */
00107 
00108 /*  RESID   (output) DOUBLE PRECISION */
00109 /*          RESID = norm( I - U * U' ) / ( n * EPS ), if ROWCOL = 'R', or */
00110 /*          RESID = norm( I - U' * U ) / ( m * EPS ), if ROWCOL = 'C'. */
00111 
00112 /*  ===================================================================== */
00113 
00114 /*     .. Parameters .. */
00115 /*     .. */
00116 /*     .. Local Scalars .. */
00117 /*     .. */
00118 /*     .. External Functions .. */
00119 /*     .. */
00120 /*     .. External Subroutines .. */
00121 /*     .. */
00122 /*     .. Intrinsic Functions .. */
00123 /*     .. */
00124 /*     .. Executable Statements .. */
00125 
00126     /* Parameter adjustments */
00127     u_dim1 = *ldu;
00128     u_offset = 1 + u_dim1;
00129     u -= u_offset;
00130     --work;
00131 
00132     /* Function Body */
00133     *resid = 0.;
00134 
00135 /*     Quick return if possible */
00136 
00137     if (*m <= 0 || *n <= 0) {
00138         return 0;
00139     }
00140 
00141     eps = dlamch_("Precision");
00142     if (*m < *n || *m == *n && lsame_(rowcol, "R")) {
00143         *(unsigned char *)transu = 'N';
00144         k = *n;
00145     } else {
00146         *(unsigned char *)transu = 'T';
00147         k = *m;
00148     }
00149     mnmin = min(*m,*n);
00150 
00151     if ((mnmin + 1) * mnmin <= *lwork) {
00152         ldwork = mnmin;
00153     } else {
00154         ldwork = 0;
00155     }
00156     if (ldwork > 0) {
00157 
00158 /*        Compute I - U*U' or I - U'*U. */
00159 
00160         dlaset_("Upper", &mnmin, &mnmin, &c_b7, &c_b8, &work[1], &ldwork);
00161         dsyrk_("Upper", transu, &mnmin, &k, &c_b10, &u[u_offset], ldu, &c_b8, 
00162                 &work[1], &ldwork);
00163 
00164 /*        Compute norm( I - U*U' ) / ( K * EPS ) . */
00165 
00166         *resid = dlansy_("1", "Upper", &mnmin, &work[1], &ldwork, &work[
00167                 ldwork * mnmin + 1]);
00168         *resid = *resid / (doublereal) k / eps;
00169     } else if (*(unsigned char *)transu == 'T') {
00170 
00171 /*        Find the maximum element in abs( I - U'*U ) / ( m * EPS ) */
00172 
00173         i__1 = *n;
00174         for (j = 1; j <= i__1; ++j) {
00175             i__2 = j;
00176             for (i__ = 1; i__ <= i__2; ++i__) {
00177                 if (i__ != j) {
00178                     tmp = 0.;
00179                 } else {
00180                     tmp = 1.;
00181                 }
00182                 tmp -= ddot_(m, &u[i__ * u_dim1 + 1], &c__1, &u[j * u_dim1 + 
00183                         1], &c__1);
00184 /* Computing MAX */
00185                 d__1 = *resid, d__2 = abs(tmp);
00186                 *resid = max(d__1,d__2);
00187 /* L10: */
00188             }
00189 /* L20: */
00190         }
00191         *resid = *resid / (doublereal) (*m) / eps;
00192     } else {
00193 
00194 /*        Find the maximum element in abs( I - U*U' ) / ( n * EPS ) */
00195 
00196         i__1 = *m;
00197         for (j = 1; j <= i__1; ++j) {
00198             i__2 = j;
00199             for (i__ = 1; i__ <= i__2; ++i__) {
00200                 if (i__ != j) {
00201                     tmp = 0.;
00202                 } else {
00203                     tmp = 1.;
00204                 }
00205                 tmp -= ddot_(n, &u[j + u_dim1], ldu, &u[i__ + u_dim1], ldu);
00206 /* Computing MAX */
00207                 d__1 = *resid, d__2 = abs(tmp);
00208                 *resid = max(d__1,d__2);
00209 /* L30: */
00210             }
00211 /* L40: */
00212         }
00213         *resid = *resid / (doublereal) (*n) / eps;
00214     }
00215     return 0;
00216 
00217 /*     End of DORT01 */
00218 
00219 } /* dort01_ */


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