slattp.c
Go to the documentation of this file.
00001 /* slattp.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__2 = 2;
00019 static integer c__1 = 1;
00020 static real c_b36 = 2.f;
00021 static real c_b48 = 1.f;
00022 
00023 /* Subroutine */ int slattp_(integer *imat, char *uplo, char *trans, char *
00024         diag, integer *iseed, integer *n, real *a, real *b, real *work, 
00025         integer *info)
00026 {
00027     /* System generated locals */
00028     integer i__1, i__2;
00029     real r__1, r__2;
00030     doublereal d__1, d__2;
00031 
00032     /* Builtin functions */
00033     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
00034     double pow_dd(doublereal *, doublereal *), sqrt(doublereal), r_sign(real *
00035             , real *);
00036 
00037     /* Local variables */
00038     real c__;
00039     integer i__, j;
00040     real s, t, x, y, z__;
00041     integer jc;
00042     real ra;
00043     integer jj;
00044     real rb;
00045     integer jl, kl, jr, ku, iy, jx;
00046     real ulp, sfac;
00047     integer mode;
00048     char path[3], dist[1];
00049     real unfl, rexp;
00050     char type__[1];
00051     real texp;
00052     extern /* Subroutine */ int srot_(integer *, real *, integer *, real *, 
00053             integer *, real *, real *);
00054     real star1, plus1, plus2, bscal;
00055     extern logical lsame_(char *, char *);
00056     extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *);
00057     real tscal, anorm, bnorm, tleft, stemp;
00058     logical upper;
00059     extern /* Subroutine */ int srotg_(real *, real *, real *, real *), 
00060             slatb4_(char *, integer *, integer *, integer *, char *, integer *
00061 , integer *, real *, integer *, real *, char *), slabad_(real *, real *);
00062     extern doublereal slamch_(char *);
00063     char packit[1];
00064     real bignum;
00065     extern integer isamax_(integer *, real *, integer *);
00066     extern doublereal slarnd_(integer *, integer *);
00067     real cndnum;
00068     integer jcnext, jcount;
00069     extern /* Subroutine */ int slatms_(integer *, integer *, char *, integer 
00070             *, char *, real *, integer *, real *, real *, integer *, integer *
00071 , char *, real *, integer *, real *, integer *), slarnv_(integer *, integer *, integer *, real *);
00072     real smlnum;
00073 
00074 
00075 /*  -- LAPACK test routine (version 3.1) -- */
00076 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00077 /*     November 2006 */
00078 
00079 /*     .. Scalar Arguments .. */
00080 /*     .. */
00081 /*     .. Array Arguments .. */
00082 /*     .. */
00083 
00084 /*  Purpose */
00085 /*  ======= */
00086 
00087 /*  SLATTP generates a triangular test matrix in packed storage. */
00088 /*  IMAT and UPLO uniquely specify the properties of the test */
00089 /*  matrix, which is returned in the array AP. */
00090 
00091 /*  Arguments */
00092 /*  ========= */
00093 
00094 /*  IMAT    (input) INTEGER */
00095 /*          An integer key describing which matrix to generate for this */
00096 /*          path. */
00097 
00098 /*  UPLO    (input) CHARACTER*1 */
00099 /*          Specifies whether the matrix A will be upper or lower */
00100 /*          triangular. */
00101 /*          = 'U':  Upper triangular */
00102 /*          = 'L':  Lower triangular */
00103 
00104 /*  TRANS   (input) CHARACTER*1 */
00105 /*          Specifies whether the matrix or its transpose will be used. */
00106 /*          = 'N':  No transpose */
00107 /*          = 'T':  Transpose */
00108 /*          = 'C':  Conjugate transpose (= Transpose) */
00109 
00110 /*  DIAG    (output) CHARACTER*1 */
00111 /*          Specifies whether or not the matrix A is unit triangular. */
00112 /*          = 'N':  Non-unit triangular */
00113 /*          = 'U':  Unit triangular */
00114 
00115 /*  ISEED   (input/output) INTEGER array, dimension (4) */
00116 /*          The seed vector for the random number generator (used in */
00117 /*          SLATMS).  Modified on exit. */
00118 
00119 /*  N       (input) INTEGER */
00120 /*          The order of the matrix to be generated. */
00121 
00122 /*  A       (output) REAL array, dimension (N*(N+1)/2) */
00123 /*          The upper or lower triangular matrix A, packed columnwise in */
00124 /*          a linear array.  The j-th column of A is stored in the array */
00125 /*          AP as follows: */
00126 /*          if UPLO = 'U', AP((j-1)*j/2 + i) = A(i,j) for 1<=i<=j; */
00127 /*          if UPLO = 'L', */
00128 /*             AP((j-1)*(n-j) + j*(j+1)/2 + i-j) = A(i,j) for j<=i<=n. */
00129 
00130 /*  B       (output) REAL array, dimension (N) */
00131 /*          The right hand side vector, if IMAT > 10. */
00132 
00133 /*  WORK    (workspace) REAL array, dimension (3*N) */
00134 
00135 /*  INFO    (output) INTEGER */
00136 /*          = 0:  successful exit */
00137 /*          < 0: if INFO = -k, the k-th argument had an illegal value */
00138 
00139 /*  ===================================================================== */
00140 
00141 /*     .. Parameters .. */
00142 /*     .. */
00143 /*     .. Local Scalars .. */
00144 /*     .. */
00145 /*     .. External Functions .. */
00146 /*     .. */
00147 /*     .. External Subroutines .. */
00148 /*     .. */
00149 /*     .. Intrinsic Functions .. */
00150 /*     .. */
00151 /*     .. Executable Statements .. */
00152 
00153     /* Parameter adjustments */
00154     --work;
00155     --b;
00156     --a;
00157     --iseed;
00158 
00159     /* Function Body */
00160     s_copy(path, "Single precision", (ftnlen)1, (ftnlen)16);
00161     s_copy(path + 1, "TP", (ftnlen)2, (ftnlen)2);
00162     unfl = slamch_("Safe minimum");
00163     ulp = slamch_("Epsilon") * slamch_("Base");
00164     smlnum = unfl;
00165     bignum = (1.f - ulp) / smlnum;
00166     slabad_(&smlnum, &bignum);
00167     if (*imat >= 7 && *imat <= 10 || *imat == 18) {
00168         *(unsigned char *)diag = 'U';
00169     } else {
00170         *(unsigned char *)diag = 'N';
00171     }
00172     *info = 0;
00173 
00174 /*     Quick return if N.LE.0. */
00175 
00176     if (*n <= 0) {
00177         return 0;
00178     }
00179 
00180 /*     Call SLATB4 to set parameters for SLATMS. */
00181 
00182     upper = lsame_(uplo, "U");
00183     if (upper) {
00184         slatb4_(path, imat, n, n, type__, &kl, &ku, &anorm, &mode, &cndnum, 
00185                 dist);
00186         *(unsigned char *)packit = 'C';
00187     } else {
00188         i__1 = -(*imat);
00189         slatb4_(path, &i__1, n, n, type__, &kl, &ku, &anorm, &mode, &cndnum, 
00190                 dist);
00191         *(unsigned char *)packit = 'R';
00192     }
00193 
00194 /*     IMAT <= 6:  Non-unit triangular matrix */
00195 
00196     if (*imat <= 6) {
00197         slatms_(n, n, dist, &iseed[1], type__, &b[1], &mode, &cndnum, &anorm, 
00198                 &kl, &ku, packit, &a[1], n, &work[1], info);
00199 
00200 /*     IMAT > 6:  Unit triangular matrix */
00201 /*     The diagonal is deliberately set to something other than 1. */
00202 
00203 /*     IMAT = 7:  Matrix is the identity */
00204 
00205     } else if (*imat == 7) {
00206         if (upper) {
00207             jc = 1;
00208             i__1 = *n;
00209             for (j = 1; j <= i__1; ++j) {
00210                 i__2 = j - 1;
00211                 for (i__ = 1; i__ <= i__2; ++i__) {
00212                     a[jc + i__ - 1] = 0.f;
00213 /* L10: */
00214                 }
00215                 a[jc + j - 1] = (real) j;
00216                 jc += j;
00217 /* L20: */
00218             }
00219         } else {
00220             jc = 1;
00221             i__1 = *n;
00222             for (j = 1; j <= i__1; ++j) {
00223                 a[jc] = (real) j;
00224                 i__2 = *n;
00225                 for (i__ = j + 1; i__ <= i__2; ++i__) {
00226                     a[jc + i__ - j] = 0.f;
00227 /* L30: */
00228                 }
00229                 jc = jc + *n - j + 1;
00230 /* L40: */
00231             }
00232         }
00233 
00234 /*     IMAT > 7:  Non-trivial unit triangular matrix */
00235 
00236 /*     Generate a unit triangular matrix T with condition CNDNUM by */
00237 /*     forming a triangular matrix with known singular values and */
00238 /*     filling in the zero entries with Givens rotations. */
00239 
00240     } else if (*imat <= 10) {
00241         if (upper) {
00242             jc = 0;
00243             i__1 = *n;
00244             for (j = 1; j <= i__1; ++j) {
00245                 i__2 = j - 1;
00246                 for (i__ = 1; i__ <= i__2; ++i__) {
00247                     a[jc + i__] = 0.f;
00248 /* L50: */
00249                 }
00250                 a[jc + j] = (real) j;
00251                 jc += j;
00252 /* L60: */
00253             }
00254         } else {
00255             jc = 1;
00256             i__1 = *n;
00257             for (j = 1; j <= i__1; ++j) {
00258                 a[jc] = (real) j;
00259                 i__2 = *n;
00260                 for (i__ = j + 1; i__ <= i__2; ++i__) {
00261                     a[jc + i__ - j] = 0.f;
00262 /* L70: */
00263                 }
00264                 jc = jc + *n - j + 1;
00265 /* L80: */
00266             }
00267         }
00268 
00269 /*        Since the trace of a unit triangular matrix is 1, the product */
00270 /*        of its singular values must be 1.  Let s = sqrt(CNDNUM), */
00271 /*        x = sqrt(s) - 1/sqrt(s), y = sqrt(2/(n-2))*x, and z = x**2. */
00272 /*        The following triangular matrix has singular values s, 1, 1, */
00273 /*        ..., 1, 1/s: */
00274 
00275 /*        1  y  y  y  ...  y  y  z */
00276 /*           1  0  0  ...  0  0  y */
00277 /*              1  0  ...  0  0  y */
00278 /*                 .  ...  .  .  . */
00279 /*                     .   .  .  . */
00280 /*                         1  0  y */
00281 /*                            1  y */
00282 /*                               1 */
00283 
00284 /*        To fill in the zeros, we first multiply by a matrix with small */
00285 /*        condition number of the form */
00286 
00287 /*        1  0  0  0  0  ... */
00288 /*           1  +  *  0  0  ... */
00289 /*              1  +  0  0  0 */
00290 /*                 1  +  *  0  0 */
00291 /*                    1  +  0  0 */
00292 /*                       ... */
00293 /*                          1  +  0 */
00294 /*                             1  0 */
00295 /*                                1 */
00296 
00297 /*        Each element marked with a '*' is formed by taking the product */
00298 /*        of the adjacent elements marked with '+'.  The '*'s can be */
00299 /*        chosen freely, and the '+'s are chosen so that the inverse of */
00300 /*        T will have elements of the same magnitude as T.  If the *'s in */
00301 /*        both T and inv(T) have small magnitude, T is well conditioned. */
00302 /*        The two offdiagonals of T are stored in WORK. */
00303 
00304 /*        The product of these two matrices has the form */
00305 
00306 /*        1  y  y  y  y  y  .  y  y  z */
00307 /*           1  +  *  0  0  .  0  0  y */
00308 /*              1  +  0  0  .  0  0  y */
00309 /*                 1  +  *  .  .  .  . */
00310 /*                    1  +  .  .  .  . */
00311 /*                       .  .  .  .  . */
00312 /*                          .  .  .  . */
00313 /*                             1  +  y */
00314 /*                                1  y */
00315 /*                                   1 */
00316 
00317 /*        Now we multiply by Givens rotations, using the fact that */
00318 
00319 /*              [  c   s ] [  1   w ] [ -c  -s ] =  [  1  -w ] */
00320 /*              [ -s   c ] [  0   1 ] [  s  -c ]    [  0   1 ] */
00321 /*        and */
00322 /*              [ -c  -s ] [  1   0 ] [  c   s ] =  [  1   0 ] */
00323 /*              [  s  -c ] [  w   1 ] [ -s   c ]    [ -w   1 ] */
00324 
00325 /*        where c = w / sqrt(w**2+4) and s = 2 / sqrt(w**2+4). */
00326 
00327         star1 = .25f;
00328         sfac = .5f;
00329         plus1 = sfac;
00330         i__1 = *n;
00331         for (j = 1; j <= i__1; j += 2) {
00332             plus2 = star1 / plus1;
00333             work[j] = plus1;
00334             work[*n + j] = star1;
00335             if (j + 1 <= *n) {
00336                 work[j + 1] = plus2;
00337                 work[*n + j + 1] = 0.f;
00338                 plus1 = star1 / plus2;
00339                 rexp = slarnd_(&c__2, &iseed[1]);
00340                 d__1 = (doublereal) sfac;
00341                 d__2 = (doublereal) rexp;
00342                 star1 *= pow_dd(&d__1, &d__2);
00343                 if (rexp < 0.f) {
00344                     d__1 = (doublereal) sfac;
00345                     d__2 = (doublereal) (1.f - rexp);
00346                     star1 = -pow_dd(&d__1, &d__2);
00347                 } else {
00348                     d__1 = (doublereal) sfac;
00349                     d__2 = (doublereal) (rexp + 1.f);
00350                     star1 = pow_dd(&d__1, &d__2);
00351                 }
00352             }
00353 /* L90: */
00354         }
00355 
00356         x = sqrt(cndnum) - 1.f / sqrt(cndnum);
00357         if (*n > 2) {
00358             y = sqrt(2.f / (real) (*n - 2)) * x;
00359         } else {
00360             y = 0.f;
00361         }
00362         z__ = x * x;
00363 
00364         if (upper) {
00365 
00366 /*           Set the upper triangle of A with a unit triangular matrix */
00367 /*           of known condition number. */
00368 
00369             jc = 1;
00370             i__1 = *n;
00371             for (j = 2; j <= i__1; ++j) {
00372                 a[jc + 1] = y;
00373                 if (j > 2) {
00374                     a[jc + j - 1] = work[j - 2];
00375                 }
00376                 if (j > 3) {
00377                     a[jc + j - 2] = work[*n + j - 3];
00378                 }
00379                 jc += j;
00380 /* L100: */
00381             }
00382             jc -= *n;
00383             a[jc + 1] = z__;
00384             i__1 = *n - 1;
00385             for (j = 2; j <= i__1; ++j) {
00386                 a[jc + j] = y;
00387 /* L110: */
00388             }
00389         } else {
00390 
00391 /*           Set the lower triangle of A with a unit triangular matrix */
00392 /*           of known condition number. */
00393 
00394             i__1 = *n - 1;
00395             for (i__ = 2; i__ <= i__1; ++i__) {
00396                 a[i__] = y;
00397 /* L120: */
00398             }
00399             a[*n] = z__;
00400             jc = *n + 1;
00401             i__1 = *n - 1;
00402             for (j = 2; j <= i__1; ++j) {
00403                 a[jc + 1] = work[j - 1];
00404                 if (j < *n - 1) {
00405                     a[jc + 2] = work[*n + j - 1];
00406                 }
00407                 a[jc + *n - j] = y;
00408                 jc = jc + *n - j + 1;
00409 /* L130: */
00410             }
00411         }
00412 
00413 /*        Fill in the zeros using Givens rotations */
00414 
00415         if (upper) {
00416             jc = 1;
00417             i__1 = *n - 1;
00418             for (j = 1; j <= i__1; ++j) {
00419                 jcnext = jc + j;
00420                 ra = a[jcnext + j - 1];
00421                 rb = 2.f;
00422                 srotg_(&ra, &rb, &c__, &s);
00423 
00424 /*              Multiply by [ c  s; -s  c] on the left. */
00425 
00426                 if (*n > j + 1) {
00427                     jx = jcnext + j;
00428                     i__2 = *n;
00429                     for (i__ = j + 2; i__ <= i__2; ++i__) {
00430                         stemp = c__ * a[jx + j] + s * a[jx + j + 1];
00431                         a[jx + j + 1] = -s * a[jx + j] + c__ * a[jx + j + 1];
00432                         a[jx + j] = stemp;
00433                         jx += i__;
00434 /* L140: */
00435                     }
00436                 }
00437 
00438 /*              Multiply by [-c -s;  s -c] on the right. */
00439 
00440                 if (j > 1) {
00441                     i__2 = j - 1;
00442                     r__1 = -c__;
00443                     r__2 = -s;
00444                     srot_(&i__2, &a[jcnext], &c__1, &a[jc], &c__1, &r__1, &
00445                             r__2);
00446                 }
00447 
00448 /*              Negate A(J,J+1). */
00449 
00450                 a[jcnext + j - 1] = -a[jcnext + j - 1];
00451                 jc = jcnext;
00452 /* L150: */
00453             }
00454         } else {
00455             jc = 1;
00456             i__1 = *n - 1;
00457             for (j = 1; j <= i__1; ++j) {
00458                 jcnext = jc + *n - j + 1;
00459                 ra = a[jc + 1];
00460                 rb = 2.f;
00461                 srotg_(&ra, &rb, &c__, &s);
00462 
00463 /*              Multiply by [ c -s;  s  c] on the right. */
00464 
00465                 if (*n > j + 1) {
00466                     i__2 = *n - j - 1;
00467                     r__1 = -s;
00468                     srot_(&i__2, &a[jcnext + 1], &c__1, &a[jc + 2], &c__1, &
00469                             c__, &r__1);
00470                 }
00471 
00472 /*              Multiply by [-c  s; -s -c] on the left. */
00473 
00474                 if (j > 1) {
00475                     jx = 1;
00476                     i__2 = j - 1;
00477                     for (i__ = 1; i__ <= i__2; ++i__) {
00478                         stemp = -c__ * a[jx + j - i__] + s * a[jx + j - i__ + 
00479                                 1];
00480                         a[jx + j - i__ + 1] = -s * a[jx + j - i__] - c__ * a[
00481                                 jx + j - i__ + 1];
00482                         a[jx + j - i__] = stemp;
00483                         jx = jx + *n - i__ + 1;
00484 /* L160: */
00485                     }
00486                 }
00487 
00488 /*              Negate A(J+1,J). */
00489 
00490                 a[jc + 1] = -a[jc + 1];
00491                 jc = jcnext;
00492 /* L170: */
00493             }
00494         }
00495 
00496 /*     IMAT > 10:  Pathological test cases.  These triangular matrices */
00497 /*     are badly scaled or badly conditioned, so when used in solving a */
00498 /*     triangular system they may cause overflow in the solution vector. */
00499 
00500     } else if (*imat == 11) {
00501 
00502 /*        Type 11:  Generate a triangular matrix with elements between */
00503 /*        -1 and 1. Give the diagonal norm 2 to make it well-conditioned. */
00504 /*        Make the right hand side large so that it requires scaling. */
00505 
00506         if (upper) {
00507             jc = 1;
00508             i__1 = *n;
00509             for (j = 1; j <= i__1; ++j) {
00510                 slarnv_(&c__2, &iseed[1], &j, &a[jc]);
00511                 a[jc + j - 1] = r_sign(&c_b36, &a[jc + j - 1]);
00512                 jc += j;
00513 /* L180: */
00514             }
00515         } else {
00516             jc = 1;
00517             i__1 = *n;
00518             for (j = 1; j <= i__1; ++j) {
00519                 i__2 = *n - j + 1;
00520                 slarnv_(&c__2, &iseed[1], &i__2, &a[jc]);
00521                 a[jc] = r_sign(&c_b36, &a[jc]);
00522                 jc = jc + *n - j + 1;
00523 /* L190: */
00524             }
00525         }
00526 
00527 /*        Set the right hand side so that the largest value is BIGNUM. */
00528 
00529         slarnv_(&c__2, &iseed[1], n, &b[1]);
00530         iy = isamax_(n, &b[1], &c__1);
00531         bnorm = (r__1 = b[iy], dabs(r__1));
00532         bscal = bignum / dmax(1.f,bnorm);
00533         sscal_(n, &bscal, &b[1], &c__1);
00534 
00535     } else if (*imat == 12) {
00536 
00537 /*        Type 12:  Make the first diagonal element in the solve small to */
00538 /*        cause immediate overflow when dividing by T(j,j). */
00539 /*        In type 12, the offdiagonal elements are small (CNORM(j) < 1). */
00540 
00541         slarnv_(&c__2, &iseed[1], n, &b[1]);
00542 /* Computing MAX */
00543         r__1 = 1.f, r__2 = (real) (*n - 1);
00544         tscal = 1.f / dmax(r__1,r__2);
00545         if (upper) {
00546             jc = 1;
00547             i__1 = *n;
00548             for (j = 1; j <= i__1; ++j) {
00549                 i__2 = j - 1;
00550                 slarnv_(&c__2, &iseed[1], &i__2, &a[jc]);
00551                 i__2 = j - 1;
00552                 sscal_(&i__2, &tscal, &a[jc], &c__1);
00553                 r__1 = slarnd_(&c__2, &iseed[1]);
00554                 a[jc + j - 1] = r_sign(&c_b48, &r__1);
00555                 jc += j;
00556 /* L200: */
00557             }
00558             a[*n * (*n + 1) / 2] = smlnum;
00559         } else {
00560             jc = 1;
00561             i__1 = *n;
00562             for (j = 1; j <= i__1; ++j) {
00563                 i__2 = *n - j;
00564                 slarnv_(&c__2, &iseed[1], &i__2, &a[jc + 1]);
00565                 i__2 = *n - j;
00566                 sscal_(&i__2, &tscal, &a[jc + 1], &c__1);
00567                 r__1 = slarnd_(&c__2, &iseed[1]);
00568                 a[jc] = r_sign(&c_b48, &r__1);
00569                 jc = jc + *n - j + 1;
00570 /* L210: */
00571             }
00572             a[1] = smlnum;
00573         }
00574 
00575     } else if (*imat == 13) {
00576 
00577 /*        Type 13:  Make the first diagonal element in the solve small to */
00578 /*        cause immediate overflow when dividing by T(j,j). */
00579 /*        In type 13, the offdiagonal elements are O(1) (CNORM(j) > 1). */
00580 
00581         slarnv_(&c__2, &iseed[1], n, &b[1]);
00582         if (upper) {
00583             jc = 1;
00584             i__1 = *n;
00585             for (j = 1; j <= i__1; ++j) {
00586                 i__2 = j - 1;
00587                 slarnv_(&c__2, &iseed[1], &i__2, &a[jc]);
00588                 r__1 = slarnd_(&c__2, &iseed[1]);
00589                 a[jc + j - 1] = r_sign(&c_b48, &r__1);
00590                 jc += j;
00591 /* L220: */
00592             }
00593             a[*n * (*n + 1) / 2] = smlnum;
00594         } else {
00595             jc = 1;
00596             i__1 = *n;
00597             for (j = 1; j <= i__1; ++j) {
00598                 i__2 = *n - j;
00599                 slarnv_(&c__2, &iseed[1], &i__2, &a[jc + 1]);
00600                 r__1 = slarnd_(&c__2, &iseed[1]);
00601                 a[jc] = r_sign(&c_b48, &r__1);
00602                 jc = jc + *n - j + 1;
00603 /* L230: */
00604             }
00605             a[1] = smlnum;
00606         }
00607 
00608     } else if (*imat == 14) {
00609 
00610 /*        Type 14:  T is diagonal with small numbers on the diagonal to */
00611 /*        make the growth factor underflow, but a small right hand side */
00612 /*        chosen so that the solution does not overflow. */
00613 
00614         if (upper) {
00615             jcount = 1;
00616             jc = (*n - 1) * *n / 2 + 1;
00617             for (j = *n; j >= 1; --j) {
00618                 i__1 = j - 1;
00619                 for (i__ = 1; i__ <= i__1; ++i__) {
00620                     a[jc + i__ - 1] = 0.f;
00621 /* L240: */
00622                 }
00623                 if (jcount <= 2) {
00624                     a[jc + j - 1] = smlnum;
00625                 } else {
00626                     a[jc + j - 1] = 1.f;
00627                 }
00628                 ++jcount;
00629                 if (jcount > 4) {
00630                     jcount = 1;
00631                 }
00632                 jc = jc - j + 1;
00633 /* L250: */
00634             }
00635         } else {
00636             jcount = 1;
00637             jc = 1;
00638             i__1 = *n;
00639             for (j = 1; j <= i__1; ++j) {
00640                 i__2 = *n;
00641                 for (i__ = j + 1; i__ <= i__2; ++i__) {
00642                     a[jc + i__ - j] = 0.f;
00643 /* L260: */
00644                 }
00645                 if (jcount <= 2) {
00646                     a[jc] = smlnum;
00647                 } else {
00648                     a[jc] = 1.f;
00649                 }
00650                 ++jcount;
00651                 if (jcount > 4) {
00652                     jcount = 1;
00653                 }
00654                 jc = jc + *n - j + 1;
00655 /* L270: */
00656             }
00657         }
00658 
00659 /*        Set the right hand side alternately zero and small. */
00660 
00661         if (upper) {
00662             b[1] = 0.f;
00663             for (i__ = *n; i__ >= 2; i__ += -2) {
00664                 b[i__] = 0.f;
00665                 b[i__ - 1] = smlnum;
00666 /* L280: */
00667             }
00668         } else {
00669             b[*n] = 0.f;
00670             i__1 = *n - 1;
00671             for (i__ = 1; i__ <= i__1; i__ += 2) {
00672                 b[i__] = 0.f;
00673                 b[i__ + 1] = smlnum;
00674 /* L290: */
00675             }
00676         }
00677 
00678     } else if (*imat == 15) {
00679 
00680 /*        Type 15:  Make the diagonal elements small to cause gradual */
00681 /*        overflow when dividing by T(j,j).  To control the amount of */
00682 /*        scaling needed, the matrix is bidiagonal. */
00683 
00684 /* Computing MAX */
00685         r__1 = 1.f, r__2 = (real) (*n - 1);
00686         texp = 1.f / dmax(r__1,r__2);
00687         d__1 = (doublereal) smlnum;
00688         d__2 = (doublereal) texp;
00689         tscal = pow_dd(&d__1, &d__2);
00690         slarnv_(&c__2, &iseed[1], n, &b[1]);
00691         if (upper) {
00692             jc = 1;
00693             i__1 = *n;
00694             for (j = 1; j <= i__1; ++j) {
00695                 i__2 = j - 2;
00696                 for (i__ = 1; i__ <= i__2; ++i__) {
00697                     a[jc + i__ - 1] = 0.f;
00698 /* L300: */
00699                 }
00700                 if (j > 1) {
00701                     a[jc + j - 2] = -1.f;
00702                 }
00703                 a[jc + j - 1] = tscal;
00704                 jc += j;
00705 /* L310: */
00706             }
00707             b[*n] = 1.f;
00708         } else {
00709             jc = 1;
00710             i__1 = *n;
00711             for (j = 1; j <= i__1; ++j) {
00712                 i__2 = *n;
00713                 for (i__ = j + 2; i__ <= i__2; ++i__) {
00714                     a[jc + i__ - j] = 0.f;
00715 /* L320: */
00716                 }
00717                 if (j < *n) {
00718                     a[jc + 1] = -1.f;
00719                 }
00720                 a[jc] = tscal;
00721                 jc = jc + *n - j + 1;
00722 /* L330: */
00723             }
00724             b[1] = 1.f;
00725         }
00726 
00727     } else if (*imat == 16) {
00728 
00729 /*        Type 16:  One zero diagonal element. */
00730 
00731         iy = *n / 2 + 1;
00732         if (upper) {
00733             jc = 1;
00734             i__1 = *n;
00735             for (j = 1; j <= i__1; ++j) {
00736                 slarnv_(&c__2, &iseed[1], &j, &a[jc]);
00737                 if (j != iy) {
00738                     a[jc + j - 1] = r_sign(&c_b36, &a[jc + j - 1]);
00739                 } else {
00740                     a[jc + j - 1] = 0.f;
00741                 }
00742                 jc += j;
00743 /* L340: */
00744             }
00745         } else {
00746             jc = 1;
00747             i__1 = *n;
00748             for (j = 1; j <= i__1; ++j) {
00749                 i__2 = *n - j + 1;
00750                 slarnv_(&c__2, &iseed[1], &i__2, &a[jc]);
00751                 if (j != iy) {
00752                     a[jc] = r_sign(&c_b36, &a[jc]);
00753                 } else {
00754                     a[jc] = 0.f;
00755                 }
00756                 jc = jc + *n - j + 1;
00757 /* L350: */
00758             }
00759         }
00760         slarnv_(&c__2, &iseed[1], n, &b[1]);
00761         sscal_(n, &c_b36, &b[1], &c__1);
00762 
00763     } else if (*imat == 17) {
00764 
00765 /*        Type 17:  Make the offdiagonal elements large to cause overflow */
00766 /*        when adding a column of T.  In the non-transposed case, the */
00767 /*        matrix is constructed to cause overflow when adding a column in */
00768 /*        every other step. */
00769 
00770         tscal = unfl / ulp;
00771         tscal = (1.f - ulp) / tscal;
00772         i__1 = *n * (*n + 1) / 2;
00773         for (j = 1; j <= i__1; ++j) {
00774             a[j] = 0.f;
00775 /* L360: */
00776         }
00777         texp = 1.f;
00778         if (upper) {
00779             jc = (*n - 1) * *n / 2 + 1;
00780             for (j = *n; j >= 2; j += -2) {
00781                 a[jc] = -tscal / (real) (*n + 1);
00782                 a[jc + j - 1] = 1.f;
00783                 b[j] = texp * (1.f - ulp);
00784                 jc = jc - j + 1;
00785                 a[jc] = -(tscal / (real) (*n + 1)) / (real) (*n + 2);
00786                 a[jc + j - 2] = 1.f;
00787                 b[j - 1] = texp * (real) (*n * *n + *n - 1);
00788                 texp *= 2.f;
00789                 jc = jc - j + 2;
00790 /* L370: */
00791             }
00792             b[1] = (real) (*n + 1) / (real) (*n + 2) * tscal;
00793         } else {
00794             jc = 1;
00795             i__1 = *n - 1;
00796             for (j = 1; j <= i__1; j += 2) {
00797                 a[jc + *n - j] = -tscal / (real) (*n + 1);
00798                 a[jc] = 1.f;
00799                 b[j] = texp * (1.f - ulp);
00800                 jc = jc + *n - j + 1;
00801                 a[jc + *n - j - 1] = -(tscal / (real) (*n + 1)) / (real) (*n 
00802                         + 2);
00803                 a[jc] = 1.f;
00804                 b[j + 1] = texp * (real) (*n * *n + *n - 1);
00805                 texp *= 2.f;
00806                 jc = jc + *n - j;
00807 /* L380: */
00808             }
00809             b[*n] = (real) (*n + 1) / (real) (*n + 2) * tscal;
00810         }
00811 
00812     } else if (*imat == 18) {
00813 
00814 /*        Type 18:  Generate a unit triangular matrix with elements */
00815 /*        between -1 and 1, and make the right hand side large so that it */
00816 /*        requires scaling. */
00817 
00818         if (upper) {
00819             jc = 1;
00820             i__1 = *n;
00821             for (j = 1; j <= i__1; ++j) {
00822                 i__2 = j - 1;
00823                 slarnv_(&c__2, &iseed[1], &i__2, &a[jc]);
00824                 a[jc + j - 1] = 0.f;
00825                 jc += j;
00826 /* L390: */
00827             }
00828         } else {
00829             jc = 1;
00830             i__1 = *n;
00831             for (j = 1; j <= i__1; ++j) {
00832                 if (j < *n) {
00833                     i__2 = *n - j;
00834                     slarnv_(&c__2, &iseed[1], &i__2, &a[jc + 1]);
00835                 }
00836                 a[jc] = 0.f;
00837                 jc = jc + *n - j + 1;
00838 /* L400: */
00839             }
00840         }
00841 
00842 /*        Set the right hand side so that the largest value is BIGNUM. */
00843 
00844         slarnv_(&c__2, &iseed[1], n, &b[1]);
00845         iy = isamax_(n, &b[1], &c__1);
00846         bnorm = (r__1 = b[iy], dabs(r__1));
00847         bscal = bignum / dmax(1.f,bnorm);
00848         sscal_(n, &bscal, &b[1], &c__1);
00849 
00850     } else if (*imat == 19) {
00851 
00852 /*        Type 19:  Generate a triangular matrix with elements between */
00853 /*        BIGNUM/(n-1) and BIGNUM so that at least one of the column */
00854 /*        norms will exceed BIGNUM. */
00855 
00856 /* Computing MAX */
00857         r__1 = 1.f, r__2 = (real) (*n - 1);
00858         tleft = bignum / dmax(r__1,r__2);
00859 /* Computing MAX */
00860         r__1 = 1.f, r__2 = (real) (*n);
00861         tscal = bignum * ((real) (*n - 1) / dmax(r__1,r__2));
00862         if (upper) {
00863             jc = 1;
00864             i__1 = *n;
00865             for (j = 1; j <= i__1; ++j) {
00866                 slarnv_(&c__2, &iseed[1], &j, &a[jc]);
00867                 i__2 = j;
00868                 for (i__ = 1; i__ <= i__2; ++i__) {
00869                     a[jc + i__ - 1] = r_sign(&tleft, &a[jc + i__ - 1]) + 
00870                             tscal * a[jc + i__ - 1];
00871 /* L410: */
00872                 }
00873                 jc += j;
00874 /* L420: */
00875             }
00876         } else {
00877             jc = 1;
00878             i__1 = *n;
00879             for (j = 1; j <= i__1; ++j) {
00880                 i__2 = *n - j + 1;
00881                 slarnv_(&c__2, &iseed[1], &i__2, &a[jc]);
00882                 i__2 = *n;
00883                 for (i__ = j; i__ <= i__2; ++i__) {
00884                     a[jc + i__ - j] = r_sign(&tleft, &a[jc + i__ - j]) + 
00885                             tscal * a[jc + i__ - j];
00886 /* L430: */
00887                 }
00888                 jc = jc + *n - j + 1;
00889 /* L440: */
00890             }
00891         }
00892         slarnv_(&c__2, &iseed[1], n, &b[1]);
00893         sscal_(n, &c_b36, &b[1], &c__1);
00894     }
00895 
00896 /*     Flip the matrix across its counter-diagonal if the transpose will */
00897 /*     be used. */
00898 
00899     if (! lsame_(trans, "N")) {
00900         if (upper) {
00901             jj = 1;
00902             jr = *n * (*n + 1) / 2;
00903             i__1 = *n / 2;
00904             for (j = 1; j <= i__1; ++j) {
00905                 jl = jj;
00906                 i__2 = *n - j;
00907                 for (i__ = j; i__ <= i__2; ++i__) {
00908                     t = a[jr - i__ + j];
00909                     a[jr - i__ + j] = a[jl];
00910                     a[jl] = t;
00911                     jl += i__;
00912 /* L450: */
00913                 }
00914                 jj = jj + j + 1;
00915                 jr -= *n - j + 1;
00916 /* L460: */
00917             }
00918         } else {
00919             jl = 1;
00920             jj = *n * (*n + 1) / 2;
00921             i__1 = *n / 2;
00922             for (j = 1; j <= i__1; ++j) {
00923                 jr = jj;
00924                 i__2 = *n - j;
00925                 for (i__ = j; i__ <= i__2; ++i__) {
00926                     t = a[jl + i__ - j];
00927                     a[jl + i__ - j] = a[jr];
00928                     a[jr] = t;
00929                     jr -= i__;
00930 /* L470: */
00931                 }
00932                 jl = jl + *n - j + 1;
00933                 jj = jj - j - 1;
00934 /* L480: */
00935             }
00936         }
00937     }
00938 
00939     return 0;
00940 
00941 /*     End of SLATTP */
00942 
00943 } /* slattp_ */


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