zlagsy.c
Go to the documentation of this file.
00001 /* zlagsy.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_b1 = {0.,0.};
00019 static doublecomplex c_b2 = {1.,0.};
00020 static integer c__3 = 3;
00021 static integer c__1 = 1;
00022 
00023 /* Subroutine */ int zlagsy_(integer *n, integer *k, doublereal *d__, 
00024         doublecomplex *a, integer *lda, integer *iseed, doublecomplex *work, 
00025         integer *info)
00026 {
00027     /* System generated locals */
00028     integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6, i__7, i__8, 
00029             i__9;
00030     doublereal d__1;
00031     doublecomplex z__1, z__2, z__3, z__4;
00032 
00033     /* Builtin functions */
00034     double z_abs(doublecomplex *);
00035     void z_div(doublecomplex *, doublecomplex *, doublecomplex *);
00036 
00037     /* Local variables */
00038     integer i__, j, ii, jj;
00039     doublecomplex wa, wb;
00040     doublereal wn;
00041     doublecomplex tau, alpha;
00042     extern /* Subroutine */ int zgerc_(integer *, integer *, doublecomplex *, 
00043             doublecomplex *, integer *, doublecomplex *, integer *, 
00044             doublecomplex *, integer *), zscal_(integer *, doublecomplex *, 
00045             doublecomplex *, integer *);
00046     extern /* Double Complex */ VOID zdotc_(doublecomplex *, integer *, 
00047             doublecomplex *, integer *, doublecomplex *, integer *);
00048     extern /* Subroutine */ int zgemv_(char *, integer *, integer *, 
00049             doublecomplex *, doublecomplex *, integer *, doublecomplex *, 
00050             integer *, doublecomplex *, doublecomplex *, integer *), 
00051             zaxpy_(integer *, doublecomplex *, doublecomplex *, integer *, 
00052             doublecomplex *, integer *), zsymv_(char *, integer *, 
00053             doublecomplex *, doublecomplex *, integer *, doublecomplex *, 
00054             integer *, doublecomplex *, doublecomplex *, integer *);
00055     extern doublereal dznrm2_(integer *, doublecomplex *, integer *);
00056     extern /* Subroutine */ int xerbla_(char *, integer *), zlacgv_(
00057             integer *, doublecomplex *, integer *), zlarnv_(integer *, 
00058             integer *, integer *, doublecomplex *);
00059 
00060 
00061 /*  -- LAPACK auxiliary test routine (version 3.1) -- */
00062 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00063 /*     November 2006 */
00064 
00065 /*     .. Scalar Arguments .. */
00066 /*     .. */
00067 /*     .. Array Arguments .. */
00068 /*     .. */
00069 
00070 /*  Purpose */
00071 /*  ======= */
00072 
00073 /*  ZLAGSY generates a complex symmetric matrix A, by pre- and post- */
00074 /*  multiplying a real diagonal matrix D with a random unitary matrix: */
00075 /*  A = U*D*U**T. The semi-bandwidth may then be reduced to k by */
00076 /*  additional unitary transformations. */
00077 
00078 /*  Arguments */
00079 /*  ========= */
00080 
00081 /*  N       (input) INTEGER */
00082 /*          The order of the matrix A.  N >= 0. */
00083 
00084 /*  K       (input) INTEGER */
00085 /*          The number of nonzero subdiagonals within the band of A. */
00086 /*          0 <= K <= N-1. */
00087 
00088 /*  D       (input) DOUBLE PRECISION array, dimension (N) */
00089 /*          The diagonal elements of the diagonal matrix D. */
00090 
00091 /*  A       (output) COMPLEX*16 array, dimension (LDA,N) */
00092 /*          The generated n by n symmetric matrix A (the full matrix is */
00093 /*          stored). */
00094 
00095 /*  LDA     (input) INTEGER */
00096 /*          The leading dimension of the array A.  LDA >= N. */
00097 
00098 /*  ISEED   (input/output) INTEGER array, dimension (4) */
00099 /*          On entry, the seed of the random number generator; the array */
00100 /*          elements must be between 0 and 4095, and ISEED(4) must be */
00101 /*          odd. */
00102 /*          On exit, the seed is updated. */
00103 
00104 /*  WORK    (workspace) COMPLEX*16 array, dimension (2*N) */
00105 
00106 /*  INFO    (output) INTEGER */
00107 /*          = 0: successful exit */
00108 /*          < 0: if INFO = -i, the i-th argument had an illegal value */
00109 
00110 /*  ===================================================================== */
00111 
00112 /*     .. Parameters .. */
00113 /*     .. */
00114 /*     .. Local Scalars .. */
00115 /*     .. */
00116 /*     .. External Subroutines .. */
00117 /*     .. */
00118 /*     .. External Functions .. */
00119 /*     .. */
00120 /*     .. Intrinsic Functions .. */
00121 /*     .. */
00122 /*     .. Executable Statements .. */
00123 
00124 /*     Test the input arguments */
00125 
00126     /* Parameter adjustments */
00127     --d__;
00128     a_dim1 = *lda;
00129     a_offset = 1 + a_dim1;
00130     a -= a_offset;
00131     --iseed;
00132     --work;
00133 
00134     /* Function Body */
00135     *info = 0;
00136     if (*n < 0) {
00137         *info = -1;
00138     } else if (*k < 0 || *k > *n - 1) {
00139         *info = -2;
00140     } else if (*lda < max(1,*n)) {
00141         *info = -5;
00142     }
00143     if (*info < 0) {
00144         i__1 = -(*info);
00145         xerbla_("ZLAGSY", &i__1);
00146         return 0;
00147     }
00148 
00149 /*     initialize lower triangle of A to diagonal matrix */
00150 
00151     i__1 = *n;
00152     for (j = 1; j <= i__1; ++j) {
00153         i__2 = *n;
00154         for (i__ = j + 1; i__ <= i__2; ++i__) {
00155             i__3 = i__ + j * a_dim1;
00156             a[i__3].r = 0., a[i__3].i = 0.;
00157 /* L10: */
00158         }
00159 /* L20: */
00160     }
00161     i__1 = *n;
00162     for (i__ = 1; i__ <= i__1; ++i__) {
00163         i__2 = i__ + i__ * a_dim1;
00164         i__3 = i__;
00165         a[i__2].r = d__[i__3], a[i__2].i = 0.;
00166 /* L30: */
00167     }
00168 
00169 /*     Generate lower triangle of symmetric matrix */
00170 
00171     for (i__ = *n - 1; i__ >= 1; --i__) {
00172 
00173 /*        generate random reflection */
00174 
00175         i__1 = *n - i__ + 1;
00176         zlarnv_(&c__3, &iseed[1], &i__1, &work[1]);
00177         i__1 = *n - i__ + 1;
00178         wn = dznrm2_(&i__1, &work[1], &c__1);
00179         d__1 = wn / z_abs(&work[1]);
00180         z__1.r = d__1 * work[1].r, z__1.i = d__1 * work[1].i;
00181         wa.r = z__1.r, wa.i = z__1.i;
00182         if (wn == 0.) {
00183             tau.r = 0., tau.i = 0.;
00184         } else {
00185             z__1.r = work[1].r + wa.r, z__1.i = work[1].i + wa.i;
00186             wb.r = z__1.r, wb.i = z__1.i;
00187             i__1 = *n - i__;
00188             z_div(&z__1, &c_b2, &wb);
00189             zscal_(&i__1, &z__1, &work[2], &c__1);
00190             work[1].r = 1., work[1].i = 0.;
00191             z_div(&z__1, &wb, &wa);
00192             d__1 = z__1.r;
00193             tau.r = d__1, tau.i = 0.;
00194         }
00195 
00196 /*        apply random reflection to A(i:n,i:n) from the left */
00197 /*        and the right */
00198 
00199 /*        compute  y := tau * A * conjg(u) */
00200 
00201         i__1 = *n - i__ + 1;
00202         zlacgv_(&i__1, &work[1], &c__1);
00203         i__1 = *n - i__ + 1;
00204         zsymv_("Lower", &i__1, &tau, &a[i__ + i__ * a_dim1], lda, &work[1], &
00205                 c__1, &c_b1, &work[*n + 1], &c__1);
00206         i__1 = *n - i__ + 1;
00207         zlacgv_(&i__1, &work[1], &c__1);
00208 
00209 /*        compute  v := y - 1/2 * tau * ( u, y ) * u */
00210 
00211         z__3.r = -.5, z__3.i = -0.;
00212         z__2.r = z__3.r * tau.r - z__3.i * tau.i, z__2.i = z__3.r * tau.i + 
00213                 z__3.i * tau.r;
00214         i__1 = *n - i__ + 1;
00215         zdotc_(&z__4, &i__1, &work[1], &c__1, &work[*n + 1], &c__1);
00216         z__1.r = z__2.r * z__4.r - z__2.i * z__4.i, z__1.i = z__2.r * z__4.i 
00217                 + z__2.i * z__4.r;
00218         alpha.r = z__1.r, alpha.i = z__1.i;
00219         i__1 = *n - i__ + 1;
00220         zaxpy_(&i__1, &alpha, &work[1], &c__1, &work[*n + 1], &c__1);
00221 
00222 /*        apply the transformation as a rank-2 update to A(i:n,i:n) */
00223 
00224 /*        CALL ZSYR2( 'Lower', N-I+1, -ONE, WORK, 1, WORK( N+1 ), 1, */
00225 /*        $               A( I, I ), LDA ) */
00226 
00227         i__1 = *n;
00228         for (jj = i__; jj <= i__1; ++jj) {
00229             i__2 = *n;
00230             for (ii = jj; ii <= i__2; ++ii) {
00231                 i__3 = ii + jj * a_dim1;
00232                 i__4 = ii + jj * a_dim1;
00233                 i__5 = ii - i__ + 1;
00234                 i__6 = *n + jj - i__ + 1;
00235                 z__3.r = work[i__5].r * work[i__6].r - work[i__5].i * work[
00236                         i__6].i, z__3.i = work[i__5].r * work[i__6].i + work[
00237                         i__5].i * work[i__6].r;
00238                 z__2.r = a[i__4].r - z__3.r, z__2.i = a[i__4].i - z__3.i;
00239                 i__7 = *n + ii - i__ + 1;
00240                 i__8 = jj - i__ + 1;
00241                 z__4.r = work[i__7].r * work[i__8].r - work[i__7].i * work[
00242                         i__8].i, z__4.i = work[i__7].r * work[i__8].i + work[
00243                         i__7].i * work[i__8].r;
00244                 z__1.r = z__2.r - z__4.r, z__1.i = z__2.i - z__4.i;
00245                 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00246 /* L40: */
00247             }
00248 /* L50: */
00249         }
00250 /* L60: */
00251     }
00252 
00253 /*     Reduce number of subdiagonals to K */
00254 
00255     i__1 = *n - 1 - *k;
00256     for (i__ = 1; i__ <= i__1; ++i__) {
00257 
00258 /*        generate reflection to annihilate A(k+i+1:n,i) */
00259 
00260         i__2 = *n - *k - i__ + 1;
00261         wn = dznrm2_(&i__2, &a[*k + i__ + i__ * a_dim1], &c__1);
00262         d__1 = wn / z_abs(&a[*k + i__ + i__ * a_dim1]);
00263         i__2 = *k + i__ + i__ * a_dim1;
00264         z__1.r = d__1 * a[i__2].r, z__1.i = d__1 * a[i__2].i;
00265         wa.r = z__1.r, wa.i = z__1.i;
00266         if (wn == 0.) {
00267             tau.r = 0., tau.i = 0.;
00268         } else {
00269             i__2 = *k + i__ + i__ * a_dim1;
00270             z__1.r = a[i__2].r + wa.r, z__1.i = a[i__2].i + wa.i;
00271             wb.r = z__1.r, wb.i = z__1.i;
00272             i__2 = *n - *k - i__;
00273             z_div(&z__1, &c_b2, &wb);
00274             zscal_(&i__2, &z__1, &a[*k + i__ + 1 + i__ * a_dim1], &c__1);
00275             i__2 = *k + i__ + i__ * a_dim1;
00276             a[i__2].r = 1., a[i__2].i = 0.;
00277             z_div(&z__1, &wb, &wa);
00278             d__1 = z__1.r;
00279             tau.r = d__1, tau.i = 0.;
00280         }
00281 
00282 /*        apply reflection to A(k+i:n,i+1:k+i-1) from the left */
00283 
00284         i__2 = *n - *k - i__ + 1;
00285         i__3 = *k - 1;
00286         zgemv_("Conjugate transpose", &i__2, &i__3, &c_b2, &a[*k + i__ + (i__ 
00287                 + 1) * a_dim1], lda, &a[*k + i__ + i__ * a_dim1], &c__1, &
00288                 c_b1, &work[1], &c__1);
00289         i__2 = *n - *k - i__ + 1;
00290         i__3 = *k - 1;
00291         z__1.r = -tau.r, z__1.i = -tau.i;
00292         zgerc_(&i__2, &i__3, &z__1, &a[*k + i__ + i__ * a_dim1], &c__1, &work[
00293                 1], &c__1, &a[*k + i__ + (i__ + 1) * a_dim1], lda);
00294 
00295 /*        apply reflection to A(k+i:n,k+i:n) from the left and the right */
00296 
00297 /*        compute  y := tau * A * conjg(u) */
00298 
00299         i__2 = *n - *k - i__ + 1;
00300         zlacgv_(&i__2, &a[*k + i__ + i__ * a_dim1], &c__1);
00301         i__2 = *n - *k - i__ + 1;
00302         zsymv_("Lower", &i__2, &tau, &a[*k + i__ + (*k + i__) * a_dim1], lda, 
00303                 &a[*k + i__ + i__ * a_dim1], &c__1, &c_b1, &work[1], &c__1);
00304         i__2 = *n - *k - i__ + 1;
00305         zlacgv_(&i__2, &a[*k + i__ + i__ * a_dim1], &c__1);
00306 
00307 /*        compute  v := y - 1/2 * tau * ( u, y ) * u */
00308 
00309         z__3.r = -.5, z__3.i = -0.;
00310         z__2.r = z__3.r * tau.r - z__3.i * tau.i, z__2.i = z__3.r * tau.i + 
00311                 z__3.i * tau.r;
00312         i__2 = *n - *k - i__ + 1;
00313         zdotc_(&z__4, &i__2, &a[*k + i__ + i__ * a_dim1], &c__1, &work[1], &
00314                 c__1);
00315         z__1.r = z__2.r * z__4.r - z__2.i * z__4.i, z__1.i = z__2.r * z__4.i 
00316                 + z__2.i * z__4.r;
00317         alpha.r = z__1.r, alpha.i = z__1.i;
00318         i__2 = *n - *k - i__ + 1;
00319         zaxpy_(&i__2, &alpha, &a[*k + i__ + i__ * a_dim1], &c__1, &work[1], &
00320                 c__1);
00321 
00322 /*        apply symmetric rank-2 update to A(k+i:n,k+i:n) */
00323 
00324 /*        CALL ZSYR2( 'Lower', N-K-I+1, -ONE, A( K+I, I ), 1, WORK, 1, */
00325 /*        $               A( K+I, K+I ), LDA ) */
00326 
00327         i__2 = *n;
00328         for (jj = *k + i__; jj <= i__2; ++jj) {
00329             i__3 = *n;
00330             for (ii = jj; ii <= i__3; ++ii) {
00331                 i__4 = ii + jj * a_dim1;
00332                 i__5 = ii + jj * a_dim1;
00333                 i__6 = ii + i__ * a_dim1;
00334                 i__7 = jj - *k - i__ + 1;
00335                 z__3.r = a[i__6].r * work[i__7].r - a[i__6].i * work[i__7].i, 
00336                         z__3.i = a[i__6].r * work[i__7].i + a[i__6].i * work[
00337                         i__7].r;
00338                 z__2.r = a[i__5].r - z__3.r, z__2.i = a[i__5].i - z__3.i;
00339                 i__8 = ii - *k - i__ + 1;
00340                 i__9 = jj + i__ * a_dim1;
00341                 z__4.r = work[i__8].r * a[i__9].r - work[i__8].i * a[i__9].i, 
00342                         z__4.i = work[i__8].r * a[i__9].i + work[i__8].i * a[
00343                         i__9].r;
00344                 z__1.r = z__2.r - z__4.r, z__1.i = z__2.i - z__4.i;
00345                 a[i__4].r = z__1.r, a[i__4].i = z__1.i;
00346 /* L70: */
00347             }
00348 /* L80: */
00349         }
00350 
00351         i__2 = *k + i__ + i__ * a_dim1;
00352         z__1.r = -wa.r, z__1.i = -wa.i;
00353         a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00354         i__2 = *n;
00355         for (j = *k + i__ + 1; j <= i__2; ++j) {
00356             i__3 = j + i__ * a_dim1;
00357             a[i__3].r = 0., a[i__3].i = 0.;
00358 /* L90: */
00359         }
00360 /* L100: */
00361     }
00362 
00363 /*     Store full symmetric matrix */
00364 
00365     i__1 = *n;
00366     for (j = 1; j <= i__1; ++j) {
00367         i__2 = *n;
00368         for (i__ = j + 1; i__ <= i__2; ++i__) {
00369             i__3 = j + i__ * a_dim1;
00370             i__4 = i__ + j * a_dim1;
00371             a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
00372 /* L110: */
00373         }
00374 /* L120: */
00375     }
00376     return 0;
00377 
00378 /*     End of ZLAGSY */
00379 
00380 } /* zlagsy_ */


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