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


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