clatmr.c
Go to the documentation of this file.
00001 /* clatmr.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__0 = 0;
00019 static integer c__1 = 1;
00020 
00021 /* Subroutine */ int clatmr_(integer *m, integer *n, char *dist, integer *
00022         iseed, char *sym, complex *d__, integer *mode, real *cond, complex *
00023         dmax__, char *rsign, char *grade, complex *dl, integer *model, real *
00024         condl, complex *dr, integer *moder, real *condr, char *pivtng, 
00025         integer *ipivot, integer *kl, integer *ku, real *sparse, real *anorm, 
00026         char *pack, complex *a, integer *lda, integer *iwork, integer *info)
00027 {
00028     /* System generated locals */
00029     integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
00030     real r__1, r__2;
00031     complex q__1, q__2;
00032 
00033     /* Builtin functions */
00034     double c_abs(complex *);
00035     void r_cnjg(complex *, complex *);
00036 
00037     /* Local variables */
00038     integer i__, j, k, kll, kuu, isub, jsub;
00039     real temp;
00040     integer isym, ipack;
00041     extern logical lsame_(char *, char *);
00042     real tempa[1];
00043     complex ctemp;
00044     integer iisub, idist, jjsub, mnmin;
00045     logical dzero;
00046     integer mnsub;
00047     real onorm;
00048     integer mxsub, npvts;
00049     extern /* Subroutine */ int clatm1_(integer *, real *, integer *, integer 
00050             *, integer *, complex *, integer *, integer *);
00051     extern /* Complex */ VOID clatm2_(complex *, integer *, integer *, 
00052             integer *, integer *, integer *, integer *, integer *, integer *, 
00053             complex *, integer *, complex *, complex *, integer *, integer *, 
00054             real *), clatm3_(complex *, integer *, integer *, integer *, 
00055             integer *, integer *, integer *, integer *, integer *, integer *, 
00056             integer *, complex *, integer *, complex *, complex *, integer *, 
00057             integer *, real *);
00058     extern doublereal clangb_(char *, integer *, integer *, integer *, 
00059             complex *, integer *, real *);
00060     complex calpha;
00061     extern doublereal clange_(char *, integer *, integer *, complex *, 
00062             integer *, real *);
00063     integer igrade;
00064     extern doublereal clansb_(char *, char *, integer *, integer *, complex *, 
00065              integer *, real *);
00066     extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer 
00067             *);
00068     logical fulbnd;
00069     extern /* Subroutine */ int xerbla_(char *, integer *);
00070     logical badpvt;
00071     extern doublereal clansp_(char *, char *, integer *, complex *, real *), clansy_(char *, char *, integer *, complex *, 
00072             integer *, real *);
00073     integer irsign, ipvtng;
00074 
00075 
00076 /*  -- LAPACK test routine (version 3.1) -- */
00077 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00078 /*     November 2006 */
00079 
00080 /*     .. Scalar Arguments .. */
00081 /*     .. */
00082 /*     .. Array Arguments .. */
00083 /*     .. */
00084 
00085 /*  Purpose */
00086 /*  ======= */
00087 
00088 /*     CLATMR generates random matrices of various types for testing */
00089 /*     LAPACK programs. */
00090 
00091 /*     CLATMR operates by applying the following sequence of */
00092 /*     operations: */
00093 
00094 /*       Generate a matrix A with random entries of distribution DIST */
00095 /*          which is symmetric if SYM='S', Hermitian if SYM='H', and */
00096 /*          nonsymmetric if SYM='N'. */
00097 
00098 /*       Set the diagonal to D, where D may be input or */
00099 /*          computed according to MODE, COND, DMAX and RSIGN */
00100 /*          as described below. */
00101 
00102 /*       Grade the matrix, if desired, from the left and/or right */
00103 /*          as specified by GRADE. The inputs DL, MODEL, CONDL, DR, */
00104 /*          MODER and CONDR also determine the grading as described */
00105 /*          below. */
00106 
00107 /*       Permute, if desired, the rows and/or columns as specified by */
00108 /*          PIVTNG and IPIVOT. */
00109 
00110 /*       Set random entries to zero, if desired, to get a random sparse */
00111 /*          matrix as specified by SPARSE. */
00112 
00113 /*       Make A a band matrix, if desired, by zeroing out the matrix */
00114 /*          outside a band of lower bandwidth KL and upper bandwidth KU. */
00115 
00116 /*       Scale A, if desired, to have maximum entry ANORM. */
00117 
00118 /*       Pack the matrix if desired. Options specified by PACK are: */
00119 /*          no packing */
00120 /*          zero out upper half (if symmetric or Hermitian) */
00121 /*          zero out lower half (if symmetric or Hermitian) */
00122 /*          store the upper half columnwise (if symmetric or Hermitian */
00123 /*              or square upper triangular) */
00124 /*          store the lower half columnwise (if symmetric or Hermitian */
00125 /*              or square lower triangular) */
00126 /*              same as upper half rowwise if symmetric */
00127 /*              same as conjugate upper half rowwise if Hermitian */
00128 /*          store the lower triangle in banded format */
00129 /*              (if symmetric or Hermitian) */
00130 /*          store the upper triangle in banded format */
00131 /*              (if symmetric or Hermitian) */
00132 /*          store the entire matrix in banded format */
00133 
00134 /*     Note: If two calls to CLATMR differ only in the PACK parameter, */
00135 /*           they will generate mathematically equivalent matrices. */
00136 
00137 /*           If two calls to CLATMR both have full bandwidth (KL = M-1 */
00138 /*           and KU = N-1), and differ only in the PIVTNG and PACK */
00139 /*           parameters, then the matrices generated will differ only */
00140 /*           in the order of the rows and/or columns, and otherwise */
00141 /*           contain the same data. This consistency cannot be and */
00142 /*           is not maintained with less than full bandwidth. */
00143 
00144 /*  Arguments */
00145 /*  ========= */
00146 
00147 /*  M      - INTEGER */
00148 /*           Number of rows of A. Not modified. */
00149 
00150 /*  N      - INTEGER */
00151 /*           Number of columns of A. Not modified. */
00152 
00153 /*  DIST   - CHARACTER*1 */
00154 /*           On entry, DIST specifies the type of distribution to be used */
00155 /*           to generate a random matrix . */
00156 /*           'U' => real and imaginary parts are independent */
00157 /*                  UNIFORM( 0, 1 )  ( 'U' for uniform ) */
00158 /*           'S' => real and imaginary parts are independent */
00159 /*                  UNIFORM( -1, 1 ) ( 'S' for symmetric ) */
00160 /*           'N' => real and imaginary parts are independent */
00161 /*                  NORMAL( 0, 1 )   ( 'N' for normal ) */
00162 /*           'D' => uniform on interior of unit disk ( 'D' for disk ) */
00163 /*           Not modified. */
00164 
00165 /*  ISEED  - INTEGER array, dimension (4) */
00166 /*           On entry ISEED specifies the seed of the random number */
00167 /*           generator. They should lie between 0 and 4095 inclusive, */
00168 /*           and ISEED(4) should be odd. The random number generator */
00169 /*           uses a linear congruential sequence limited to small */
00170 /*           integers, and so should produce machine independent */
00171 /*           random numbers. The values of ISEED are changed on */
00172 /*           exit, and can be used in the next call to CLATMR */
00173 /*           to continue the same random number sequence. */
00174 /*           Changed on exit. */
00175 
00176 /*  SYM    - CHARACTER*1 */
00177 /*           If SYM='S', generated matrix is symmetric. */
00178 /*           If SYM='H', generated matrix is Hermitian. */
00179 /*           If SYM='N', generated matrix is nonsymmetric. */
00180 /*           Not modified. */
00181 
00182 /*  D      - COMPLEX array, dimension (min(M,N)) */
00183 /*           On entry this array specifies the diagonal entries */
00184 /*           of the diagonal of A.  D may either be specified */
00185 /*           on entry, or set according to MODE and COND as described */
00186 /*           below. If the matrix is Hermitian, the real part of D */
00187 /*           will be taken. May be changed on exit if MODE is nonzero. */
00188 
00189 /*  MODE   - INTEGER */
00190 /*           On entry describes how D is to be used: */
00191 /*           MODE = 0 means use D as input */
00192 /*           MODE = 1 sets D(1)=1 and D(2:N)=1.0/COND */
00193 /*           MODE = 2 sets D(1:N-1)=1 and D(N)=1.0/COND */
00194 /*           MODE = 3 sets D(I)=COND**(-(I-1)/(N-1)) */
00195 /*           MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */
00196 /*           MODE = 5 sets D to random numbers in the range */
00197 /*                    ( 1/COND , 1 ) such that their logarithms */
00198 /*                    are uniformly distributed. */
00199 /*           MODE = 6 set D to random numbers from same distribution */
00200 /*                    as the rest of the matrix. */
00201 /*           MODE < 0 has the same meaning as ABS(MODE), except that */
00202 /*              the order of the elements of D is reversed. */
00203 /*           Thus if MODE is positive, D has entries ranging from */
00204 /*              1 to 1/COND, if negative, from 1/COND to 1, */
00205 /*           Not modified. */
00206 
00207 /*  COND   - REAL */
00208 /*           On entry, used as described under MODE above. */
00209 /*           If used, it must be >= 1. Not modified. */
00210 
00211 /*  DMAX   - COMPLEX */
00212 /*           If MODE neither -6, 0 nor 6, the diagonal is scaled by */
00213 /*           DMAX / max(abs(D(i))), so that maximum absolute entry */
00214 /*           of diagonal is abs(DMAX). If DMAX is complex (or zero), */
00215 /*           diagonal will be scaled by a complex number (or zero). */
00216 
00217 /*  RSIGN  - CHARACTER*1 */
00218 /*           If MODE neither -6, 0 nor 6, specifies sign of diagonal */
00219 /*           as follows: */
00220 /*           'T' => diagonal entries are multiplied by a random complex */
00221 /*                  number uniformly distributed with absolute value 1 */
00222 /*           'F' => diagonal unchanged */
00223 /*           Not modified. */
00224 
00225 /*  GRADE  - CHARACTER*1 */
00226 /*           Specifies grading of matrix as follows: */
00227 /*           'N'  => no grading */
00228 /*           'L'  => matrix premultiplied by diag( DL ) */
00229 /*                   (only if matrix nonsymmetric) */
00230 /*           'R'  => matrix postmultiplied by diag( DR ) */
00231 /*                   (only if matrix nonsymmetric) */
00232 /*           'B'  => matrix premultiplied by diag( DL ) and */
00233 /*                         postmultiplied by diag( DR ) */
00234 /*                   (only if matrix nonsymmetric) */
00235 /*           'H'  => matrix premultiplied by diag( DL ) and */
00236 /*                         postmultiplied by diag( CONJG(DL) ) */
00237 /*                   (only if matrix Hermitian or nonsymmetric) */
00238 /*           'S'  => matrix premultiplied by diag( DL ) and */
00239 /*                         postmultiplied by diag( DL ) */
00240 /*                   (only if matrix symmetric or nonsymmetric) */
00241 /*           'E'  => matrix premultiplied by diag( DL ) and */
00242 /*                         postmultiplied by inv( diag( DL ) ) */
00243 /*                         ( 'S' for similarity ) */
00244 /*                   (only if matrix nonsymmetric) */
00245 /*                   Note: if GRADE='S', then M must equal N. */
00246 /*           Not modified. */
00247 
00248 /*  DL     - COMPLEX array, dimension (M) */
00249 /*           If MODEL=0, then on entry this array specifies the diagonal */
00250 /*           entries of a diagonal matrix used as described under GRADE */
00251 /*           above. If MODEL is not zero, then DL will be set according */
00252 /*           to MODEL and CONDL, analogous to the way D is set according */
00253 /*           to MODE and COND (except there is no DMAX parameter for DL). */
00254 /*           If GRADE='E', then DL cannot have zero entries. */
00255 /*           Not referenced if GRADE = 'N' or 'R'. Changed on exit. */
00256 
00257 /*  MODEL  - INTEGER */
00258 /*           This specifies how the diagonal array DL is to be computed, */
00259 /*           just as MODE specifies how D is to be computed. */
00260 /*           Not modified. */
00261 
00262 /*  CONDL  - REAL */
00263 /*           When MODEL is not zero, this specifies the condition number */
00264 /*           of the computed DL.  Not modified. */
00265 
00266 /*  DR     - COMPLEX array, dimension (N) */
00267 /*           If MODER=0, then on entry this array specifies the diagonal */
00268 /*           entries of a diagonal matrix used as described under GRADE */
00269 /*           above. If MODER is not zero, then DR will be set according */
00270 /*           to MODER and CONDR, analogous to the way D is set according */
00271 /*           to MODE and COND (except there is no DMAX parameter for DR). */
00272 /*           Not referenced if GRADE = 'N', 'L', 'H' or 'S'. */
00273 /*           Changed on exit. */
00274 
00275 /*  MODER  - INTEGER */
00276 /*           This specifies how the diagonal array DR is to be computed, */
00277 /*           just as MODE specifies how D is to be computed. */
00278 /*           Not modified. */
00279 
00280 /*  CONDR  - REAL */
00281 /*           When MODER is not zero, this specifies the condition number */
00282 /*           of the computed DR.  Not modified. */
00283 
00284 /*  PIVTNG - CHARACTER*1 */
00285 /*           On entry specifies pivoting permutations as follows: */
00286 /*           'N' or ' ' => none. */
00287 /*           'L' => left or row pivoting (matrix must be nonsymmetric). */
00288 /*           'R' => right or column pivoting (matrix must be */
00289 /*                  nonsymmetric). */
00290 /*           'B' or 'F' => both or full pivoting, i.e., on both sides. */
00291 /*                         In this case, M must equal N */
00292 
00293 /*           If two calls to CLATMR both have full bandwidth (KL = M-1 */
00294 /*           and KU = N-1), and differ only in the PIVTNG and PACK */
00295 /*           parameters, then the matrices generated will differ only */
00296 /*           in the order of the rows and/or columns, and otherwise */
00297 /*           contain the same data. This consistency cannot be */
00298 /*           maintained with less than full bandwidth. */
00299 
00300 /*  IPIVOT - INTEGER array, dimension (N or M) */
00301 /*           This array specifies the permutation used.  After the */
00302 /*           basic matrix is generated, the rows, columns, or both */
00303 /*           are permuted.   If, say, row pivoting is selected, CLATMR */
00304 /*           starts with the *last* row and interchanges the M-th and */
00305 /*           IPIVOT(M)-th rows, then moves to the next-to-last row, */
00306 /*           interchanging the (M-1)-th and the IPIVOT(M-1)-th rows, */
00307 /*           and so on.  In terms of "2-cycles", the permutation is */
00308 /*           (1 IPIVOT(1)) (2 IPIVOT(2)) ... (M IPIVOT(M)) */
00309 /*           where the rightmost cycle is applied first.  This is the */
00310 /*           *inverse* of the effect of pivoting in LINPACK.  The idea */
00311 /*           is that factoring (with pivoting) an identity matrix */
00312 /*           which has been inverse-pivoted in this way should */
00313 /*           result in a pivot vector identical to IPIVOT. */
00314 /*           Not referenced if PIVTNG = 'N'. Not modified. */
00315 
00316 /*  SPARSE - REAL */
00317 /*           On entry specifies the sparsity of the matrix if a sparse */
00318 /*           matrix is to be generated. SPARSE should lie between */
00319 /*           0 and 1. To generate a sparse matrix, for each matrix entry */
00320 /*           a uniform ( 0, 1 ) random number x is generated and */
00321 /*           compared to SPARSE; if x is larger the matrix entry */
00322 /*           is unchanged and if x is smaller the entry is set */
00323 /*           to zero. Thus on the average a fraction SPARSE of the */
00324 /*           entries will be set to zero. */
00325 /*           Not modified. */
00326 
00327 /*  KL     - INTEGER */
00328 /*           On entry specifies the lower bandwidth of the  matrix. For */
00329 /*           example, KL=0 implies upper triangular, KL=1 implies upper */
00330 /*           Hessenberg, and KL at least M-1 implies the matrix is not */
00331 /*           banded. Must equal KU if matrix is symmetric or Hermitian. */
00332 /*           Not modified. */
00333 
00334 /*  KU     - INTEGER */
00335 /*           On entry specifies the upper bandwidth of the  matrix. For */
00336 /*           example, KU=0 implies lower triangular, KU=1 implies lower */
00337 /*           Hessenberg, and KU at least N-1 implies the matrix is not */
00338 /*           banded. Must equal KL if matrix is symmetric or Hermitian. */
00339 /*           Not modified. */
00340 
00341 /*  ANORM  - REAL */
00342 /*           On entry specifies maximum entry of output matrix */
00343 /*           (output matrix will by multiplied by a constant so that */
00344 /*           its largest absolute entry equal ANORM) */
00345 /*           if ANORM is nonnegative. If ANORM is negative no scaling */
00346 /*           is done. Not modified. */
00347 
00348 /*  PACK   - CHARACTER*1 */
00349 /*           On entry specifies packing of matrix as follows: */
00350 /*           'N' => no packing */
00351 /*           'U' => zero out all subdiagonal entries */
00352 /*                  (if symmetric or Hermitian) */
00353 /*           'L' => zero out all superdiagonal entries */
00354 /*                  (if symmetric or Hermitian) */
00355 /*           'C' => store the upper triangle columnwise */
00356 /*                  (only if matrix symmetric or Hermitian or */
00357 /*                   square upper triangular) */
00358 /*           'R' => store the lower triangle columnwise */
00359 /*                  (only if matrix symmetric or Hermitian or */
00360 /*                   square lower triangular) */
00361 /*                  (same as upper half rowwise if symmetric) */
00362 /*                  (same as conjugate upper half rowwise if Hermitian) */
00363 /*           'B' => store the lower triangle in band storage scheme */
00364 /*                  (only if matrix symmetric or Hermitian) */
00365 /*           'Q' => store the upper triangle in band storage scheme */
00366 /*                  (only if matrix symmetric or Hermitian) */
00367 /*           'Z' => store the entire matrix in band storage scheme */
00368 /*                      (pivoting can be provided for by using this */
00369 /*                      option to store A in the trailing rows of */
00370 /*                      the allocated storage) */
00371 
00372 /*           Using these options, the various LAPACK packed and banded */
00373 /*           storage schemes can be obtained: */
00374 /*           GB               - use 'Z' */
00375 /*           PB, HB or TB     - use 'B' or 'Q' */
00376 /*           PP, HP or TP     - use 'C' or 'R' */
00377 
00378 /*           If two calls to CLATMR differ only in the PACK parameter, */
00379 /*           they will generate mathematically equivalent matrices. */
00380 /*           Not modified. */
00381 
00382 /*  A      - COMPLEX array, dimension (LDA,N) */
00383 /*           On exit A is the desired test matrix. Only those */
00384 /*           entries of A which are significant on output */
00385 /*           will be referenced (even if A is in packed or band */
00386 /*           storage format). The 'unoccupied corners' of A in */
00387 /*           band format will be zeroed out. */
00388 
00389 /*  LDA    - INTEGER */
00390 /*           on entry LDA specifies the first dimension of A as */
00391 /*           declared in the calling program. */
00392 /*           If PACK='N', 'U' or 'L', LDA must be at least max ( 1, M ). */
00393 /*           If PACK='C' or 'R', LDA must be at least 1. */
00394 /*           If PACK='B', or 'Q', LDA must be MIN ( KU+1, N ) */
00395 /*           If PACK='Z', LDA must be at least KUU+KLL+1, where */
00396 /*           KUU = MIN ( KU, N-1 ) and KLL = MIN ( KL, N-1 ) */
00397 /*           Not modified. */
00398 
00399 /*  IWORK  - INTEGER array, dimension (N or M) */
00400 /*           Workspace. Not referenced if PIVTNG = 'N'. Changed on exit. */
00401 
00402 /*  INFO   - INTEGER */
00403 /*           Error parameter on exit: */
00404 /*             0 => normal return */
00405 /*            -1 => M negative or unequal to N and SYM='S' or 'H' */
00406 /*            -2 => N negative */
00407 /*            -3 => DIST illegal string */
00408 /*            -5 => SYM illegal string */
00409 /*            -7 => MODE not in range -6 to 6 */
00410 /*            -8 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
00411 /*           -10 => MODE neither -6, 0 nor 6 and RSIGN illegal string */
00412 /*           -11 => GRADE illegal string, or GRADE='E' and */
00413 /*                  M not equal to N, or GRADE='L', 'R', 'B', 'S' or 'E' */
00414 /*                  and SYM = 'H', or GRADE='L', 'R', 'B', 'H' or 'E' */
00415 /*                  and SYM = 'S' */
00416 /*           -12 => GRADE = 'E' and DL contains zero */
00417 /*           -13 => MODEL not in range -6 to 6 and GRADE= 'L', 'B', 'H', */
00418 /*                  'S' or 'E' */
00419 /*           -14 => CONDL less than 1.0, GRADE='L', 'B', 'H', 'S' or 'E', */
00420 /*                  and MODEL neither -6, 0 nor 6 */
00421 /*           -16 => MODER not in range -6 to 6 and GRADE= 'R' or 'B' */
00422 /*           -17 => CONDR less than 1.0, GRADE='R' or 'B', and */
00423 /*                  MODER neither -6, 0 nor 6 */
00424 /*           -18 => PIVTNG illegal string, or PIVTNG='B' or 'F' and */
00425 /*                  M not equal to N, or PIVTNG='L' or 'R' and SYM='S' */
00426 /*                  or 'H' */
00427 /*           -19 => IPIVOT contains out of range number and */
00428 /*                  PIVTNG not equal to 'N' */
00429 /*           -20 => KL negative */
00430 /*           -21 => KU negative, or SYM='S' or 'H' and KU not equal to KL */
00431 /*           -22 => SPARSE not in range 0. to 1. */
00432 /*           -24 => PACK illegal string, or PACK='U', 'L', 'B' or 'Q' */
00433 /*                  and SYM='N', or PACK='C' and SYM='N' and either KL */
00434 /*                  not equal to 0 or N not equal to M, or PACK='R' and */
00435 /*                  SYM='N', and either KU not equal to 0 or N not equal */
00436 /*                  to M */
00437 /*           -26 => LDA too small */
00438 /*             1 => Error return from CLATM1 (computing D) */
00439 /*             2 => Cannot scale diagonal to DMAX (max. entry is 0) */
00440 /*             3 => Error return from CLATM1 (computing DL) */
00441 /*             4 => Error return from CLATM1 (computing DR) */
00442 /*             5 => ANORM is positive, but matrix constructed prior to */
00443 /*                  attempting to scale it to have norm ANORM, is zero */
00444 
00445 /*  ===================================================================== */
00446 
00447 /*     .. Parameters .. */
00448 /*     .. */
00449 /*     .. Local Scalars .. */
00450 /*     .. */
00451 /*     .. Local Arrays .. */
00452 /*     .. */
00453 /*     .. External Functions .. */
00454 /*     .. */
00455 /*     .. External Subroutines .. */
00456 /*     .. */
00457 /*     .. Intrinsic Functions .. */
00458 /*     .. */
00459 /*     .. Executable Statements .. */
00460 
00461 /*     1)      Decode and Test the input parameters. */
00462 /*             Initialize flags & seed. */
00463 
00464     /* Parameter adjustments */
00465     --iseed;
00466     --d__;
00467     --dl;
00468     --dr;
00469     --ipivot;
00470     a_dim1 = *lda;
00471     a_offset = 1 + a_dim1;
00472     a -= a_offset;
00473     --iwork;
00474 
00475     /* Function Body */
00476     *info = 0;
00477 
00478 /*     Quick return if possible */
00479 
00480     if (*m == 0 || *n == 0) {
00481         return 0;
00482     }
00483 
00484 /*     Decode DIST */
00485 
00486     if (lsame_(dist, "U")) {
00487         idist = 1;
00488     } else if (lsame_(dist, "S")) {
00489         idist = 2;
00490     } else if (lsame_(dist, "N")) {
00491         idist = 3;
00492     } else if (lsame_(dist, "D")) {
00493         idist = 4;
00494     } else {
00495         idist = -1;
00496     }
00497 
00498 /*     Decode SYM */
00499 
00500     if (lsame_(sym, "H")) {
00501         isym = 0;
00502     } else if (lsame_(sym, "N")) {
00503         isym = 1;
00504     } else if (lsame_(sym, "S")) {
00505         isym = 2;
00506     } else {
00507         isym = -1;
00508     }
00509 
00510 /*     Decode RSIGN */
00511 
00512     if (lsame_(rsign, "F")) {
00513         irsign = 0;
00514     } else if (lsame_(rsign, "T")) {
00515         irsign = 1;
00516     } else {
00517         irsign = -1;
00518     }
00519 
00520 /*     Decode PIVTNG */
00521 
00522     if (lsame_(pivtng, "N")) {
00523         ipvtng = 0;
00524     } else if (lsame_(pivtng, " ")) {
00525         ipvtng = 0;
00526     } else if (lsame_(pivtng, "L")) {
00527         ipvtng = 1;
00528         npvts = *m;
00529     } else if (lsame_(pivtng, "R")) {
00530         ipvtng = 2;
00531         npvts = *n;
00532     } else if (lsame_(pivtng, "B")) {
00533         ipvtng = 3;
00534         npvts = min(*n,*m);
00535     } else if (lsame_(pivtng, "F")) {
00536         ipvtng = 3;
00537         npvts = min(*n,*m);
00538     } else {
00539         ipvtng = -1;
00540     }
00541 
00542 /*     Decode GRADE */
00543 
00544     if (lsame_(grade, "N")) {
00545         igrade = 0;
00546     } else if (lsame_(grade, "L")) {
00547         igrade = 1;
00548     } else if (lsame_(grade, "R")) {
00549         igrade = 2;
00550     } else if (lsame_(grade, "B")) {
00551         igrade = 3;
00552     } else if (lsame_(grade, "E")) {
00553         igrade = 4;
00554     } else if (lsame_(grade, "H")) {
00555         igrade = 5;
00556     } else if (lsame_(grade, "S")) {
00557         igrade = 6;
00558     } else {
00559         igrade = -1;
00560     }
00561 
00562 /*     Decode PACK */
00563 
00564     if (lsame_(pack, "N")) {
00565         ipack = 0;
00566     } else if (lsame_(pack, "U")) {
00567         ipack = 1;
00568     } else if (lsame_(pack, "L")) {
00569         ipack = 2;
00570     } else if (lsame_(pack, "C")) {
00571         ipack = 3;
00572     } else if (lsame_(pack, "R")) {
00573         ipack = 4;
00574     } else if (lsame_(pack, "B")) {
00575         ipack = 5;
00576     } else if (lsame_(pack, "Q")) {
00577         ipack = 6;
00578     } else if (lsame_(pack, "Z")) {
00579         ipack = 7;
00580     } else {
00581         ipack = -1;
00582     }
00583 
00584 /*     Set certain internal parameters */
00585 
00586     mnmin = min(*m,*n);
00587 /* Computing MIN */
00588     i__1 = *kl, i__2 = *m - 1;
00589     kll = min(i__1,i__2);
00590 /* Computing MIN */
00591     i__1 = *ku, i__2 = *n - 1;
00592     kuu = min(i__1,i__2);
00593 
00594 /*     If inv(DL) is used, check to see if DL has a zero entry. */
00595 
00596     dzero = FALSE_;
00597     if (igrade == 4 && *model == 0) {
00598         i__1 = *m;
00599         for (i__ = 1; i__ <= i__1; ++i__) {
00600             i__2 = i__;
00601             if (dl[i__2].r == 0.f && dl[i__2].i == 0.f) {
00602                 dzero = TRUE_;
00603             }
00604 /* L10: */
00605         }
00606     }
00607 
00608 /*     Check values in IPIVOT */
00609 
00610     badpvt = FALSE_;
00611     if (ipvtng > 0) {
00612         i__1 = npvts;
00613         for (j = 1; j <= i__1; ++j) {
00614             if (ipivot[j] <= 0 || ipivot[j] > npvts) {
00615                 badpvt = TRUE_;
00616             }
00617 /* L20: */
00618         }
00619     }
00620 
00621 /*     Set INFO if an error */
00622 
00623     if (*m < 0) {
00624         *info = -1;
00625     } else if (*m != *n && (isym == 0 || isym == 2)) {
00626         *info = -1;
00627     } else if (*n < 0) {
00628         *info = -2;
00629     } else if (idist == -1) {
00630         *info = -3;
00631     } else if (isym == -1) {
00632         *info = -5;
00633     } else if (*mode < -6 || *mode > 6) {
00634         *info = -7;
00635     } else if (*mode != -6 && *mode != 0 && *mode != 6 && *cond < 1.f) {
00636         *info = -8;
00637     } else if (*mode != -6 && *mode != 0 && *mode != 6 && irsign == -1) {
00638         *info = -10;
00639     } else if (igrade == -1 || igrade == 4 && *m != *n || (igrade == 1 || 
00640             igrade == 2 || igrade == 3 || igrade == 4 || igrade == 6) && isym 
00641             == 0 || (igrade == 1 || igrade == 2 || igrade == 3 || igrade == 4 
00642             || igrade == 5) && isym == 2) {
00643         *info = -11;
00644     } else if (igrade == 4 && dzero) {
00645         *info = -12;
00646     } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 || 
00647             igrade == 6) && (*model < -6 || *model > 6)) {
00648         *info = -13;
00649     } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 || 
00650             igrade == 6) && (*model != -6 && *model != 0 && *model != 6) && *
00651             condl < 1.f) {
00652         *info = -14;
00653     } else if ((igrade == 2 || igrade == 3) && (*moder < -6 || *moder > 6)) {
00654         *info = -16;
00655     } else if ((igrade == 2 || igrade == 3) && (*moder != -6 && *moder != 0 &&
00656              *moder != 6) && *condr < 1.f) {
00657         *info = -17;
00658     } else if (ipvtng == -1 || ipvtng == 3 && *m != *n || (ipvtng == 1 || 
00659             ipvtng == 2) && (isym == 0 || isym == 2)) {
00660         *info = -18;
00661     } else if (ipvtng != 0 && badpvt) {
00662         *info = -19;
00663     } else if (*kl < 0) {
00664         *info = -20;
00665     } else if (*ku < 0 || (isym == 0 || isym == 2) && *kl != *ku) {
00666         *info = -21;
00667     } else if (*sparse < 0.f || *sparse > 1.f) {
00668         *info = -22;
00669     } else if (ipack == -1 || (ipack == 1 || ipack == 2 || ipack == 5 || 
00670             ipack == 6) && isym == 1 || ipack == 3 && isym == 1 && (*kl != 0 
00671             || *m != *n) || ipack == 4 && isym == 1 && (*ku != 0 || *m != *n))
00672              {
00673         *info = -24;
00674     } else if ((ipack == 0 || ipack == 1 || ipack == 2) && *lda < max(1,*m) ||
00675              (ipack == 3 || ipack == 4) && *lda < 1 || (ipack == 5 || ipack ==
00676              6) && *lda < kuu + 1 || ipack == 7 && *lda < kll + kuu + 1) {
00677         *info = -26;
00678     }
00679 
00680     if (*info != 0) {
00681         i__1 = -(*info);
00682         xerbla_("CLATMR", &i__1);
00683         return 0;
00684     }
00685 
00686 /*     Decide if we can pivot consistently */
00687 
00688     fulbnd = FALSE_;
00689     if (kuu == *n - 1 && kll == *m - 1) {
00690         fulbnd = TRUE_;
00691     }
00692 
00693 /*     Initialize random number generator */
00694 
00695     for (i__ = 1; i__ <= 4; ++i__) {
00696         iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
00697 /* L30: */
00698     }
00699 
00700     iseed[4] = (iseed[4] / 2 << 1) + 1;
00701 
00702 /*     2)      Set up D, DL, and DR, if indicated. */
00703 
00704 /*             Compute D according to COND and MODE */
00705 
00706     clatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, info);
00707     if (*info != 0) {
00708         *info = 1;
00709         return 0;
00710     }
00711     if (*mode != 0 && *mode != -6 && *mode != 6) {
00712 
00713 /*        Scale by DMAX */
00714 
00715         temp = c_abs(&d__[1]);
00716         i__1 = mnmin;
00717         for (i__ = 2; i__ <= i__1; ++i__) {
00718 /* Computing MAX */
00719             r__1 = temp, r__2 = c_abs(&d__[i__]);
00720             temp = dmax(r__1,r__2);
00721 /* L40: */
00722         }
00723         if (temp == 0.f && (dmax__->r != 0.f || dmax__->i != 0.f)) {
00724             *info = 2;
00725             return 0;
00726         }
00727         if (temp != 0.f) {
00728             q__1.r = dmax__->r / temp, q__1.i = dmax__->i / temp;
00729             calpha.r = q__1.r, calpha.i = q__1.i;
00730         } else {
00731             calpha.r = 1.f, calpha.i = 0.f;
00732         }
00733         i__1 = mnmin;
00734         for (i__ = 1; i__ <= i__1; ++i__) {
00735             i__2 = i__;
00736             i__3 = i__;
00737             q__1.r = calpha.r * d__[i__3].r - calpha.i * d__[i__3].i, q__1.i =
00738                      calpha.r * d__[i__3].i + calpha.i * d__[i__3].r;
00739             d__[i__2].r = q__1.r, d__[i__2].i = q__1.i;
00740 /* L50: */
00741         }
00742 
00743     }
00744 
00745 /*     If matrix Hermitian, make D real */
00746 
00747     if (isym == 0) {
00748         i__1 = mnmin;
00749         for (i__ = 1; i__ <= i__1; ++i__) {
00750             i__2 = i__;
00751             i__3 = i__;
00752             r__1 = d__[i__3].r;
00753             d__[i__2].r = r__1, d__[i__2].i = 0.f;
00754 /* L60: */
00755         }
00756     }
00757 
00758 /*     Compute DL if grading set */
00759 
00760     if (igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 || igrade == 
00761             6) {
00762         clatm1_(model, condl, &c__0, &idist, &iseed[1], &dl[1], m, info);
00763         if (*info != 0) {
00764             *info = 3;
00765             return 0;
00766         }
00767     }
00768 
00769 /*     Compute DR if grading set */
00770 
00771     if (igrade == 2 || igrade == 3) {
00772         clatm1_(moder, condr, &c__0, &idist, &iseed[1], &dr[1], n, info);
00773         if (*info != 0) {
00774             *info = 4;
00775             return 0;
00776         }
00777     }
00778 
00779 /*     3)     Generate IWORK if pivoting */
00780 
00781     if (ipvtng > 0) {
00782         i__1 = npvts;
00783         for (i__ = 1; i__ <= i__1; ++i__) {
00784             iwork[i__] = i__;
00785 /* L70: */
00786         }
00787         if (fulbnd) {
00788             i__1 = npvts;
00789             for (i__ = 1; i__ <= i__1; ++i__) {
00790                 k = ipivot[i__];
00791                 j = iwork[i__];
00792                 iwork[i__] = iwork[k];
00793                 iwork[k] = j;
00794 /* L80: */
00795             }
00796         } else {
00797             for (i__ = npvts; i__ >= 1; --i__) {
00798                 k = ipivot[i__];
00799                 j = iwork[i__];
00800                 iwork[i__] = iwork[k];
00801                 iwork[k] = j;
00802 /* L90: */
00803             }
00804         }
00805     }
00806 
00807 /*     4)      Generate matrices for each kind of PACKing */
00808 /*             Always sweep matrix columnwise (if symmetric, upper */
00809 /*             half only) so that matrix generated does not depend */
00810 /*             on PACK */
00811 
00812     if (fulbnd) {
00813 
00814 /*        Use CLATM3 so matrices generated with differing PIVOTing only */
00815 /*        differ only in the order of their rows and/or columns. */
00816 
00817         if (ipack == 0) {
00818             if (isym == 0) {
00819                 i__1 = *n;
00820                 for (j = 1; j <= i__1; ++j) {
00821                     i__2 = j;
00822                     for (i__ = 1; i__ <= i__2; ++i__) {
00823                         clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
00824                                 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
00825                                 dr[1], &ipvtng, &iwork[1], sparse);
00826                         ctemp.r = q__1.r, ctemp.i = q__1.i;
00827                         i__3 = isub + jsub * a_dim1;
00828                         a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
00829                         i__3 = jsub + isub * a_dim1;
00830                         r_cnjg(&q__1, &ctemp);
00831                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00832 /* L100: */
00833                     }
00834 /* L110: */
00835                 }
00836             } else if (isym == 1) {
00837                 i__1 = *n;
00838                 for (j = 1; j <= i__1; ++j) {
00839                     i__2 = *m;
00840                     for (i__ = 1; i__ <= i__2; ++i__) {
00841                         clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
00842                                 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
00843                                 dr[1], &ipvtng, &iwork[1], sparse);
00844                         ctemp.r = q__1.r, ctemp.i = q__1.i;
00845                         i__3 = isub + jsub * a_dim1;
00846                         a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
00847 /* L120: */
00848                     }
00849 /* L130: */
00850                 }
00851             } else if (isym == 2) {
00852                 i__1 = *n;
00853                 for (j = 1; j <= i__1; ++j) {
00854                     i__2 = j;
00855                     for (i__ = 1; i__ <= i__2; ++i__) {
00856                         clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
00857                                 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
00858                                 dr[1], &ipvtng, &iwork[1], sparse);
00859                         ctemp.r = q__1.r, ctemp.i = q__1.i;
00860                         i__3 = isub + jsub * a_dim1;
00861                         a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
00862                         i__3 = jsub + isub * a_dim1;
00863                         a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
00864 /* L140: */
00865                     }
00866 /* L150: */
00867                 }
00868             }
00869 
00870         } else if (ipack == 1) {
00871 
00872             i__1 = *n;
00873             for (j = 1; j <= i__1; ++j) {
00874                 i__2 = j;
00875                 for (i__ = 1; i__ <= i__2; ++i__) {
00876                     clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
00877                             idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
00878 , &ipvtng, &iwork[1], sparse);
00879                     ctemp.r = q__1.r, ctemp.i = q__1.i;
00880                     mnsub = min(isub,jsub);
00881                     mxsub = max(isub,jsub);
00882                     if (mxsub == isub && isym == 0) {
00883                         i__3 = mnsub + mxsub * a_dim1;
00884                         r_cnjg(&q__1, &ctemp);
00885                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00886                     } else {
00887                         i__3 = mnsub + mxsub * a_dim1;
00888                         a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
00889                     }
00890                     if (mnsub != mxsub) {
00891                         i__3 = mxsub + mnsub * a_dim1;
00892                         a[i__3].r = 0.f, a[i__3].i = 0.f;
00893                     }
00894 /* L160: */
00895                 }
00896 /* L170: */
00897             }
00898 
00899         } else if (ipack == 2) {
00900 
00901             i__1 = *n;
00902             for (j = 1; j <= i__1; ++j) {
00903                 i__2 = j;
00904                 for (i__ = 1; i__ <= i__2; ++i__) {
00905                     clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
00906                             idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
00907 , &ipvtng, &iwork[1], sparse);
00908                     ctemp.r = q__1.r, ctemp.i = q__1.i;
00909                     mnsub = min(isub,jsub);
00910                     mxsub = max(isub,jsub);
00911                     if (mxsub == jsub && isym == 0) {
00912                         i__3 = mxsub + mnsub * a_dim1;
00913                         r_cnjg(&q__1, &ctemp);
00914                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00915                     } else {
00916                         i__3 = mxsub + mnsub * a_dim1;
00917                         a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
00918                     }
00919                     if (mnsub != mxsub) {
00920                         i__3 = mnsub + mxsub * a_dim1;
00921                         a[i__3].r = 0.f, a[i__3].i = 0.f;
00922                     }
00923 /* L180: */
00924                 }
00925 /* L190: */
00926             }
00927 
00928         } else if (ipack == 3) {
00929 
00930             i__1 = *n;
00931             for (j = 1; j <= i__1; ++j) {
00932                 i__2 = j;
00933                 for (i__ = 1; i__ <= i__2; ++i__) {
00934                     clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
00935                             idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
00936 , &ipvtng, &iwork[1], sparse);
00937                     ctemp.r = q__1.r, ctemp.i = q__1.i;
00938 
00939 /*                 Compute K = location of (ISUB,JSUB) entry in packed */
00940 /*                 array */
00941 
00942                     mnsub = min(isub,jsub);
00943                     mxsub = max(isub,jsub);
00944                     k = mxsub * (mxsub - 1) / 2 + mnsub;
00945 
00946 /*                 Convert K to (IISUB,JJSUB) location */
00947 
00948                     jjsub = (k - 1) / *lda + 1;
00949                     iisub = k - *lda * (jjsub - 1);
00950 
00951                     if (mxsub == isub && isym == 0) {
00952                         i__3 = iisub + jjsub * a_dim1;
00953                         r_cnjg(&q__1, &ctemp);
00954                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00955                     } else {
00956                         i__3 = iisub + jjsub * a_dim1;
00957                         a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
00958                     }
00959 /* L200: */
00960                 }
00961 /* L210: */
00962             }
00963 
00964         } else if (ipack == 4) {
00965 
00966             i__1 = *n;
00967             for (j = 1; j <= i__1; ++j) {
00968                 i__2 = j;
00969                 for (i__ = 1; i__ <= i__2; ++i__) {
00970                     clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
00971                             idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
00972 , &ipvtng, &iwork[1], sparse);
00973                     ctemp.r = q__1.r, ctemp.i = q__1.i;
00974 
00975 /*                 Compute K = location of (I,J) entry in packed array */
00976 
00977                     mnsub = min(isub,jsub);
00978                     mxsub = max(isub,jsub);
00979                     if (mnsub == 1) {
00980                         k = mxsub;
00981                     } else {
00982                         k = *n * (*n + 1) / 2 - (*n - mnsub + 1) * (*n - 
00983                                 mnsub + 2) / 2 + mxsub - mnsub + 1;
00984                     }
00985 
00986 /*                 Convert K to (IISUB,JJSUB) location */
00987 
00988                     jjsub = (k - 1) / *lda + 1;
00989                     iisub = k - *lda * (jjsub - 1);
00990 
00991                     if (mxsub == jsub && isym == 0) {
00992                         i__3 = iisub + jjsub * a_dim1;
00993                         r_cnjg(&q__1, &ctemp);
00994                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00995                     } else {
00996                         i__3 = iisub + jjsub * a_dim1;
00997                         a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
00998                     }
00999 /* L220: */
01000                 }
01001 /* L230: */
01002             }
01003 
01004         } else if (ipack == 5) {
01005 
01006             i__1 = *n;
01007             for (j = 1; j <= i__1; ++j) {
01008                 i__2 = j;
01009                 for (i__ = j - kuu; i__ <= i__2; ++i__) {
01010                     if (i__ < 1) {
01011                         i__3 = j - i__ + 1 + (i__ + *n) * a_dim1;
01012                         a[i__3].r = 0.f, a[i__3].i = 0.f;
01013                     } else {
01014                         clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
01015                                 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
01016                                 dr[1], &ipvtng, &iwork[1], sparse);
01017                         ctemp.r = q__1.r, ctemp.i = q__1.i;
01018                         mnsub = min(isub,jsub);
01019                         mxsub = max(isub,jsub);
01020                         if (mxsub == jsub && isym == 0) {
01021                             i__3 = mxsub - mnsub + 1 + mnsub * a_dim1;
01022                             r_cnjg(&q__1, &ctemp);
01023                             a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01024                         } else {
01025                             i__3 = mxsub - mnsub + 1 + mnsub * a_dim1;
01026                             a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
01027                         }
01028                     }
01029 /* L240: */
01030                 }
01031 /* L250: */
01032             }
01033 
01034         } else if (ipack == 6) {
01035 
01036             i__1 = *n;
01037             for (j = 1; j <= i__1; ++j) {
01038                 i__2 = j;
01039                 for (i__ = j - kuu; i__ <= i__2; ++i__) {
01040                     clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
01041                             idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
01042 , &ipvtng, &iwork[1], sparse);
01043                     ctemp.r = q__1.r, ctemp.i = q__1.i;
01044                     mnsub = min(isub,jsub);
01045                     mxsub = max(isub,jsub);
01046                     if (mxsub == isub && isym == 0) {
01047                         i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
01048                         r_cnjg(&q__1, &ctemp);
01049                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01050                     } else {
01051                         i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
01052                         a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
01053                     }
01054 /* L260: */
01055                 }
01056 /* L270: */
01057             }
01058 
01059         } else if (ipack == 7) {
01060 
01061             if (isym != 1) {
01062                 i__1 = *n;
01063                 for (j = 1; j <= i__1; ++j) {
01064                     i__2 = j;
01065                     for (i__ = j - kuu; i__ <= i__2; ++i__) {
01066                         clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
01067                                 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
01068                                 dr[1], &ipvtng, &iwork[1], sparse);
01069                         ctemp.r = q__1.r, ctemp.i = q__1.i;
01070                         mnsub = min(isub,jsub);
01071                         mxsub = max(isub,jsub);
01072                         if (i__ < 1) {
01073                             i__3 = j - i__ + 1 + kuu + (i__ + *n) * a_dim1;
01074                             a[i__3].r = 0.f, a[i__3].i = 0.f;
01075                         }
01076                         if (mxsub == isub && isym == 0) {
01077                             i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
01078                             r_cnjg(&q__1, &ctemp);
01079                             a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01080                         } else {
01081                             i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
01082                             a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
01083                         }
01084                         if (i__ >= 1 && mnsub != mxsub) {
01085                             if (mnsub == isub && isym == 0) {
01086                                 i__3 = mxsub - mnsub + 1 + kuu + mnsub * 
01087                                         a_dim1;
01088                                 r_cnjg(&q__1, &ctemp);
01089                                 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01090                             } else {
01091                                 i__3 = mxsub - mnsub + 1 + kuu + mnsub * 
01092                                         a_dim1;
01093                                 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
01094                             }
01095                         }
01096 /* L280: */
01097                     }
01098 /* L290: */
01099                 }
01100             } else if (isym == 1) {
01101                 i__1 = *n;
01102                 for (j = 1; j <= i__1; ++j) {
01103                     i__2 = j + kll;
01104                     for (i__ = j - kuu; i__ <= i__2; ++i__) {
01105                         clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
01106                                 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
01107                                 dr[1], &ipvtng, &iwork[1], sparse);
01108                         ctemp.r = q__1.r, ctemp.i = q__1.i;
01109                         i__3 = isub - jsub + kuu + 1 + jsub * a_dim1;
01110                         a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
01111 /* L300: */
01112                     }
01113 /* L310: */
01114                 }
01115             }
01116 
01117         }
01118 
01119     } else {
01120 
01121 /*        Use CLATM2 */
01122 
01123         if (ipack == 0) {
01124             if (isym == 0) {
01125                 i__1 = *n;
01126                 for (j = 1; j <= i__1; ++j) {
01127                     i__2 = j;
01128                     for (i__ = 1; i__ <= i__2; ++i__) {
01129                         i__3 = i__ + j * a_dim1;
01130                         clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
01131                                 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, 
01132                                  &iwork[1], sparse);
01133                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01134                         i__3 = j + i__ * a_dim1;
01135                         r_cnjg(&q__1, &a[i__ + j * a_dim1]);
01136                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01137 /* L320: */
01138                     }
01139 /* L330: */
01140                 }
01141             } else if (isym == 1) {
01142                 i__1 = *n;
01143                 for (j = 1; j <= i__1; ++j) {
01144                     i__2 = *m;
01145                     for (i__ = 1; i__ <= i__2; ++i__) {
01146                         i__3 = i__ + j * a_dim1;
01147                         clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
01148                                 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, 
01149                                  &iwork[1], sparse);
01150                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01151 /* L340: */
01152                     }
01153 /* L350: */
01154                 }
01155             } else if (isym == 2) {
01156                 i__1 = *n;
01157                 for (j = 1; j <= i__1; ++j) {
01158                     i__2 = j;
01159                     for (i__ = 1; i__ <= i__2; ++i__) {
01160                         i__3 = i__ + j * a_dim1;
01161                         clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
01162                                 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, 
01163                                  &iwork[1], sparse);
01164                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01165                         i__3 = j + i__ * a_dim1;
01166                         i__4 = i__ + j * a_dim1;
01167                         a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
01168 /* L360: */
01169                     }
01170 /* L370: */
01171                 }
01172             }
01173 
01174         } else if (ipack == 1) {
01175 
01176             i__1 = *n;
01177             for (j = 1; j <= i__1; ++j) {
01178                 i__2 = j;
01179                 for (i__ = 1; i__ <= i__2; ++i__) {
01180                     i__3 = i__ + j * a_dim1;
01181                     clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1], 
01182                             &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
01183                             1], sparse);
01184                     a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01185                     if (i__ != j) {
01186                         i__3 = j + i__ * a_dim1;
01187                         a[i__3].r = 0.f, a[i__3].i = 0.f;
01188                     }
01189 /* L380: */
01190                 }
01191 /* L390: */
01192             }
01193 
01194         } else if (ipack == 2) {
01195 
01196             i__1 = *n;
01197             for (j = 1; j <= i__1; ++j) {
01198                 i__2 = j;
01199                 for (i__ = 1; i__ <= i__2; ++i__) {
01200                     if (isym == 0) {
01201                         i__3 = j + i__ * a_dim1;
01202                         clatm2_(&q__2, m, n, &i__, &j, kl, ku, &idist, &iseed[
01203                                 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, 
01204                                  &iwork[1], sparse);
01205                         r_cnjg(&q__1, &q__2);
01206                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01207                     } else {
01208                         i__3 = j + i__ * a_dim1;
01209                         clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
01210                                 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, 
01211                                  &iwork[1], sparse);
01212                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01213                     }
01214                     if (i__ != j) {
01215                         i__3 = i__ + j * a_dim1;
01216                         a[i__3].r = 0.f, a[i__3].i = 0.f;
01217                     }
01218 /* L400: */
01219                 }
01220 /* L410: */
01221             }
01222 
01223         } else if (ipack == 3) {
01224 
01225             isub = 0;
01226             jsub = 1;
01227             i__1 = *n;
01228             for (j = 1; j <= i__1; ++j) {
01229                 i__2 = j;
01230                 for (i__ = 1; i__ <= i__2; ++i__) {
01231                     ++isub;
01232                     if (isub > *lda) {
01233                         isub = 1;
01234                         ++jsub;
01235                     }
01236                     i__3 = isub + jsub * a_dim1;
01237                     clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1], 
01238                             &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
01239                             1], sparse);
01240                     a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01241 /* L420: */
01242                 }
01243 /* L430: */
01244             }
01245 
01246         } else if (ipack == 4) {
01247 
01248             if (isym == 0 || isym == 2) {
01249                 i__1 = *n;
01250                 for (j = 1; j <= i__1; ++j) {
01251                     i__2 = j;
01252                     for (i__ = 1; i__ <= i__2; ++i__) {
01253 
01254 /*                    Compute K = location of (I,J) entry in packed array */
01255 
01256                         if (i__ == 1) {
01257                             k = j;
01258                         } else {
01259                             k = *n * (*n + 1) / 2 - (*n - i__ + 1) * (*n - 
01260                                     i__ + 2) / 2 + j - i__ + 1;
01261                         }
01262 
01263 /*                    Convert K to (ISUB,JSUB) location */
01264 
01265                         jsub = (k - 1) / *lda + 1;
01266                         isub = k - *lda * (jsub - 1);
01267 
01268                         i__3 = isub + jsub * a_dim1;
01269                         clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
01270                                 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, 
01271                                  &iwork[1], sparse);
01272                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01273                         if (isym == 0) {
01274                             i__3 = isub + jsub * a_dim1;
01275                             r_cnjg(&q__1, &a[isub + jsub * a_dim1]);
01276                             a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01277                         }
01278 /* L440: */
01279                     }
01280 /* L450: */
01281                 }
01282             } else {
01283                 isub = 0;
01284                 jsub = 1;
01285                 i__1 = *n;
01286                 for (j = 1; j <= i__1; ++j) {
01287                     i__2 = *m;
01288                     for (i__ = j; i__ <= i__2; ++i__) {
01289                         ++isub;
01290                         if (isub > *lda) {
01291                             isub = 1;
01292                             ++jsub;
01293                         }
01294                         i__3 = isub + jsub * a_dim1;
01295                         clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
01296                                 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, 
01297                                  &iwork[1], sparse);
01298                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01299 /* L460: */
01300                     }
01301 /* L470: */
01302                 }
01303             }
01304 
01305         } else if (ipack == 5) {
01306 
01307             i__1 = *n;
01308             for (j = 1; j <= i__1; ++j) {
01309                 i__2 = j;
01310                 for (i__ = j - kuu; i__ <= i__2; ++i__) {
01311                     if (i__ < 1) {
01312                         i__3 = j - i__ + 1 + (i__ + *n) * a_dim1;
01313                         a[i__3].r = 0.f, a[i__3].i = 0.f;
01314                     } else {
01315                         if (isym == 0) {
01316                             i__3 = j - i__ + 1 + i__ * a_dim1;
01317                             clatm2_(&q__2, m, n, &i__, &j, kl, ku, &idist, &
01318                                     iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
01319 , &ipvtng, &iwork[1], sparse);
01320                             r_cnjg(&q__1, &q__2);
01321                             a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01322                         } else {
01323                             i__3 = j - i__ + 1 + i__ * a_dim1;
01324                             clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &
01325                                     iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
01326 , &ipvtng, &iwork[1], sparse);
01327                             a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01328                         }
01329                     }
01330 /* L480: */
01331                 }
01332 /* L490: */
01333             }
01334 
01335         } else if (ipack == 6) {
01336 
01337             i__1 = *n;
01338             for (j = 1; j <= i__1; ++j) {
01339                 i__2 = j;
01340                 for (i__ = j - kuu; i__ <= i__2; ++i__) {
01341                     i__3 = i__ - j + kuu + 1 + j * a_dim1;
01342                     clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1], 
01343                             &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
01344                             1], sparse);
01345                     a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01346 /* L500: */
01347                 }
01348 /* L510: */
01349             }
01350 
01351         } else if (ipack == 7) {
01352 
01353             if (isym != 1) {
01354                 i__1 = *n;
01355                 for (j = 1; j <= i__1; ++j) {
01356                     i__2 = j;
01357                     for (i__ = j - kuu; i__ <= i__2; ++i__) {
01358                         i__3 = i__ - j + kuu + 1 + j * a_dim1;
01359                         clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
01360                                 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, 
01361                                  &iwork[1], sparse);
01362                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01363                         if (i__ < 1) {
01364                             i__3 = j - i__ + 1 + kuu + (i__ + *n) * a_dim1;
01365                             a[i__3].r = 0.f, a[i__3].i = 0.f;
01366                         }
01367                         if (i__ >= 1 && i__ != j) {
01368                             if (isym == 0) {
01369                                 i__3 = j - i__ + 1 + kuu + i__ * a_dim1;
01370                                 r_cnjg(&q__1, &a[i__ - j + kuu + 1 + j * 
01371                                         a_dim1]);
01372                                 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01373                             } else {
01374                                 i__3 = j - i__ + 1 + kuu + i__ * a_dim1;
01375                                 i__4 = i__ - j + kuu + 1 + j * a_dim1;
01376                                 a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
01377                             }
01378                         }
01379 /* L520: */
01380                     }
01381 /* L530: */
01382                 }
01383             } else if (isym == 1) {
01384                 i__1 = *n;
01385                 for (j = 1; j <= i__1; ++j) {
01386                     i__2 = j + kll;
01387                     for (i__ = j - kuu; i__ <= i__2; ++i__) {
01388                         i__3 = i__ - j + kuu + 1 + j * a_dim1;
01389                         clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
01390                                 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, 
01391                                  &iwork[1], sparse);
01392                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
01393 /* L540: */
01394                     }
01395 /* L550: */
01396                 }
01397             }
01398 
01399         }
01400 
01401     }
01402 
01403 /*     5)      Scaling the norm */
01404 
01405     if (ipack == 0) {
01406         onorm = clange_("M", m, n, &a[a_offset], lda, tempa);
01407     } else if (ipack == 1) {
01408         onorm = clansy_("M", "U", n, &a[a_offset], lda, tempa);
01409     } else if (ipack == 2) {
01410         onorm = clansy_("M", "L", n, &a[a_offset], lda, tempa);
01411     } else if (ipack == 3) {
01412         onorm = clansp_("M", "U", n, &a[a_offset], tempa);
01413     } else if (ipack == 4) {
01414         onorm = clansp_("M", "L", n, &a[a_offset], tempa);
01415     } else if (ipack == 5) {
01416         onorm = clansb_("M", "L", n, &kll, &a[a_offset], lda, tempa);
01417     } else if (ipack == 6) {
01418         onorm = clansb_("M", "U", n, &kuu, &a[a_offset], lda, tempa);
01419     } else if (ipack == 7) {
01420         onorm = clangb_("M", n, &kll, &kuu, &a[a_offset], lda, tempa);
01421     }
01422 
01423     if (*anorm >= 0.f) {
01424 
01425         if (*anorm > 0.f && onorm == 0.f) {
01426 
01427 /*           Desired scaling impossible */
01428 
01429             *info = 5;
01430             return 0;
01431 
01432         } else if (*anorm > 1.f && onorm < 1.f || *anorm < 1.f && onorm > 1.f)
01433                  {
01434 
01435 /*           Scale carefully to avoid over / underflow */
01436 
01437             if (ipack <= 2) {
01438                 i__1 = *n;
01439                 for (j = 1; j <= i__1; ++j) {
01440                     r__1 = 1.f / onorm;
01441                     csscal_(m, &r__1, &a[j * a_dim1 + 1], &c__1);
01442                     csscal_(m, anorm, &a[j * a_dim1 + 1], &c__1);
01443 /* L560: */
01444                 }
01445 
01446             } else if (ipack == 3 || ipack == 4) {
01447 
01448                 i__1 = *n * (*n + 1) / 2;
01449                 r__1 = 1.f / onorm;
01450                 csscal_(&i__1, &r__1, &a[a_offset], &c__1);
01451                 i__1 = *n * (*n + 1) / 2;
01452                 csscal_(&i__1, anorm, &a[a_offset], &c__1);
01453 
01454             } else if (ipack >= 5) {
01455 
01456                 i__1 = *n;
01457                 for (j = 1; j <= i__1; ++j) {
01458                     i__2 = kll + kuu + 1;
01459                     r__1 = 1.f / onorm;
01460                     csscal_(&i__2, &r__1, &a[j * a_dim1 + 1], &c__1);
01461                     i__2 = kll + kuu + 1;
01462                     csscal_(&i__2, anorm, &a[j * a_dim1 + 1], &c__1);
01463 /* L570: */
01464                 }
01465 
01466             }
01467 
01468         } else {
01469 
01470 /*           Scale straightforwardly */
01471 
01472             if (ipack <= 2) {
01473                 i__1 = *n;
01474                 for (j = 1; j <= i__1; ++j) {
01475                     r__1 = *anorm / onorm;
01476                     csscal_(m, &r__1, &a[j * a_dim1 + 1], &c__1);
01477 /* L580: */
01478                 }
01479 
01480             } else if (ipack == 3 || ipack == 4) {
01481 
01482                 i__1 = *n * (*n + 1) / 2;
01483                 r__1 = *anorm / onorm;
01484                 csscal_(&i__1, &r__1, &a[a_offset], &c__1);
01485 
01486             } else if (ipack >= 5) {
01487 
01488                 i__1 = *n;
01489                 for (j = 1; j <= i__1; ++j) {
01490                     i__2 = kll + kuu + 1;
01491                     r__1 = *anorm / onorm;
01492                     csscal_(&i__2, &r__1, &a[j * a_dim1 + 1], &c__1);
01493 /* L590: */
01494                 }
01495             }
01496 
01497         }
01498 
01499     }
01500 
01501 /*     End of CLATMR */
01502 
01503     return 0;
01504 } /* clatmr_ */


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