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


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