dlaror.c
Go to the documentation of this file.
00001 /* dlaror.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_b9 = 0.;
00019 static doublereal c_b10 = 1.;
00020 static integer c__3 = 3;
00021 static integer c__1 = 1;
00022 
00023 /* Subroutine */ int dlaror_(char *side, char *init, integer *m, integer *n, 
00024         doublereal *a, integer *lda, integer *iseed, doublereal *x, integer *
00025         info)
00026 {
00027     /* System generated locals */
00028     integer a_dim1, a_offset, i__1, i__2;
00029     doublereal d__1;
00030 
00031     /* Builtin functions */
00032     double d_sign(doublereal *, doublereal *);
00033 
00034     /* Local variables */
00035     integer j, kbeg;
00036     extern /* Subroutine */ int dger_(integer *, integer *, doublereal *, 
00037             doublereal *, integer *, doublereal *, integer *, doublereal *, 
00038             integer *);
00039     integer jcol, irow;
00040     extern doublereal dnrm2_(integer *, doublereal *, integer *);
00041     extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, 
00042             integer *);
00043     extern logical lsame_(char *, char *);
00044     extern /* Subroutine */ int dgemv_(char *, integer *, integer *, 
00045             doublereal *, doublereal *, integer *, doublereal *, integer *, 
00046             doublereal *, doublereal *, integer *);
00047     integer ixfrm, itype, nxfrm;
00048     doublereal xnorm;
00049     extern doublereal dlarnd_(integer *, integer *);
00050     extern /* Subroutine */ int dlaset_(char *, integer *, integer *, 
00051             doublereal *, doublereal *, doublereal *, integer *), 
00052             xerbla_(char *, integer *);
00053     doublereal factor, xnorms;
00054 
00055 
00056 /*  -- LAPACK auxiliary 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 /*  DLAROR pre- or post-multiplies an M by N matrix A by a random */
00069 /*  orthogonal matrix U, overwriting A.  A may optionally be initialized */
00070 /*  to the identity matrix before multiplying by U.  U is generated using */
00071 /*  the method of G.W. Stewart (SIAM J. Numer. Anal. 17, 1980, 403-409). */
00072 
00073 /*  Arguments */
00074 /*  ========= */
00075 
00076 /*  SIDE    (input) CHARACTER*1 */
00077 /*          Specifies whether A is multiplied on the left or right by U. */
00078 /*          = 'L':         Multiply A on the left (premultiply) by U */
00079 /*          = 'R':         Multiply A on the right (postmultiply) by U' */
00080 /*          = 'C' or 'T':  Multiply A on the left by U and the right */
00081 /*                          by U' (Here, U' means U-transpose.) */
00082 
00083 /*  INIT    (input) CHARACTER*1 */
00084 /*          Specifies whether or not A should be initialized to the */
00085 /*          identity matrix. */
00086 /*          = 'I':  Initialize A to (a section of) the identity matrix */
00087 /*                   before applying U. */
00088 /*          = 'N':  No initialization.  Apply U to the input matrix A. */
00089 
00090 /*          INIT = 'I' may be used to generate square or rectangular */
00091 /*          orthogonal matrices: */
00092 
00093 /*          For M = N and SIDE = 'L' or 'R', the rows will be orthogonal */
00094 /*          to each other, as will the columns. */
00095 
00096 /*          If M < N, SIDE = 'R' produces a dense matrix whose rows are */
00097 /*          orthogonal and whose columns are not, while SIDE = 'L' */
00098 /*          produces a matrix whose rows are orthogonal, and whose first */
00099 /*          M columns are orthogonal, and whose remaining columns are */
00100 /*          zero. */
00101 
00102 /*          If M > N, SIDE = 'L' produces a dense matrix whose columns */
00103 /*          are orthogonal and whose rows are not, while SIDE = 'R' */
00104 /*          produces a matrix whose columns are orthogonal, and whose */
00105 /*          first M rows are orthogonal, and whose remaining rows are */
00106 /*          zero. */
00107 
00108 /*  M       (input) INTEGER */
00109 /*          The number of rows of A. */
00110 
00111 /*  N       (input) INTEGER */
00112 /*          The number of columns of A. */
00113 
00114 /*  A       (input/output) DOUBLE PRECISION array, dimension (LDA, N) */
00115 /*          On entry, the array A. */
00116 /*          On exit, overwritten by U A ( if SIDE = 'L' ), */
00117 /*           or by A U ( if SIDE = 'R' ), */
00118 /*           or by U A U' ( if SIDE = 'C' or 'T'). */
00119 
00120 /*  LDA     (input) INTEGER */
00121 /*          The leading dimension of the array A.  LDA >= max(1,M). */
00122 
00123 /*  ISEED   (input/output) INTEGER array, dimension (4) */
00124 /*          On entry ISEED specifies the seed of the random number */
00125 /*          generator. The array elements should be between 0 and 4095; */
00126 /*          if not they will be reduced mod 4096.  Also, ISEED(4) must */
00127 /*          be odd.  The random number generator uses a linear */
00128 /*          congruential sequence limited to small integers, and so */
00129 /*          should produce machine independent random numbers. The */
00130 /*          values of ISEED are changed on exit, and can be used in the */
00131 /*          next call to DLAROR to continue the same random number */
00132 /*          sequence. */
00133 
00134 /*  X       (workspace) DOUBLE PRECISION array, dimension (3*MAX( M, N )) */
00135 /*          Workspace of length */
00136 /*              2*M + N if SIDE = 'L', */
00137 /*              2*N + M if SIDE = 'R', */
00138 /*              3*N     if SIDE = 'C' or 'T'. */
00139 
00140 /*  INFO    (output) INTEGER */
00141 /*          An error flag.  It is set to: */
00142 /*          = 0:  normal return */
00143 /*          < 0:  if INFO = -k, the k-th argument had an illegal value */
00144 /*          = 1:  if the random numbers generated by DLARND are bad. */
00145 
00146 /*  ===================================================================== */
00147 
00148 /*     .. Parameters .. */
00149 /*     .. */
00150 /*     .. Local Scalars .. */
00151 /*     .. */
00152 /*     .. External Functions .. */
00153 /*     .. */
00154 /*     .. External Subroutines .. */
00155 /*     .. */
00156 /*     .. Intrinsic Functions .. */
00157 /*     .. */
00158 /*     .. Executable Statements .. */
00159 
00160     /* Parameter adjustments */
00161     a_dim1 = *lda;
00162     a_offset = 1 + a_dim1;
00163     a -= a_offset;
00164     --iseed;
00165     --x;
00166 
00167     /* Function Body */
00168     if (*n == 0 || *m == 0) {
00169         return 0;
00170     }
00171 
00172     itype = 0;
00173     if (lsame_(side, "L")) {
00174         itype = 1;
00175     } else if (lsame_(side, "R")) {
00176         itype = 2;
00177     } else if (lsame_(side, "C") || lsame_(side, "T")) {
00178         itype = 3;
00179     }
00180 
00181 /*     Check for argument errors. */
00182 
00183     *info = 0;
00184     if (itype == 0) {
00185         *info = -1;
00186     } else if (*m < 0) {
00187         *info = -3;
00188     } else if (*n < 0 || itype == 3 && *n != *m) {
00189         *info = -4;
00190     } else if (*lda < *m) {
00191         *info = -6;
00192     }
00193     if (*info != 0) {
00194         i__1 = -(*info);
00195         xerbla_("DLAROR", &i__1);
00196         return 0;
00197     }
00198 
00199     if (itype == 1) {
00200         nxfrm = *m;
00201     } else {
00202         nxfrm = *n;
00203     }
00204 
00205 /*     Initialize A to the identity matrix if desired */
00206 
00207     if (lsame_(init, "I")) {
00208         dlaset_("Full", m, n, &c_b9, &c_b10, &a[a_offset], lda);
00209     }
00210 
00211 /*     If no rotation possible, multiply by random +/-1 */
00212 
00213 /*     Compute rotation by computing Householder transformations */
00214 /*     H(2), H(3), ..., H(nhouse) */
00215 
00216     i__1 = nxfrm;
00217     for (j = 1; j <= i__1; ++j) {
00218         x[j] = 0.;
00219 /* L10: */
00220     }
00221 
00222     i__1 = nxfrm;
00223     for (ixfrm = 2; ixfrm <= i__1; ++ixfrm) {
00224         kbeg = nxfrm - ixfrm + 1;
00225 
00226 /*        Generate independent normal( 0, 1 ) random numbers */
00227 
00228         i__2 = nxfrm;
00229         for (j = kbeg; j <= i__2; ++j) {
00230             x[j] = dlarnd_(&c__3, &iseed[1]);
00231 /* L20: */
00232         }
00233 
00234 /*        Generate a Householder transformation from the random vector X */
00235 
00236         xnorm = dnrm2_(&ixfrm, &x[kbeg], &c__1);
00237         xnorms = d_sign(&xnorm, &x[kbeg]);
00238         d__1 = -x[kbeg];
00239         x[kbeg + nxfrm] = d_sign(&c_b10, &d__1);
00240         factor = xnorms * (xnorms + x[kbeg]);
00241         if (abs(factor) < 1e-20) {
00242             *info = 1;
00243             xerbla_("DLAROR", info);
00244             return 0;
00245         } else {
00246             factor = 1. / factor;
00247         }
00248         x[kbeg] += xnorms;
00249 
00250 /*        Apply Householder transformation to A */
00251 
00252         if (itype == 1 || itype == 3) {
00253 
00254 /*           Apply H(k) from the left. */
00255 
00256             dgemv_("T", &ixfrm, n, &c_b10, &a[kbeg + a_dim1], lda, &x[kbeg], &
00257                     c__1, &c_b9, &x[(nxfrm << 1) + 1], &c__1);
00258             d__1 = -factor;
00259             dger_(&ixfrm, n, &d__1, &x[kbeg], &c__1, &x[(nxfrm << 1) + 1], &
00260                     c__1, &a[kbeg + a_dim1], lda);
00261 
00262         }
00263 
00264         if (itype == 2 || itype == 3) {
00265 
00266 /*           Apply H(k) from the right. */
00267 
00268             dgemv_("N", m, &ixfrm, &c_b10, &a[kbeg * a_dim1 + 1], lda, &x[
00269                     kbeg], &c__1, &c_b9, &x[(nxfrm << 1) + 1], &c__1);
00270             d__1 = -factor;
00271             dger_(m, &ixfrm, &d__1, &x[(nxfrm << 1) + 1], &c__1, &x[kbeg], &
00272                     c__1, &a[kbeg * a_dim1 + 1], lda);
00273 
00274         }
00275 /* L30: */
00276     }
00277 
00278     d__1 = dlarnd_(&c__3, &iseed[1]);
00279     x[nxfrm * 2] = d_sign(&c_b10, &d__1);
00280 
00281 /*     Scale the matrix A by D. */
00282 
00283     if (itype == 1 || itype == 3) {
00284         i__1 = *m;
00285         for (irow = 1; irow <= i__1; ++irow) {
00286             dscal_(n, &x[nxfrm + irow], &a[irow + a_dim1], lda);
00287 /* L40: */
00288         }
00289     }
00290 
00291     if (itype == 2 || itype == 3) {
00292         i__1 = *n;
00293         for (jcol = 1; jcol <= i__1; ++jcol) {
00294             dscal_(m, &x[nxfrm + jcol], &a[jcol * a_dim1 + 1], &c__1);
00295 /* L50: */
00296         }
00297     }
00298     return 0;
00299 
00300 /*     End of DLAROR */
00301 
00302 } /* dlaror_ */


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