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]/Cd(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)
514 /* Table of constant values */
516 static doublecomplex c_b1 = {0.,0.};
517 static integer c__1 = 1;
518 static integer c__5 = 5;
519 static logical c_true = TRUE_;
520 static logical c_false = FALSE_;
522 /* > \brief \b ZLATMT */
524 /* =========== DOCUMENTATION =========== */
526 /* Online html documentation available at */
527 /* http://www.netlib.org/lapack/explore-html/ */
532 /* SUBROUTINE ZLATMT( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, */
533 /* RANK, KL, KU, PACK, A, LDA, WORK, INFO ) */
535 /* DOUBLE PRECISION COND, DMAX */
536 /* INTEGER INFO, KL, KU, LDA, M, MODE, N, RANK */
537 /* CHARACTER DIST, PACK, SYM */
538 /* COMPLEX*16 A( LDA, * ), WORK( * ) */
539 /* DOUBLE PRECISION D( * ) */
540 /* INTEGER ISEED( 4 ) */
543 /* > \par Purpose: */
548 /* > ZLATMT generates random matrices with specified singular values */
549 /* > (or hermitian with specified eigenvalues) */
550 /* > for testing LAPACK programs. */
552 /* > ZLATMT operates by applying the following sequence of */
555 /* > Set the diagonal to D, where D may be input or */
556 /* > computed according to MODE, COND, DMAX, and SYM */
557 /* > as described below. */
559 /* > Generate a matrix with the appropriate band structure, by one */
560 /* > of two methods: */
563 /* > Generate a dense M x N matrix by multiplying D on the left */
564 /* > and the right by random unitary matrices, then: */
566 /* > Reduce the bandwidth according to KL and KU, using */
567 /* > Householder transformations. */
570 /* > Convert the bandwidth-0 (i.e., diagonal) matrix to a */
571 /* > bandwidth-1 matrix using Givens rotations, "chasing" */
572 /* > out-of-band elements back, much as in QR; then convert */
573 /* > the bandwidth-1 to a bandwidth-2 matrix, etc. Note */
574 /* > that for reasonably small bandwidths (relative to M and */
575 /* > N) this requires less storage, as a dense matrix is not */
576 /* > generated. Also, for hermitian or symmetric matrices, */
577 /* > only one triangle is generated. */
579 /* > Method A is chosen if the bandwidth is a large fraction of the */
580 /* > order of the matrix, and LDA is at least M (so a dense */
581 /* > matrix can be stored.) Method B is chosen if the bandwidth */
582 /* > is small (< 1/2 N for hermitian or symmetric, < .3 N+M for */
583 /* > non-symmetric), or LDA is less than M and not less than the */
586 /* > Pack the matrix if desired. Options specified by PACK are: */
588 /* > zero out upper half (if hermitian) */
589 /* > zero out lower half (if hermitian) */
590 /* > store the upper half columnwise (if hermitian or upper */
592 /* > store the lower half columnwise (if hermitian or lower */
594 /* > store the lower triangle in banded format (if hermitian or */
595 /* > lower triangular) */
596 /* > store the upper triangle in banded format (if hermitian or */
597 /* > upper triangular) */
598 /* > store the entire matrix in banded format */
599 /* > If Method B is chosen, and band format is specified, then the */
600 /* > matrix will be generated in the band format, so no repacking */
601 /* > will be necessary. */
610 /* > The number of rows of A. Not modified. */
616 /* > The number of columns of A. N must equal M if the matrix */
617 /* > is symmetric or hermitian (i.e., if SYM is not 'N') */
618 /* > Not modified. */
621 /* > \param[in] DIST */
623 /* > DIST is CHARACTER*1 */
624 /* > On entry, DIST specifies the type of distribution to be used */
625 /* > to generate the random eigen-/singular values. */
626 /* > 'U' => UNIFORM( 0, 1 ) ( 'U' for uniform ) */
627 /* > 'S' => UNIFORM( -1, 1 ) ( 'S' for symmetric ) */
628 /* > 'N' => NORMAL( 0, 1 ) ( 'N' for normal ) */
629 /* > Not modified. */
632 /* > \param[in,out] ISEED */
634 /* > ISEED is INTEGER array, dimension ( 4 ) */
635 /* > On entry ISEED specifies the seed of the random number */
636 /* > generator. They should lie between 0 and 4095 inclusive, */
637 /* > and ISEED(4) should be odd. The random number generator */
638 /* > uses a linear congruential sequence limited to small */
639 /* > integers, and so should produce machine independent */
640 /* > random numbers. The values of ISEED are changed on */
641 /* > exit, and can be used in the next call to ZLATMT */
642 /* > to continue the same random number sequence. */
643 /* > Changed on exit. */
646 /* > \param[in] SYM */
648 /* > SYM is CHARACTER*1 */
649 /* > If SYM='H', the generated matrix is hermitian, with */
650 /* > eigenvalues specified by D, COND, MODE, and DMAX; they */
651 /* > may be positive, negative, or zero. */
652 /* > If SYM='P', the generated matrix is hermitian, with */
653 /* > eigenvalues (= singular values) specified by D, COND, */
654 /* > MODE, and DMAX; they will not be negative. */
655 /* > If SYM='N', the generated matrix is nonsymmetric, with */
656 /* > singular values specified by D, COND, MODE, and DMAX; */
657 /* > they will not be negative. */
658 /* > If SYM='S', the generated matrix is (complex) symmetric, */
659 /* > with singular values specified by D, COND, MODE, and */
660 /* > DMAX; they will not be negative. */
661 /* > Not modified. */
664 /* > \param[in,out] D */
666 /* > D is DOUBLE PRECISION array, dimension ( MIN( M, N ) ) */
667 /* > This array is used to specify the singular values or */
668 /* > eigenvalues of A (see SYM, above.) If MODE=0, then D is */
669 /* > assumed to contain the singular/eigenvalues, otherwise */
670 /* > they will be computed according to MODE, COND, and DMAX, */
671 /* > and placed in D. */
672 /* > Modified if MODE is nonzero. */
675 /* > \param[in] MODE */
677 /* > MODE is INTEGER */
678 /* > On entry this describes how the singular/eigenvalues are to */
679 /* > be specified: */
680 /* > MODE = 0 means use D as input */
681 /* > MODE = 1 sets D(1)=1 and D(2:RANK)=1.0/COND */
682 /* > MODE = 2 sets D(1:RANK-1)=1 and D(RANK)=1.0/COND */
683 /* > MODE = 3 sets D(I)=COND**(-(I-1)/(RANK-1)) */
684 /* > MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */
685 /* > MODE = 5 sets D to random numbers in the range */
686 /* > ( 1/COND , 1 ) such that their logarithms */
687 /* > are uniformly distributed. */
688 /* > MODE = 6 set D to random numbers from same distribution */
689 /* > as the rest of the matrix. */
690 /* > MODE < 0 has the same meaning as ABS(MODE), except that */
691 /* > the order of the elements of D is reversed. */
692 /* > Thus if MODE is positive, D has entries ranging from */
693 /* > 1 to 1/COND, if negative, from 1/COND to 1, */
694 /* > If SYM='H', and MODE is neither 0, 6, nor -6, then */
695 /* > the elements of D will also be multiplied by a random */
696 /* > sign (i.e., +1 or -1.) */
697 /* > Not modified. */
700 /* > \param[in] COND */
702 /* > COND is DOUBLE PRECISION */
703 /* > On entry, this is used as described under MODE above. */
704 /* > If used, it must be >= 1. Not modified. */
707 /* > \param[in] DMAX */
709 /* > DMAX is DOUBLE PRECISION */
710 /* > If MODE is neither -6, 0 nor 6, the contents of D, as */
711 /* > computed according to MODE and COND, will be scaled by */
712 /* > DMAX / f2cmax(abs(D(i))); thus, the maximum absolute eigen- or */
713 /* > singular value (which is to say the norm) will be abs(DMAX). */
714 /* > Note that DMAX need not be positive: if DMAX is negative */
715 /* > (or zero), D will be scaled by a negative number (or zero). */
716 /* > Not modified. */
719 /* > \param[in] RANK */
721 /* > RANK is INTEGER */
722 /* > The rank of matrix to be generated for modes 1,2,3 only. */
723 /* > D( RANK+1:N ) = 0. */
724 /* > Not modified. */
727 /* > \param[in] KL */
729 /* > KL is INTEGER */
730 /* > This specifies the lower bandwidth of the matrix. For */
731 /* > example, KL=0 implies upper triangular, KL=1 implies upper */
732 /* > Hessenberg, and KL being at least M-1 means that the matrix */
733 /* > has full lower bandwidth. KL must equal KU if the matrix */
734 /* > is symmetric or hermitian. */
735 /* > Not modified. */
738 /* > \param[in] KU */
740 /* > KU is INTEGER */
741 /* > This specifies the upper bandwidth of the matrix. For */
742 /* > example, KU=0 implies lower triangular, KU=1 implies lower */
743 /* > Hessenberg, and KU being at least N-1 means that the matrix */
744 /* > has full upper bandwidth. KL must equal KU if the matrix */
745 /* > is symmetric or hermitian. */
746 /* > Not modified. */
749 /* > \param[in] PACK */
751 /* > PACK is CHARACTER*1 */
752 /* > This specifies packing of matrix as follows: */
753 /* > 'N' => no packing */
754 /* > 'U' => zero out all subdiagonal entries (if symmetric */
755 /* > or hermitian) */
756 /* > 'L' => zero out all superdiagonal entries (if symmetric */
757 /* > or hermitian) */
758 /* > 'C' => store the upper triangle columnwise (only if the */
759 /* > matrix is symmetric, hermitian, or upper triangular) */
760 /* > 'R' => store the lower triangle columnwise (only if the */
761 /* > matrix is symmetric, hermitian, or lower triangular) */
762 /* > 'B' => store the lower triangle in band storage scheme */
763 /* > (only if the matrix is symmetric, hermitian, or */
764 /* > lower triangular) */
765 /* > 'Q' => store the upper triangle in band storage scheme */
766 /* > (only if the matrix is symmetric, hermitian, or */
767 /* > upper triangular) */
768 /* > 'Z' => store the entire matrix in band storage scheme */
769 /* > (pivoting can be provided for by using this */
770 /* > option to store A in the trailing rows of */
771 /* > the allocated storage) */
773 /* > Using these options, the various LAPACK packed and banded */
774 /* > storage schemes can be obtained: */
776 /* > PB, SB, HB, or TB - use 'B' or 'Q' */
777 /* > PP, SP, HB, or TP - use 'C' or 'R' */
779 /* > If two calls to ZLATMT differ only in the PACK parameter, */
780 /* > they will generate mathematically equivalent matrices. */
781 /* > Not modified. */
784 /* > \param[in,out] A */
786 /* > A is COMPLEX*16 array, dimension ( LDA, N ) */
787 /* > On exit A is the desired test matrix. A is first generated */
788 /* > in full (unpacked) form, and then packed, if so specified */
789 /* > by PACK. Thus, the first M elements of the first N */
790 /* > columns will always be modified. If PACK specifies a */
791 /* > packed or banded storage scheme, all LDA elements of the */
792 /* > first N columns will be modified; the elements of the */
793 /* > array which do not correspond to elements of the generated */
794 /* > matrix are set to zero. */
798 /* > \param[in] LDA */
800 /* > LDA is INTEGER */
801 /* > LDA specifies the first dimension of A as declared in the */
802 /* > calling program. If PACK='N', 'U', 'L', 'C', or 'R', then */
803 /* > LDA must be at least M. If PACK='B' or 'Q', then LDA must */
804 /* > be at least MIN( KL, M-1) (which is equal to MIN(KU,N-1)). */
805 /* > If PACK='Z', LDA must be large enough to hold the packed */
806 /* > array: MIN( KU, N-1) + MIN( KL, M-1) + 1. */
807 /* > Not modified. */
810 /* > \param[out] WORK */
812 /* > WORK is COMPLEX*16 array, dimension ( 3*MAX( N, M ) ) */
817 /* > \param[out] INFO */
819 /* > INFO is INTEGER */
820 /* > Error code. On exit, INFO will be set to one of the */
821 /* > following values: */
822 /* > 0 => normal return */
823 /* > -1 => M negative or unequal to N and SYM='S', 'H', or 'P' */
824 /* > -2 => N negative */
825 /* > -3 => DIST illegal string */
826 /* > -5 => SYM illegal string */
827 /* > -7 => MODE not in range -6 to 6 */
828 /* > -8 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
829 /* > -10 => KL negative */
830 /* > -11 => KU negative, or SYM is not 'N' and KU is not equal to */
832 /* > -12 => PACK illegal string, or PACK='U' or 'L', and SYM='N'; */
833 /* > or PACK='C' or 'Q' and SYM='N' and KL is not zero; */
834 /* > or PACK='R' or 'B' and SYM='N' and KU is not zero; */
835 /* > or PACK='U', 'L', 'C', 'R', 'B', or 'Q', and M is not */
837 /* > -14 => LDA is less than M, or PACK='Z' and LDA is less than */
838 /* > MIN(KU,N-1) + MIN(KL,M-1) + 1. */
839 /* > 1 => Error return from DLATM7 */
840 /* > 2 => Cannot scale to DMAX (f2cmax. sing. value is 0) */
841 /* > 3 => Error return from ZLAGGE, ZLAGHE or ZLAGSY */
847 /* > \author Univ. of Tennessee */
848 /* > \author Univ. of California Berkeley */
849 /* > \author Univ. of Colorado Denver */
850 /* > \author NAG Ltd. */
852 /* > \date December 2016 */
854 /* > \ingroup complex16_matgen */
856 /* ===================================================================== */
857 /* Subroutine */ int zlatmt_(integer *m, integer *n, char *dist, integer *
858 iseed, char *sym, doublereal *d__, integer *mode, doublereal *cond,
859 doublereal *dmax__, integer *rank, integer *kl, integer *ku, char *
860 pack, doublecomplex *a, integer *lda, doublecomplex *work, integer *
863 /* System generated locals */
864 integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
865 doublereal d__1, d__2, d__3;
866 doublecomplex z__1, z__2, z__3;
869 /* Local variables */
877 doublereal alpha, angle, realc;
878 integer ipack, ioffg;
879 extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
881 extern logical lsame_(char *, char *);
882 integer iinfo, idist, mnmin;
885 doublecomplex dummy, ztemp;
886 extern /* Subroutine */ int dlatm7_(integer *, doublereal *, integer *,
887 integer *, integer *, doublereal *, integer *, integer *, integer
889 integer ic, jc, nc, il;
891 integer iendch, ir, jr, ipackg, mr, minlda;
892 extern doublereal dlarnd_(integer *, integer *);
894 extern /* Subroutine */ int zlagge_(integer *, integer *, integer *,
895 integer *, doublereal *, doublecomplex *, integer *, integer *,
896 doublecomplex *, integer *), zlaghe_(integer *, integer *,
897 doublereal *, doublecomplex *, integer *, integer *,
898 doublecomplex *, integer *), xerbla_(char *, integer *);
899 integer ioffst, irsign;
900 logical givens, iltemp;
901 //extern /* Double Complex */ VOID zlarnd_(doublecomplex *, integer *,
902 extern doublecomplex zlarnd_(integer *,
904 extern /* Subroutine */ int zlaset_(char *, integer *, integer *,
905 doublecomplex *, doublecomplex *, doublecomplex *, integer *), zlartg_(doublecomplex *, doublecomplex *, doublereal *,
906 doublecomplex *, doublecomplex *);
908 extern /* Subroutine */ int zlagsy_(integer *, integer *, doublereal *,
909 doublecomplex *, integer *, integer *, doublecomplex *, integer *)
911 integer ir1, ir2, isympk;
913 extern /* Subroutine */ int zlarot_(logical *, logical *, logical *,
914 integer *, doublecomplex *, doublecomplex *, doublecomplex *,
915 integer *, doublecomplex *, doublecomplex *);
916 integer jch, llb, jkl, jku, uub;
919 /* -- LAPACK computational routine (version 3.7.0) -- */
920 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
921 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
925 /* ===================================================================== */
928 /* 1) Decode and Test the input parameters. */
929 /* Initialize flags & seed. */
931 /* Parameter adjustments */
935 a_offset = 1 + a_dim1 * 1;
942 /* Quick return if possible */
944 if (*m == 0 || *n == 0) {
950 if (lsame_(dist, "U")) {
952 } else if (lsame_(dist, "S")) {
954 } else if (lsame_(dist, "N")) {
962 if (lsame_(sym, "N")) {
966 } else if (lsame_(sym, "P")) {
970 } else if (lsame_(sym, "S")) {
974 } else if (lsame_(sym, "H")) {
985 if (lsame_(pack, "N")) {
987 } else if (lsame_(pack, "U")) {
990 } else if (lsame_(pack, "L")) {
993 } else if (lsame_(pack, "C")) {
996 } else if (lsame_(pack, "R")) {
999 } else if (lsame_(pack, "B")) {
1002 } else if (lsame_(pack, "Q")) {
1005 } else if (lsame_(pack, "Z")) {
1011 /* Set certain internal parameters */
1013 mnmin = f2cmin(*m,*n);
1015 i__1 = *kl, i__2 = *m - 1;
1016 llb = f2cmin(i__1,i__2);
1018 i__1 = *ku, i__2 = *n - 1;
1019 uub = f2cmin(i__1,i__2);
1021 i__1 = *m, i__2 = *n + llb;
1022 mr = f2cmin(i__1,i__2);
1024 i__1 = *n, i__2 = *m + uub;
1025 nc = f2cmin(i__1,i__2);
1027 if (ipack == 5 || ipack == 6) {
1029 } else if (ipack == 7) {
1030 minlda = llb + uub + 1;
1035 /* Use Givens rotation method if bandwidth small enough, */
1036 /* or if LDA is too small to store the matrix unpacked. */
1041 i__1 = 1, i__2 = mr + nc;
1042 if ((doublereal) (llb + uub) < (doublereal) f2cmax(i__1,i__2) * .3) {
1046 if (llb << 1 < *m) {
1050 if (*lda < *m && *lda >= minlda) {
1054 /* Set INFO if an error */
1058 } else if (*m != *n && isym != 1) {
1060 } else if (*n < 0) {
1062 } else if (idist == -1) {
1064 } else if (isym == -1) {
1066 } else if (abs(*mode) > 6) {
1068 } else if (*mode != 0 && abs(*mode) != 6 && *cond < 1.) {
1070 } else if (*kl < 0) {
1072 } else if (*ku < 0 || isym != 1 && *kl != *ku) {
1074 } else if (ipack == -1 || isympk == 1 && isym == 1 || isympk == 2 && isym
1075 == 1 && *kl > 0 || isympk == 3 && isym == 1 && *ku > 0 || isympk
1078 } else if (*lda < f2cmax(1,minlda)) {
1084 xerbla_("ZLATMT", &i__1);
1088 /* Initialize random number generator */
1090 for (i__ = 1; i__ <= 4; ++i__) {
1091 iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
1095 if (iseed[4] % 2 != 1) {
1099 /* 2) Set up D if indicated. */
1101 /* Compute D according to COND and MODE */
1103 dlatm7_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, rank, &
1110 /* Choose Top-Down if D is (apparently) increasing, */
1111 /* Bottom-Up if D is (apparently) decreasing. */
1113 if (abs(d__[1]) <= (d__1 = d__[*rank], abs(d__1))) {
1119 if (*mode != 0 && abs(*mode) != 6) {
1125 for (i__ = 2; i__ <= i__1; ++i__) {
1127 d__2 = temp, d__3 = (d__1 = d__[i__], abs(d__1));
1128 temp = f2cmax(d__2,d__3);
1133 alpha = *dmax__ / temp;
1139 dscal_(rank, &alpha, &d__[1], &c__1);
1143 zlaset_("Full", lda, n, &c_b1, &c_b1, &a[a_offset], lda);
1145 /* 3) Generate Banded Matrix using Givens rotations. */
1146 /* Also the special case of UUB=LLB=0 */
1148 /* Compute Addressing constants to cover all */
1149 /* storage formats. Whether GE, HE, SY, GB, HB, or SB, */
1150 /* upper or lower triangle or both, */
1151 /* the (i,j)-th element is in */
1152 /* A( i - ISKEW*j + IOFFST, j ) */
1168 /* IPACKG is the format that the matrix is generated in. If this is */
1169 /* different from IPACK, then the matrix must be repacked at the */
1170 /* end. It also signals how to compute the norm, for scaling. */
1174 /* Diagonal Matrix -- We are done, unless it */
1175 /* is to be stored HP/SP/PP/TP (PACK='R' or 'C') */
1177 if (llb == 0 && uub == 0) {
1179 for (j = 1; j <= i__1; ++j) {
1180 i__2 = (1 - iskew) * j + ioffst + j * a_dim1;
1182 z__1.r = d__[i__3], z__1.i = 0.;
1183 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
1187 if (ipack <= 2 || ipack >= 5) {
1191 } else if (givens) {
1193 /* Check whether to use Givens rotations, */
1194 /* Householder transformations, or nothing. */
1198 /* Non-symmetric -- A = U D V */
1207 for (j = 1; j <= i__1; ++j) {
1208 i__2 = (1 - iskew) * j + ioffst + j * a_dim1;
1210 z__1.r = d__[i__3], z__1.i = 0.;
1211 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
1218 for (jku = 1; jku <= i__1; ++jku) {
1220 /* Transform from bandwidth JKL, JKU-1 to JKL, JKU */
1222 /* Last row actually rotated is M */
1223 /* Last column actually rotated is MIN( M+JKU, N ) */
1227 i__2 = f2cmin(i__3,*n) + jkl - 1;
1228 for (jr = 1; jr <= i__2; ++jr) {
1229 extra.r = 0., extra.i = 0.;
1230 angle = dlarnd_(&c__1, &iseed[1]) *
1231 6.2831853071795864769252867663;
1233 //zlarnd_(&z__2, &c__5, &iseed[1]);
1234 z__2=zlarnd_(&c__5, &iseed[1]);
1235 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1236 c__.r = z__1.r, c__.i = z__1.i;
1238 //zlarnd_(&z__2, &c__5, &iseed[1]);
1239 z__2=zlarnd_( &c__5, &iseed[1]);
1240 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1241 s.r = z__1.r, s.i = z__1.i;
1243 i__3 = 1, i__4 = jr - jkl;
1244 icol = f2cmax(i__3,i__4);
1247 i__3 = *n, i__4 = jr + jku;
1248 il = f2cmin(i__3,i__4) + 1 - icol;
1250 zlarot_(&c_true, &L__1, &c_false, &il, &c__, &s, &
1251 a[jr - iskew * icol + ioffst + icol *
1252 a_dim1], &ilda, &extra, &dummy);
1255 /* Chase "EXTRA" back up */
1260 for (jch = jr - jkl; i__3 < 0 ? jch >= 1 : jch <= 1;
1263 zlartg_(&a[ir + 1 - iskew * (ic + 1) + ioffst
1264 + (ic + 1) * a_dim1], &extra, &realc,
1266 d__1 = dlarnd_(&c__5, &iseed[1]);
1267 dummy.r = d__1, dummy.i = 0.;
1268 z__2.r = realc * dummy.r, z__2.i = realc *
1270 d_cnjg(&z__1, &z__2);
1271 c__.r = z__1.r, c__.i = z__1.i;
1272 z__3.r = -s.r, z__3.i = -s.i;
1273 z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
1274 z__2.i = z__3.r * dummy.i + z__3.i *
1276 d_cnjg(&z__1, &z__2);
1277 s.r = z__1.r, s.i = z__1.i;
1280 i__4 = 1, i__5 = jch - jku;
1281 irow = f2cmax(i__4,i__5);
1283 ztemp.r = 0., ztemp.i = 0.;
1285 zlarot_(&c_false, &iltemp, &c_true, &il, &c__, &s,
1286 &a[irow - iskew * ic + ioffst + ic *
1287 a_dim1], &ilda, &ztemp, &extra);
1289 zlartg_(&a[irow + 1 - iskew * (ic + 1) +
1290 ioffst + (ic + 1) * a_dim1], &ztemp, &
1292 //zlarnd_(&z__1, &c__5, &iseed[1]);
1293 z__1=zlarnd_( &c__5, &iseed[1]);
1294 dummy.r = z__1.r, dummy.i = z__1.i;
1295 z__2.r = realc * dummy.r, z__2.i = realc *
1297 d_cnjg(&z__1, &z__2);
1298 c__.r = z__1.r, c__.i = z__1.i;
1299 z__3.r = -s.r, z__3.i = -s.i;
1300 z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
1301 z__2.i = z__3.r * dummy.i + z__3.i *
1303 d_cnjg(&z__1, &z__2);
1304 s.r = z__1.r, s.i = z__1.i;
1307 i__4 = 1, i__5 = jch - jku - jkl;
1308 icol = f2cmax(i__4,i__5);
1310 extra.r = 0., extra.i = 0.;
1311 L__1 = jch > jku + jkl;
1312 zlarot_(&c_true, &L__1, &c_true, &il, &c__, &
1313 s, &a[irow - iskew * icol + ioffst +
1314 icol * a_dim1], &ilda, &extra, &ztemp)
1328 for (jkl = 1; jkl <= i__1; ++jkl) {
1330 /* Transform from bandwidth JKL-1, JKU to JKL, JKU */
1334 i__2 = f2cmin(i__3,*m) + jku - 1;
1335 for (jc = 1; jc <= i__2; ++jc) {
1336 extra.r = 0., extra.i = 0.;
1337 angle = dlarnd_(&c__1, &iseed[1]) *
1338 6.2831853071795864769252867663;
1340 //zlarnd_(&z__2, &c__5, &iseed[1]);
1341 z__2=zlarnd_(&c__5, &iseed[1]);
1342 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1343 c__.r = z__1.r, c__.i = z__1.i;
1345 //zlarnd_(&z__2, &c__5, &iseed[1]);
1346 z__2=zlarnd_(&c__5, &iseed[1]);
1347 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1348 s.r = z__1.r, s.i = z__1.i;
1350 i__3 = 1, i__4 = jc - jku;
1351 irow = f2cmax(i__3,i__4);
1354 i__3 = *m, i__4 = jc + jkl;
1355 il = f2cmin(i__3,i__4) + 1 - irow;
1357 zlarot_(&c_false, &L__1, &c_false, &il, &c__, &s,
1358 &a[irow - iskew * jc + ioffst + jc *
1359 a_dim1], &ilda, &extra, &dummy);
1362 /* Chase "EXTRA" back up */
1367 for (jch = jc - jku; i__3 < 0 ? jch >= 1 : jch <= 1;
1370 zlartg_(&a[ir + 1 - iskew * (ic + 1) + ioffst
1371 + (ic + 1) * a_dim1], &extra, &realc,
1373 //zlarnd_(&z__1, &c__5, &iseed[1]);
1374 z__1=zlarnd_(&c__5, &iseed[1]);
1375 dummy.r = z__1.r, dummy.i = z__1.i;
1376 z__2.r = realc * dummy.r, z__2.i = realc *
1378 d_cnjg(&z__1, &z__2);
1379 c__.r = z__1.r, c__.i = z__1.i;
1380 z__3.r = -s.r, z__3.i = -s.i;
1381 z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
1382 z__2.i = z__3.r * dummy.i + z__3.i *
1384 d_cnjg(&z__1, &z__2);
1385 s.r = z__1.r, s.i = z__1.i;
1388 i__4 = 1, i__5 = jch - jkl;
1389 icol = f2cmax(i__4,i__5);
1391 ztemp.r = 0., ztemp.i = 0.;
1393 zlarot_(&c_true, &iltemp, &c_true, &il, &c__, &s,
1394 &a[ir - iskew * icol + ioffst + icol *
1395 a_dim1], &ilda, &ztemp, &extra);
1397 zlartg_(&a[ir + 1 - iskew * (icol + 1) +
1398 ioffst + (icol + 1) * a_dim1], &ztemp,
1399 &realc, &s, &dummy);
1400 //zlarnd_(&z__1, &c__5, &iseed[1]);
1401 z__1=zlarnd_(&c__5, &iseed[1]);
1402 dummy.r = z__1.r, dummy.i = z__1.i;
1403 z__2.r = realc * dummy.r, z__2.i = realc *
1405 d_cnjg(&z__1, &z__2);
1406 c__.r = z__1.r, c__.i = z__1.i;
1407 z__3.r = -s.r, z__3.i = -s.i;
1408 z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
1409 z__2.i = z__3.r * dummy.i + z__3.i *
1411 d_cnjg(&z__1, &z__2);
1412 s.r = z__1.r, s.i = z__1.i;
1414 i__4 = 1, i__5 = jch - jkl - jku;
1415 irow = f2cmax(i__4,i__5);
1417 extra.r = 0., extra.i = 0.;
1418 L__1 = jch > jkl + jku;
1419 zlarot_(&c_false, &L__1, &c_true, &il, &c__, &
1420 s, &a[irow - iskew * icol + ioffst +
1421 icol * a_dim1], &ilda, &extra, &ztemp)
1435 /* Bottom-Up -- Start at the bottom right. */
1439 for (jku = 1; jku <= i__1; ++jku) {
1441 /* Transform from bandwidth JKL, JKU-1 to JKL, JKU */
1443 /* First row actually rotated is M */
1444 /* First column actually rotated is MIN( M+JKU, N ) */
1447 i__2 = *m, i__3 = *n + jkl;
1448 iendch = f2cmin(i__2,i__3) - 1;
1452 for (jc = f2cmin(i__2,*n) - 1; jc >= i__3; --jc) {
1453 extra.r = 0., extra.i = 0.;
1454 angle = dlarnd_(&c__1, &iseed[1]) *
1455 6.2831853071795864769252867663;
1457 //zlarnd_(&z__2, &c__5, &iseed[1]);
1458 z__2=zlarnd_( &c__5, &iseed[1]);
1459 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1460 c__.r = z__1.r, c__.i = z__1.i;
1462 //zlarnd_(&z__2, &c__5, &iseed[1]);
1463 z__2=zlarnd_( &c__5, &iseed[1]);
1464 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1465 s.r = z__1.r, s.i = z__1.i;
1467 i__2 = 1, i__4 = jc - jku + 1;
1468 irow = f2cmax(i__2,i__4);
1471 i__2 = *m, i__4 = jc + jkl + 1;
1472 il = f2cmin(i__2,i__4) + 1 - irow;
1473 L__1 = jc + jkl < *m;
1474 zlarot_(&c_false, &c_false, &L__1, &il, &c__, &s,
1475 &a[irow - iskew * jc + ioffst + jc *
1476 a_dim1], &ilda, &dummy, &extra);
1479 /* Chase "EXTRA" back down */
1484 for (jch = jc + jkl; i__4 < 0 ? jch >= i__2 : jch <=
1485 i__2; jch += i__4) {
1488 zlartg_(&a[jch - iskew * ic + ioffst + ic *
1489 a_dim1], &extra, &realc, &s, &dummy);
1490 //zlarnd_(&z__1, &c__5, &iseed[1]);
1491 z__1=zlarnd_(&c__5, &iseed[1]);
1492 dummy.r = z__1.r, dummy.i = z__1.i;
1493 z__1.r = realc * dummy.r, z__1.i = realc *
1495 c__.r = z__1.r, c__.i = z__1.i;
1496 z__1.r = s.r * dummy.r - s.i * dummy.i,
1497 z__1.i = s.r * dummy.i + s.i *
1499 s.r = z__1.r, s.i = z__1.i;
1503 i__5 = *n - 1, i__6 = jch + jku;
1504 icol = f2cmin(i__5,i__6);
1505 iltemp = jch + jku < *n;
1506 ztemp.r = 0., ztemp.i = 0.;
1507 i__5 = icol + 2 - ic;
1508 zlarot_(&c_true, &ilextr, &iltemp, &i__5, &c__, &
1509 s, &a[jch - iskew * ic + ioffst + ic *
1510 a_dim1], &ilda, &extra, &ztemp);
1512 zlartg_(&a[jch - iskew * icol + ioffst + icol
1513 * a_dim1], &ztemp, &realc, &s, &dummy)
1515 //zlarnd_(&z__1, &c__5, &iseed[1]);
1516 z__1=zlarnd_(&c__5, &iseed[1]);
1517 dummy.r = z__1.r, dummy.i = z__1.i;
1518 z__1.r = realc * dummy.r, z__1.i = realc *
1520 c__.r = z__1.r, c__.i = z__1.i;
1521 z__1.r = s.r * dummy.r - s.i * dummy.i,
1522 z__1.i = s.r * dummy.i + s.i *
1524 s.r = z__1.r, s.i = z__1.i;
1526 i__5 = iendch, i__6 = jch + jkl + jku;
1527 il = f2cmin(i__5,i__6) + 2 - jch;
1528 extra.r = 0., extra.i = 0.;
1529 L__1 = jch + jkl + jku <= iendch;
1530 zlarot_(&c_false, &c_true, &L__1, &il, &c__, &
1531 s, &a[jch - iskew * icol + ioffst +
1532 icol * a_dim1], &ilda, &ztemp, &extra)
1545 for (jkl = 1; jkl <= i__1; ++jkl) {
1547 /* Transform from bandwidth JKL-1, JKU to JKL, JKU */
1549 /* First row actually rotated is MIN( N+JKL, M ) */
1550 /* First column actually rotated is N */
1553 i__3 = *n, i__4 = *m + jku;
1554 iendch = f2cmin(i__3,i__4) - 1;
1558 for (jr = f2cmin(i__3,*m) - 1; jr >= i__4; --jr) {
1559 extra.r = 0., extra.i = 0.;
1560 angle = dlarnd_(&c__1, &iseed[1]) *
1561 6.2831853071795864769252867663;
1563 //zlarnd_(&z__2, &c__5, &iseed[1]);
1564 z__2=zlarnd_(&c__5, &iseed[1]);
1565 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1566 c__.r = z__1.r, c__.i = z__1.i;
1568 //zlarnd_(&z__2, &c__5, &iseed[1]);
1569 z__2=zlarnd_(&c__5, &iseed[1]);
1570 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1571 s.r = z__1.r, s.i = z__1.i;
1573 i__3 = 1, i__2 = jr - jkl + 1;
1574 icol = f2cmax(i__3,i__2);
1577 i__3 = *n, i__2 = jr + jku + 1;
1578 il = f2cmin(i__3,i__2) + 1 - icol;
1579 L__1 = jr + jku < *n;
1580 zlarot_(&c_true, &c_false, &L__1, &il, &c__, &s, &
1581 a[jr - iskew * icol + ioffst + icol *
1582 a_dim1], &ilda, &dummy, &extra);
1585 /* Chase "EXTRA" back down */
1590 for (jch = jr + jku; i__2 < 0 ? jch >= i__3 : jch <=
1591 i__3; jch += i__2) {
1594 zlartg_(&a[ir - iskew * jch + ioffst + jch *
1595 a_dim1], &extra, &realc, &s, &dummy);
1596 //zlarnd_(&z__1, &c__5, &iseed[1]);
1597 z__1=zlarnd_( &c__5, &iseed[1]);
1598 dummy.r = z__1.r, dummy.i = z__1.i;
1599 z__1.r = realc * dummy.r, z__1.i = realc *
1601 c__.r = z__1.r, c__.i = z__1.i;
1602 z__1.r = s.r * dummy.r - s.i * dummy.i,
1603 z__1.i = s.r * dummy.i + s.i *
1605 s.r = z__1.r, s.i = z__1.i;
1609 i__5 = *m - 1, i__6 = jch + jkl;
1610 irow = f2cmin(i__5,i__6);
1611 iltemp = jch + jkl < *m;
1612 ztemp.r = 0., ztemp.i = 0.;
1613 i__5 = irow + 2 - ir;
1614 zlarot_(&c_false, &ilextr, &iltemp, &i__5, &c__, &
1615 s, &a[ir - iskew * jch + ioffst + jch *
1616 a_dim1], &ilda, &extra, &ztemp);
1618 zlartg_(&a[irow - iskew * jch + ioffst + jch *
1619 a_dim1], &ztemp, &realc, &s, &dummy);
1620 //zlarnd_(&z__1, &c__5, &iseed[1]);
1621 z__1=zlarnd_(&c__5, &iseed[1]);
1622 dummy.r = z__1.r, dummy.i = z__1.i;
1623 z__1.r = realc * dummy.r, z__1.i = realc *
1625 c__.r = z__1.r, c__.i = z__1.i;
1626 z__1.r = s.r * dummy.r - s.i * dummy.i,
1627 z__1.i = s.r * dummy.i + s.i *
1629 s.r = z__1.r, s.i = z__1.i;
1631 i__5 = iendch, i__6 = jch + jkl + jku;
1632 il = f2cmin(i__5,i__6) + 2 - jch;
1633 extra.r = 0., extra.i = 0.;
1634 L__1 = jch + jkl + jku <= iendch;
1635 zlarot_(&c_true, &c_true, &L__1, &il, &c__, &
1636 s, &a[irow - iskew * jch + ioffst +
1637 jch * a_dim1], &ilda, &ztemp, &extra);
1651 /* Symmetric -- A = U D U' */
1652 /* Hermitian -- A = U D U* */
1659 /* Top-Down -- Generate Upper triangle only */
1669 for (j = 1; j <= i__1; ++j) {
1670 i__4 = (1 - iskew) * j + ioffg + j * a_dim1;
1672 z__1.r = d__[i__2], z__1.i = 0.;
1673 a[i__4].r = z__1.r, a[i__4].i = z__1.i;
1678 for (k = 1; k <= i__1; ++k) {
1680 for (jc = 1; jc <= i__4; ++jc) {
1682 i__2 = 1, i__3 = jc - k;
1683 irow = f2cmax(i__2,i__3);
1685 i__2 = jc + 1, i__3 = k + 2;
1686 il = f2cmin(i__2,i__3);
1687 extra.r = 0., extra.i = 0.;
1688 i__2 = jc - iskew * (jc + 1) + ioffg + (jc + 1) *
1690 ztemp.r = a[i__2].r, ztemp.i = a[i__2].i;
1691 angle = dlarnd_(&c__1, &iseed[1]) *
1692 6.2831853071795864769252867663;
1694 //zlarnd_(&z__2, &c__5, &iseed[1]);
1695 z__2=zlarnd_(&c__5, &iseed[1]);
1696 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1697 c__.r = z__1.r, c__.i = z__1.i;
1699 //zlarnd_(&z__2, &c__5, &iseed[1]);
1700 z__2=zlarnd_( &c__5, &iseed[1]);
1701 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1702 s.r = z__1.r, s.i = z__1.i;
1704 ct.r = c__.r, ct.i = c__.i;
1705 st.r = s.r, st.i = s.i;
1707 d_cnjg(&z__1, &ztemp);
1708 ztemp.r = z__1.r, ztemp.i = z__1.i;
1709 d_cnjg(&z__1, &c__);
1710 ct.r = z__1.r, ct.i = z__1.i;
1712 st.r = z__1.r, st.i = z__1.i;
1715 zlarot_(&c_false, &L__1, &c_true, &il, &c__, &s, &a[
1716 irow - iskew * jc + ioffg + jc * a_dim1], &
1717 ilda, &extra, &ztemp);
1719 i__3 = k, i__5 = *n - jc;
1720 i__2 = f2cmin(i__3,i__5) + 1;
1721 zlarot_(&c_true, &c_true, &c_false, &i__2, &ct, &st, &
1722 a[(1 - iskew) * jc + ioffg + jc * a_dim1], &
1723 ilda, &ztemp, &dummy);
1725 /* Chase EXTRA back up the matrix */
1729 for (jch = jc - k; i__2 < 0 ? jch >= 1 : jch <= 1;
1731 zlartg_(&a[jch + 1 - iskew * (icol + 1) + ioffg +
1732 (icol + 1) * a_dim1], &extra, &realc, &s,
1734 //zlarnd_(&z__1, &c__5, &iseed[1]);
1735 z__1=zlarnd_(&c__5, &iseed[1]);
1736 dummy.r = z__1.r, dummy.i = z__1.i;
1737 z__2.r = realc * dummy.r, z__2.i = realc *
1739 d_cnjg(&z__1, &z__2);
1740 c__.r = z__1.r, c__.i = z__1.i;
1741 z__3.r = -s.r, z__3.i = -s.i;
1742 z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
1743 z__2.i = z__3.r * dummy.i + z__3.i *
1745 d_cnjg(&z__1, &z__2);
1746 s.r = z__1.r, s.i = z__1.i;
1747 i__3 = jch - iskew * (jch + 1) + ioffg + (jch + 1)
1749 ztemp.r = a[i__3].r, ztemp.i = a[i__3].i;
1751 ct.r = c__.r, ct.i = c__.i;
1752 st.r = s.r, st.i = s.i;
1754 d_cnjg(&z__1, &ztemp);
1755 ztemp.r = z__1.r, ztemp.i = z__1.i;
1756 d_cnjg(&z__1, &c__);
1757 ct.r = z__1.r, ct.i = z__1.i;
1759 st.r = z__1.r, st.i = z__1.i;
1762 zlarot_(&c_true, &c_true, &c_true, &i__3, &c__, &
1763 s, &a[(1 - iskew) * jch + ioffg + jch *
1764 a_dim1], &ilda, &ztemp, &extra);
1766 i__3 = 1, i__5 = jch - k;
1767 irow = f2cmax(i__3,i__5);
1769 i__3 = jch + 1, i__5 = k + 2;
1770 il = f2cmin(i__3,i__5);
1771 extra.r = 0., extra.i = 0.;
1773 zlarot_(&c_false, &L__1, &c_true, &il, &ct, &st, &
1774 a[irow - iskew * jch + ioffg + jch *
1775 a_dim1], &ilda, &extra, &ztemp);
1784 /* If we need lower triangle, copy from upper. Note that */
1785 /* the order of copying is chosen to work for 'q' -> 'b' */
1787 if (ipack != ipackg && ipack != 3) {
1789 for (jc = 1; jc <= i__1; ++jc) {
1790 irow = ioffst - iskew * jc;
1793 i__2 = *n, i__3 = jc + uub;
1794 i__4 = f2cmin(i__2,i__3);
1795 for (jr = jc; jr <= i__4; ++jr) {
1796 i__2 = jr + irow + jc * a_dim1;
1797 i__3 = jc - iskew * jr + ioffg + jr * a_dim1;
1798 a[i__2].r = a[i__3].r, a[i__2].i = a[i__3].i;
1803 i__2 = *n, i__3 = jc + uub;
1804 i__4 = f2cmin(i__2,i__3);
1805 for (jr = jc; jr <= i__4; ++jr) {
1806 i__2 = jr + irow + jc * a_dim1;
1807 d_cnjg(&z__1, &a[jc - iskew * jr + ioffg + jr
1809 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
1817 for (jc = *n - uub + 1; jc <= i__1; ++jc) {
1819 for (jr = *n + 2 - jc; jr <= i__4; ++jr) {
1820 i__2 = jr + jc * a_dim1;
1821 a[i__2].r = 0., a[i__2].i = 0.;
1835 /* Bottom-Up -- Generate Lower triangle only */
1847 for (j = 1; j <= i__1; ++j) {
1848 i__4 = (1 - iskew) * j + ioffg + j * a_dim1;
1850 z__1.r = d__[i__2], z__1.i = 0.;
1851 a[i__4].r = z__1.r, a[i__4].i = z__1.i;
1856 for (k = 1; k <= i__1; ++k) {
1857 for (jc = *n - 1; jc >= 1; --jc) {
1859 i__4 = *n + 1 - jc, i__2 = k + 2;
1860 il = f2cmin(i__4,i__2);
1861 extra.r = 0., extra.i = 0.;
1862 i__4 = (1 - iskew) * jc + 1 + ioffg + jc * a_dim1;
1863 ztemp.r = a[i__4].r, ztemp.i = a[i__4].i;
1864 angle = dlarnd_(&c__1, &iseed[1]) *
1865 6.2831853071795864769252867663;
1867 //zlarnd_(&z__2, &c__5, &iseed[1]);
1868 z__2=zlarnd_(&c__5, &iseed[1]);
1869 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1870 c__.r = z__1.r, c__.i = z__1.i;
1872 //zlarnd_(&z__2, &c__5, &iseed[1]);
1873 z__2=zlarnd_(&c__5, &iseed[1]);
1874 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1875 s.r = z__1.r, s.i = z__1.i;
1877 ct.r = c__.r, ct.i = c__.i;
1878 st.r = s.r, st.i = s.i;
1880 d_cnjg(&z__1, &ztemp);
1881 ztemp.r = z__1.r, ztemp.i = z__1.i;
1882 d_cnjg(&z__1, &c__);
1883 ct.r = z__1.r, ct.i = z__1.i;
1885 st.r = z__1.r, st.i = z__1.i;
1888 zlarot_(&c_false, &c_true, &L__1, &il, &c__, &s, &a[(
1889 1 - iskew) * jc + ioffg + jc * a_dim1], &ilda,
1892 i__4 = 1, i__2 = jc - k + 1;
1893 icol = f2cmax(i__4,i__2);
1894 i__4 = jc + 2 - icol;
1895 zlarot_(&c_true, &c_false, &c_true, &i__4, &ct, &st, &
1896 a[jc - iskew * icol + ioffg + icol * a_dim1],
1897 &ilda, &dummy, &ztemp);
1899 /* Chase EXTRA back down the matrix */
1904 for (jch = jc + k; i__2 < 0 ? jch >= i__4 : jch <=
1905 i__4; jch += i__2) {
1906 zlartg_(&a[jch - iskew * icol + ioffg + icol *
1907 a_dim1], &extra, &realc, &s, &dummy);
1908 //zlarnd_(&z__1, &c__5, &iseed[1]);
1909 z__1=zlarnd_(&c__5, &iseed[1]);
1910 dummy.r = z__1.r, dummy.i = z__1.i;
1911 z__1.r = realc * dummy.r, z__1.i = realc *
1913 c__.r = z__1.r, c__.i = z__1.i;
1914 z__1.r = s.r * dummy.r - s.i * dummy.i, z__1.i =
1915 s.r * dummy.i + s.i * dummy.r;
1916 s.r = z__1.r, s.i = z__1.i;
1917 i__3 = (1 - iskew) * jch + 1 + ioffg + jch *
1919 ztemp.r = a[i__3].r, ztemp.i = a[i__3].i;
1921 ct.r = c__.r, ct.i = c__.i;
1922 st.r = s.r, st.i = s.i;
1924 d_cnjg(&z__1, &ztemp);
1925 ztemp.r = z__1.r, ztemp.i = z__1.i;
1926 d_cnjg(&z__1, &c__);
1927 ct.r = z__1.r, ct.i = z__1.i;
1929 st.r = z__1.r, st.i = z__1.i;
1932 zlarot_(&c_true, &c_true, &c_true, &i__3, &c__, &
1933 s, &a[jch - iskew * icol + ioffg + icol *
1934 a_dim1], &ilda, &extra, &ztemp);
1936 i__3 = *n + 1 - jch, i__5 = k + 2;
1937 il = f2cmin(i__3,i__5);
1938 extra.r = 0., extra.i = 0.;
1939 L__1 = *n - jch > k;
1940 zlarot_(&c_false, &c_true, &L__1, &il, &ct, &st, &
1941 a[(1 - iskew) * jch + ioffg + jch *
1942 a_dim1], &ilda, &ztemp, &extra);
1951 /* If we need upper triangle, copy from lower. Note that */
1952 /* the order of copying is chosen to work for 'b' -> 'q' */
1954 if (ipack != ipackg && ipack != 4) {
1955 for (jc = *n; jc >= 1; --jc) {
1956 irow = ioffst - iskew * jc;
1959 i__2 = 1, i__4 = jc - uub;
1960 i__1 = f2cmax(i__2,i__4);
1961 for (jr = jc; jr >= i__1; --jr) {
1962 i__2 = jr + irow + jc * a_dim1;
1963 i__4 = jc - iskew * jr + ioffg + jr * a_dim1;
1964 a[i__2].r = a[i__4].r, a[i__2].i = a[i__4].i;
1969 i__2 = 1, i__4 = jc - uub;
1970 i__1 = f2cmax(i__2,i__4);
1971 for (jr = jc; jr >= i__1; --jr) {
1972 i__2 = jr + irow + jc * a_dim1;
1973 d_cnjg(&z__1, &a[jc - iskew * jr + ioffg + jr
1975 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
1983 for (jc = 1; jc <= i__1; ++jc) {
1984 i__2 = uub + 1 - jc;
1985 for (jr = 1; jr <= i__2; ++jr) {
1986 i__4 = jr + jc * a_dim1;
1987 a[i__4].r = 0., a[i__4].i = 0.;
2001 /* Ensure that the diagonal is real if Hermitian */
2005 for (jc = 1; jc <= i__1; ++jc) {
2006 irow = ioffst + (1 - iskew) * jc;
2007 i__2 = irow + jc * a_dim1;
2008 i__4 = irow + jc * a_dim1;
2010 z__1.r = d__1, z__1.i = 0.;
2011 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
2020 /* 4) Generate Banded Matrix by first */
2021 /* Rotating by random Unitary matrices, */
2022 /* then reducing the bandwidth using Householder */
2023 /* transformations. */
2025 /* Note: we should get here only if LDA .ge. N */
2029 /* Non-symmetric -- A = U D V */
2031 zlagge_(&mr, &nc, &llb, &uub, &d__[1], &a[a_offset], lda, &iseed[
2032 1], &work[1], &iinfo);
2035 /* Symmetric -- A = U D U' or */
2036 /* Hermitian -- A = U D U* */
2039 zlagsy_(m, &llb, &d__[1], &a[a_offset], lda, &iseed[1], &work[
2042 zlaghe_(m, &llb, &d__[1], &a[a_offset], lda, &iseed[1], &work[
2053 /* 5) Pack the matrix */
2055 if (ipack != ipackg) {
2058 /* 'U' -- Upper triangular, not packed */
2061 for (j = 1; j <= i__1; ++j) {
2063 for (i__ = j + 1; i__ <= i__2; ++i__) {
2064 i__4 = i__ + j * a_dim1;
2065 a[i__4].r = 0., a[i__4].i = 0.;
2071 } else if (ipack == 2) {
2073 /* 'L' -- Lower triangular, not packed */
2076 for (j = 2; j <= i__1; ++j) {
2078 for (i__ = 1; i__ <= i__2; ++i__) {
2079 i__4 = i__ + j * a_dim1;
2080 a[i__4].r = 0., a[i__4].i = 0.;
2086 } else if (ipack == 3) {
2088 /* 'C' -- Upper triangle packed Columnwise. */
2093 for (j = 1; j <= i__1; ++j) {
2095 for (i__ = 1; i__ <= i__2; ++i__) {
2101 i__4 = irow + icol * a_dim1;
2102 i__3 = i__ + j * a_dim1;
2103 a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
2109 } else if (ipack == 4) {
2111 /* 'R' -- Lower triangle packed Columnwise. */
2116 for (j = 1; j <= i__1; ++j) {
2118 for (i__ = j; i__ <= i__2; ++i__) {
2124 i__4 = irow + icol * a_dim1;
2125 i__3 = i__ + j * a_dim1;
2126 a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
2132 } else if (ipack >= 5) {
2134 /* 'B' -- The lower triangle is packed as a band matrix. */
2135 /* 'Q' -- The upper triangle is packed as a band matrix. */
2136 /* 'Z' -- The whole matrix is packed as a band matrix. */
2146 for (j = 1; j <= i__1; ++j) {
2149 for (i__ = f2cmin(i__2,*m); i__ >= 1; --i__) {
2150 i__2 = i__ - j + uub + 1 + j * a_dim1;
2151 i__4 = i__ + j * a_dim1;
2152 a[i__2].r = a[i__4].r, a[i__2].i = a[i__4].i;
2159 for (j = uub + 2; j <= i__1; ++j) {
2162 i__2 = f2cmin(i__4,*m);
2163 for (i__ = j - uub; i__ <= i__2; ++i__) {
2164 i__4 = i__ - j + uub + 1 + j * a_dim1;
2165 i__3 = i__ + j * a_dim1;
2166 a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
2173 /* If packed, zero out extraneous elements. */
2175 /* Symmetric/Triangular Packed -- */
2176 /* zero out everything after A(IROW,ICOL) */
2178 if (ipack == 3 || ipack == 4) {
2180 for (jc = icol; jc <= i__1; ++jc) {
2182 for (jr = irow + 1; jr <= i__2; ++jr) {
2183 i__4 = jr + jc * a_dim1;
2184 a[i__4].r = 0., a[i__4].i = 0.;
2191 } else if (ipack >= 5) {
2193 /* Packed Band -- */
2194 /* 1st row is now in A( UUB+2-j, j), zero above it */
2195 /* m-th row is now in A( M+UUB-j,j), zero below it */
2196 /* last non-zero diagonal is now in A( UUB+LLB+1,j ), */
2197 /* zero below it, too. */
2199 ir1 = uub + llb + 2;
2202 for (jc = 1; jc <= i__1; ++jc) {
2203 i__2 = uub + 1 - jc;
2204 for (jr = 1; jr <= i__2; ++jr) {
2205 i__4 = jr + jc * a_dim1;
2206 a[i__4].r = 0., a[i__4].i = 0.;
2211 i__3 = ir1, i__5 = ir2 - jc;
2212 i__2 = 1, i__4 = f2cmin(i__3,i__5);
2214 for (jr = f2cmax(i__2,i__4); jr <= i__6; ++jr) {
2215 i__2 = jr + jc * a_dim1;
2216 a[i__2].r = 0., a[i__2].i = 0.;