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


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