dlattb.c
Go to the documentation of this file.
00001 /* dlattb.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 doublereal c_b36 = 2.;
00021 static doublereal c_b47 = 1.;
00022 static integer c_n1 = -1;
00023 
00024 /* Subroutine */ int dlattb_(integer *imat, char *uplo, char *trans, char *
00025         diag, integer *iseed, integer *n, integer *kd, doublereal *ab, 
00026         integer *ldab, doublereal *b, doublereal *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     doublereal d__1, d__2;
00031 
00032     /* Builtin functions */
00033     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
00034     double sqrt(doublereal), d_sign(doublereal *, doublereal *), pow_dd(
00035             doublereal *, doublereal *);
00036 
00037     /* Local variables */
00038     integer i__, j, kl, ku, iy;
00039     doublereal ulp, sfac;
00040     integer ioff, mode, lenj;
00041     char path[3], dist[1];
00042     doublereal unfl, rexp;
00043     char type__[1];
00044     doublereal texp, star1, plus1, plus2, bscal;
00045     extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, 
00046             integer *);
00047     extern logical lsame_(char *, char *);
00048     doublereal tscal, anorm, bnorm, tleft;
00049     extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *, 
00050             doublereal *, integer *), dswap_(integer *, doublereal *, integer 
00051             *, doublereal *, integer *);
00052     logical upper;
00053     doublereal tnorm;
00054     extern /* Subroutine */ int dlatb4_(char *, integer *, integer *, integer 
00055             *, char *, integer *, integer *, doublereal *, integer *, 
00056             doublereal *, char *), dlabad_(doublereal 
00057             *, doublereal *);
00058     extern doublereal dlamch_(char *);
00059     extern integer idamax_(integer *, doublereal *, integer *);
00060     extern doublereal dlarnd_(integer *, integer *);
00061     char packit[1];
00062     doublereal bignum, cndnum;
00063     extern /* Subroutine */ int dlatms_(integer *, integer *, char *, integer 
00064             *, char *, doublereal *, integer *, doublereal *, doublereal *, 
00065             integer *, integer *, char *, doublereal *, integer *, doublereal 
00066             *, integer *), dlarnv_(integer *, integer 
00067             *, integer *, doublereal *);
00068     integer jcount;
00069     doublereal smlnum;
00070 
00071 
00072 /*  -- LAPACK test routine (version 3.1) -- */
00073 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00074 /*     November 2006 */
00075 
00076 /*     .. Scalar Arguments .. */
00077 /*     .. */
00078 /*     .. Array Arguments .. */
00079 /*     .. */
00080 
00081 /*  Purpose */
00082 /*  ======= */
00083 
00084 /*  DLATTB generates a triangular test matrix in 2-dimensional storage. */
00085 /*  IMAT and UPLO uniquely specify the properties of the test matrix, */
00086 /*  which is returned in the array A. */
00087 
00088 /*  Arguments */
00089 /*  ========= */
00090 
00091 /*  IMAT    (input) INTEGER */
00092 /*          An integer key describing which matrix to generate for this */
00093 /*          path. */
00094 
00095 /*  UPLO    (input) CHARACTER*1 */
00096 /*          Specifies whether the matrix A will be upper or lower */
00097 /*          triangular. */
00098 /*          = 'U':  Upper triangular */
00099 /*          = 'L':  Lower triangular */
00100 
00101 /*  TRANS   (input) CHARACTER*1 */
00102 /*          Specifies whether the matrix or its transpose will be used. */
00103 /*          = 'N':  No transpose */
00104 /*          = 'T':  Transpose */
00105 /*          = 'C':  Conjugate transpose (= transpose) */
00106 
00107 /*  DIAG    (output) CHARACTER*1 */
00108 /*          Specifies whether or not the matrix A is unit triangular. */
00109 /*          = 'N':  Non-unit triangular */
00110 /*          = 'U':  Unit triangular */
00111 
00112 /*  ISEED   (input/output) INTEGER array, dimension (4) */
00113 /*          The seed vector for the random number generator (used in */
00114 /*          DLATMS).  Modified on exit. */
00115 
00116 /*  N       (input) INTEGER */
00117 /*          The order of the matrix to be generated. */
00118 
00119 /*  KD      (input) INTEGER */
00120 /*          The number of superdiagonals or subdiagonals of the banded */
00121 /*          triangular matrix A.  KD >= 0. */
00122 
00123 /*  AB      (output) DOUBLE PRECISION array, dimension (LDAB,N) */
00124 /*          The upper or lower triangular banded matrix A, stored in the */
00125 /*          first KD+1 rows of AB.  Let j be a column of A, 1<=j<=n. */
00126 /*          If UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j. */
00127 /*          If UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd). */
00128 
00129 /*  LDAB    (input) INTEGER */
00130 /*          The leading dimension of the array AB.  LDAB >= KD+1. */
00131 
00132 /*  B       (workspace) DOUBLE PRECISION array, dimension (N) */
00133 
00134 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (2*N) */
00135 
00136 /*  INFO    (output) INTEGER */
00137 /*          = 0:  successful exit */
00138 /*          < 0: if INFO = -k, the k-th argument had an illegal value */
00139 
00140 /*  ===================================================================== */
00141 
00142 /*     .. Parameters .. */
00143 /*     .. */
00144 /*     .. Local Scalars .. */
00145 /*     .. */
00146 /*     .. External Functions .. */
00147 /*     .. */
00148 /*     .. External Subroutines .. */
00149 /*     .. */
00150 /*     .. Intrinsic Functions .. */
00151 /*     .. */
00152 /*     .. Executable Statements .. */
00153 
00154     /* Parameter adjustments */
00155     --iseed;
00156     ab_dim1 = *ldab;
00157     ab_offset = 1 + ab_dim1;
00158     ab -= ab_offset;
00159     --b;
00160     --work;
00161 
00162     /* Function Body */
00163     s_copy(path, "Double precision", (ftnlen)1, (ftnlen)16);
00164     s_copy(path + 1, "TB", (ftnlen)2, (ftnlen)2);
00165     unfl = dlamch_("Safe minimum");
00166     ulp = dlamch_("Epsilon") * dlamch_("Base");
00167     smlnum = unfl;
00168     bignum = (1. - ulp) / smlnum;
00169     dlabad_(&smlnum, &bignum);
00170     if (*imat >= 6 && *imat <= 9 || *imat == 17) {
00171         *(unsigned char *)diag = 'U';
00172     } else {
00173         *(unsigned char *)diag = 'N';
00174     }
00175     *info = 0;
00176 
00177 /*     Quick return if N.LE.0. */
00178 
00179     if (*n <= 0) {
00180         return 0;
00181     }
00182 
00183 /*     Call DLATB4 to set parameters for SLATMS. */
00184 
00185     upper = lsame_(uplo, "U");
00186     if (upper) {
00187         dlatb4_(path, imat, n, n, type__, &kl, &ku, &anorm, &mode, &cndnum, 
00188                 dist);
00189         ku = *kd;
00190 /* Computing MAX */
00191         i__1 = 0, i__2 = *kd - *n + 1;
00192         ioff = max(i__1,i__2) + 1;
00193         kl = 0;
00194         *(unsigned char *)packit = 'Q';
00195     } else {
00196         i__1 = -(*imat);
00197         dlatb4_(path, &i__1, n, n, type__, &kl, &ku, &anorm, &mode, &cndnum, 
00198                 dist);
00199         kl = *kd;
00200         ioff = 1;
00201         ku = 0;
00202         *(unsigned char *)packit = 'B';
00203     }
00204 
00205 /*     IMAT <= 5:  Non-unit triangular matrix */
00206 
00207     if (*imat <= 5) {
00208         dlatms_(n, n, dist, &iseed[1], type__, &b[1], &mode, &cndnum, &anorm, 
00209                 &kl, &ku, packit, &ab[ioff + ab_dim1], ldab, &work[1], info);
00210 
00211 /*     IMAT > 5:  Unit triangular matrix */
00212 /*     The diagonal is deliberately set to something other than 1. */
00213 
00214 /*     IMAT = 6:  Matrix is the identity */
00215 
00216     } else if (*imat == 6) {
00217         if (upper) {
00218             i__1 = *n;
00219             for (j = 1; j <= i__1; ++j) {
00220 /* Computing MAX */
00221                 i__2 = 1, i__3 = *kd + 2 - j;
00222                 i__4 = *kd;
00223                 for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
00224                     ab[i__ + j * ab_dim1] = 0.;
00225 /* L10: */
00226                 }
00227                 ab[*kd + 1 + j * ab_dim1] = (doublereal) j;
00228 /* L20: */
00229             }
00230         } else {
00231             i__1 = *n;
00232             for (j = 1; j <= i__1; ++j) {
00233                 ab[j * ab_dim1 + 1] = (doublereal) j;
00234 /* Computing MIN */
00235                 i__2 = *kd + 1, i__3 = *n - j + 1;
00236                 i__4 = min(i__2,i__3);
00237                 for (i__ = 2; i__ <= i__4; ++i__) {
00238                     ab[i__ + j * ab_dim1] = 0.;
00239 /* L30: */
00240                 }
00241 /* L40: */
00242             }
00243         }
00244 
00245 /*     IMAT > 6:  Non-trivial unit triangular matrix */
00246 
00247 /*     A unit triangular matrix T with condition CNDNUM is formed. */
00248 /*     In this version, T only has bandwidth 2, the rest of it is zero. */
00249 
00250     } else if (*imat <= 9) {
00251         tnorm = sqrt(cndnum);
00252 
00253 /*        Initialize AB to zero. */
00254 
00255         if (upper) {
00256             i__1 = *n;
00257             for (j = 1; j <= i__1; ++j) {
00258 /* Computing MAX */
00259                 i__4 = 1, i__2 = *kd + 2 - j;
00260                 i__3 = *kd;
00261                 for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) {
00262                     ab[i__ + j * ab_dim1] = 0.;
00263 /* L50: */
00264                 }
00265                 ab[*kd + 1 + j * ab_dim1] = (doublereal) j;
00266 /* L60: */
00267             }
00268         } else {
00269             i__1 = *n;
00270             for (j = 1; j <= i__1; ++j) {
00271 /* Computing MIN */
00272                 i__4 = *kd + 1, i__2 = *n - j + 1;
00273                 i__3 = min(i__4,i__2);
00274                 for (i__ = 2; i__ <= i__3; ++i__) {
00275                     ab[i__ + j * ab_dim1] = 0.;
00276 /* L70: */
00277                 }
00278                 ab[j * ab_dim1 + 1] = (doublereal) j;
00279 /* L80: */
00280             }
00281         }
00282 
00283 /*        Special case:  T is tridiagonal.  Set every other offdiagonal */
00284 /*        so that the matrix has norm TNORM+1. */
00285 
00286         if (*kd == 1) {
00287             if (upper) {
00288                 d__1 = dlarnd_(&c__2, &iseed[1]);
00289                 ab[(ab_dim1 << 1) + 1] = d_sign(&tnorm, &d__1);
00290                 lenj = (*n - 3) / 2;
00291                 dlarnv_(&c__2, &iseed[1], &lenj, &work[1]);
00292                 i__1 = lenj;
00293                 for (j = 1; j <= i__1; ++j) {
00294                     ab[(j + 1 << 1) * ab_dim1 + 1] = tnorm * work[j];
00295 /* L90: */
00296                 }
00297             } else {
00298                 d__1 = dlarnd_(&c__2, &iseed[1]);
00299                 ab[ab_dim1 + 2] = d_sign(&tnorm, &d__1);
00300                 lenj = (*n - 3) / 2;
00301                 dlarnv_(&c__2, &iseed[1], &lenj, &work[1]);
00302                 i__1 = lenj;
00303                 for (j = 1; j <= i__1; ++j) {
00304                     ab[((j << 1) + 1) * ab_dim1 + 2] = tnorm * work[j];
00305 /* L100: */
00306                 }
00307             }
00308         } else if (*kd > 1) {
00309 
00310 /*           Form a unit triangular matrix T with condition CNDNUM.  T is */
00311 /*           given by */
00312 /*                   | 1   +   *                      | */
00313 /*                   |     1   +                      | */
00314 /*               T = |         1   +   *              | */
00315 /*                   |             1   +              | */
00316 /*                   |                 1   +   *      | */
00317 /*                   |                     1   +      | */
00318 /*                   |                          . . . | */
00319 /*        Each element marked with a '*' is formed by taking the product */
00320 /*        of the adjacent elements marked with '+'.  The '*'s can be */
00321 /*        chosen freely, and the '+'s are chosen so that the inverse of */
00322 /*        T will have elements of the same magnitude as T. */
00323 
00324 /*        The two offdiagonals of T are stored in WORK. */
00325 
00326             d__1 = dlarnd_(&c__2, &iseed[1]);
00327             star1 = d_sign(&tnorm, &d__1);
00328             sfac = sqrt(tnorm);
00329             d__1 = dlarnd_(&c__2, &iseed[1]);
00330             plus1 = d_sign(&sfac, &d__1);
00331             i__1 = *n;
00332             for (j = 1; j <= i__1; j += 2) {
00333                 plus2 = star1 / plus1;
00334                 work[j] = plus1;
00335                 work[*n + j] = star1;
00336                 if (j + 1 <= *n) {
00337                     work[j + 1] = plus2;
00338                     work[*n + j + 1] = 0.;
00339                     plus1 = star1 / plus2;
00340 
00341 /*                 Generate a new *-value with norm between sqrt(TNORM) */
00342 /*                 and TNORM. */
00343 
00344                     rexp = dlarnd_(&c__2, &iseed[1]);
00345                     if (rexp < 0.) {
00346                         d__1 = 1. - rexp;
00347                         star1 = -pow_dd(&sfac, &d__1);
00348                     } else {
00349                         d__1 = rexp + 1.;
00350                         star1 = pow_dd(&sfac, &d__1);
00351                     }
00352                 }
00353 /* L110: */
00354             }
00355 
00356 /*           Copy the tridiagonal T to AB. */
00357 
00358             if (upper) {
00359                 i__1 = *n - 1;
00360                 dcopy_(&i__1, &work[1], &c__1, &ab[*kd + (ab_dim1 << 1)], 
00361                         ldab);
00362                 i__1 = *n - 2;
00363                 dcopy_(&i__1, &work[*n + 1], &c__1, &ab[*kd - 1 + ab_dim1 * 3]
00364 , ldab);
00365             } else {
00366                 i__1 = *n - 1;
00367                 dcopy_(&i__1, &work[1], &c__1, &ab[ab_dim1 + 2], ldab);
00368                 i__1 = *n - 2;
00369                 dcopy_(&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                 dlarnv_(&c__2, &iseed[1], &lenj, &ab[*kd + 2 - lenj + j * 
00390                         ab_dim1]);
00391                 ab[*kd + 1 + j * ab_dim1] = d_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                     dlarnv_(&c__2, &iseed[1], &lenj, &ab[j * ab_dim1 + 1]);
00403                 }
00404                 ab[j * ab_dim1 + 1] = d_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         dlarnv_(&c__2, &iseed[1], n, &b[1]);
00412         iy = idamax_(n, &b[1], &c__1);
00413         bnorm = (d__1 = b[iy], abs(d__1));
00414         bscal = bignum / max(1.,bnorm);
00415         dscal_(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         dlarnv_(&c__2, &iseed[1], n, &b[1]);
00424         tscal = 1. / (doublereal) (*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                 dlarnv_(&c__2, &iseed[1], &lenj, &ab[*kd + 2 - lenj + j * 
00432                         ab_dim1]);
00433                 i__3 = lenj - 1;
00434                 dscal_(&i__3, &tscal, &ab[*kd + 2 - lenj + j * ab_dim1], &
00435                         c__1);
00436                 ab[*kd + 1 + j * ab_dim1] = d_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                 dlarnv_(&c__2, &iseed[1], &lenj, &ab[j * ab_dim1 + 1]);
00448                 if (lenj > 1) {
00449                     i__3 = lenj - 1;
00450                     dscal_(&i__3, &tscal, &ab[j * ab_dim1 + 2], &c__1);
00451                 }
00452                 ab[j * ab_dim1 + 1] = d_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         dlarnv_(&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                 dlarnv_(&c__2, &iseed[1], &lenj, &ab[*kd + 2 - lenj + j * 
00472                         ab_dim1]);
00473                 ab[*kd + 1 + j * ab_dim1] = d_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                 dlarnv_(&c__2, &iseed[1], &lenj, &ab[j * ab_dim1 + 1]);
00485                 ab[j * ab_dim1 + 1] = d_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.;
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.;
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.;
00527 /* L200: */
00528                 }
00529                 if (jcount <= 2) {
00530                     ab[j * ab_dim1 + 1] = smlnum;
00531                 } else {
00532                     ab[j * ab_dim1 + 1] = 1.;
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.;
00546             for (i__ = *n; i__ >= 2; i__ += -2) {
00547                 b[i__] = 0.;
00548                 b[i__ - 1] = smlnum;
00549 /* L220: */
00550             }
00551         } else {
00552             b[*n] = 0.;
00553             i__4 = *n - 1;
00554             for (i__ = 1; i__ <= i__4; i__ += 2) {
00555                 b[i__] = 0.;
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. / (doublereal) (*kd + 1);
00568         tscal = pow_dd(&smlnum, &texp);
00569         dlarnv_(&c__2, &iseed[1], n, &b[1]);
00570         if (upper) {
00571             i__4 = *n;
00572             for (j = 1; j <= i__4; ++j) {
00573 /* Computing MAX */
00574                 i__1 = 1, i__3 = *kd + 2 - j;
00575                 i__2 = *kd;
00576                 for (i__ = max(i__1,i__3); i__ <= i__2; ++i__) {
00577                     ab[i__ + j * ab_dim1] = 0.;
00578 /* L240: */
00579                 }
00580                 if (j > 1 && *kd > 0) {
00581                     ab[*kd + j * ab_dim1] = -1.;
00582                 }
00583                 ab[*kd + 1 + j * ab_dim1] = tscal;
00584 /* L250: */
00585             }
00586             b[*n] = 1.;
00587         } else {
00588             i__4 = *n;
00589             for (j = 1; j <= i__4; ++j) {
00590 /* Computing MIN */
00591                 i__1 = *n - j + 1, i__3 = *kd + 1;
00592                 i__2 = min(i__1,i__3);
00593                 for (i__ = 3; i__ <= i__2; ++i__) {
00594                     ab[i__ + j * ab_dim1] = 0.;
00595 /* L260: */
00596                 }
00597                 if (j < *n && *kd > 0) {
00598                     ab[j * ab_dim1 + 2] = -1.;
00599                 }
00600                 ab[j * ab_dim1 + 1] = tscal;
00601 /* L270: */
00602             }
00603             b[1] = 1.;
00604         }
00605 
00606     } else if (*imat == 15) {
00607 
00608 /*        Type 15:  One zero diagonal element. */
00609 
00610         iy = *n / 2 + 1;
00611         if (upper) {
00612             i__4 = *n;
00613             for (j = 1; j <= i__4; ++j) {
00614 /* Computing MIN */
00615                 i__2 = j, i__1 = *kd + 1;
00616                 lenj = min(i__2,i__1);
00617                 dlarnv_(&c__2, &iseed[1], &lenj, &ab[*kd + 2 - lenj + j * 
00618                         ab_dim1]);
00619                 if (j != iy) {
00620                     ab[*kd + 1 + j * ab_dim1] = d_sign(&c_b36, &ab[*kd + 1 + 
00621                             j * ab_dim1]);
00622                 } else {
00623                     ab[*kd + 1 + j * ab_dim1] = 0.;
00624                 }
00625 /* L280: */
00626             }
00627         } else {
00628             i__4 = *n;
00629             for (j = 1; j <= i__4; ++j) {
00630 /* Computing MIN */
00631                 i__2 = *n - j + 1, i__1 = *kd + 1;
00632                 lenj = min(i__2,i__1);
00633                 dlarnv_(&c__2, &iseed[1], &lenj, &ab[j * ab_dim1 + 1]);
00634                 if (j != iy) {
00635                     ab[j * ab_dim1 + 1] = d_sign(&c_b36, &ab[j * ab_dim1 + 1])
00636                             ;
00637                 } else {
00638                     ab[j * ab_dim1 + 1] = 0.;
00639                 }
00640 /* L290: */
00641             }
00642         }
00643         dlarnv_(&c__2, &iseed[1], n, &b[1]);
00644         dscal_(n, &c_b36, &b[1], &c__1);
00645 
00646     } else if (*imat == 16) {
00647 
00648 /*        Type 16:  Make the offdiagonal elements large to cause overflow */
00649 /*        when adding a column of T.  In the non-transposed case, the */
00650 /*        matrix is constructed to cause overflow when adding a column in */
00651 /*        every other step. */
00652 
00653         tscal = unfl / ulp;
00654         tscal = (1. - ulp) / tscal;
00655         i__4 = *n;
00656         for (j = 1; j <= i__4; ++j) {
00657             i__2 = *kd + 1;
00658             for (i__ = 1; i__ <= i__2; ++i__) {
00659                 ab[i__ + j * ab_dim1] = 0.;
00660 /* L300: */
00661             }
00662 /* L310: */
00663         }
00664         texp = 1.;
00665         if (*kd > 0) {
00666             if (upper) {
00667                 i__4 = -(*kd);
00668                 for (j = *n; i__4 < 0 ? j >= 1 : j <= 1; j += i__4) {
00669 /* Computing MAX */
00670                     i__1 = 1, i__3 = j - *kd + 1;
00671                     i__2 = max(i__1,i__3);
00672                     for (i__ = j; i__ >= i__2; i__ += -2) {
00673                         ab[j - i__ + 1 + i__ * ab_dim1] = -tscal / (
00674                                 doublereal) (*kd + 2);
00675                         ab[*kd + 1 + i__ * ab_dim1] = 1.;
00676                         b[i__] = texp * (1. - ulp);
00677 /* Computing MAX */
00678                         i__1 = 1, i__3 = j - *kd + 1;
00679                         if (i__ > max(i__1,i__3)) {
00680                             ab[j - i__ + 2 + (i__ - 1) * ab_dim1] = -(tscal / 
00681                                     (doublereal) (*kd + 2)) / (doublereal) (*
00682                                     kd + 3);
00683                             ab[*kd + 1 + (i__ - 1) * ab_dim1] = 1.;
00684                             b[i__ - 1] = texp * (doublereal) ((*kd + 1) * (*
00685                                     kd + 1) + *kd);
00686                         }
00687                         texp *= 2.;
00688 /* L320: */
00689                     }
00690 /* Computing MAX */
00691                     i__2 = 1, i__1 = j - *kd + 1;
00692                     b[max(i__2,i__1)] = (doublereal) (*kd + 2) / (doublereal) 
00693                             (*kd + 3) * tscal;
00694 /* L330: */
00695                 }
00696             } else {
00697                 i__4 = *n;
00698                 i__2 = *kd;
00699                 for (j = 1; i__2 < 0 ? j >= i__4 : j <= i__4; j += i__2) {
00700                     texp = 1.;
00701 /* Computing MIN */
00702                     i__1 = *kd + 1, i__3 = *n - j + 1;
00703                     lenj = min(i__1,i__3);
00704 /* Computing MIN */
00705                     i__3 = *n, i__5 = j + *kd - 1;
00706                     i__1 = min(i__3,i__5);
00707                     for (i__ = j; i__ <= i__1; i__ += 2) {
00708                         ab[lenj - (i__ - j) + j * ab_dim1] = -tscal / (
00709                                 doublereal) (*kd + 2);
00710                         ab[j * ab_dim1 + 1] = 1.;
00711                         b[j] = texp * (1. - ulp);
00712 /* Computing MIN */
00713                         i__3 = *n, i__5 = j + *kd - 1;
00714                         if (i__ < min(i__3,i__5)) {
00715                             ab[lenj - (i__ - j + 1) + (i__ + 1) * ab_dim1] = 
00716                                     -(tscal / (doublereal) (*kd + 2)) / (
00717                                     doublereal) (*kd + 3);
00718                             ab[(i__ + 1) * ab_dim1 + 1] = 1.;
00719                             b[i__ + 1] = texp * (doublereal) ((*kd + 1) * (*
00720                                     kd + 1) + *kd);
00721                         }
00722                         texp *= 2.;
00723 /* L340: */
00724                     }
00725 /* Computing MIN */
00726                     i__1 = *n, i__3 = j + *kd - 1;
00727                     b[min(i__1,i__3)] = (doublereal) (*kd + 2) / (doublereal) 
00728                             (*kd + 3) * tscal;
00729 /* L350: */
00730                 }
00731             }
00732         } else {
00733             i__2 = *n;
00734             for (j = 1; j <= i__2; ++j) {
00735                 ab[j * ab_dim1 + 1] = 1.;
00736                 b[j] = (doublereal) j;
00737 /* L360: */
00738             }
00739         }
00740 
00741     } else if (*imat == 17) {
00742 
00743 /*        Type 17:  Generate a unit triangular matrix with elements */
00744 /*        between -1 and 1, and make the right hand side large so that it */
00745 /*        requires scaling. */
00746 
00747         if (upper) {
00748             i__2 = *n;
00749             for (j = 1; j <= i__2; ++j) {
00750 /* Computing MIN */
00751                 i__4 = j - 1;
00752                 lenj = min(i__4,*kd);
00753                 dlarnv_(&c__2, &iseed[1], &lenj, &ab[*kd + 1 - lenj + j * 
00754                         ab_dim1]);
00755                 ab[*kd + 1 + j * ab_dim1] = (doublereal) j;
00756 /* L370: */
00757             }
00758         } else {
00759             i__2 = *n;
00760             for (j = 1; j <= i__2; ++j) {
00761 /* Computing MIN */
00762                 i__4 = *n - j;
00763                 lenj = min(i__4,*kd);
00764                 if (lenj > 0) {
00765                     dlarnv_(&c__2, &iseed[1], &lenj, &ab[j * ab_dim1 + 2]);
00766                 }
00767                 ab[j * ab_dim1 + 1] = (doublereal) j;
00768 /* L380: */
00769             }
00770         }
00771 
00772 /*        Set the right hand side so that the largest value is BIGNUM. */
00773 
00774         dlarnv_(&c__2, &iseed[1], n, &b[1]);
00775         iy = idamax_(n, &b[1], &c__1);
00776         bnorm = (d__1 = b[iy], abs(d__1));
00777         bscal = bignum / max(1.,bnorm);
00778         dscal_(n, &bscal, &b[1], &c__1);
00779 
00780     } else if (*imat == 18) {
00781 
00782 /*        Type 18:  Generate a triangular matrix with elements between */
00783 /*        BIGNUM/KD and BIGNUM so that at least one of the column */
00784 /*        norms will exceed BIGNUM. */
00785 
00786 /* Computing MAX */
00787         d__1 = 1., d__2 = (doublereal) (*kd);
00788         tleft = bignum / max(d__1,d__2);
00789         tscal = bignum * ((doublereal) (*kd) / (doublereal) (*kd + 1));
00790         if (upper) {
00791             i__2 = *n;
00792             for (j = 1; j <= i__2; ++j) {
00793 /* Computing MIN */
00794                 i__4 = j, i__1 = *kd + 1;
00795                 lenj = min(i__4,i__1);
00796                 dlarnv_(&c__2, &iseed[1], &lenj, &ab[*kd + 2 - lenj + j * 
00797                         ab_dim1]);
00798                 i__4 = *kd + 1;
00799                 for (i__ = *kd + 2 - lenj; i__ <= i__4; ++i__) {
00800                     ab[i__ + j * ab_dim1] = d_sign(&tleft, &ab[i__ + j * 
00801                             ab_dim1]) + tscal * ab[i__ + j * ab_dim1];
00802 /* L390: */
00803                 }
00804 /* L400: */
00805             }
00806         } else {
00807             i__2 = *n;
00808             for (j = 1; j <= i__2; ++j) {
00809 /* Computing MIN */
00810                 i__4 = *n - j + 1, i__1 = *kd + 1;
00811                 lenj = min(i__4,i__1);
00812                 dlarnv_(&c__2, &iseed[1], &lenj, &ab[j * ab_dim1 + 1]);
00813                 i__4 = lenj;
00814                 for (i__ = 1; i__ <= i__4; ++i__) {
00815                     ab[i__ + j * ab_dim1] = d_sign(&tleft, &ab[i__ + j * 
00816                             ab_dim1]) + tscal * ab[i__ + j * ab_dim1];
00817 /* L410: */
00818                 }
00819 /* L420: */
00820             }
00821         }
00822         dlarnv_(&c__2, &iseed[1], n, &b[1]);
00823         dscal_(n, &c_b36, &b[1], &c__1);
00824     }
00825 
00826 /*     Flip the matrix if the transpose will be used. */
00827 
00828     if (! lsame_(trans, "N")) {
00829         if (upper) {
00830             i__2 = *n / 2;
00831             for (j = 1; j <= i__2; ++j) {
00832 /* Computing MIN */
00833                 i__4 = *n - (j << 1) + 1, i__1 = *kd + 1;
00834                 lenj = min(i__4,i__1);
00835                 i__4 = *ldab - 1;
00836                 dswap_(&lenj, &ab[*kd + 1 + j * ab_dim1], &i__4, &ab[*kd + 2 
00837                         - lenj + (*n - j + 1) * ab_dim1], &c_n1);
00838 /* L430: */
00839             }
00840         } else {
00841             i__2 = *n / 2;
00842             for (j = 1; j <= i__2; ++j) {
00843 /* Computing MIN */
00844                 i__4 = *n - (j << 1) + 1, i__1 = *kd + 1;
00845                 lenj = min(i__4,i__1);
00846                 i__4 = -(*ldab) + 1;
00847                 dswap_(&lenj, &ab[j * ab_dim1 + 1], &c__1, &ab[lenj + (*n - j 
00848                         + 2 - lenj) * ab_dim1], &i__4);
00849 /* L440: */
00850             }
00851         }
00852     }
00853 
00854     return 0;
00855 
00856 /*     End of DLATTB */
00857 
00858 } /* dlattb_ */


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