clatsp.c
Go to the documentation of this file.
00001 /* clatsp.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__5 = 5;
00019 static integer c__2 = 2;
00020 
00021 /* Subroutine */ int clatsp_(char *uplo, integer *n, complex *x, integer *
00022         iseed)
00023 {
00024     /* System generated locals */
00025     integer i__1, i__2, i__3;
00026     complex q__1, q__2, q__3;
00027 
00028     /* Builtin functions */
00029     double sqrt(doublereal), c_abs(complex *);
00030 
00031     /* Local variables */
00032     complex a, b, c__;
00033     integer j;
00034     complex r__;
00035     integer n5, jj;
00036     real beta, alpha, alpha3;
00037     extern /* Complex */ VOID clarnd_(complex *, integer *, integer *);
00038 
00039 
00040 /*  -- LAPACK auxiliary test routine (version 3.1) -- */
00041 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00042 /*     November 2006 */
00043 
00044 /*     .. Scalar Arguments .. */
00045 /*     .. */
00046 /*     .. Array Arguments .. */
00047 /*     .. */
00048 
00049 /*  Purpose */
00050 /*  ======= */
00051 
00052 /*  CLATSP generates a special test matrix for the complex symmetric */
00053 /*  (indefinite) factorization for packed matrices.  The pivot blocks of */
00054 /*  the generated matrix will be in the following order: */
00055 /*     2x2 pivot block, non diagonalizable */
00056 /*     1x1 pivot block */
00057 /*     2x2 pivot block, diagonalizable */
00058 /*     (cycle repeats) */
00059 /*  A row interchange is required for each non-diagonalizable 2x2 block. */
00060 
00061 /*  Arguments */
00062 /*  ========= */
00063 
00064 /*  UPLO    (input) CHARACTER */
00065 /*          Specifies whether the generated matrix is to be upper or */
00066 /*          lower triangular. */
00067 /*          = 'U':  Upper triangular */
00068 /*          = 'L':  Lower triangular */
00069 
00070 /*  N       (input) INTEGER */
00071 /*          The dimension of the matrix to be generated. */
00072 
00073 /*  X       (output) COMPLEX array, dimension (N*(N+1)/2) */
00074 /*          The generated matrix in packed storage format.  The matrix */
00075 /*          consists of 3x3 and 2x2 diagonal blocks which result in the */
00076 /*          pivot sequence given above.  The matrix outside these */
00077 /*          diagonal blocks is zero. */
00078 
00079 /*  ISEED   (input/output) INTEGER array, dimension (4) */
00080 /*          On entry, the seed for the random number generator.  The last */
00081 /*          of the four integers must be odd.  (modified on exit) */
00082 
00083 /*  ===================================================================== */
00084 
00085 /*     .. Parameters .. */
00086 /*     .. */
00087 /*     .. Local Scalars .. */
00088 /*     .. */
00089 /*     .. External Functions .. */
00090 /*     .. */
00091 /*     .. Intrinsic Functions .. */
00092 /*     .. */
00093 /*     .. Executable Statements .. */
00094 
00095 /*     Initialize constants */
00096 
00097     /* Parameter adjustments */
00098     --iseed;
00099     --x;
00100 
00101     /* Function Body */
00102     alpha = (sqrt(17.f) + 1.f) / 8.f;
00103     beta = alpha - .001f;
00104     alpha3 = alpha * alpha * alpha;
00105 
00106 /*     Fill the matrix with zeros. */
00107 
00108     i__1 = *n * (*n + 1) / 2;
00109     for (j = 1; j <= i__1; ++j) {
00110         i__2 = j;
00111         x[i__2].r = 0.f, x[i__2].i = 0.f;
00112 /* L10: */
00113     }
00114 
00115 /*     UPLO = 'U':  Upper triangular storage */
00116 
00117     if (*(unsigned char *)uplo == 'U') {
00118         n5 = *n / 5;
00119         n5 = *n - n5 * 5 + 1;
00120 
00121         jj = *n * (*n + 1) / 2;
00122         i__1 = n5;
00123         for (j = *n; j >= i__1; j += -5) {
00124             clarnd_(&q__2, &c__5, &iseed[1]);
00125             q__1.r = alpha3 * q__2.r, q__1.i = alpha3 * q__2.i;
00126             a.r = q__1.r, a.i = q__1.i;
00127             clarnd_(&q__2, &c__5, &iseed[1]);
00128             q__1.r = q__2.r / alpha, q__1.i = q__2.i / alpha;
00129             b.r = q__1.r, b.i = q__1.i;
00130             q__3.r = b.r * 2.f, q__3.i = b.i * 2.f;
00131             q__2.r = q__3.r * 0.f - q__3.i * 1.f, q__2.i = q__3.r * 1.f + 
00132                     q__3.i * 0.f;
00133             q__1.r = a.r - q__2.r, q__1.i = a.i - q__2.i;
00134             c__.r = q__1.r, c__.i = q__1.i;
00135             q__1.r = c__.r / beta, q__1.i = c__.i / beta;
00136             r__.r = q__1.r, r__.i = q__1.i;
00137             i__2 = jj;
00138             x[i__2].r = a.r, x[i__2].i = a.i;
00139             i__2 = jj - 2;
00140             x[i__2].r = b.r, x[i__2].i = b.i;
00141             jj -= j;
00142             i__2 = jj;
00143             clarnd_(&q__1, &c__2, &iseed[1]);
00144             x[i__2].r = q__1.r, x[i__2].i = q__1.i;
00145             i__2 = jj - 1;
00146             x[i__2].r = r__.r, x[i__2].i = r__.i;
00147             jj -= j - 1;
00148             i__2 = jj;
00149             x[i__2].r = c__.r, x[i__2].i = c__.i;
00150             jj -= j - 2;
00151             i__2 = jj;
00152             clarnd_(&q__1, &c__2, &iseed[1]);
00153             x[i__2].r = q__1.r, x[i__2].i = q__1.i;
00154             jj -= j - 3;
00155             i__2 = jj;
00156             clarnd_(&q__1, &c__2, &iseed[1]);
00157             x[i__2].r = q__1.r, x[i__2].i = q__1.i;
00158             if (c_abs(&x[jj + (j - 3)]) > c_abs(&x[jj])) {
00159                 i__2 = jj + (j - 4);
00160                 i__3 = jj + (j - 3);
00161                 q__1.r = x[i__3].r * 2.f, q__1.i = x[i__3].i * 2.f;
00162                 x[i__2].r = q__1.r, x[i__2].i = q__1.i;
00163             } else {
00164                 i__2 = jj + (j - 4);
00165                 i__3 = jj;
00166                 q__1.r = x[i__3].r * 2.f, q__1.i = x[i__3].i * 2.f;
00167                 x[i__2].r = q__1.r, x[i__2].i = q__1.i;
00168             }
00169             jj -= j - 4;
00170 /* L20: */
00171         }
00172 
00173 /*        Clean-up for N not a multiple of 5. */
00174 
00175         j = n5 - 1;
00176         if (j > 2) {
00177             clarnd_(&q__2, &c__5, &iseed[1]);
00178             q__1.r = alpha3 * q__2.r, q__1.i = alpha3 * q__2.i;
00179             a.r = q__1.r, a.i = q__1.i;
00180             clarnd_(&q__2, &c__5, &iseed[1]);
00181             q__1.r = q__2.r / alpha, q__1.i = q__2.i / alpha;
00182             b.r = q__1.r, b.i = q__1.i;
00183             q__3.r = b.r * 2.f, q__3.i = b.i * 2.f;
00184             q__2.r = q__3.r * 0.f - q__3.i * 1.f, q__2.i = q__3.r * 1.f + 
00185                     q__3.i * 0.f;
00186             q__1.r = a.r - q__2.r, q__1.i = a.i - q__2.i;
00187             c__.r = q__1.r, c__.i = q__1.i;
00188             q__1.r = c__.r / beta, q__1.i = c__.i / beta;
00189             r__.r = q__1.r, r__.i = q__1.i;
00190             i__1 = jj;
00191             x[i__1].r = a.r, x[i__1].i = a.i;
00192             i__1 = jj - 2;
00193             x[i__1].r = b.r, x[i__1].i = b.i;
00194             jj -= j;
00195             i__1 = jj;
00196             clarnd_(&q__1, &c__2, &iseed[1]);
00197             x[i__1].r = q__1.r, x[i__1].i = q__1.i;
00198             i__1 = jj - 1;
00199             x[i__1].r = r__.r, x[i__1].i = r__.i;
00200             jj -= j - 1;
00201             i__1 = jj;
00202             x[i__1].r = c__.r, x[i__1].i = c__.i;
00203             jj -= j - 2;
00204             j += -3;
00205         }
00206         if (j > 1) {
00207             i__1 = jj;
00208             clarnd_(&q__1, &c__2, &iseed[1]);
00209             x[i__1].r = q__1.r, x[i__1].i = q__1.i;
00210             i__1 = jj - j;
00211             clarnd_(&q__1, &c__2, &iseed[1]);
00212             x[i__1].r = q__1.r, x[i__1].i = q__1.i;
00213             if (c_abs(&x[jj]) > c_abs(&x[jj - j])) {
00214                 i__1 = jj - 1;
00215                 i__2 = jj;
00216                 q__1.r = x[i__2].r * 2.f, q__1.i = x[i__2].i * 2.f;
00217                 x[i__1].r = q__1.r, x[i__1].i = q__1.i;
00218             } else {
00219                 i__1 = jj - 1;
00220                 i__2 = jj - j;
00221                 q__1.r = x[i__2].r * 2.f, q__1.i = x[i__2].i * 2.f;
00222                 x[i__1].r = q__1.r, x[i__1].i = q__1.i;
00223             }
00224             jj = jj - j - (j - 1);
00225             j += -2;
00226         } else if (j == 1) {
00227             i__1 = jj;
00228             clarnd_(&q__1, &c__2, &iseed[1]);
00229             x[i__1].r = q__1.r, x[i__1].i = q__1.i;
00230             --j;
00231         }
00232 
00233 /*     UPLO = 'L':  Lower triangular storage */
00234 
00235     } else {
00236         n5 = *n / 5;
00237         n5 *= 5;
00238 
00239         jj = 1;
00240         i__1 = n5;
00241         for (j = 1; j <= i__1; j += 5) {
00242             clarnd_(&q__2, &c__5, &iseed[1]);
00243             q__1.r = alpha3 * q__2.r, q__1.i = alpha3 * q__2.i;
00244             a.r = q__1.r, a.i = q__1.i;
00245             clarnd_(&q__2, &c__5, &iseed[1]);
00246             q__1.r = q__2.r / alpha, q__1.i = q__2.i / alpha;
00247             b.r = q__1.r, b.i = q__1.i;
00248             q__3.r = b.r * 2.f, q__3.i = b.i * 2.f;
00249             q__2.r = q__3.r * 0.f - q__3.i * 1.f, q__2.i = q__3.r * 1.f + 
00250                     q__3.i * 0.f;
00251             q__1.r = a.r - q__2.r, q__1.i = a.i - q__2.i;
00252             c__.r = q__1.r, c__.i = q__1.i;
00253             q__1.r = c__.r / beta, q__1.i = c__.i / beta;
00254             r__.r = q__1.r, r__.i = q__1.i;
00255             i__2 = jj;
00256             x[i__2].r = a.r, x[i__2].i = a.i;
00257             i__2 = jj + 2;
00258             x[i__2].r = b.r, x[i__2].i = b.i;
00259             jj += *n - j + 1;
00260             i__2 = jj;
00261             clarnd_(&q__1, &c__2, &iseed[1]);
00262             x[i__2].r = q__1.r, x[i__2].i = q__1.i;
00263             i__2 = jj + 1;
00264             x[i__2].r = r__.r, x[i__2].i = r__.i;
00265             jj += *n - j;
00266             i__2 = jj;
00267             x[i__2].r = c__.r, x[i__2].i = c__.i;
00268             jj += *n - j - 1;
00269             i__2 = jj;
00270             clarnd_(&q__1, &c__2, &iseed[1]);
00271             x[i__2].r = q__1.r, x[i__2].i = q__1.i;
00272             jj += *n - j - 2;
00273             i__2 = jj;
00274             clarnd_(&q__1, &c__2, &iseed[1]);
00275             x[i__2].r = q__1.r, x[i__2].i = q__1.i;
00276             if (c_abs(&x[jj - (*n - j - 2)]) > c_abs(&x[jj])) {
00277                 i__2 = jj - (*n - j - 2) + 1;
00278                 i__3 = jj - (*n - j - 2);
00279                 q__1.r = x[i__3].r * 2.f, q__1.i = x[i__3].i * 2.f;
00280                 x[i__2].r = q__1.r, x[i__2].i = q__1.i;
00281             } else {
00282                 i__2 = jj - (*n - j - 2) + 1;
00283                 i__3 = jj;
00284                 q__1.r = x[i__3].r * 2.f, q__1.i = x[i__3].i * 2.f;
00285                 x[i__2].r = q__1.r, x[i__2].i = q__1.i;
00286             }
00287             jj += *n - j - 3;
00288 /* L30: */
00289         }
00290 
00291 /*        Clean-up for N not a multiple of 5. */
00292 
00293         j = n5 + 1;
00294         if (j < *n - 1) {
00295             clarnd_(&q__2, &c__5, &iseed[1]);
00296             q__1.r = alpha3 * q__2.r, q__1.i = alpha3 * q__2.i;
00297             a.r = q__1.r, a.i = q__1.i;
00298             clarnd_(&q__2, &c__5, &iseed[1]);
00299             q__1.r = q__2.r / alpha, q__1.i = q__2.i / alpha;
00300             b.r = q__1.r, b.i = q__1.i;
00301             q__3.r = b.r * 2.f, q__3.i = b.i * 2.f;
00302             q__2.r = q__3.r * 0.f - q__3.i * 1.f, q__2.i = q__3.r * 1.f + 
00303                     q__3.i * 0.f;
00304             q__1.r = a.r - q__2.r, q__1.i = a.i - q__2.i;
00305             c__.r = q__1.r, c__.i = q__1.i;
00306             q__1.r = c__.r / beta, q__1.i = c__.i / beta;
00307             r__.r = q__1.r, r__.i = q__1.i;
00308             i__1 = jj;
00309             x[i__1].r = a.r, x[i__1].i = a.i;
00310             i__1 = jj + 2;
00311             x[i__1].r = b.r, x[i__1].i = b.i;
00312             jj += *n - j + 1;
00313             i__1 = jj;
00314             clarnd_(&q__1, &c__2, &iseed[1]);
00315             x[i__1].r = q__1.r, x[i__1].i = q__1.i;
00316             i__1 = jj + 1;
00317             x[i__1].r = r__.r, x[i__1].i = r__.i;
00318             jj += *n - j;
00319             i__1 = jj;
00320             x[i__1].r = c__.r, x[i__1].i = c__.i;
00321             jj += *n - j - 1;
00322             j += 3;
00323         }
00324         if (j < *n) {
00325             i__1 = jj;
00326             clarnd_(&q__1, &c__2, &iseed[1]);
00327             x[i__1].r = q__1.r, x[i__1].i = q__1.i;
00328             i__1 = jj + (*n - j + 1);
00329             clarnd_(&q__1, &c__2, &iseed[1]);
00330             x[i__1].r = q__1.r, x[i__1].i = q__1.i;
00331             if (c_abs(&x[jj]) > c_abs(&x[jj + (*n - j + 1)])) {
00332                 i__1 = jj + 1;
00333                 i__2 = jj;
00334                 q__1.r = x[i__2].r * 2.f, q__1.i = x[i__2].i * 2.f;
00335                 x[i__1].r = q__1.r, x[i__1].i = q__1.i;
00336             } else {
00337                 i__1 = jj + 1;
00338                 i__2 = jj + (*n - j + 1);
00339                 q__1.r = x[i__2].r * 2.f, q__1.i = x[i__2].i * 2.f;
00340                 x[i__1].r = q__1.r, x[i__1].i = q__1.i;
00341             }
00342             jj = jj + (*n - j + 1) + (*n - j);
00343             j += 2;
00344         } else if (j == *n) {
00345             i__1 = jj;
00346             clarnd_(&q__1, &c__2, &iseed[1]);
00347             x[i__1].r = q__1.r, x[i__1].i = q__1.i;
00348             jj += *n - j + 1;
00349             ++j;
00350         }
00351     }
00352 
00353     return 0;
00354 
00355 /*     End of CLATSP */
00356 
00357 } /* clatsp_ */


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