slarge.c
Go to the documentation of this file.
00001 /* slarge.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__3 = 3;
00019 static integer c__1 = 1;
00020 static real c_b8 = 1.f;
00021 static real c_b10 = 0.f;
00022 
00023 /* Subroutine */ int slarge_(integer *n, real *a, integer *lda, integer *
00024         iseed, real *work, integer *info)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, i__1;
00028     real r__1;
00029 
00030     /* Builtin functions */
00031     double r_sign(real *, real *);
00032 
00033     /* Local variables */
00034     integer i__;
00035     real wa, wb, wn, tau;
00036     extern /* Subroutine */ int sger_(integer *, integer *, real *, real *, 
00037             integer *, real *, integer *, real *, integer *);
00038     extern doublereal snrm2_(integer *, real *, integer *);
00039     extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *), 
00040             sgemv_(char *, integer *, integer *, real *, real *, integer *, 
00041             real *, integer *, real *, real *, integer *), xerbla_(
00042             char *, integer *), slarnv_(integer *, integer *, integer 
00043             *, real *);
00044 
00045 
00046 /*  -- LAPACK auxiliary 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 /*  SLARGE pre- and post-multiplies a real general n by n matrix A */
00059 /*  with a random orthogonal matrix: A = U*D*U'. */
00060 
00061 /*  Arguments */
00062 /*  ========= */
00063 
00064 /*  N       (input) INTEGER */
00065 /*          The order of the matrix A.  N >= 0. */
00066 
00067 /*  A       (input/output) REAL array, dimension (LDA,N) */
00068 /*          On entry, the original n by n matrix A. */
00069 /*          On exit, A is overwritten by U*A*U' for some random */
00070 /*          orthogonal matrix U. */
00071 
00072 /*  LDA     (input) INTEGER */
00073 /*          The leading dimension of the array A.  LDA >= N. */
00074 
00075 /*  ISEED   (input/output) INTEGER array, dimension (4) */
00076 /*          On entry, the seed of the random number generator; the array */
00077 /*          elements must be between 0 and 4095, and ISEED(4) must be */
00078 /*          odd. */
00079 /*          On exit, the seed is updated. */
00080 
00081 /*  WORK    (workspace) REAL array, dimension (2*N) */
00082 
00083 /*  INFO    (output) INTEGER */
00084 /*          = 0: successful exit */
00085 /*          < 0: if INFO = -i, the i-th argument had an illegal value */
00086 
00087 /*  ===================================================================== */
00088 
00089 /*     .. Parameters .. */
00090 /*     .. */
00091 /*     .. Local Scalars .. */
00092 /*     .. */
00093 /*     .. External Subroutines .. */
00094 /*     .. */
00095 /*     .. Intrinsic Functions .. */
00096 /*     .. */
00097 /*     .. External Functions .. */
00098 /*     .. */
00099 /*     .. Executable Statements .. */
00100 
00101 /*     Test the input arguments */
00102 
00103     /* Parameter adjustments */
00104     a_dim1 = *lda;
00105     a_offset = 1 + a_dim1;
00106     a -= a_offset;
00107     --iseed;
00108     --work;
00109 
00110     /* Function Body */
00111     *info = 0;
00112     if (*n < 0) {
00113         *info = -1;
00114     } else if (*lda < max(1,*n)) {
00115         *info = -3;
00116     }
00117     if (*info < 0) {
00118         i__1 = -(*info);
00119         xerbla_("SLARGE", &i__1);
00120         return 0;
00121     }
00122 
00123 /*     pre- and post-multiply A by random orthogonal matrix */
00124 
00125     for (i__ = *n; i__ >= 1; --i__) {
00126 
00127 /*        generate random reflection */
00128 
00129         i__1 = *n - i__ + 1;
00130         slarnv_(&c__3, &iseed[1], &i__1, &work[1]);
00131         i__1 = *n - i__ + 1;
00132         wn = snrm2_(&i__1, &work[1], &c__1);
00133         wa = r_sign(&wn, &work[1]);
00134         if (wn == 0.f) {
00135             tau = 0.f;
00136         } else {
00137             wb = work[1] + wa;
00138             i__1 = *n - i__;
00139             r__1 = 1.f / wb;
00140             sscal_(&i__1, &r__1, &work[2], &c__1);
00141             work[1] = 1.f;
00142             tau = wb / wa;
00143         }
00144 
00145 /*        multiply A(i:n,1:n) by random reflection from the left */
00146 
00147         i__1 = *n - i__ + 1;
00148         sgemv_("Transpose", &i__1, n, &c_b8, &a[i__ + a_dim1], lda, &work[1], 
00149                 &c__1, &c_b10, &work[*n + 1], &c__1);
00150         i__1 = *n - i__ + 1;
00151         r__1 = -tau;
00152         sger_(&i__1, n, &r__1, &work[1], &c__1, &work[*n + 1], &c__1, &a[i__ 
00153                 + a_dim1], lda);
00154 
00155 /*        multiply A(1:n,i:n) by random reflection from the right */
00156 
00157         i__1 = *n - i__ + 1;
00158         sgemv_("No transpose", n, &i__1, &c_b8, &a[i__ * a_dim1 + 1], lda, &
00159                 work[1], &c__1, &c_b10, &work[*n + 1], &c__1);
00160         i__1 = *n - i__ + 1;
00161         r__1 = -tau;
00162         sger_(n, &i__1, &r__1, &work[*n + 1], &c__1, &work[1], &c__1, &a[i__ *
00163                  a_dim1 + 1], lda);
00164 /* L10: */
00165     }
00166     return 0;
00167 
00168 /*     End of SLARGE */
00169 
00170 } /* slarge_ */


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