14 typedef long long BLASLONG;
15 typedef unsigned long long BLASULONG;
17 typedef long BLASLONG;
18 typedef unsigned long BLASULONG;
22 typedef BLASLONG blasint;
24 #define blasabs(x) llabs(x)
26 #define blasabs(x) labs(x)
30 #define blasabs(x) abs(x)
33 typedef blasint integer;
35 typedef unsigned int uinteger;
36 typedef char *address;
37 typedef short int shortint;
39 typedef double doublereal;
40 typedef struct { real r, i; } complex;
41 typedef struct { doublereal r, i; } doublecomplex;
43 static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
44 static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
45 static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
46 static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
48 static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
49 static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
50 static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
51 static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
53 #define pCf(z) (*_pCf(z))
54 #define pCd(z) (*_pCd(z))
56 typedef short int shortlogical;
57 typedef char logical1;
58 typedef char integer1;
63 /* Extern is for use with -E */
74 /*external read, write*/
83 /*internal read, write*/
113 /*rewind, backspace, endfile*/
125 ftnint *inex; /*parameters in standard's order*/
151 union Multitype { /* for multiple entry points */
162 typedef union Multitype Multitype;
164 struct Vardesc { /* for Namelist */
170 typedef struct Vardesc Vardesc;
177 typedef struct Namelist Namelist;
179 #define abs(x) ((x) >= 0 ? (x) : -(x))
180 #define dabs(x) (fabs(x))
181 #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
182 #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
183 #define dmin(a,b) (f2cmin(a,b))
184 #define dmax(a,b) (f2cmax(a,b))
185 #define bit_test(a,b) ((a) >> (b) & 1)
186 #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
187 #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
189 #define abort_() { sig_die("Fortran abort routine called", 1); }
190 #define c_abs(z) (cabsf(Cf(z)))
191 #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
193 #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
194 #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);}
196 #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
197 #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
199 #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
200 #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
201 #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
202 //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
203 #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
204 #define d_abs(x) (fabs(*(x)))
205 #define d_acos(x) (acos(*(x)))
206 #define d_asin(x) (asin(*(x)))
207 #define d_atan(x) (atan(*(x)))
208 #define d_atn2(x, y) (atan2(*(x),*(y)))
209 #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
210 #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
211 #define d_cos(x) (cos(*(x)))
212 #define d_cosh(x) (cosh(*(x)))
213 #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
214 #define d_exp(x) (exp(*(x)))
215 #define d_imag(z) (cimag(Cd(z)))
216 #define r_imag(z) (cimagf(Cf(z)))
217 #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
218 #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
219 #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
220 #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
221 #define d_log(x) (log(*(x)))
222 #define d_mod(x, y) (fmod(*(x), *(y)))
223 #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
224 #define d_nint(x) u_nint(*(x))
225 #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
226 #define d_sign(a,b) u_sign(*(a),*(b))
227 #define r_sign(a,b) u_sign(*(a),*(b))
228 #define d_sin(x) (sin(*(x)))
229 #define d_sinh(x) (sinh(*(x)))
230 #define d_sqrt(x) (sqrt(*(x)))
231 #define d_tan(x) (tan(*(x)))
232 #define d_tanh(x) (tanh(*(x)))
233 #define i_abs(x) abs(*(x))
234 #define i_dnnt(x) ((integer)u_nint(*(x)))
235 #define i_len(s, n) (n)
236 #define i_nint(x) ((integer)u_nint(*(x)))
237 #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
238 #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
239 #define pow_si(B,E) spow_ui(*(B),*(E))
240 #define pow_ri(B,E) spow_ui(*(B),*(E))
241 #define pow_di(B,E) dpow_ui(*(B),*(E))
242 #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
243 #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
244 #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
245 #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; }
246 #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
247 #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
248 #define sig_die(s, kill) { exit(1); }
249 #define s_stop(s, n) {exit(0);}
250 static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
251 #define z_abs(z) (cabs(Cd(z)))
252 #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
253 #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
254 #define myexit_() break;
255 #define mycycle() continue;
256 #define myceiling(w) {ceil(w)}
257 #define myhuge(w) {HUGE_VAL}
258 //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
259 #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
261 /* procedure parameter types for -A and -C++ */
263 #define F2C_proc_par_types 1
265 typedef logical (*L_fp)(...);
267 typedef logical (*L_fp)();
270 static float spow_ui(float x, integer n) {
271 float pow=1.0; unsigned long int u;
273 if(n < 0) n = -n, x = 1/x;
282 static double dpow_ui(double x, integer n) {
283 double pow=1.0; unsigned long int u;
285 if(n < 0) n = -n, x = 1/x;
295 static _Fcomplex cpow_ui(complex x, integer n) {
296 complex pow={1.0,0.0}; unsigned long int u;
298 if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
300 if(u & 01) pow.r *= x.r, pow.i *= x.i;
301 if(u >>= 1) x.r *= x.r, x.i *= x.i;
305 _Fcomplex p={pow.r, pow.i};
309 static _Complex float cpow_ui(_Complex float x, integer n) {
310 _Complex float pow=1.0; unsigned long int u;
312 if(n < 0) n = -n, x = 1/x;
323 static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
324 _Dcomplex pow={1.0,0.0}; unsigned long int u;
326 if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
328 if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
329 if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
333 _Dcomplex p = {pow._Val[0], pow._Val[1]};
337 static _Complex double zpow_ui(_Complex double x, integer n) {
338 _Complex double pow=1.0; unsigned long int u;
340 if(n < 0) n = -n, x = 1/x;
350 static integer pow_ii(integer x, integer n) {
351 integer pow; unsigned long int u;
353 if (n == 0 || x == 1) pow = 1;
354 else if (x != -1) pow = x == 0 ? 1/x : 0;
357 if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
367 static integer dmaxloc_(double *w, integer s, integer e, integer *n)
369 double m; integer i, mi;
370 for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
371 if (w[i-1]>m) mi=i ,m=w[i-1];
374 static integer smaxloc_(float *w, integer s, integer e, integer *n)
376 float m; integer i, mi;
377 for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
378 if (w[i-1]>m) mi=i ,m=w[i-1];
381 static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
382 integer n = *n_, incx = *incx_, incy = *incy_, i;
384 _Fcomplex zdotc = {0.0, 0.0};
385 if (incx == 1 && incy == 1) {
386 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
387 zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
388 zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
391 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
392 zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
393 zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
399 _Complex float zdotc = 0.0;
400 if (incx == 1 && incy == 1) {
401 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
402 zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
405 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
406 zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
412 static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
413 integer n = *n_, incx = *incx_, incy = *incy_, i;
415 _Dcomplex zdotc = {0.0, 0.0};
416 if (incx == 1 && incy == 1) {
417 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
418 zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
419 zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
422 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
423 zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
424 zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
430 _Complex double zdotc = 0.0;
431 if (incx == 1 && incy == 1) {
432 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
433 zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
436 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
437 zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
443 static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
444 integer n = *n_, incx = *incx_, incy = *incy_, i;
446 _Fcomplex zdotc = {0.0, 0.0};
447 if (incx == 1 && incy == 1) {
448 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
449 zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
450 zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
453 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
454 zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
455 zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
461 _Complex float zdotc = 0.0;
462 if (incx == 1 && incy == 1) {
463 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
464 zdotc += Cf(&x[i]) * Cf(&y[i]);
467 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
468 zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
474 static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
475 integer n = *n_, incx = *incx_, incy = *incy_, i;
477 _Dcomplex zdotc = {0.0, 0.0};
478 if (incx == 1 && incy == 1) {
479 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
480 zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
481 zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
484 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
485 zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
486 zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
492 _Complex double zdotc = 0.0;
493 if (incx == 1 && incy == 1) {
494 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
495 zdotc += Cd(&x[i]) * Cd(&y[i]);
498 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
499 zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
505 /* -- translated by f2c (version 20000121).
506 You must link the resulting object file with the libraries:
507 -lf2c -lm (in that order)
513 /* Table of constant values */
515 static integer c__0 = 0;
516 static integer c__1 = 1;
518 /* > \brief \b DLATMR */
520 /* =========== DOCUMENTATION =========== */
522 /* Online html documentation available at */
523 /* http://www.netlib.org/lapack/explore-html/ */
528 /* SUBROUTINE DLATMR( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, */
529 /* RSIGN, GRADE, DL, MODEL, CONDL, DR, MODER, */
530 /* CONDR, PIVTNG, IPIVOT, KL, KU, SPARSE, ANORM, */
531 /* PACK, A, LDA, IWORK, INFO ) */
533 /* CHARACTER DIST, GRADE, PACK, PIVTNG, RSIGN, SYM */
534 /* INTEGER INFO, KL, KU, LDA, M, MODE, MODEL, MODER, N */
535 /* DOUBLE PRECISION ANORM, COND, CONDL, CONDR, DMAX, SPARSE */
536 /* INTEGER IPIVOT( * ), ISEED( 4 ), IWORK( * ) */
537 /* DOUBLE PRECISION A( LDA, * ), D( * ), DL( * ), DR( * ) */
540 /* > \par Purpose: */
545 /* > DLATMR generates random matrices of various types for testing */
546 /* > LAPACK programs. */
548 /* > DLATMR operates by applying the following sequence of */
551 /* > Generate a matrix A with random entries of distribution DIST */
552 /* > which is symmetric if SYM='S', and nonsymmetric */
555 /* > Set the diagonal to D, where D may be input or */
556 /* > computed according to MODE, COND, DMAX and RSIGN */
557 /* > as described below. */
559 /* > Grade the matrix, if desired, from the left and/or right */
560 /* > as specified by GRADE. The inputs DL, MODEL, CONDL, DR, */
561 /* > MODER and CONDR also determine the grading as described */
564 /* > Permute, if desired, the rows and/or columns as specified by */
565 /* > PIVTNG and IPIVOT. */
567 /* > Set random entries to zero, if desired, to get a random sparse */
568 /* > matrix as specified by SPARSE. */
570 /* > Make A a band matrix, if desired, by zeroing out the matrix */
571 /* > outside a band of lower bandwidth KL and upper bandwidth KU. */
573 /* > Scale A, if desired, to have maximum entry ANORM. */
575 /* > Pack the matrix if desired. Options specified by PACK are: */
577 /* > zero out upper half (if symmetric) */
578 /* > zero out lower half (if symmetric) */
579 /* > store the upper half columnwise (if symmetric or */
580 /* > square upper triangular) */
581 /* > store the lower half columnwise (if symmetric or */
582 /* > square lower triangular) */
583 /* > same as upper half rowwise if symmetric */
584 /* > store the lower triangle in banded format (if symmetric) */
585 /* > store the upper triangle in banded format (if symmetric) */
586 /* > store the entire matrix in banded format */
588 /* > Note: If two calls to DLATMR differ only in the PACK parameter, */
589 /* > they will generate mathematically equivalent matrices. */
591 /* > If two calls to DLATMR both have full bandwidth (KL = M-1 */
592 /* > and KU = N-1), and differ only in the PIVTNG and PACK */
593 /* > parameters, then the matrices generated will differ only */
594 /* > in the order of the rows and/or columns, and otherwise */
595 /* > contain the same data. This consistency cannot be and */
596 /* > is not maintained with less than full bandwidth. */
605 /* > Number of rows of A. Not modified. */
611 /* > Number of columns of A. Not modified. */
614 /* > \param[in] DIST */
616 /* > DIST is CHARACTER*1 */
617 /* > On entry, DIST specifies the type of distribution to be used */
618 /* > to generate a random matrix . */
619 /* > 'U' => UNIFORM( 0, 1 ) ( 'U' for uniform ) */
620 /* > 'S' => UNIFORM( -1, 1 ) ( 'S' for symmetric ) */
621 /* > 'N' => NORMAL( 0, 1 ) ( 'N' for normal ) */
622 /* > Not modified. */
625 /* > \param[in,out] ISEED */
627 /* > ISEED is INTEGER array, dimension (4) */
628 /* > On entry ISEED specifies the seed of the random number */
629 /* > generator. They should lie between 0 and 4095 inclusive, */
630 /* > and ISEED(4) should be odd. The random number generator */
631 /* > uses a linear congruential sequence limited to small */
632 /* > integers, and so should produce machine independent */
633 /* > random numbers. The values of ISEED are changed on */
634 /* > exit, and can be used in the next call to DLATMR */
635 /* > to continue the same random number sequence. */
636 /* > Changed on exit. */
639 /* > \param[in] SYM */
641 /* > SYM is CHARACTER*1 */
642 /* > If SYM='S' or 'H', generated matrix is symmetric. */
643 /* > If SYM='N', generated matrix is nonsymmetric. */
644 /* > Not modified. */
647 /* > \param[in,out] D */
649 /* > D is DOUBLE PRECISION array, dimension (f2cmin(M,N)) */
650 /* > On entry this array specifies the diagonal entries */
651 /* > of the diagonal of A. D may either be specified */
652 /* > on entry, or set according to MODE and COND as described */
653 /* > below. May be changed on exit if MODE is nonzero. */
656 /* > \param[in] MODE */
658 /* > MODE is INTEGER */
659 /* > On entry describes how D is to be used: */
660 /* > MODE = 0 means use D as input */
661 /* > MODE = 1 sets D(1)=1 and D(2:N)=1.0/COND */
662 /* > MODE = 2 sets D(1:N-1)=1 and D(N)=1.0/COND */
663 /* > MODE = 3 sets D(I)=COND**(-(I-1)/(N-1)) */
664 /* > MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */
665 /* > MODE = 5 sets D to random numbers in the range */
666 /* > ( 1/COND , 1 ) such that their logarithms */
667 /* > are uniformly distributed. */
668 /* > MODE = 6 set D to random numbers from same distribution */
669 /* > as the rest of the matrix. */
670 /* > MODE < 0 has the same meaning as ABS(MODE), except that */
671 /* > the order of the elements of D is reversed. */
672 /* > Thus if MODE is positive, D has entries ranging from */
673 /* > 1 to 1/COND, if negative, from 1/COND to 1, */
674 /* > Not modified. */
677 /* > \param[in] COND */
679 /* > COND is DOUBLE PRECISION */
680 /* > On entry, used as described under MODE above. */
681 /* > If used, it must be >= 1. Not modified. */
684 /* > \param[in] DMAX */
686 /* > DMAX is DOUBLE PRECISION */
687 /* > If MODE neither -6, 0 nor 6, the diagonal is scaled by */
688 /* > DMAX / f2cmax(abs(D(i))), so that maximum absolute entry */
689 /* > of diagonal is abs(DMAX). If DMAX is negative (or zero), */
690 /* > diagonal will be scaled by a negative number (or zero). */
693 /* > \param[in] RSIGN */
695 /* > RSIGN is CHARACTER*1 */
696 /* > If MODE neither -6, 0 nor 6, specifies sign of diagonal */
698 /* > 'T' => diagonal entries are multiplied by 1 or -1 */
699 /* > with probability .5 */
700 /* > 'F' => diagonal unchanged */
701 /* > Not modified. */
704 /* > \param[in] GRADE */
706 /* > GRADE is CHARACTER*1 */
707 /* > Specifies grading of matrix as follows: */
708 /* > 'N' => no grading */
709 /* > 'L' => matrix premultiplied by diag( DL ) */
710 /* > (only if matrix nonsymmetric) */
711 /* > 'R' => matrix postmultiplied by diag( DR ) */
712 /* > (only if matrix nonsymmetric) */
713 /* > 'B' => matrix premultiplied by diag( DL ) and */
714 /* > postmultiplied by diag( DR ) */
715 /* > (only if matrix nonsymmetric) */
716 /* > 'S' or 'H' => matrix premultiplied by diag( DL ) and */
717 /* > postmultiplied by diag( DL ) */
718 /* > ('S' for symmetric, or 'H' for Hermitian) */
719 /* > 'E' => matrix premultiplied by diag( DL ) and */
720 /* > postmultiplied by inv( diag( DL ) ) */
721 /* > ( 'E' for eigenvalue invariance) */
722 /* > (only if matrix nonsymmetric) */
723 /* > Note: if GRADE='E', then M must equal N. */
724 /* > Not modified. */
727 /* > \param[in,out] DL */
729 /* > DL is DOUBLE PRECISION array, dimension (M) */
730 /* > If MODEL=0, then on entry this array specifies the diagonal */
731 /* > entries of a diagonal matrix used as described under GRADE */
732 /* > above. If MODEL is not zero, then DL will be set according */
733 /* > to MODEL and CONDL, analogous to the way D is set according */
734 /* > to MODE and COND (except there is no DMAX parameter for DL). */
735 /* > If GRADE='E', then DL cannot have zero entries. */
736 /* > Not referenced if GRADE = 'N' or 'R'. Changed on exit. */
739 /* > \param[in] MODEL */
741 /* > MODEL is INTEGER */
742 /* > This specifies how the diagonal array DL is to be computed, */
743 /* > just as MODE specifies how D is to be computed. */
744 /* > Not modified. */
747 /* > \param[in] CONDL */
749 /* > CONDL is DOUBLE PRECISION */
750 /* > When MODEL is not zero, this specifies the condition number */
751 /* > of the computed DL. Not modified. */
754 /* > \param[in,out] DR */
756 /* > DR is DOUBLE PRECISION array, dimension (N) */
757 /* > If MODER=0, then on entry this array specifies the diagonal */
758 /* > entries of a diagonal matrix used as described under GRADE */
759 /* > above. If MODER is not zero, then DR will be set according */
760 /* > to MODER and CONDR, analogous to the way D is set according */
761 /* > to MODE and COND (except there is no DMAX parameter for DR). */
762 /* > Not referenced if GRADE = 'N', 'L', 'H', 'S' or 'E'. */
763 /* > Changed on exit. */
766 /* > \param[in] MODER */
768 /* > MODER is INTEGER */
769 /* > This specifies how the diagonal array DR is to be computed, */
770 /* > just as MODE specifies how D is to be computed. */
771 /* > Not modified. */
774 /* > \param[in] CONDR */
776 /* > CONDR is DOUBLE PRECISION */
777 /* > When MODER is not zero, this specifies the condition number */
778 /* > of the computed DR. Not modified. */
781 /* > \param[in] PIVTNG */
783 /* > PIVTNG is CHARACTER*1 */
784 /* > On entry specifies pivoting permutations as follows: */
785 /* > 'N' or ' ' => none. */
786 /* > 'L' => left or row pivoting (matrix must be nonsymmetric). */
787 /* > 'R' => right or column pivoting (matrix must be */
788 /* > nonsymmetric). */
789 /* > 'B' or 'F' => both or full pivoting, i.e., on both sides. */
790 /* > In this case, M must equal N */
792 /* > If two calls to DLATMR both have full bandwidth (KL = M-1 */
793 /* > and KU = N-1), and differ only in the PIVTNG and PACK */
794 /* > parameters, then the matrices generated will differ only */
795 /* > in the order of the rows and/or columns, and otherwise */
796 /* > contain the same data. This consistency cannot be */
797 /* > maintained with less than full bandwidth. */
800 /* > \param[in] IPIVOT */
802 /* > IPIVOT is INTEGER array, dimension (N or M) */
803 /* > This array specifies the permutation used. After the */
804 /* > basic matrix is generated, the rows, columns, or both */
805 /* > are permuted. If, say, row pivoting is selected, DLATMR */
806 /* > starts with the *last* row and interchanges the M-th and */
807 /* > IPIVOT(M)-th rows, then moves to the next-to-last row, */
808 /* > interchanging the (M-1)-th and the IPIVOT(M-1)-th rows, */
809 /* > and so on. In terms of "2-cycles", the permutation is */
810 /* > (1 IPIVOT(1)) (2 IPIVOT(2)) ... (M IPIVOT(M)) */
811 /* > where the rightmost cycle is applied first. This is the */
812 /* > *inverse* of the effect of pivoting in LINPACK. The idea */
813 /* > is that factoring (with pivoting) an identity matrix */
814 /* > which has been inverse-pivoted in this way should */
815 /* > result in a pivot vector identical to IPIVOT. */
816 /* > Not referenced if PIVTNG = 'N'. Not modified. */
819 /* > \param[in] KL */
821 /* > KL is INTEGER */
822 /* > On entry specifies the lower bandwidth of the matrix. For */
823 /* > example, KL=0 implies upper triangular, KL=1 implies upper */
824 /* > Hessenberg, and KL at least M-1 implies the matrix is not */
825 /* > banded. Must equal KU if matrix is symmetric. */
826 /* > Not modified. */
829 /* > \param[in] KU */
831 /* > KU is INTEGER */
832 /* > On entry specifies the upper bandwidth of the matrix. For */
833 /* > example, KU=0 implies lower triangular, KU=1 implies lower */
834 /* > Hessenberg, and KU at least N-1 implies the matrix is not */
835 /* > banded. Must equal KL if matrix is symmetric. */
836 /* > Not modified. */
839 /* > \param[in] SPARSE */
841 /* > SPARSE is DOUBLE PRECISION */
842 /* > On entry specifies the sparsity of the matrix if a sparse */
843 /* > matrix is to be generated. SPARSE should lie between */
844 /* > 0 and 1. To generate a sparse matrix, for each matrix entry */
845 /* > a uniform ( 0, 1 ) random number x is generated and */
846 /* > compared to SPARSE; if x is larger the matrix entry */
847 /* > is unchanged and if x is smaller the entry is set */
848 /* > to zero. Thus on the average a fraction SPARSE of the */
849 /* > entries will be set to zero. */
850 /* > Not modified. */
853 /* > \param[in] ANORM */
855 /* > ANORM is DOUBLE PRECISION */
856 /* > On entry specifies maximum entry of output matrix */
857 /* > (output matrix will by multiplied by a constant so that */
858 /* > its largest absolute entry equal ANORM) */
859 /* > if ANORM is nonnegative. If ANORM is negative no scaling */
860 /* > is done. Not modified. */
863 /* > \param[in] PACK */
865 /* > PACK is CHARACTER*1 */
866 /* > On entry specifies packing of matrix as follows: */
867 /* > 'N' => no packing */
868 /* > 'U' => zero out all subdiagonal entries (if symmetric) */
869 /* > 'L' => zero out all superdiagonal entries (if symmetric) */
870 /* > 'C' => store the upper triangle columnwise */
871 /* > (only if matrix symmetric or square upper triangular) */
872 /* > 'R' => store the lower triangle columnwise */
873 /* > (only if matrix symmetric or square lower triangular) */
874 /* > (same as upper half rowwise if symmetric) */
875 /* > 'B' => store the lower triangle in band storage scheme */
876 /* > (only if matrix symmetric) */
877 /* > 'Q' => store the upper triangle in band storage scheme */
878 /* > (only if matrix symmetric) */
879 /* > 'Z' => store the entire matrix in band storage scheme */
880 /* > (pivoting can be provided for by using this */
881 /* > option to store A in the trailing rows of */
882 /* > the allocated storage) */
884 /* > Using these options, the various LAPACK packed and banded */
885 /* > storage schemes can be obtained: */
887 /* > PB, SB or TB - use 'B' or 'Q' */
888 /* > PP, SP or TP - use 'C' or 'R' */
890 /* > If two calls to DLATMR differ only in the PACK parameter, */
891 /* > they will generate mathematically equivalent matrices. */
892 /* > Not modified. */
895 /* > \param[out] A */
897 /* > A is DOUBLE PRECISION array, dimension (LDA,N) */
898 /* > On exit A is the desired test matrix. Only those */
899 /* > entries of A which are significant on output */
900 /* > will be referenced (even if A is in packed or band */
901 /* > storage format). The 'unoccupied corners' of A in */
902 /* > band format will be zeroed out. */
905 /* > \param[in] LDA */
907 /* > LDA is INTEGER */
908 /* > on entry LDA specifies the first dimension of A as */
909 /* > declared in the calling program. */
910 /* > If PACK='N', 'U' or 'L', LDA must be at least f2cmax ( 1, M ). */
911 /* > If PACK='C' or 'R', LDA must be at least 1. */
912 /* > If PACK='B', or 'Q', LDA must be MIN ( KU+1, N ) */
913 /* > If PACK='Z', LDA must be at least KUU+KLL+1, where */
914 /* > KUU = MIN ( KU, N-1 ) and KLL = MIN ( KL, M-1 ) */
915 /* > Not modified. */
918 /* > \param[out] IWORK */
920 /* > IWORK is INTEGER array, dimension ( N or M) */
921 /* > Workspace. Not referenced if PIVTNG = 'N'. Changed on exit. */
924 /* > \param[out] INFO */
926 /* > INFO is INTEGER */
927 /* > Error parameter on exit: */
928 /* > 0 => normal return */
929 /* > -1 => M negative or unequal to N and SYM='S' or 'H' */
930 /* > -2 => N negative */
931 /* > -3 => DIST illegal string */
932 /* > -5 => SYM illegal string */
933 /* > -7 => MODE not in range -6 to 6 */
934 /* > -8 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
935 /* > -10 => MODE neither -6, 0 nor 6 and RSIGN illegal string */
936 /* > -11 => GRADE illegal string, or GRADE='E' and */
937 /* > M not equal to N, or GRADE='L', 'R', 'B' or 'E' and */
938 /* > SYM = 'S' or 'H' */
939 /* > -12 => GRADE = 'E' and DL contains zero */
940 /* > -13 => MODEL not in range -6 to 6 and GRADE= 'L', 'B', 'H', */
942 /* > -14 => CONDL less than 1.0, GRADE='L', 'B', 'H', 'S' or 'E', */
943 /* > and MODEL neither -6, 0 nor 6 */
944 /* > -16 => MODER not in range -6 to 6 and GRADE= 'R' or 'B' */
945 /* > -17 => CONDR less than 1.0, GRADE='R' or 'B', and */
946 /* > MODER neither -6, 0 nor 6 */
947 /* > -18 => PIVTNG illegal string, or PIVTNG='B' or 'F' and */
948 /* > M not equal to N, or PIVTNG='L' or 'R' and SYM='S' */
950 /* > -19 => IPIVOT contains out of range number and */
951 /* > PIVTNG not equal to 'N' */
952 /* > -20 => KL negative */
953 /* > -21 => KU negative, or SYM='S' or 'H' and KU not equal to KL */
954 /* > -22 => SPARSE not in range 0. to 1. */
955 /* > -24 => PACK illegal string, or PACK='U', 'L', 'B' or 'Q' */
956 /* > and SYM='N', or PACK='C' and SYM='N' and either KL */
957 /* > not equal to 0 or N not equal to M, or PACK='R' and */
958 /* > SYM='N', and either KU not equal to 0 or N not equal */
960 /* > -26 => LDA too small */
961 /* > 1 => Error return from DLATM1 (computing D) */
962 /* > 2 => Cannot scale diagonal to DMAX (f2cmax. entry is 0) */
963 /* > 3 => Error return from DLATM1 (computing DL) */
964 /* > 4 => Error return from DLATM1 (computing DR) */
965 /* > 5 => ANORM is positive, but matrix constructed prior to */
966 /* > attempting to scale it to have norm ANORM, is zero */
972 /* > \author Univ. of Tennessee */
973 /* > \author Univ. of California Berkeley */
974 /* > \author Univ. of Colorado Denver */
975 /* > \author NAG Ltd. */
977 /* > \date December 2016 */
979 /* > \ingroup double_matgen */
981 /* ===================================================================== */
982 /* Subroutine */ int dlatmr_(integer *m, integer *n, char *dist, integer *
983 iseed, char *sym, doublereal *d__, integer *mode, doublereal *cond,
984 doublereal *dmax__, char *rsign, char *grade, doublereal *dl, integer
985 *model, doublereal *condl, doublereal *dr, integer *moder, doublereal
986 *condr, char *pivtng, integer *ipivot, integer *kl, integer *ku,
987 doublereal *sparse, doublereal *anorm, char *pack, doublereal *a,
988 integer *lda, integer *iwork, integer *info)
990 /* System generated locals */
991 integer a_dim1, a_offset, i__1, i__2;
992 doublereal d__1, d__2, d__3;
994 /* Local variables */
997 integer isym, i__, j, k;
999 extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
1002 extern logical lsame_(char *, char *);
1003 doublereal tempa[1];
1004 integer iisub, idist, jjsub, mnmin;
1008 integer mxsub, npvts;
1009 extern /* Subroutine */ int dlatm1_(integer *, doublereal *, integer *,
1010 integer *, integer *, doublereal *, integer *, integer *);
1011 extern doublereal dlatm2_(integer *, integer *, integer *, integer *,
1012 integer *, integer *, integer *, integer *, doublereal *, integer
1013 *, doublereal *, doublereal *, integer *, integer *, doublereal *)
1014 , dlatm3_(integer *, integer *, integer *, integer *, integer *,
1015 integer *, integer *, integer *, integer *, integer *, doublereal
1016 *, integer *, doublereal *, doublereal *, integer *, integer *,
1017 doublereal *), dlangb_(char *, integer *, integer *, integer *,
1018 doublereal *, integer *, doublereal *), dlange_(char *,
1019 integer *, integer *, doublereal *, integer *, doublereal *);
1021 extern doublereal dlansb_(char *, char *, integer *, integer *,
1022 doublereal *, integer *, doublereal *);
1024 extern /* Subroutine */ int xerbla_(char *, integer *);
1026 extern doublereal dlansp_(char *, char *, integer *, doublereal *,
1027 doublereal *), dlansy_(char *, char *, integer *,
1028 doublereal *, integer *, doublereal *);
1029 integer irsign, ipvtng, kll, kuu;
1032 /* -- LAPACK computational routine (version 3.7.0) -- */
1033 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
1034 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
1038 /* ===================================================================== */
1041 /* 1) Decode and Test the input parameters. */
1042 /* Initialize flags & seed. */
1044 /* Parameter adjustments */
1051 a_offset = 1 + a_dim1 * 1;
1058 /* Quick return if possible */
1060 if (*m == 0 || *n == 0) {
1066 if (lsame_(dist, "U")) {
1068 } else if (lsame_(dist, "S")) {
1070 } else if (lsame_(dist, "N")) {
1078 if (lsame_(sym, "S")) {
1080 } else if (lsame_(sym, "N")) {
1082 } else if (lsame_(sym, "H")) {
1090 if (lsame_(rsign, "F")) {
1092 } else if (lsame_(rsign, "T")) {
1100 if (lsame_(pivtng, "N")) {
1102 } else if (lsame_(pivtng, " ")) {
1104 } else if (lsame_(pivtng, "L")) {
1107 } else if (lsame_(pivtng, "R")) {
1110 } else if (lsame_(pivtng, "B")) {
1112 npvts = f2cmin(*n,*m);
1113 } else if (lsame_(pivtng, "F")) {
1115 npvts = f2cmin(*n,*m);
1122 if (lsame_(grade, "N")) {
1124 } else if (lsame_(grade, "L")) {
1126 } else if (lsame_(grade, "R")) {
1128 } else if (lsame_(grade, "B")) {
1130 } else if (lsame_(grade, "E")) {
1132 } else if (lsame_(grade, "H") || lsame_(grade,
1141 if (lsame_(pack, "N")) {
1143 } else if (lsame_(pack, "U")) {
1145 } else if (lsame_(pack, "L")) {
1147 } else if (lsame_(pack, "C")) {
1149 } else if (lsame_(pack, "R")) {
1151 } else if (lsame_(pack, "B")) {
1153 } else if (lsame_(pack, "Q")) {
1155 } else if (lsame_(pack, "Z")) {
1161 /* Set certain internal parameters */
1163 mnmin = f2cmin(*m,*n);
1165 i__1 = *kl, i__2 = *m - 1;
1166 kll = f2cmin(i__1,i__2);
1168 i__1 = *ku, i__2 = *n - 1;
1169 kuu = f2cmin(i__1,i__2);
1171 /* If inv(DL) is used, check to see if DL has a zero entry. */
1174 if (igrade == 4 && *model == 0) {
1176 for (i__ = 1; i__ <= i__1; ++i__) {
1177 if (dl[i__] == 0.) {
1184 /* Check values in IPIVOT */
1189 for (j = 1; j <= i__1; ++j) {
1190 if (ipivot[j] <= 0 || ipivot[j] > npvts) {
1197 /* Set INFO if an error */
1201 } else if (*m != *n && isym == 0) {
1203 } else if (*n < 0) {
1205 } else if (idist == -1) {
1207 } else if (isym == -1) {
1209 } else if (*mode < -6 || *mode > 6) {
1211 } else if (*mode != -6 && *mode != 0 && *mode != 6 && *cond < 1.) {
1213 } else if (*mode != -6 && *mode != 0 && *mode != 6 && irsign == -1) {
1215 } else if (igrade == -1 || igrade == 4 && *m != *n || igrade >= 1 &&
1216 igrade <= 4 && isym == 0) {
1218 } else if (igrade == 4 && dzero) {
1220 } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5) && (
1221 *model < -6 || *model > 6)) {
1223 } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5) && (
1224 *model != -6 && *model != 0 && *model != 6) && *condl < 1.) {
1226 } else if ((igrade == 2 || igrade == 3) && (*moder < -6 || *moder > 6)) {
1228 } else if ((igrade == 2 || igrade == 3) && (*moder != -6 && *moder != 0 &&
1229 *moder != 6) && *condr < 1.) {
1231 } else if (ipvtng == -1 || ipvtng == 3 && *m != *n || (ipvtng == 1 ||
1232 ipvtng == 2) && isym == 0) {
1234 } else if (ipvtng != 0 && badpvt) {
1236 } else if (*kl < 0) {
1238 } else if (*ku < 0 || isym == 0 && *kl != *ku) {
1240 } else if (*sparse < 0. || *sparse > 1.) {
1242 } else if (ipack == -1 || (ipack == 1 || ipack == 2 || ipack == 5 ||
1243 ipack == 6) && isym == 1 || ipack == 3 && isym == 1 && (*kl != 0
1244 || *m != *n) || ipack == 4 && isym == 1 && (*ku != 0 || *m != *n))
1247 } else if ((ipack == 0 || ipack == 1 || ipack == 2) && *lda < f2cmax(1,*m) ||
1248 (ipack == 3 || ipack == 4) && *lda < 1 || (ipack == 5 || ipack ==
1249 6) && *lda < kuu + 1 || ipack == 7 && *lda < kll + kuu + 1) {
1255 xerbla_("DLATMR", &i__1);
1259 /* Decide if we can pivot consistently */
1262 if (kuu == *n - 1 && kll == *m - 1) {
1266 /* Initialize random number generator */
1268 for (i__ = 1; i__ <= 4; ++i__) {
1269 iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
1273 iseed[4] = (iseed[4] / 2 << 1) + 1;
1275 /* 2) Set up D, DL, and DR, if indicated. */
1277 /* Compute D according to COND and MODE */
1279 dlatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, info);
1284 if (*mode != 0 && *mode != -6 && *mode != 6) {
1290 for (i__ = 2; i__ <= i__1; ++i__) {
1292 d__2 = temp, d__3 = (d__1 = d__[i__], abs(d__1));
1293 temp = f2cmax(d__2,d__3);
1296 if (temp == 0. && *dmax__ != 0.) {
1301 alpha = *dmax__ / temp;
1306 for (i__ = 1; i__ <= i__1; ++i__) {
1307 d__[i__] = alpha * d__[i__];
1313 /* Compute DL if grading set */
1315 if (igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5) {
1316 dlatm1_(model, condl, &c__0, &idist, &iseed[1], &dl[1], m, info);
1323 /* Compute DR if grading set */
1325 if (igrade == 2 || igrade == 3) {
1326 dlatm1_(moder, condr, &c__0, &idist, &iseed[1], &dr[1], n, info);
1333 /* 3) Generate IWORK if pivoting */
1337 for (i__ = 1; i__ <= i__1; ++i__) {
1343 for (i__ = 1; i__ <= i__1; ++i__) {
1346 iwork[i__] = iwork[k];
1351 for (i__ = npvts; i__ >= 1; --i__) {
1354 iwork[i__] = iwork[k];
1361 /* 4) Generate matrices for each kind of PACKing */
1362 /* Always sweep matrix columnwise (if symmetric, upper */
1363 /* half only) so that matrix generated does not depend */
1368 /* Use DLATM3 so matrices generated with differing PIVOTing only */
1369 /* differ only in the order of their rows and/or columns. */
1374 for (j = 1; j <= i__1; ++j) {
1376 for (i__ = 1; i__ <= i__2; ++i__) {
1377 temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
1378 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1379 dr[1], &ipvtng, &iwork[1], sparse);
1380 a[isub + jsub * a_dim1] = temp;
1381 a[jsub + isub * a_dim1] = temp;
1386 } else if (isym == 1) {
1388 for (j = 1; j <= i__1; ++j) {
1390 for (i__ = 1; i__ <= i__2; ++i__) {
1391 temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
1392 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1393 dr[1], &ipvtng, &iwork[1], sparse);
1394 a[isub + jsub * a_dim1] = temp;
1401 } else if (ipack == 1) {
1404 for (j = 1; j <= i__1; ++j) {
1406 for (i__ = 1; i__ <= i__2; ++i__) {
1407 temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
1408 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1409 , &ipvtng, &iwork[1], sparse);
1410 mnsub = f2cmin(isub,jsub);
1411 mxsub = f2cmax(isub,jsub);
1412 a[mnsub + mxsub * a_dim1] = temp;
1413 if (mnsub != mxsub) {
1414 a[mxsub + mnsub * a_dim1] = 0.;
1421 } else if (ipack == 2) {
1424 for (j = 1; j <= i__1; ++j) {
1426 for (i__ = 1; i__ <= i__2; ++i__) {
1427 temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
1428 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1429 , &ipvtng, &iwork[1], sparse);
1430 mnsub = f2cmin(isub,jsub);
1431 mxsub = f2cmax(isub,jsub);
1432 a[mxsub + mnsub * a_dim1] = temp;
1433 if (mnsub != mxsub) {
1434 a[mnsub + mxsub * a_dim1] = 0.;
1441 } else if (ipack == 3) {
1444 for (j = 1; j <= i__1; ++j) {
1446 for (i__ = 1; i__ <= i__2; ++i__) {
1447 temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
1448 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1449 , &ipvtng, &iwork[1], sparse);
1451 /* Compute K = location of (ISUB,JSUB) entry in packed */
1454 mnsub = f2cmin(isub,jsub);
1455 mxsub = f2cmax(isub,jsub);
1456 k = mxsub * (mxsub - 1) / 2 + mnsub;
1458 /* Convert K to (IISUB,JJSUB) location */
1460 jjsub = (k - 1) / *lda + 1;
1461 iisub = k - *lda * (jjsub - 1);
1463 a[iisub + jjsub * a_dim1] = temp;
1469 } else if (ipack == 4) {
1472 for (j = 1; j <= i__1; ++j) {
1474 for (i__ = 1; i__ <= i__2; ++i__) {
1475 temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
1476 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1477 , &ipvtng, &iwork[1], sparse);
1479 /* Compute K = location of (I,J) entry in packed array */
1481 mnsub = f2cmin(isub,jsub);
1482 mxsub = f2cmax(isub,jsub);
1486 k = *n * (*n + 1) / 2 - (*n - mnsub + 1) * (*n -
1487 mnsub + 2) / 2 + mxsub - mnsub + 1;
1490 /* Convert K to (IISUB,JJSUB) location */
1492 jjsub = (k - 1) / *lda + 1;
1493 iisub = k - *lda * (jjsub - 1);
1495 a[iisub + jjsub * a_dim1] = temp;
1501 } else if (ipack == 5) {
1504 for (j = 1; j <= i__1; ++j) {
1506 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1508 a[j - i__ + 1 + (i__ + *n) * a_dim1] = 0.;
1510 temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
1511 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1512 dr[1], &ipvtng, &iwork[1], sparse);
1513 mnsub = f2cmin(isub,jsub);
1514 mxsub = f2cmax(isub,jsub);
1515 a[mxsub - mnsub + 1 + mnsub * a_dim1] = temp;
1522 } else if (ipack == 6) {
1525 for (j = 1; j <= i__1; ++j) {
1527 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1528 temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
1529 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1530 , &ipvtng, &iwork[1], sparse);
1531 mnsub = f2cmin(isub,jsub);
1532 mxsub = f2cmax(isub,jsub);
1533 a[mnsub - mxsub + kuu + 1 + mxsub * a_dim1] = temp;
1539 } else if (ipack == 7) {
1543 for (j = 1; j <= i__1; ++j) {
1545 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1546 temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
1547 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1548 dr[1], &ipvtng, &iwork[1], sparse);
1549 mnsub = f2cmin(isub,jsub);
1550 mxsub = f2cmax(isub,jsub);
1551 a[mnsub - mxsub + kuu + 1 + mxsub * a_dim1] = temp;
1553 a[j - i__ + 1 + kuu + (i__ + *n) * a_dim1] = 0.;
1555 if (i__ >= 1 && mnsub != mxsub) {
1556 a[mxsub - mnsub + 1 + kuu + mnsub * a_dim1] =
1563 } else if (isym == 1) {
1565 for (j = 1; j <= i__1; ++j) {
1567 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1568 temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
1569 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1570 dr[1], &ipvtng, &iwork[1], sparse);
1571 a[isub - jsub + kuu + 1 + jsub * a_dim1] = temp;
1587 for (j = 1; j <= i__1; ++j) {
1589 for (i__ = 1; i__ <= i__2; ++i__) {
1590 a[i__ + j * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku,
1591 &idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1592 dr[1], &ipvtng, &iwork[1], sparse);
1593 a[j + i__ * a_dim1] = a[i__ + j * a_dim1];
1598 } else if (isym == 1) {
1600 for (j = 1; j <= i__1; ++j) {
1602 for (i__ = 1; i__ <= i__2; ++i__) {
1603 a[i__ + j * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku,
1604 &idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1605 dr[1], &ipvtng, &iwork[1], sparse);
1612 } else if (ipack == 1) {
1615 for (j = 1; j <= i__1; ++j) {
1617 for (i__ = 1; i__ <= i__2; ++i__) {
1618 a[i__ + j * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku, &
1619 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1620 , &ipvtng, &iwork[1], sparse);
1622 a[j + i__ * a_dim1] = 0.;
1629 } else if (ipack == 2) {
1632 for (j = 1; j <= i__1; ++j) {
1634 for (i__ = 1; i__ <= i__2; ++i__) {
1635 a[j + i__ * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku, &
1636 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1637 , &ipvtng, &iwork[1], sparse);
1639 a[i__ + j * a_dim1] = 0.;
1646 } else if (ipack == 3) {
1651 for (j = 1; j <= i__1; ++j) {
1653 for (i__ = 1; i__ <= i__2; ++i__) {
1659 a[isub + jsub * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku,
1660 &idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[
1661 1], &ipvtng, &iwork[1], sparse);
1667 } else if (ipack == 4) {
1671 for (j = 1; j <= i__1; ++j) {
1673 for (i__ = 1; i__ <= i__2; ++i__) {
1675 /* Compute K = location of (I,J) entry in packed array */
1680 k = *n * (*n + 1) / 2 - (*n - i__ + 1) * (*n -
1681 i__ + 2) / 2 + j - i__ + 1;
1684 /* Convert K to (ISUB,JSUB) location */
1686 jsub = (k - 1) / *lda + 1;
1687 isub = k - *lda * (jsub - 1);
1689 a[isub + jsub * a_dim1] = dlatm2_(m, n, &i__, &j, kl,
1690 ku, &idist, &iseed[1], &d__[1], &igrade, &dl[
1691 1], &dr[1], &ipvtng, &iwork[1], sparse);
1700 for (j = 1; j <= i__1; ++j) {
1702 for (i__ = j; i__ <= i__2; ++i__) {
1708 a[isub + jsub * a_dim1] = dlatm2_(m, n, &i__, &j, kl,
1709 ku, &idist, &iseed[1], &d__[1], &igrade, &dl[
1710 1], &dr[1], &ipvtng, &iwork[1], sparse);
1717 } else if (ipack == 5) {
1720 for (j = 1; j <= i__1; ++j) {
1722 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1724 a[j - i__ + 1 + (i__ + *n) * a_dim1] = 0.;
1726 a[j - i__ + 1 + i__ * a_dim1] = dlatm2_(m, n, &i__, &
1727 j, kl, ku, &idist, &iseed[1], &d__[1], &
1728 igrade, &dl[1], &dr[1], &ipvtng, &iwork[1],
1736 } else if (ipack == 6) {
1739 for (j = 1; j <= i__1; ++j) {
1741 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1742 a[i__ - j + kuu + 1 + j * a_dim1] = dlatm2_(m, n, &i__, &
1743 j, kl, ku, &idist, &iseed[1], &d__[1], &igrade, &
1744 dl[1], &dr[1], &ipvtng, &iwork[1], sparse);
1750 } else if (ipack == 7) {
1754 for (j = 1; j <= i__1; ++j) {
1756 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1757 a[i__ - j + kuu + 1 + j * a_dim1] = dlatm2_(m, n, &
1758 i__, &j, kl, ku, &idist, &iseed[1], &d__[1], &
1759 igrade, &dl[1], &dr[1], &ipvtng, &iwork[1],
1762 a[j - i__ + 1 + kuu + (i__ + *n) * a_dim1] = 0.;
1764 if (i__ >= 1 && i__ != j) {
1765 a[j - i__ + 1 + kuu + i__ * a_dim1] = a[i__ - j +
1766 kuu + 1 + j * a_dim1];
1772 } else if (isym == 1) {
1774 for (j = 1; j <= i__1; ++j) {
1776 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1777 a[i__ - j + kuu + 1 + j * a_dim1] = dlatm2_(m, n, &
1778 i__, &j, kl, ku, &idist, &iseed[1], &d__[1], &
1779 igrade, &dl[1], &dr[1], &ipvtng, &iwork[1],
1791 /* 5) Scaling the norm */
1794 onorm = dlange_("M", m, n, &a[a_offset], lda, tempa);
1795 } else if (ipack == 1) {
1796 onorm = dlansy_("M", "U", n, &a[a_offset], lda, tempa);
1797 } else if (ipack == 2) {
1798 onorm = dlansy_("M", "L", n, &a[a_offset], lda, tempa);
1799 } else if (ipack == 3) {
1800 onorm = dlansp_("M", "U", n, &a[a_offset], tempa);
1801 } else if (ipack == 4) {
1802 onorm = dlansp_("M", "L", n, &a[a_offset], tempa);
1803 } else if (ipack == 5) {
1804 onorm = dlansb_("M", "L", n, &kll, &a[a_offset], lda, tempa);
1805 } else if (ipack == 6) {
1806 onorm = dlansb_("M", "U", n, &kuu, &a[a_offset], lda, tempa);
1807 } else if (ipack == 7) {
1808 onorm = dlangb_("M", n, &kll, &kuu, &a[a_offset], lda, tempa);
1813 if (*anorm > 0. && onorm == 0.) {
1815 /* Desired scaling impossible */
1820 } else if (*anorm > 1. && onorm < 1. || *anorm < 1. && onorm > 1.) {
1822 /* Scale carefully to avoid over / underflow */
1826 for (j = 1; j <= i__1; ++j) {
1828 dscal_(m, &d__1, &a[j * a_dim1 + 1], &c__1);
1829 dscal_(m, anorm, &a[j * a_dim1 + 1], &c__1);
1833 } else if (ipack == 3 || ipack == 4) {
1835 i__1 = *n * (*n + 1) / 2;
1837 dscal_(&i__1, &d__1, &a[a_offset], &c__1);
1838 i__1 = *n * (*n + 1) / 2;
1839 dscal_(&i__1, anorm, &a[a_offset], &c__1);
1841 } else if (ipack >= 5) {
1844 for (j = 1; j <= i__1; ++j) {
1845 i__2 = kll + kuu + 1;
1847 dscal_(&i__2, &d__1, &a[j * a_dim1 + 1], &c__1);
1848 i__2 = kll + kuu + 1;
1849 dscal_(&i__2, anorm, &a[j * a_dim1 + 1], &c__1);
1857 /* Scale straightforwardly */
1861 for (j = 1; j <= i__1; ++j) {
1862 d__1 = *anorm / onorm;
1863 dscal_(m, &d__1, &a[j * a_dim1 + 1], &c__1);
1867 } else if (ipack == 3 || ipack == 4) {
1869 i__1 = *n * (*n + 1) / 2;
1870 d__1 = *anorm / onorm;
1871 dscal_(&i__1, &d__1, &a[a_offset], &c__1);
1873 } else if (ipack >= 5) {
1876 for (j = 1; j <= i__1; ++j) {
1877 i__2 = kll + kuu + 1;
1878 d__1 = *anorm / onorm;
1879 dscal_(&i__2, &d__1, &a[j * a_dim1 + 1], &c__1);