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__1 = 1;
516 static real c_b22 = 0.f;
517 static logical c_true = TRUE_;
518 static logical c_false = FALSE_;
520 /* > \brief \b SLATMT */
522 /* =========== DOCUMENTATION =========== */
524 /* Online html documentation available at */
525 /* http://www.netlib.org/lapack/explore-html/ */
530 /* SUBROUTINE SLATMT( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, */
531 /* RANK, KL, KU, PACK, A, LDA, WORK, INFO ) */
533 /* REAL COND, DMAX */
534 /* INTEGER INFO, KL, KU, LDA, M, MODE, N, RANK */
535 /* CHARACTER DIST, PACK, SYM */
536 /* REAL A( LDA, * ), D( * ), WORK( * ) */
537 /* INTEGER ISEED( 4 ) */
540 /* > \par Purpose: */
545 /* > SLATMT generates random matrices with specified singular values */
546 /* > (or symmetric/hermitian with specified eigenvalues) */
547 /* > for testing LAPACK programs. */
549 /* > SLATMT operates by applying the following sequence of */
552 /* > Set the diagonal to D, where D may be input or */
553 /* > computed according to MODE, COND, DMAX, and SYM */
554 /* > as described below. */
556 /* > Generate a matrix with the appropriate band structure, by one */
557 /* > of two methods: */
560 /* > Generate a dense M x N matrix by multiplying D on the left */
561 /* > and the right by random unitary matrices, then: */
563 /* > Reduce the bandwidth according to KL and KU, using */
564 /* > Householder transformations. */
567 /* > Convert the bandwidth-0 (i.e., diagonal) matrix to a */
568 /* > bandwidth-1 matrix using Givens rotations, "chasing" */
569 /* > out-of-band elements back, much as in QR; then */
570 /* > convert the bandwidth-1 to a bandwidth-2 matrix, etc. */
571 /* > Note that for reasonably small bandwidths (relative to */
572 /* > M and N) this requires less storage, as a dense matrix */
573 /* > is not generated. Also, for symmetric matrices, only */
574 /* > one triangle is generated. */
576 /* > Method A is chosen if the bandwidth is a large fraction of the */
577 /* > order of the matrix, and LDA is at least M (so a dense */
578 /* > matrix can be stored.) Method B is chosen if the bandwidth */
579 /* > is small (< 1/2 N for symmetric, < .3 N+M for */
580 /* > non-symmetric), or LDA is less than M and not less than the */
583 /* > Pack the matrix if desired. Options specified by PACK are: */
585 /* > zero out upper half (if symmetric) */
586 /* > zero out lower half (if symmetric) */
587 /* > store the upper half columnwise (if symmetric or upper */
589 /* > store the lower half columnwise (if symmetric or lower */
591 /* > store the lower triangle in banded format (if symmetric */
592 /* > or lower triangular) */
593 /* > store the upper triangle in banded format (if symmetric */
594 /* > or upper triangular) */
595 /* > store the entire matrix in banded format */
596 /* > If Method B is chosen, and band format is specified, then the */
597 /* > matrix will be generated in the band format, so no repacking */
598 /* > will be necessary. */
607 /* > The number of rows of A. Not modified. */
613 /* > The number of columns of A. Not modified. */
616 /* > \param[in] DIST */
618 /* > DIST is CHARACTER*1 */
619 /* > On entry, DIST specifies the type of distribution to be used */
620 /* > to generate the random eigen-/singular values. */
621 /* > 'U' => UNIFORM( 0, 1 ) ( 'U' for uniform ) */
622 /* > 'S' => UNIFORM( -1, 1 ) ( 'S' for symmetric ) */
623 /* > 'N' => NORMAL( 0, 1 ) ( 'N' for normal ) */
624 /* > Not modified. */
627 /* > \param[in,out] ISEED */
629 /* > ISEED is INTEGER array, dimension ( 4 ) */
630 /* > On entry ISEED specifies the seed of the random number */
631 /* > generator. They should lie between 0 and 4095 inclusive, */
632 /* > and ISEED(4) should be odd. The random number generator */
633 /* > uses a linear congruential sequence limited to small */
634 /* > integers, and so should produce machine independent */
635 /* > random numbers. The values of ISEED are changed on */
636 /* > exit, and can be used in the next call to SLATMT */
637 /* > to continue the same random number sequence. */
638 /* > Changed on exit. */
641 /* > \param[in] SYM */
643 /* > SYM is CHARACTER*1 */
644 /* > If SYM='S' or 'H', the generated matrix is symmetric, with */
645 /* > eigenvalues specified by D, COND, MODE, and DMAX; they */
646 /* > may be positive, negative, or zero. */
647 /* > If SYM='P', the generated matrix is symmetric, with */
648 /* > eigenvalues (= singular values) specified by D, COND, */
649 /* > MODE, and DMAX; they will not be negative. */
650 /* > If SYM='N', the generated matrix is nonsymmetric, with */
651 /* > singular values specified by D, COND, MODE, and DMAX; */
652 /* > they will not be negative. */
653 /* > Not modified. */
656 /* > \param[in,out] D */
658 /* > D is REAL array, dimension ( MIN( M , N ) ) */
659 /* > This array is used to specify the singular values or */
660 /* > eigenvalues of A (see SYM, above.) If MODE=0, then D is */
661 /* > assumed to contain the singular/eigenvalues, otherwise */
662 /* > they will be computed according to MODE, COND, and DMAX, */
663 /* > and placed in D. */
664 /* > Modified if MODE is nonzero. */
667 /* > \param[in] MODE */
669 /* > MODE is INTEGER */
670 /* > On entry this describes how the singular/eigenvalues are to */
671 /* > be specified: */
672 /* > MODE = 0 means use D as input */
674 /* > MODE = 1 sets D(1)=1 and D(2:RANK)=1.0/COND */
675 /* > MODE = 2 sets D(1:RANK-1)=1 and D(RANK)=1.0/COND */
676 /* > MODE = 3 sets D(I)=COND**(-(I-1)/(RANK-1)) */
678 /* > MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */
679 /* > MODE = 5 sets D to random numbers in the range */
680 /* > ( 1/COND , 1 ) such that their logarithms */
681 /* > are uniformly distributed. */
682 /* > MODE = 6 set D to random numbers from same distribution */
683 /* > as the rest of the matrix. */
684 /* > MODE < 0 has the same meaning as ABS(MODE), except that */
685 /* > the order of the elements of D is reversed. */
686 /* > Thus if MODE is positive, D has entries ranging from */
687 /* > 1 to 1/COND, if negative, from 1/COND to 1, */
688 /* > If SYM='S' or 'H', and MODE is neither 0, 6, nor -6, then */
689 /* > the elements of D will also be multiplied by a random */
690 /* > sign (i.e., +1 or -1.) */
691 /* > Not modified. */
694 /* > \param[in] COND */
697 /* > On entry, this is used as described under MODE above. */
698 /* > If used, it must be >= 1. Not modified. */
701 /* > \param[in] DMAX */
704 /* > If MODE is neither -6, 0 nor 6, the contents of D, as */
705 /* > computed according to MODE and COND, will be scaled by */
706 /* > DMAX / f2cmax(abs(D(i))); thus, the maximum absolute eigen- or */
707 /* > singular value (which is to say the norm) will be abs(DMAX). */
708 /* > Note that DMAX need not be positive: if DMAX is negative */
709 /* > (or zero), D will be scaled by a negative number (or zero). */
710 /* > Not modified. */
713 /* > \param[in] RANK */
715 /* > RANK is INTEGER */
716 /* > The rank of matrix to be generated for modes 1,2,3 only. */
717 /* > D( RANK+1:N ) = 0. */
718 /* > Not modified. */
721 /* > \param[in] KL */
723 /* > KL is INTEGER */
724 /* > This specifies the lower bandwidth of the matrix. For */
725 /* > example, KL=0 implies upper triangular, KL=1 implies upper */
726 /* > Hessenberg, and KL being at least M-1 means that the matrix */
727 /* > has full lower bandwidth. KL must equal KU if the matrix */
728 /* > is symmetric. */
729 /* > Not modified. */
732 /* > \param[in] KU */
734 /* > KU is INTEGER */
735 /* > This specifies the upper bandwidth of the matrix. For */
736 /* > example, KU=0 implies lower triangular, KU=1 implies lower */
737 /* > Hessenberg, and KU being at least N-1 means that the matrix */
738 /* > has full upper bandwidth. KL must equal KU if the matrix */
739 /* > is symmetric. */
740 /* > Not modified. */
743 /* > \param[in] PACK */
745 /* > PACK is CHARACTER*1 */
746 /* > This specifies packing of matrix as follows: */
747 /* > 'N' => no packing */
748 /* > 'U' => zero out all subdiagonal entries (if symmetric) */
749 /* > 'L' => zero out all superdiagonal entries (if symmetric) */
750 /* > 'C' => store the upper triangle columnwise */
751 /* > (only if the matrix is symmetric or upper triangular) */
752 /* > 'R' => store the lower triangle columnwise */
753 /* > (only if the matrix is symmetric or lower triangular) */
754 /* > 'B' => store the lower triangle in band storage scheme */
755 /* > (only if matrix symmetric or lower triangular) */
756 /* > 'Q' => store the upper triangle in band storage scheme */
757 /* > (only if matrix symmetric or upper triangular) */
758 /* > 'Z' => store the entire matrix in band storage scheme */
759 /* > (pivoting can be provided for by using this */
760 /* > option to store A in the trailing rows of */
761 /* > the allocated storage) */
763 /* > Using these options, the various LAPACK packed and banded */
764 /* > storage schemes can be obtained: */
766 /* > PB, SB or TB - use 'B' or 'Q' */
767 /* > PP, SP or TP - use 'C' or 'R' */
769 /* > If two calls to SLATMT differ only in the PACK parameter, */
770 /* > they will generate mathematically equivalent matrices. */
771 /* > Not modified. */
774 /* > \param[in,out] A */
776 /* > A is REAL array, dimension ( LDA, N ) */
777 /* > On exit A is the desired test matrix. A is first generated */
778 /* > in full (unpacked) form, and then packed, if so specified */
779 /* > by PACK. Thus, the first M elements of the first N */
780 /* > columns will always be modified. If PACK specifies a */
781 /* > packed or banded storage scheme, all LDA elements of the */
782 /* > first N columns will be modified; the elements of the */
783 /* > array which do not correspond to elements of the generated */
784 /* > matrix are set to zero. */
788 /* > \param[in] LDA */
790 /* > LDA is INTEGER */
791 /* > LDA specifies the first dimension of A as declared in the */
792 /* > calling program. If PACK='N', 'U', 'L', 'C', or 'R', then */
793 /* > LDA must be at least M. If PACK='B' or 'Q', then LDA must */
794 /* > be at least MIN( KL, M-1) (which is equal to MIN(KU,N-1)). */
795 /* > If PACK='Z', LDA must be large enough to hold the packed */
796 /* > array: MIN( KU, N-1) + MIN( KL, M-1) + 1. */
797 /* > Not modified. */
800 /* > \param[out] WORK */
802 /* > WORK is REAL array, dimension ( 3*MAX( N , M ) ) */
807 /* > \param[out] INFO */
809 /* > INFO is INTEGER */
810 /* > Error code. On exit, INFO will be set to one of the */
811 /* > following values: */
812 /* > 0 => normal return */
813 /* > -1 => M negative or unequal to N and SYM='S', 'H', or 'P' */
814 /* > -2 => N negative */
815 /* > -3 => DIST illegal string */
816 /* > -5 => SYM illegal string */
817 /* > -7 => MODE not in range -6 to 6 */
818 /* > -8 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
819 /* > -10 => KL negative */
820 /* > -11 => KU negative, or SYM='S' or 'H' and KU not equal to KL */
821 /* > -12 => PACK illegal string, or PACK='U' or 'L', and SYM='N'; */
822 /* > or PACK='C' or 'Q' and SYM='N' and KL is not zero; */
823 /* > or PACK='R' or 'B' and SYM='N' and KU is not zero; */
824 /* > or PACK='U', 'L', 'C', 'R', 'B', or 'Q', and M is not */
826 /* > -14 => LDA is less than M, or PACK='Z' and LDA is less than */
827 /* > MIN(KU,N-1) + MIN(KL,M-1) + 1. */
828 /* > 1 => Error return from SLATM7 */
829 /* > 2 => Cannot scale to DMAX (f2cmax. sing. value is 0) */
830 /* > 3 => Error return from SLAGGE or SLAGSY */
836 /* > \author Univ. of Tennessee */
837 /* > \author Univ. of California Berkeley */
838 /* > \author Univ. of Colorado Denver */
839 /* > \author NAG Ltd. */
841 /* > \date December 2016 */
843 /* > \ingroup real_matgen */
845 /* ===================================================================== */
846 /* Subroutine */ int slatmt_(integer *m, integer *n, char *dist, integer *
847 iseed, char *sym, real *d__, integer *mode, real *cond, real *dmax__,
848 integer *rank, integer *kl, integer *ku, char *pack, real *a, integer
849 *lda, real *work, integer *info)
851 /* System generated locals */
852 integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
853 real r__1, r__2, r__3;
856 /* Local variables */
862 real s, alpha, angle;
863 integer ipack, ioffg;
864 extern logical lsame_(char *, char *);
866 extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *);
867 integer idist, mnmin, iskew;
869 extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *,
870 integer *), slatm7_(integer *, real *, integer *, integer *,
871 integer *, real *, integer *, integer *, integer *);
872 integer ic, jc, nc, il, iendch, ir, jr, ipackg, mr;
873 extern /* Subroutine */ int slagge_(integer *, integer *, integer *,
874 integer *, real *, real *, integer *, integer *, real *, integer *
877 extern /* Subroutine */ int xerbla_(char *, integer *);
878 extern real slarnd_(integer *, integer *);
879 integer ioffst, irsign;
880 logical givens, iltemp;
881 extern /* Subroutine */ int slartg_(real *, real *, real *, real *, real *
882 ), slaset_(char *, integer *, integer *, real *, real *, real *,
883 integer *), slagsy_(integer *, integer *, real *, real *,
884 integer *, integer *, real *, integer *), slarot_(logical *,
885 logical *, logical *, integer *, real *, real *, real *, integer *
887 logical ilextr, topdwn;
888 integer ir1, ir2, isympk, jch, llb, jkl, jku, uub;
891 /* -- LAPACK computational routine (version 3.7.0) -- */
892 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
893 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
897 /* ===================================================================== */
900 /* 1) Decode and Test the input parameters. */
901 /* Initialize flags & seed. */
903 /* Parameter adjustments */
907 a_offset = 1 + a_dim1 * 1;
914 /* Quick return if possible */
916 if (*m == 0 || *n == 0) {
922 if (lsame_(dist, "U")) {
924 } else if (lsame_(dist, "S")) {
926 } else if (lsame_(dist, "N")) {
934 if (lsame_(sym, "N")) {
937 } else if (lsame_(sym, "P")) {
940 } else if (lsame_(sym, "S")) {
943 } else if (lsame_(sym, "H")) {
953 if (lsame_(pack, "N")) {
955 } else if (lsame_(pack, "U")) {
958 } else if (lsame_(pack, "L")) {
961 } else if (lsame_(pack, "C")) {
964 } else if (lsame_(pack, "R")) {
967 } else if (lsame_(pack, "B")) {
970 } else if (lsame_(pack, "Q")) {
973 } else if (lsame_(pack, "Z")) {
979 /* Set certain internal parameters */
981 mnmin = f2cmin(*m,*n);
983 i__1 = *kl, i__2 = *m - 1;
984 llb = f2cmin(i__1,i__2);
986 i__1 = *ku, i__2 = *n - 1;
987 uub = f2cmin(i__1,i__2);
989 i__1 = *m, i__2 = *n + llb;
990 mr = f2cmin(i__1,i__2);
992 i__1 = *n, i__2 = *m + uub;
993 nc = f2cmin(i__1,i__2);
995 if (ipack == 5 || ipack == 6) {
997 } else if (ipack == 7) {
998 minlda = llb + uub + 1;
1003 /* Use Givens rotation method if bandwidth small enough, */
1004 /* or if LDA is too small to store the matrix unpacked. */
1009 i__1 = 1, i__2 = mr + nc;
1010 if ((real) (llb + uub) < (real) f2cmax(i__1,i__2) * .3f) {
1014 if (llb << 1 < *m) {
1018 if (*lda < *m && *lda >= minlda) {
1022 /* Set INFO if an error */
1026 } else if (*m != *n && isym != 1) {
1028 } else if (*n < 0) {
1030 } else if (idist == -1) {
1032 } else if (isym == -1) {
1034 } else if (abs(*mode) > 6) {
1036 } else if (*mode != 0 && abs(*mode) != 6 && *cond < 1.f) {
1038 } else if (*kl < 0) {
1040 } else if (*ku < 0 || isym != 1 && *kl != *ku) {
1042 } else if (ipack == -1 || isympk == 1 && isym == 1 || isympk == 2 && isym
1043 == 1 && *kl > 0 || isympk == 3 && isym == 1 && *ku > 0 || isympk
1046 } else if (*lda < f2cmax(1,minlda)) {
1052 xerbla_("SLATMT", &i__1);
1056 /* Initialize random number generator */
1058 for (i__ = 1; i__ <= 4; ++i__) {
1059 iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
1063 if (iseed[4] % 2 != 1) {
1067 /* 2) Set up D if indicated. */
1069 /* Compute D according to COND and MODE */
1071 slatm7_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, rank, &
1078 /* Choose Top-Down if D is (apparently) increasing, */
1079 /* Bottom-Up if D is (apparently) decreasing. */
1081 if (abs(d__[1]) <= (r__1 = d__[*rank], abs(r__1))) {
1087 if (*mode != 0 && abs(*mode) != 6) {
1093 for (i__ = 2; i__ <= i__1; ++i__) {
1095 r__2 = temp, r__3 = (r__1 = d__[i__], abs(r__1));
1096 temp = f2cmax(r__2,r__3);
1101 alpha = *dmax__ / temp;
1107 sscal_(rank, &alpha, &d__[1], &c__1);
1111 /* 3) Generate Banded Matrix using Givens rotations. */
1112 /* Also the special case of UUB=LLB=0 */
1114 /* Compute Addressing constants to cover all */
1115 /* storage formats. Whether GE, SY, GB, or SB, */
1116 /* upper or lower triangle or both, */
1117 /* the (i,j)-th element is in */
1118 /* A( i - ISKEW*j + IOFFST, j ) */
1134 /* IPACKG is the format that the matrix is generated in. If this is */
1135 /* different from IPACK, then the matrix must be repacked at the */
1136 /* end. It also signals how to compute the norm, for scaling. */
1139 slaset_("Full", lda, n, &c_b22, &c_b22, &a[a_offset], lda);
1141 /* Diagonal Matrix -- We are done, unless it */
1142 /* is to be stored SP/PP/TP (PACK='R' or 'C') */
1144 if (llb == 0 && uub == 0) {
1146 scopy_(&mnmin, &d__[1], &c__1, &a[1 - iskew + ioffst + a_dim1], &i__1)
1148 if (ipack <= 2 || ipack >= 5) {
1152 } else if (givens) {
1154 /* Check whether to use Givens rotations, */
1155 /* Householder transformations, or nothing. */
1159 /* Non-symmetric -- A = U D V */
1168 scopy_(&mnmin, &d__[1], &c__1, &a[1 - iskew + ioffst + a_dim1], &
1174 for (jku = 1; jku <= i__1; ++jku) {
1176 /* Transform from bandwidth JKL, JKU-1 to JKL, JKU */
1178 /* Last row actually rotated is M */
1179 /* Last column actually rotated is MIN( M+JKU, N ) */
1183 i__2 = f2cmin(i__3,*n) + jkl - 1;
1184 for (jr = 1; jr <= i__2; ++jr) {
1186 angle = slarnd_(&c__1, &iseed[1]) *
1187 6.2831853071795864769252867663f;
1191 i__3 = 1, i__4 = jr - jkl;
1192 icol = f2cmax(i__3,i__4);
1195 i__3 = *n, i__4 = jr + jku;
1196 il = f2cmin(i__3,i__4) + 1 - icol;
1198 slarot_(&c_true, &L__1, &c_false, &il, &c__, &s, &
1199 a[jr - iskew * icol + ioffst + icol *
1200 a_dim1], &ilda, &extra, &dummy);
1203 /* Chase "EXTRA" back up */
1208 for (jch = jr - jkl; i__3 < 0 ? jch >= 1 : jch <= 1;
1211 slartg_(&a[ir + 1 - iskew * (ic + 1) + ioffst
1212 + (ic + 1) * a_dim1], &extra, &c__, &
1216 i__4 = 1, i__5 = jch - jku;
1217 irow = f2cmax(i__4,i__5);
1222 slarot_(&c_false, &iltemp, &c_true, &il, &c__, &
1223 r__1, &a[irow - iskew * ic + ioffst + ic *
1224 a_dim1], &ilda, &temp, &extra);
1226 slartg_(&a[irow + 1 - iskew * (ic + 1) +
1227 ioffst + (ic + 1) * a_dim1], &temp, &
1230 i__4 = 1, i__5 = jch - jku - jkl;
1231 icol = f2cmax(i__4,i__5);
1234 L__1 = jch > jku + jkl;
1236 slarot_(&c_true, &L__1, &c_true, &il, &c__, &
1237 r__1, &a[irow - iskew * icol + ioffst
1238 + icol * a_dim1], &ilda, &extra, &
1252 for (jkl = 1; jkl <= i__1; ++jkl) {
1254 /* Transform from bandwidth JKL-1, JKU to JKL, JKU */
1258 i__2 = f2cmin(i__3,*m) + jku - 1;
1259 for (jc = 1; jc <= i__2; ++jc) {
1261 angle = slarnd_(&c__1, &iseed[1]) *
1262 6.2831853071795864769252867663f;
1266 i__3 = 1, i__4 = jc - jku;
1267 irow = f2cmax(i__3,i__4);
1270 i__3 = *m, i__4 = jc + jkl;
1271 il = f2cmin(i__3,i__4) + 1 - irow;
1273 slarot_(&c_false, &L__1, &c_false, &il, &c__, &s,
1274 &a[irow - iskew * jc + ioffst + jc *
1275 a_dim1], &ilda, &extra, &dummy);
1278 /* Chase "EXTRA" back up */
1283 for (jch = jc - jku; i__3 < 0 ? jch >= 1 : jch <= 1;
1286 slartg_(&a[ir + 1 - iskew * (ic + 1) + ioffst
1287 + (ic + 1) * a_dim1], &extra, &c__, &
1291 i__4 = 1, i__5 = jch - jkl;
1292 icol = f2cmax(i__4,i__5);
1297 slarot_(&c_true, &iltemp, &c_true, &il, &c__, &
1298 r__1, &a[ir - iskew * icol + ioffst +
1299 icol * a_dim1], &ilda, &temp, &extra);
1301 slartg_(&a[ir + 1 - iskew * (icol + 1) +
1302 ioffst + (icol + 1) * a_dim1], &temp,
1305 i__4 = 1, i__5 = jch - jkl - jku;
1306 irow = f2cmax(i__4,i__5);
1309 L__1 = jch > jkl + jku;
1311 slarot_(&c_false, &L__1, &c_true, &il, &c__, &
1312 r__1, &a[irow - iskew * icol + ioffst
1313 + icol * a_dim1], &ilda, &extra, &
1327 /* Bottom-Up -- Start at the bottom right. */
1331 for (jku = 1; jku <= i__1; ++jku) {
1333 /* Transform from bandwidth JKL, JKU-1 to JKL, JKU */
1335 /* First row actually rotated is M */
1336 /* First column actually rotated is MIN( M+JKU, N ) */
1339 i__2 = *m, i__3 = *n + jkl;
1340 iendch = f2cmin(i__2,i__3) - 1;
1344 for (jc = f2cmin(i__2,*n) - 1; jc >= i__3; --jc) {
1346 angle = slarnd_(&c__1, &iseed[1]) *
1347 6.2831853071795864769252867663f;
1351 i__2 = 1, i__4 = jc - jku + 1;
1352 irow = f2cmax(i__2,i__4);
1355 i__2 = *m, i__4 = jc + jkl + 1;
1356 il = f2cmin(i__2,i__4) + 1 - irow;
1357 L__1 = jc + jkl < *m;
1358 slarot_(&c_false, &c_false, &L__1, &il, &c__, &s,
1359 &a[irow - iskew * jc + ioffst + jc *
1360 a_dim1], &ilda, &dummy, &extra);
1363 /* Chase "EXTRA" back down */
1368 for (jch = jc + jkl; i__4 < 0 ? jch >= i__2 : jch <=
1369 i__2; jch += i__4) {
1372 slartg_(&a[jch - iskew * ic + ioffst + ic *
1373 a_dim1], &extra, &c__, &s, &dummy);
1377 i__5 = *n - 1, i__6 = jch + jku;
1378 icol = f2cmin(i__5,i__6);
1379 iltemp = jch + jku < *n;
1381 i__5 = icol + 2 - ic;
1382 slarot_(&c_true, &ilextr, &iltemp, &i__5, &c__, &
1383 s, &a[jch - iskew * ic + ioffst + ic *
1384 a_dim1], &ilda, &extra, &temp);
1386 slartg_(&a[jch - iskew * icol + ioffst + icol
1387 * a_dim1], &temp, &c__, &s, &dummy);
1389 i__5 = iendch, i__6 = jch + jkl + jku;
1390 il = f2cmin(i__5,i__6) + 2 - jch;
1392 L__1 = jch + jkl + jku <= iendch;
1393 slarot_(&c_false, &c_true, &L__1, &il, &c__, &
1394 s, &a[jch - iskew * icol + ioffst +
1395 icol * a_dim1], &ilda, &temp, &extra);
1407 for (jkl = 1; jkl <= i__1; ++jkl) {
1409 /* Transform from bandwidth JKL-1, JKU to JKL, JKU */
1411 /* First row actually rotated is MIN( N+JKL, M ) */
1412 /* First column actually rotated is N */
1415 i__3 = *n, i__4 = *m + jku;
1416 iendch = f2cmin(i__3,i__4) - 1;
1420 for (jr = f2cmin(i__3,*m) - 1; jr >= i__4; --jr) {
1422 angle = slarnd_(&c__1, &iseed[1]) *
1423 6.2831853071795864769252867663f;
1427 i__3 = 1, i__2 = jr - jkl + 1;
1428 icol = f2cmax(i__3,i__2);
1431 i__3 = *n, i__2 = jr + jku + 1;
1432 il = f2cmin(i__3,i__2) + 1 - icol;
1433 L__1 = jr + jku < *n;
1434 slarot_(&c_true, &c_false, &L__1, &il, &c__, &s, &
1435 a[jr - iskew * icol + ioffst + icol *
1436 a_dim1], &ilda, &dummy, &extra);
1439 /* Chase "EXTRA" back down */
1444 for (jch = jr + jku; i__2 < 0 ? jch >= i__3 : jch <=
1445 i__3; jch += i__2) {
1448 slartg_(&a[ir - iskew * jch + ioffst + jch *
1449 a_dim1], &extra, &c__, &s, &dummy);
1453 i__5 = *m - 1, i__6 = jch + jkl;
1454 irow = f2cmin(i__5,i__6);
1455 iltemp = jch + jkl < *m;
1457 i__5 = irow + 2 - ir;
1458 slarot_(&c_false, &ilextr, &iltemp, &i__5, &c__, &
1459 s, &a[ir - iskew * jch + ioffst + jch *
1460 a_dim1], &ilda, &extra, &temp);
1462 slartg_(&a[irow - iskew * jch + ioffst + jch *
1463 a_dim1], &temp, &c__, &s, &dummy);
1465 i__5 = iendch, i__6 = jch + jkl + jku;
1466 il = f2cmin(i__5,i__6) + 2 - jch;
1468 L__1 = jch + jkl + jku <= iendch;
1469 slarot_(&c_true, &c_true, &L__1, &il, &c__, &
1470 s, &a[irow - iskew * jch + ioffst +
1471 jch * a_dim1], &ilda, &temp, &extra);
1484 /* Symmetric -- A = U D U' */
1491 /* Top-Down -- Generate Upper triangle only */
1500 scopy_(&mnmin, &d__[1], &c__1, &a[1 - iskew + ioffg + a_dim1],
1504 for (k = 1; k <= i__1; ++k) {
1506 for (jc = 1; jc <= i__4; ++jc) {
1508 i__2 = 1, i__3 = jc - k;
1509 irow = f2cmax(i__2,i__3);
1511 i__2 = jc + 1, i__3 = k + 2;
1512 il = f2cmin(i__2,i__3);
1514 temp = a[jc - iskew * (jc + 1) + ioffg + (jc + 1) *
1516 angle = slarnd_(&c__1, &iseed[1]) *
1517 6.2831853071795864769252867663f;
1521 slarot_(&c_false, &L__1, &c_true, &il, &c__, &s, &a[
1522 irow - iskew * jc + ioffg + jc * a_dim1], &
1523 ilda, &extra, &temp);
1525 i__3 = k, i__5 = *n - jc;
1526 i__2 = f2cmin(i__3,i__5) + 1;
1527 slarot_(&c_true, &c_true, &c_false, &i__2, &c__, &s, &
1528 a[(1 - iskew) * jc + ioffg + jc * a_dim1], &
1529 ilda, &temp, &dummy);
1531 /* Chase EXTRA back up the matrix */
1535 for (jch = jc - k; i__2 < 0 ? jch >= 1 : jch <= 1;
1537 slartg_(&a[jch + 1 - iskew * (icol + 1) + ioffg +
1538 (icol + 1) * a_dim1], &extra, &c__, &s, &
1540 temp = a[jch - iskew * (jch + 1) + ioffg + (jch +
1544 slarot_(&c_true, &c_true, &c_true, &i__3, &c__, &
1545 r__1, &a[(1 - iskew) * jch + ioffg + jch *
1546 a_dim1], &ilda, &temp, &extra);
1548 i__3 = 1, i__5 = jch - k;
1549 irow = f2cmax(i__3,i__5);
1551 i__3 = jch + 1, i__5 = k + 2;
1552 il = f2cmin(i__3,i__5);
1556 slarot_(&c_false, &L__1, &c_true, &il, &c__, &
1557 r__1, &a[irow - iskew * jch + ioffg + jch
1558 * a_dim1], &ilda, &extra, &temp);
1567 /* If we need lower triangle, copy from upper. Note that */
1568 /* the order of copying is chosen to work for 'q' -> 'b' */
1570 if (ipack != ipackg && ipack != 3) {
1572 for (jc = 1; jc <= i__1; ++jc) {
1573 irow = ioffst - iskew * jc;
1575 i__2 = *n, i__3 = jc + uub;
1576 i__4 = f2cmin(i__2,i__3);
1577 for (jr = jc; jr <= i__4; ++jr) {
1578 a[jr + irow + jc * a_dim1] = a[jc - iskew * jr +
1579 ioffg + jr * a_dim1];
1586 for (jc = *n - uub + 1; jc <= i__1; ++jc) {
1588 for (jr = *n + 2 - jc; jr <= i__4; ++jr) {
1589 a[jr + jc * a_dim1] = 0.f;
1603 /* Bottom-Up -- Generate Lower triangle only */
1614 scopy_(&mnmin, &d__[1], &c__1, &a[1 - iskew + ioffg + a_dim1],
1618 for (k = 1; k <= i__1; ++k) {
1619 for (jc = *n - 1; jc >= 1; --jc) {
1621 i__4 = *n + 1 - jc, i__2 = k + 2;
1622 il = f2cmin(i__4,i__2);
1624 temp = a[(1 - iskew) * jc + 1 + ioffg + jc * a_dim1];
1625 angle = slarnd_(&c__1, &iseed[1]) *
1626 6.2831853071795864769252867663f;
1630 slarot_(&c_false, &c_true, &L__1, &il, &c__, &s, &a[(
1631 1 - iskew) * jc + ioffg + jc * a_dim1], &ilda,
1634 i__4 = 1, i__2 = jc - k + 1;
1635 icol = f2cmax(i__4,i__2);
1636 i__4 = jc + 2 - icol;
1637 slarot_(&c_true, &c_false, &c_true, &i__4, &c__, &s, &
1638 a[jc - iskew * icol + ioffg + icol * a_dim1],
1639 &ilda, &dummy, &temp);
1641 /* Chase EXTRA back down the matrix */
1646 for (jch = jc + k; i__2 < 0 ? jch >= i__4 : jch <=
1647 i__4; jch += i__2) {
1648 slartg_(&a[jch - iskew * icol + ioffg + icol *
1649 a_dim1], &extra, &c__, &s, &dummy);
1650 temp = a[(1 - iskew) * jch + 1 + ioffg + jch *
1653 slarot_(&c_true, &c_true, &c_true, &i__3, &c__, &
1654 s, &a[jch - iskew * icol + ioffg + icol *
1655 a_dim1], &ilda, &extra, &temp);
1657 i__3 = *n + 1 - jch, i__5 = k + 2;
1658 il = f2cmin(i__3,i__5);
1660 L__1 = *n - jch > k;
1661 slarot_(&c_false, &c_true, &L__1, &il, &c__, &s, &
1662 a[(1 - iskew) * jch + ioffg + jch *
1663 a_dim1], &ilda, &temp, &extra);
1672 /* If we need upper triangle, copy from lower. Note that */
1673 /* the order of copying is chosen to work for 'b' -> 'q' */
1675 if (ipack != ipackg && ipack != 4) {
1676 for (jc = *n; jc >= 1; --jc) {
1677 irow = ioffst - iskew * jc;
1679 i__2 = 1, i__4 = jc - uub;
1680 i__1 = f2cmax(i__2,i__4);
1681 for (jr = jc; jr >= i__1; --jr) {
1682 a[jr + irow + jc * a_dim1] = a[jc - iskew * jr +
1683 ioffg + jr * a_dim1];
1690 for (jc = 1; jc <= i__1; ++jc) {
1691 i__2 = uub + 1 - jc;
1692 for (jr = 1; jr <= i__2; ++jr) {
1693 a[jr + jc * a_dim1] = 0.f;
1710 /* 4) Generate Banded Matrix by first */
1711 /* Rotating by random Unitary matrices, */
1712 /* then reducing the bandwidth using Householder */
1713 /* transformations. */
1715 /* Note: we should get here only if LDA .ge. N */
1719 /* Non-symmetric -- A = U D V */
1721 slagge_(&mr, &nc, &llb, &uub, &d__[1], &a[a_offset], lda, &iseed[
1722 1], &work[1], &iinfo);
1725 /* Symmetric -- A = U D U' */
1727 slagsy_(m, &llb, &d__[1], &a[a_offset], lda, &iseed[1], &work[1],
1737 /* 5) Pack the matrix */
1739 if (ipack != ipackg) {
1742 /* 'U' -- Upper triangular, not packed */
1745 for (j = 1; j <= i__1; ++j) {
1747 for (i__ = j + 1; i__ <= i__2; ++i__) {
1748 a[i__ + j * a_dim1] = 0.f;
1754 } else if (ipack == 2) {
1756 /* 'L' -- Lower triangular, not packed */
1759 for (j = 2; j <= i__1; ++j) {
1761 for (i__ = 1; i__ <= i__2; ++i__) {
1762 a[i__ + j * a_dim1] = 0.f;
1768 } else if (ipack == 3) {
1770 /* 'C' -- Upper triangle packed Columnwise. */
1775 for (j = 1; j <= i__1; ++j) {
1777 for (i__ = 1; i__ <= i__2; ++i__) {
1783 a[irow + icol * a_dim1] = a[i__ + j * a_dim1];
1789 } else if (ipack == 4) {
1791 /* 'R' -- Lower triangle packed Columnwise. */
1796 for (j = 1; j <= i__1; ++j) {
1798 for (i__ = j; i__ <= i__2; ++i__) {
1804 a[irow + icol * a_dim1] = a[i__ + j * a_dim1];
1810 } else if (ipack >= 5) {
1812 /* 'B' -- The lower triangle is packed as a band matrix. */
1813 /* 'Q' -- The upper triangle is packed as a band matrix. */
1814 /* 'Z' -- The whole matrix is packed as a band matrix. */
1824 for (j = 1; j <= i__1; ++j) {
1827 for (i__ = f2cmin(i__2,*m); i__ >= 1; --i__) {
1828 a[i__ - j + uub + 1 + j * a_dim1] = a[i__ + j * a_dim1];
1835 for (j = uub + 2; j <= i__1; ++j) {
1838 i__2 = f2cmin(i__4,*m);
1839 for (i__ = j - uub; i__ <= i__2; ++i__) {
1840 a[i__ - j + uub + 1 + j * a_dim1] = a[i__ + j * a_dim1];
1847 /* If packed, zero out extraneous elements. */
1849 /* Symmetric/Triangular Packed -- */
1850 /* zero out everything after A(IROW,ICOL) */
1852 if (ipack == 3 || ipack == 4) {
1854 for (jc = icol; jc <= i__1; ++jc) {
1856 for (jr = irow + 1; jr <= i__2; ++jr) {
1857 a[jr + jc * a_dim1] = 0.f;
1864 } else if (ipack >= 5) {
1866 /* Packed Band -- */
1867 /* 1st row is now in A( UUB+2-j, j), zero above it */
1868 /* m-th row is now in A( M+UUB-j,j), zero below it */
1869 /* last non-zero diagonal is now in A( UUB+LLB+1,j ), */
1870 /* zero below it, too. */
1872 ir1 = uub + llb + 2;
1875 for (jc = 1; jc <= i__1; ++jc) {
1876 i__2 = uub + 1 - jc;
1877 for (jr = 1; jr <= i__2; ++jr) {
1878 a[jr + jc * a_dim1] = 0.f;
1883 i__3 = ir1, i__5 = ir2 - jc;
1884 i__2 = 1, i__4 = f2cmin(i__3,i__5);
1886 for (jr = f2cmax(i__2,i__4); jr <= i__6; ++jr) {
1887 a[jr + jc * a_dim1] = 0.f;