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 ZLATMS */
524 /* =========== DOCUMENTATION =========== */
526 /* Online html documentation available at */
527 /* http://www.netlib.org/lapack/explore-html/ */
532 /* SUBROUTINE ZLATMS( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, */
533 /* KL, KU, PACK, A, LDA, WORK, INFO ) */
535 /* CHARACTER DIST, PACK, SYM */
536 /* INTEGER INFO, KL, KU, LDA, M, MODE, N */
537 /* DOUBLE PRECISION COND, DMAX */
538 /* INTEGER ISEED( 4 ) */
539 /* DOUBLE PRECISION D( * ) */
540 /* COMPLEX*16 A( LDA, * ), WORK( * ) */
543 /* > \par Purpose: */
548 /* > ZLATMS generates random matrices with specified singular values */
549 /* > (or hermitian with specified eigenvalues) */
550 /* > for testing LAPACK programs. */
552 /* > ZLATMS 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 ZLATMS */
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:N)=1.0/COND */
682 /* > MODE = 2 sets D(1:N-1)=1 and D(N)=1.0/COND */
683 /* > MODE = 3 sets D(I)=COND**(-(I-1)/(N-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] KL */
721 /* > KL is INTEGER */
722 /* > This specifies the lower bandwidth of the matrix. For */
723 /* > example, KL=0 implies upper triangular, KL=1 implies upper */
724 /* > Hessenberg, and KL being at least M-1 means that the matrix */
725 /* > has full lower bandwidth. KL must equal KU if the matrix */
726 /* > is symmetric or hermitian. */
727 /* > Not modified. */
730 /* > \param[in] KU */
732 /* > KU is INTEGER */
733 /* > This specifies the upper bandwidth of the matrix. For */
734 /* > example, KU=0 implies lower triangular, KU=1 implies lower */
735 /* > Hessenberg, and KU being at least N-1 means that the matrix */
736 /* > has full upper bandwidth. KL must equal KU if the matrix */
737 /* > is symmetric or hermitian. */
738 /* > Not modified. */
741 /* > \param[in] PACK */
743 /* > PACK is CHARACTER*1 */
744 /* > This specifies packing of matrix as follows: */
745 /* > 'N' => no packing */
746 /* > 'U' => zero out all subdiagonal entries (if symmetric */
747 /* > or hermitian) */
748 /* > 'L' => zero out all superdiagonal entries (if symmetric */
749 /* > or hermitian) */
750 /* > 'C' => store the upper triangle columnwise (only if the */
751 /* > matrix is symmetric, hermitian, or upper triangular) */
752 /* > 'R' => store the lower triangle columnwise (only if the */
753 /* > matrix is symmetric, hermitian, or lower triangular) */
754 /* > 'B' => store the lower triangle in band storage scheme */
755 /* > (only if the matrix is symmetric, hermitian, or */
756 /* > lower triangular) */
757 /* > 'Q' => store the upper triangle in band storage scheme */
758 /* > (only if the matrix is symmetric, hermitian, or */
759 /* > upper triangular) */
760 /* > 'Z' => store the entire matrix in band storage scheme */
761 /* > (pivoting can be provided for by using this */
762 /* > option to store A in the trailing rows of */
763 /* > the allocated storage) */
765 /* > Using these options, the various LAPACK packed and banded */
766 /* > storage schemes can be obtained: */
768 /* > PB, SB, HB, or TB - use 'B' or 'Q' */
769 /* > PP, SP, HB, or TP - use 'C' or 'R' */
771 /* > If two calls to ZLATMS differ only in the PACK parameter, */
772 /* > they will generate mathematically equivalent matrices. */
773 /* > Not modified. */
776 /* > \param[in,out] A */
778 /* > A is COMPLEX*16 array, dimension ( LDA, N ) */
779 /* > On exit A is the desired test matrix. A is first generated */
780 /* > in full (unpacked) form, and then packed, if so specified */
781 /* > by PACK. Thus, the first M elements of the first N */
782 /* > columns will always be modified. If PACK specifies a */
783 /* > packed or banded storage scheme, all LDA elements of the */
784 /* > first N columns will be modified; the elements of the */
785 /* > array which do not correspond to elements of the generated */
786 /* > matrix are set to zero. */
790 /* > \param[in] LDA */
792 /* > LDA is INTEGER */
793 /* > LDA specifies the first dimension of A as declared in the */
794 /* > calling program. If PACK='N', 'U', 'L', 'C', or 'R', then */
795 /* > LDA must be at least M. If PACK='B' or 'Q', then LDA must */
796 /* > be at least MIN( KL, M-1) (which is equal to MIN(KU,N-1)). */
797 /* > If PACK='Z', LDA must be large enough to hold the packed */
798 /* > array: MIN( KU, N-1) + MIN( KL, M-1) + 1. */
799 /* > Not modified. */
802 /* > \param[out] WORK */
804 /* > WORK is COMPLEX*16 array, dimension ( 3*MAX( N, M ) ) */
809 /* > \param[out] INFO */
811 /* > INFO is INTEGER */
812 /* > Error code. On exit, INFO will be set to one of the */
813 /* > following values: */
814 /* > 0 => normal return */
815 /* > -1 => M negative or unequal to N and SYM='S', 'H', or 'P' */
816 /* > -2 => N negative */
817 /* > -3 => DIST illegal string */
818 /* > -5 => SYM illegal string */
819 /* > -7 => MODE not in range -6 to 6 */
820 /* > -8 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
821 /* > -10 => KL negative */
822 /* > -11 => KU negative, or SYM is not 'N' and KU is not equal to */
824 /* > -12 => PACK illegal string, or PACK='U' or 'L', and SYM='N'; */
825 /* > or PACK='C' or 'Q' and SYM='N' and KL is not zero; */
826 /* > or PACK='R' or 'B' and SYM='N' and KU is not zero; */
827 /* > or PACK='U', 'L', 'C', 'R', 'B', or 'Q', and M is not */
829 /* > -14 => LDA is less than M, or PACK='Z' and LDA is less than */
830 /* > MIN(KU,N-1) + MIN(KL,M-1) + 1. */
831 /* > 1 => Error return from DLATM1 */
832 /* > 2 => Cannot scale to DMAX (f2cmax. sing. value is 0) */
833 /* > 3 => Error return from ZLAGGE, CLAGHE or CLAGSY */
839 /* > \author Univ. of Tennessee */
840 /* > \author Univ. of California Berkeley */
841 /* > \author Univ. of Colorado Denver */
842 /* > \author NAG Ltd. */
844 /* > \date December 2016 */
846 /* > \ingroup complex16_matgen */
848 /* ===================================================================== */
849 /* Subroutine */ int zlatms_(integer *m, integer *n, char *dist, integer *
850 iseed, char *sym, doublereal *d__, integer *mode, doublereal *cond,
851 doublereal *dmax__, integer *kl, integer *ku, char *pack,
852 doublecomplex *a, integer *lda, doublecomplex *work, integer *info)
854 /* System generated locals */
855 integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
856 doublereal d__1, d__2, d__3;
857 doublecomplex z__1, z__2, z__3;
860 /* Local variables */
868 doublereal alpha, angle;
872 extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
874 extern logical lsame_(char *, char *);
877 integer idist, mnmin, iskew;
878 doublecomplex extra, dummy;
879 extern /* Subroutine */ int dlatm1_(integer *, doublereal *, integer *,
880 integer *, integer *, doublereal *, integer *, integer *);
881 integer ic, jc, nc, il;
883 integer iendch, ir, jr, ipackg, mr, minlda;
884 extern doublereal dlarnd_(integer *, integer *);
886 extern /* Subroutine */ int zlagge_(integer *, integer *, integer *,
887 integer *, doublereal *, doublecomplex *, integer *, integer *,
888 doublecomplex *, integer *), zlaghe_(integer *, integer *,
889 doublereal *, doublecomplex *, integer *, integer *,
890 doublecomplex *, integer *), xerbla_(char *, integer *);
891 logical iltemp, givens;
892 integer ioffst, irsign;
893 //extern /* Double Complex */ VOID zlarnd_(doublecomplex *, integer *,
894 extern doublecomplex zlarnd_(integer *,
896 extern /* Subroutine */ int zlaset_(char *, integer *, integer *,
897 doublecomplex *, doublecomplex *, doublecomplex *, integer *), zlartg_(doublecomplex *, doublecomplex *, doublereal *,
898 doublecomplex *, doublecomplex *);
900 extern /* Subroutine */ int zlagsy_(integer *, integer *, doublereal *,
901 doublecomplex *, integer *, integer *, doublecomplex *, integer *)
904 integer ir1, ir2, isympk;
905 extern /* Subroutine */ int zlarot_(logical *, logical *, logical *,
906 integer *, doublecomplex *, doublecomplex *, doublecomplex *,
907 integer *, doublecomplex *, doublecomplex *);
908 integer jch, llb, jkl, jku, uub;
911 /* -- LAPACK computational routine (version 3.7.0) -- */
912 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
913 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
917 /* ===================================================================== */
920 /* 1) Decode and Test the input parameters. */
921 /* Initialize flags & seed. */
923 /* Parameter adjustments */
927 a_offset = 1 + a_dim1 * 1;
934 /* Quick return if possible */
936 if (*m == 0 || *n == 0) {
942 if (lsame_(dist, "U")) {
944 } else if (lsame_(dist, "S")) {
946 } else if (lsame_(dist, "N")) {
954 if (lsame_(sym, "N")) {
958 } else if (lsame_(sym, "P")) {
962 } else if (lsame_(sym, "S")) {
966 } else if (lsame_(sym, "H")) {
977 if (lsame_(pack, "N")) {
979 } else if (lsame_(pack, "U")) {
982 } else if (lsame_(pack, "L")) {
985 } else if (lsame_(pack, "C")) {
988 } else if (lsame_(pack, "R")) {
991 } else if (lsame_(pack, "B")) {
994 } else if (lsame_(pack, "Q")) {
997 } else if (lsame_(pack, "Z")) {
1003 /* Set certain internal parameters */
1005 mnmin = f2cmin(*m,*n);
1007 i__1 = *kl, i__2 = *m - 1;
1008 llb = f2cmin(i__1,i__2);
1010 i__1 = *ku, i__2 = *n - 1;
1011 uub = f2cmin(i__1,i__2);
1013 i__1 = *m, i__2 = *n + llb;
1014 mr = f2cmin(i__1,i__2);
1016 i__1 = *n, i__2 = *m + uub;
1017 nc = f2cmin(i__1,i__2);
1019 if (ipack == 5 || ipack == 6) {
1021 } else if (ipack == 7) {
1022 minlda = llb + uub + 1;
1027 /* Use Givens rotation method if bandwidth small enough, */
1028 /* or if LDA is too small to store the matrix unpacked. */
1033 i__1 = 1, i__2 = mr + nc;
1034 if ((doublereal) (llb + uub) < (doublereal) f2cmax(i__1,i__2) * .3) {
1038 if (llb << 1 < *m) {
1042 if (*lda < *m && *lda >= minlda) {
1046 /* Set INFO if an error */
1050 } else if (*m != *n && isym != 1) {
1052 } else if (*n < 0) {
1054 } else if (idist == -1) {
1056 } else if (isym == -1) {
1058 } else if (abs(*mode) > 6) {
1060 } else if (*mode != 0 && abs(*mode) != 6 && *cond < 1.) {
1062 } else if (*kl < 0) {
1064 } else if (*ku < 0 || isym != 1 && *kl != *ku) {
1066 } else if (ipack == -1 || isympk == 1 && isym == 1 || isympk == 2 && isym
1067 == 1 && *kl > 0 || isympk == 3 && isym == 1 && *ku > 0 || isympk
1070 } else if (*lda < f2cmax(1,minlda)) {
1076 xerbla_("ZLATMS", &i__1);
1080 /* Initialize random number generator */
1082 for (i__ = 1; i__ <= 4; ++i__) {
1083 iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
1087 if (iseed[4] % 2 != 1) {
1091 /* 2) Set up D if indicated. */
1093 /* Compute D according to COND and MODE */
1095 dlatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, &iinfo);
1101 /* Choose Top-Down if D is (apparently) increasing, */
1102 /* Bottom-Up if D is (apparently) decreasing. */
1104 if (abs(d__[1]) <= (d__1 = d__[mnmin], abs(d__1))) {
1110 if (*mode != 0 && abs(*mode) != 6) {
1116 for (i__ = 2; i__ <= i__1; ++i__) {
1118 d__2 = temp, d__3 = (d__1 = d__[i__], abs(d__1));
1119 temp = f2cmax(d__2,d__3);
1124 alpha = *dmax__ / temp;
1130 dscal_(&mnmin, &alpha, &d__[1], &c__1);
1134 zlaset_("Full", lda, n, &c_b1, &c_b1, &a[a_offset], lda);
1136 /* 3) Generate Banded Matrix using Givens rotations. */
1137 /* Also the special case of UUB=LLB=0 */
1139 /* Compute Addressing constants to cover all */
1140 /* storage formats. Whether GE, HE, SY, GB, HB, or SB, */
1141 /* upper or lower triangle or both, */
1142 /* the (i,j)-th element is in */
1143 /* A( i - ISKEW*j + IOFFST, j ) */
1159 /* IPACKG is the format that the matrix is generated in. If this is */
1160 /* different from IPACK, then the matrix must be repacked at the */
1161 /* end. It also signals how to compute the norm, for scaling. */
1165 /* Diagonal Matrix -- We are done, unless it */
1166 /* is to be stored HP/SP/PP/TP (PACK='R' or 'C') */
1168 if (llb == 0 && uub == 0) {
1170 for (j = 1; j <= i__1; ++j) {
1171 i__2 = (1 - iskew) * j + ioffst + j * a_dim1;
1173 z__1.r = d__[i__3], z__1.i = 0.;
1174 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
1178 if (ipack <= 2 || ipack >= 5) {
1182 } else if (givens) {
1184 /* Check whether to use Givens rotations, */
1185 /* Householder transformations, or nothing. */
1189 /* Non-symmetric -- A = U D V */
1198 for (j = 1; j <= i__1; ++j) {
1199 i__2 = (1 - iskew) * j + ioffst + j * a_dim1;
1201 z__1.r = d__[i__3], z__1.i = 0.;
1202 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
1209 for (jku = 1; jku <= i__1; ++jku) {
1211 /* Transform from bandwidth JKL, JKU-1 to JKL, JKU */
1213 /* Last row actually rotated is M */
1214 /* Last column actually rotated is MIN( M+JKU, N ) */
1218 i__2 = f2cmin(i__3,*n) + jkl - 1;
1219 for (jr = 1; jr <= i__2; ++jr) {
1220 extra.r = 0., extra.i = 0.;
1221 angle = dlarnd_(&c__1, &iseed[1]) *
1222 6.2831853071795864769252867663;
1224 //zlarnd_(&z__2, &c__5, &iseed[1]);
1225 z__2=zlarnd_(&c__5, &iseed[1]);
1226 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1227 c__.r = z__1.r, c__.i = z__1.i;
1229 //zlarnd_(&z__2, &c__5, &iseed[1]);
1230 z__2=zlarnd_(&c__5, &iseed[1]);
1231 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1232 s.r = z__1.r, s.i = z__1.i;
1234 i__3 = 1, i__4 = jr - jkl;
1235 icol = f2cmax(i__3,i__4);
1238 i__3 = *n, i__4 = jr + jku;
1239 il = f2cmin(i__3,i__4) + 1 - icol;
1241 zlarot_(&c_true, &L__1, &c_false, &il, &c__, &s, &
1242 a[jr - iskew * icol + ioffst + icol *
1243 a_dim1], &ilda, &extra, &dummy);
1246 /* Chase "EXTRA" back up */
1251 for (jch = jr - jkl; i__3 < 0 ? jch >= 1 : jch <= 1;
1254 zlartg_(&a[ir + 1 - iskew * (ic + 1) + ioffst
1255 + (ic + 1) * a_dim1], &extra, &realc,
1257 //zlarnd_(&z__1, &c__5, &iseed[1]);
1258 z__1=zlarnd_(&c__5, &iseed[1]);
1259 dummy.r = z__1.r, dummy.i = z__1.i;
1260 z__2.r = realc * dummy.r, z__2.i = realc *
1262 d_cnjg(&z__1, &z__2);
1263 c__.r = z__1.r, c__.i = z__1.i;
1264 z__3.r = -s.r, z__3.i = -s.i;
1265 z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
1266 z__2.i = z__3.r * dummy.i + z__3.i *
1268 d_cnjg(&z__1, &z__2);
1269 s.r = z__1.r, s.i = z__1.i;
1272 i__4 = 1, i__5 = jch - jku;
1273 irow = f2cmax(i__4,i__5);
1275 ctemp.r = 0., ctemp.i = 0.;
1277 zlarot_(&c_false, &iltemp, &c_true, &il, &c__, &s,
1278 &a[irow - iskew * ic + ioffst + ic *
1279 a_dim1], &ilda, &ctemp, &extra);
1281 zlartg_(&a[irow + 1 - iskew * (ic + 1) +
1282 ioffst + (ic + 1) * a_dim1], &ctemp, &
1284 //zlarnd_(&z__1, &c__5, &iseed[1]);
1285 z__1=zlarnd_(&c__5, &iseed[1]);
1286 dummy.r = z__1.r, dummy.i = z__1.i;
1287 z__2.r = realc * dummy.r, z__2.i = realc *
1289 d_cnjg(&z__1, &z__2);
1290 c__.r = z__1.r, c__.i = z__1.i;
1291 z__3.r = -s.r, z__3.i = -s.i;
1292 z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
1293 z__2.i = z__3.r * dummy.i + z__3.i *
1295 d_cnjg(&z__1, &z__2);
1296 s.r = z__1.r, s.i = z__1.i;
1299 i__4 = 1, i__5 = jch - jku - jkl;
1300 icol = f2cmax(i__4,i__5);
1302 extra.r = 0., extra.i = 0.;
1303 L__1 = jch > jku + jkl;
1304 zlarot_(&c_true, &L__1, &c_true, &il, &c__, &
1305 s, &a[irow - iskew * icol + ioffst +
1306 icol * a_dim1], &ilda, &extra, &ctemp)
1320 for (jkl = 1; jkl <= i__1; ++jkl) {
1322 /* Transform from bandwidth JKL-1, JKU to JKL, JKU */
1326 i__2 = f2cmin(i__3,*m) + jku - 1;
1327 for (jc = 1; jc <= i__2; ++jc) {
1328 extra.r = 0., extra.i = 0.;
1329 angle = dlarnd_(&c__1, &iseed[1]) *
1330 6.2831853071795864769252867663;
1332 //zlarnd_(&z__2, &c__5, &iseed[1]);
1333 z__2=zlarnd_(&c__5, &iseed[1]);
1334 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1335 c__.r = z__1.r, c__.i = z__1.i;
1337 //zlarnd_(&z__2, &c__5, &iseed[1]);
1338 z__2=zlarnd_(&c__5, &iseed[1]);
1339 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1340 s.r = z__1.r, s.i = z__1.i;
1342 i__3 = 1, i__4 = jc - jku;
1343 irow = f2cmax(i__3,i__4);
1346 i__3 = *m, i__4 = jc + jkl;
1347 il = f2cmin(i__3,i__4) + 1 - irow;
1349 zlarot_(&c_false, &L__1, &c_false, &il, &c__, &s,
1350 &a[irow - iskew * jc + ioffst + jc *
1351 a_dim1], &ilda, &extra, &dummy);
1354 /* Chase "EXTRA" back up */
1359 for (jch = jc - jku; i__3 < 0 ? jch >= 1 : jch <= 1;
1362 zlartg_(&a[ir + 1 - iskew * (ic + 1) + ioffst
1363 + (ic + 1) * a_dim1], &extra, &realc,
1365 //zlarnd_(&z__1, &c__5, &iseed[1]);
1366 z__1=zlarnd_(&c__5, &iseed[1]);
1367 dummy.r = z__1.r, dummy.i = z__1.i;
1368 z__2.r = realc * dummy.r, z__2.i = realc *
1370 d_cnjg(&z__1, &z__2);
1371 c__.r = z__1.r, c__.i = z__1.i;
1372 z__3.r = -s.r, z__3.i = -s.i;
1373 z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
1374 z__2.i = z__3.r * dummy.i + z__3.i *
1376 d_cnjg(&z__1, &z__2);
1377 s.r = z__1.r, s.i = z__1.i;
1380 i__4 = 1, i__5 = jch - jkl;
1381 icol = f2cmax(i__4,i__5);
1383 ctemp.r = 0., ctemp.i = 0.;
1385 zlarot_(&c_true, &iltemp, &c_true, &il, &c__, &s,
1386 &a[ir - iskew * icol + ioffst + icol *
1387 a_dim1], &ilda, &ctemp, &extra);
1389 zlartg_(&a[ir + 1 - iskew * (icol + 1) +
1390 ioffst + (icol + 1) * a_dim1], &ctemp,
1391 &realc, &s, &dummy);
1392 //zlarnd_(&z__1, &c__5, &iseed[1]);
1393 z__1=zlarnd_(&c__5, &iseed[1]);
1394 dummy.r = z__1.r, dummy.i = z__1.i;
1395 z__2.r = realc * dummy.r, z__2.i = realc *
1397 d_cnjg(&z__1, &z__2);
1398 c__.r = z__1.r, c__.i = z__1.i;
1399 z__3.r = -s.r, z__3.i = -s.i;
1400 z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
1401 z__2.i = z__3.r * dummy.i + z__3.i *
1403 d_cnjg(&z__1, &z__2);
1404 s.r = z__1.r, s.i = z__1.i;
1406 i__4 = 1, i__5 = jch - jkl - jku;
1407 irow = f2cmax(i__4,i__5);
1409 extra.r = 0., extra.i = 0.;
1410 L__1 = jch > jkl + jku;
1411 zlarot_(&c_false, &L__1, &c_true, &il, &c__, &
1412 s, &a[irow - iskew * icol + ioffst +
1413 icol * a_dim1], &ilda, &extra, &ctemp)
1427 /* Bottom-Up -- Start at the bottom right. */
1431 for (jku = 1; jku <= i__1; ++jku) {
1433 /* Transform from bandwidth JKL, JKU-1 to JKL, JKU */
1435 /* First row actually rotated is M */
1436 /* First column actually rotated is MIN( M+JKU, N ) */
1439 i__2 = *m, i__3 = *n + jkl;
1440 iendch = f2cmin(i__2,i__3) - 1;
1444 for (jc = f2cmin(i__2,*n) - 1; jc >= i__3; --jc) {
1445 extra.r = 0., extra.i = 0.;
1446 angle = dlarnd_(&c__1, &iseed[1]) *
1447 6.2831853071795864769252867663;
1449 //zlarnd_(&z__2, &c__5, &iseed[1]);
1450 z__2=zlarnd_(&c__5, &iseed[1]);
1451 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1452 c__.r = z__1.r, c__.i = z__1.i;
1454 //zlarnd_(&z__2, &c__5, &iseed[1]);
1455 z__2=zlarnd_(&c__5, &iseed[1]);
1456 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1457 s.r = z__1.r, s.i = z__1.i;
1459 i__2 = 1, i__4 = jc - jku + 1;
1460 irow = f2cmax(i__2,i__4);
1463 i__2 = *m, i__4 = jc + jkl + 1;
1464 il = f2cmin(i__2,i__4) + 1 - irow;
1465 L__1 = jc + jkl < *m;
1466 zlarot_(&c_false, &c_false, &L__1, &il, &c__, &s,
1467 &a[irow - iskew * jc + ioffst + jc *
1468 a_dim1], &ilda, &dummy, &extra);
1471 /* Chase "EXTRA" back down */
1476 for (jch = jc + jkl; i__4 < 0 ? jch >= i__2 : jch <=
1477 i__2; jch += i__4) {
1480 zlartg_(&a[jch - iskew * ic + ioffst + ic *
1481 a_dim1], &extra, &realc, &s, &dummy);
1482 //zlarnd_(&z__1, &c__5, &iseed[1]);
1483 z__1=zlarnd_(&c__5, &iseed[1]);
1484 dummy.r = z__1.r, dummy.i = z__1.i;
1485 z__1.r = realc * dummy.r, z__1.i = realc *
1487 c__.r = z__1.r, c__.i = z__1.i;
1488 z__1.r = s.r * dummy.r - s.i * dummy.i,
1489 z__1.i = s.r * dummy.i + s.i *
1491 s.r = z__1.r, s.i = z__1.i;
1495 i__5 = *n - 1, i__6 = jch + jku;
1496 icol = f2cmin(i__5,i__6);
1497 iltemp = jch + jku < *n;
1498 ctemp.r = 0., ctemp.i = 0.;
1499 i__5 = icol + 2 - ic;
1500 zlarot_(&c_true, &ilextr, &iltemp, &i__5, &c__, &
1501 s, &a[jch - iskew * ic + ioffst + ic *
1502 a_dim1], &ilda, &extra, &ctemp);
1504 zlartg_(&a[jch - iskew * icol + ioffst + icol
1505 * a_dim1], &ctemp, &realc, &s, &dummy)
1507 //zlarnd_(&z__1, &c__5, &iseed[1]);
1508 z__1=zlarnd_(&c__5, &iseed[1]);
1509 dummy.r = z__1.r, dummy.i = z__1.i;
1510 z__1.r = realc * dummy.r, z__1.i = realc *
1512 c__.r = z__1.r, c__.i = z__1.i;
1513 z__1.r = s.r * dummy.r - s.i * dummy.i,
1514 z__1.i = s.r * dummy.i + s.i *
1516 s.r = z__1.r, s.i = z__1.i;
1518 i__5 = iendch, i__6 = jch + jkl + jku;
1519 il = f2cmin(i__5,i__6) + 2 - jch;
1520 extra.r = 0., extra.i = 0.;
1521 L__1 = jch + jkl + jku <= iendch;
1522 zlarot_(&c_false, &c_true, &L__1, &il, &c__, &
1523 s, &a[jch - iskew * icol + ioffst +
1524 icol * a_dim1], &ilda, &ctemp, &extra)
1537 for (jkl = 1; jkl <= i__1; ++jkl) {
1539 /* Transform from bandwidth JKL-1, JKU to JKL, JKU */
1541 /* First row actually rotated is MIN( N+JKL, M ) */
1542 /* First column actually rotated is N */
1545 i__3 = *n, i__4 = *m + jku;
1546 iendch = f2cmin(i__3,i__4) - 1;
1550 for (jr = f2cmin(i__3,*m) - 1; jr >= i__4; --jr) {
1551 extra.r = 0., extra.i = 0.;
1552 angle = dlarnd_(&c__1, &iseed[1]) *
1553 6.2831853071795864769252867663;
1555 //zlarnd_(&z__2, &c__5, &iseed[1]);
1556 z__2=zlarnd_(&c__5, &iseed[1]);
1557 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1558 c__.r = z__1.r, c__.i = z__1.i;
1560 //zlarnd_(&z__2, &c__5, &iseed[1]);
1561 z__2=zlarnd_(&c__5, &iseed[1]);
1562 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1563 s.r = z__1.r, s.i = z__1.i;
1565 i__3 = 1, i__2 = jr - jkl + 1;
1566 icol = f2cmax(i__3,i__2);
1569 i__3 = *n, i__2 = jr + jku + 1;
1570 il = f2cmin(i__3,i__2) + 1 - icol;
1571 L__1 = jr + jku < *n;
1572 zlarot_(&c_true, &c_false, &L__1, &il, &c__, &s, &
1573 a[jr - iskew * icol + ioffst + icol *
1574 a_dim1], &ilda, &dummy, &extra);
1577 /* Chase "EXTRA" back down */
1582 for (jch = jr + jku; i__2 < 0 ? jch >= i__3 : jch <=
1583 i__3; jch += i__2) {
1586 zlartg_(&a[ir - iskew * jch + ioffst + jch *
1587 a_dim1], &extra, &realc, &s, &dummy);
1588 //zlarnd_(&z__1, &c__5, &iseed[1]);
1589 z__1=zlarnd_(&c__5, &iseed[1]);
1590 dummy.r = z__1.r, dummy.i = z__1.i;
1591 z__1.r = realc * dummy.r, z__1.i = realc *
1593 c__.r = z__1.r, c__.i = z__1.i;
1594 z__1.r = s.r * dummy.r - s.i * dummy.i,
1595 z__1.i = s.r * dummy.i + s.i *
1597 s.r = z__1.r, s.i = z__1.i;
1601 i__5 = *m - 1, i__6 = jch + jkl;
1602 irow = f2cmin(i__5,i__6);
1603 iltemp = jch + jkl < *m;
1604 ctemp.r = 0., ctemp.i = 0.;
1605 i__5 = irow + 2 - ir;
1606 zlarot_(&c_false, &ilextr, &iltemp, &i__5, &c__, &
1607 s, &a[ir - iskew * jch + ioffst + jch *
1608 a_dim1], &ilda, &extra, &ctemp);
1610 zlartg_(&a[irow - iskew * jch + ioffst + jch *
1611 a_dim1], &ctemp, &realc, &s, &dummy);
1612 //zlarnd_(&z__1, &c__5, &iseed[1]);
1613 z__1=zlarnd_(&c__5, &iseed[1]);
1614 dummy.r = z__1.r, dummy.i = z__1.i;
1615 z__1.r = realc * dummy.r, z__1.i = realc *
1617 c__.r = z__1.r, c__.i = z__1.i;
1618 z__1.r = s.r * dummy.r - s.i * dummy.i,
1619 z__1.i = s.r * dummy.i + s.i *
1621 s.r = z__1.r, s.i = z__1.i;
1623 i__5 = iendch, i__6 = jch + jkl + jku;
1624 il = f2cmin(i__5,i__6) + 2 - jch;
1625 extra.r = 0., extra.i = 0.;
1626 L__1 = jch + jkl + jku <= iendch;
1627 zlarot_(&c_true, &c_true, &L__1, &il, &c__, &
1628 s, &a[irow - iskew * jch + ioffst +
1629 jch * a_dim1], &ilda, &ctemp, &extra);
1643 /* Symmetric -- A = U D U' */
1644 /* Hermitian -- A = U D U* */
1651 /* Top-Down -- Generate Upper triangle only */
1661 for (j = 1; j <= i__1; ++j) {
1662 i__4 = (1 - iskew) * j + ioffg + j * a_dim1;
1664 z__1.r = d__[i__2], z__1.i = 0.;
1665 a[i__4].r = z__1.r, a[i__4].i = z__1.i;
1670 for (k = 1; k <= i__1; ++k) {
1672 for (jc = 1; jc <= i__4; ++jc) {
1674 i__2 = 1, i__3 = jc - k;
1675 irow = f2cmax(i__2,i__3);
1677 i__2 = jc + 1, i__3 = k + 2;
1678 il = f2cmin(i__2,i__3);
1679 extra.r = 0., extra.i = 0.;
1680 i__2 = jc - iskew * (jc + 1) + ioffg + (jc + 1) *
1682 ctemp.r = a[i__2].r, ctemp.i = a[i__2].i;
1683 angle = dlarnd_(&c__1, &iseed[1]) *
1684 6.2831853071795864769252867663;
1686 //zlarnd_(&z__2, &c__5, &iseed[1]);
1687 z__2=zlarnd_(&c__5, &iseed[1]);
1688 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1689 c__.r = z__1.r, c__.i = z__1.i;
1691 //zlarnd_(&z__2, &c__5, &iseed[1]);
1692 z__2=zlarnd_(&c__5, &iseed[1]);
1693 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1694 s.r = z__1.r, s.i = z__1.i;
1696 ct.r = c__.r, ct.i = c__.i;
1697 st.r = s.r, st.i = s.i;
1699 d_cnjg(&z__1, &ctemp);
1700 ctemp.r = z__1.r, ctemp.i = z__1.i;
1701 d_cnjg(&z__1, &c__);
1702 ct.r = z__1.r, ct.i = z__1.i;
1704 st.r = z__1.r, st.i = z__1.i;
1707 zlarot_(&c_false, &L__1, &c_true, &il, &c__, &s, &a[
1708 irow - iskew * jc + ioffg + jc * a_dim1], &
1709 ilda, &extra, &ctemp);
1711 i__3 = k, i__5 = *n - jc;
1712 i__2 = f2cmin(i__3,i__5) + 1;
1713 zlarot_(&c_true, &c_true, &c_false, &i__2, &ct, &st, &
1714 a[(1 - iskew) * jc + ioffg + jc * a_dim1], &
1715 ilda, &ctemp, &dummy);
1717 /* Chase EXTRA back up the matrix */
1721 for (jch = jc - k; i__2 < 0 ? jch >= 1 : jch <= 1;
1723 zlartg_(&a[jch + 1 - iskew * (icol + 1) + ioffg +
1724 (icol + 1) * a_dim1], &extra, &realc, &s,
1726 //zlarnd_(&z__1, &c__5, &iseed[1]);
1727 z__1=zlarnd_(&c__5, &iseed[1]);
1728 dummy.r = z__1.r, dummy.i = z__1.i;
1729 z__2.r = realc * dummy.r, z__2.i = realc *
1731 d_cnjg(&z__1, &z__2);
1732 c__.r = z__1.r, c__.i = z__1.i;
1733 z__3.r = -s.r, z__3.i = -s.i;
1734 z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
1735 z__2.i = z__3.r * dummy.i + z__3.i *
1737 d_cnjg(&z__1, &z__2);
1738 s.r = z__1.r, s.i = z__1.i;
1739 i__3 = jch - iskew * (jch + 1) + ioffg + (jch + 1)
1741 ctemp.r = a[i__3].r, ctemp.i = a[i__3].i;
1743 ct.r = c__.r, ct.i = c__.i;
1744 st.r = s.r, st.i = s.i;
1746 d_cnjg(&z__1, &ctemp);
1747 ctemp.r = z__1.r, ctemp.i = z__1.i;
1748 d_cnjg(&z__1, &c__);
1749 ct.r = z__1.r, ct.i = z__1.i;
1751 st.r = z__1.r, st.i = z__1.i;
1754 zlarot_(&c_true, &c_true, &c_true, &i__3, &c__, &
1755 s, &a[(1 - iskew) * jch + ioffg + jch *
1756 a_dim1], &ilda, &ctemp, &extra);
1758 i__3 = 1, i__5 = jch - k;
1759 irow = f2cmax(i__3,i__5);
1761 i__3 = jch + 1, i__5 = k + 2;
1762 il = f2cmin(i__3,i__5);
1763 extra.r = 0., extra.i = 0.;
1765 zlarot_(&c_false, &L__1, &c_true, &il, &ct, &st, &
1766 a[irow - iskew * jch + ioffg + jch *
1767 a_dim1], &ilda, &extra, &ctemp);
1776 /* If we need lower triangle, copy from upper. Note that */
1777 /* the order of copying is chosen to work for 'q' -> 'b' */
1779 if (ipack != ipackg && ipack != 3) {
1781 for (jc = 1; jc <= i__1; ++jc) {
1782 irow = ioffst - iskew * jc;
1785 i__2 = *n, i__3 = jc + uub;
1786 i__4 = f2cmin(i__2,i__3);
1787 for (jr = jc; jr <= i__4; ++jr) {
1788 i__2 = jr + irow + jc * a_dim1;
1789 i__3 = jc - iskew * jr + ioffg + jr * a_dim1;
1790 a[i__2].r = a[i__3].r, a[i__2].i = a[i__3].i;
1795 i__2 = *n, i__3 = jc + uub;
1796 i__4 = f2cmin(i__2,i__3);
1797 for (jr = jc; jr <= i__4; ++jr) {
1798 i__2 = jr + irow + jc * a_dim1;
1799 d_cnjg(&z__1, &a[jc - iskew * jr + ioffg + jr
1801 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
1809 for (jc = *n - uub + 1; jc <= i__1; ++jc) {
1811 for (jr = *n + 2 - jc; jr <= i__4; ++jr) {
1812 i__2 = jr + jc * a_dim1;
1813 a[i__2].r = 0., a[i__2].i = 0.;
1827 /* Bottom-Up -- Generate Lower triangle only */
1839 for (j = 1; j <= i__1; ++j) {
1840 i__4 = (1 - iskew) * j + ioffg + j * a_dim1;
1842 z__1.r = d__[i__2], z__1.i = 0.;
1843 a[i__4].r = z__1.r, a[i__4].i = z__1.i;
1848 for (k = 1; k <= i__1; ++k) {
1849 for (jc = *n - 1; jc >= 1; --jc) {
1851 i__4 = *n + 1 - jc, i__2 = k + 2;
1852 il = f2cmin(i__4,i__2);
1853 extra.r = 0., extra.i = 0.;
1854 i__4 = (1 - iskew) * jc + 1 + ioffg + jc * a_dim1;
1855 ctemp.r = a[i__4].r, ctemp.i = a[i__4].i;
1856 angle = dlarnd_(&c__1, &iseed[1]) *
1857 6.2831853071795864769252867663;
1859 //zlarnd_(&z__2, &c__5, &iseed[1]);
1860 z__2=zlarnd_(&c__5, &iseed[1]);
1861 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1862 c__.r = z__1.r, c__.i = z__1.i;
1864 //zlarnd_(&z__2, &c__5, &iseed[1]);
1865 z__2=zlarnd_(&c__5, &iseed[1]);
1866 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
1867 s.r = z__1.r, s.i = z__1.i;
1869 ct.r = c__.r, ct.i = c__.i;
1870 st.r = s.r, st.i = s.i;
1872 d_cnjg(&z__1, &ctemp);
1873 ctemp.r = z__1.r, ctemp.i = z__1.i;
1874 d_cnjg(&z__1, &c__);
1875 ct.r = z__1.r, ct.i = z__1.i;
1877 st.r = z__1.r, st.i = z__1.i;
1880 zlarot_(&c_false, &c_true, &L__1, &il, &c__, &s, &a[(
1881 1 - iskew) * jc + ioffg + jc * a_dim1], &ilda,
1884 i__4 = 1, i__2 = jc - k + 1;
1885 icol = f2cmax(i__4,i__2);
1886 i__4 = jc + 2 - icol;
1887 zlarot_(&c_true, &c_false, &c_true, &i__4, &ct, &st, &
1888 a[jc - iskew * icol + ioffg + icol * a_dim1],
1889 &ilda, &dummy, &ctemp);
1891 /* Chase EXTRA back down the matrix */
1896 for (jch = jc + k; i__2 < 0 ? jch >= i__4 : jch <=
1897 i__4; jch += i__2) {
1898 zlartg_(&a[jch - iskew * icol + ioffg + icol *
1899 a_dim1], &extra, &realc, &s, &dummy);
1900 //zlarnd_(&z__1, &c__5, &iseed[1]);
1901 z__1=zlarnd_(&c__5, &iseed[1]);
1902 dummy.r = z__1.r, dummy.i = z__1.i;
1903 z__1.r = realc * dummy.r, z__1.i = realc *
1905 c__.r = z__1.r, c__.i = z__1.i;
1906 z__1.r = s.r * dummy.r - s.i * dummy.i, z__1.i =
1907 s.r * dummy.i + s.i * dummy.r;
1908 s.r = z__1.r, s.i = z__1.i;
1909 i__3 = (1 - iskew) * jch + 1 + ioffg + jch *
1911 ctemp.r = a[i__3].r, ctemp.i = a[i__3].i;
1913 ct.r = c__.r, ct.i = c__.i;
1914 st.r = s.r, st.i = s.i;
1916 d_cnjg(&z__1, &ctemp);
1917 ctemp.r = z__1.r, ctemp.i = z__1.i;
1918 d_cnjg(&z__1, &c__);
1919 ct.r = z__1.r, ct.i = z__1.i;
1921 st.r = z__1.r, st.i = z__1.i;
1924 zlarot_(&c_true, &c_true, &c_true, &i__3, &c__, &
1925 s, &a[jch - iskew * icol + ioffg + icol *
1926 a_dim1], &ilda, &extra, &ctemp);
1928 i__3 = *n + 1 - jch, i__5 = k + 2;
1929 il = f2cmin(i__3,i__5);
1930 extra.r = 0., extra.i = 0.;
1931 L__1 = *n - jch > k;
1932 zlarot_(&c_false, &c_true, &L__1, &il, &ct, &st, &
1933 a[(1 - iskew) * jch + ioffg + jch *
1934 a_dim1], &ilda, &ctemp, &extra);
1943 /* If we need upper triangle, copy from lower. Note that */
1944 /* the order of copying is chosen to work for 'b' -> 'q' */
1946 if (ipack != ipackg && ipack != 4) {
1947 for (jc = *n; jc >= 1; --jc) {
1948 irow = ioffst - iskew * jc;
1951 i__2 = 1, i__4 = jc - uub;
1952 i__1 = f2cmax(i__2,i__4);
1953 for (jr = jc; jr >= i__1; --jr) {
1954 i__2 = jr + irow + jc * a_dim1;
1955 i__4 = jc - iskew * jr + ioffg + jr * a_dim1;
1956 a[i__2].r = a[i__4].r, a[i__2].i = a[i__4].i;
1961 i__2 = 1, i__4 = jc - uub;
1962 i__1 = f2cmax(i__2,i__4);
1963 for (jr = jc; jr >= i__1; --jr) {
1964 i__2 = jr + irow + jc * a_dim1;
1965 d_cnjg(&z__1, &a[jc - iskew * jr + ioffg + jr
1967 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
1975 for (jc = 1; jc <= i__1; ++jc) {
1976 i__2 = uub + 1 - jc;
1977 for (jr = 1; jr <= i__2; ++jr) {
1978 i__4 = jr + jc * a_dim1;
1979 a[i__4].r = 0., a[i__4].i = 0.;
1993 /* Ensure that the diagonal is real if Hermitian */
1997 for (jc = 1; jc <= i__1; ++jc) {
1998 irow = ioffst + (1 - iskew) * jc;
1999 i__2 = irow + jc * a_dim1;
2000 i__4 = irow + jc * a_dim1;
2002 z__1.r = d__1, z__1.i = 0.;
2003 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
2012 /* 4) Generate Banded Matrix by first */
2013 /* Rotating by random Unitary matrices, */
2014 /* then reducing the bandwidth using Householder */
2015 /* transformations. */
2017 /* Note: we should get here only if LDA .ge. N */
2021 /* Non-symmetric -- A = U D V */
2023 zlagge_(&mr, &nc, &llb, &uub, &d__[1], &a[a_offset], lda, &iseed[
2024 1], &work[1], &iinfo);
2027 /* Symmetric -- A = U D U' or */
2028 /* Hermitian -- A = U D U* */
2031 zlagsy_(m, &llb, &d__[1], &a[a_offset], lda, &iseed[1], &work[
2034 zlaghe_(m, &llb, &d__[1], &a[a_offset], lda, &iseed[1], &work[
2045 /* 5) Pack the matrix */
2047 if (ipack != ipackg) {
2050 /* 'U' -- Upper triangular, not packed */
2053 for (j = 1; j <= i__1; ++j) {
2055 for (i__ = j + 1; i__ <= i__2; ++i__) {
2056 i__4 = i__ + j * a_dim1;
2057 a[i__4].r = 0., a[i__4].i = 0.;
2063 } else if (ipack == 2) {
2065 /* 'L' -- Lower triangular, not packed */
2068 for (j = 2; j <= i__1; ++j) {
2070 for (i__ = 1; i__ <= i__2; ++i__) {
2071 i__4 = i__ + j * a_dim1;
2072 a[i__4].r = 0., a[i__4].i = 0.;
2078 } else if (ipack == 3) {
2080 /* 'C' -- Upper triangle packed Columnwise. */
2085 for (j = 1; j <= i__1; ++j) {
2087 for (i__ = 1; i__ <= i__2; ++i__) {
2093 i__4 = irow + icol * a_dim1;
2094 i__3 = i__ + j * a_dim1;
2095 a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
2101 } else if (ipack == 4) {
2103 /* 'R' -- Lower triangle packed Columnwise. */
2108 for (j = 1; j <= i__1; ++j) {
2110 for (i__ = j; i__ <= i__2; ++i__) {
2116 i__4 = irow + icol * a_dim1;
2117 i__3 = i__ + j * a_dim1;
2118 a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
2124 } else if (ipack >= 5) {
2126 /* 'B' -- The lower triangle is packed as a band matrix. */
2127 /* 'Q' -- The upper triangle is packed as a band matrix. */
2128 /* 'Z' -- The whole matrix is packed as a band matrix. */
2138 for (j = 1; j <= i__1; ++j) {
2141 for (i__ = f2cmin(i__2,*m); i__ >= 1; --i__) {
2142 i__2 = i__ - j + uub + 1 + j * a_dim1;
2143 i__4 = i__ + j * a_dim1;
2144 a[i__2].r = a[i__4].r, a[i__2].i = a[i__4].i;
2151 for (j = uub + 2; j <= i__1; ++j) {
2154 i__2 = f2cmin(i__4,*m);
2155 for (i__ = j - uub; i__ <= i__2; ++i__) {
2156 i__4 = i__ - j + uub + 1 + j * a_dim1;
2157 i__3 = i__ + j * a_dim1;
2158 a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
2165 /* If packed, zero out extraneous elements. */
2167 /* Symmetric/Triangular Packed -- */
2168 /* zero out everything after A(IROW,ICOL) */
2170 if (ipack == 3 || ipack == 4) {
2172 for (jc = icol; jc <= i__1; ++jc) {
2174 for (jr = irow + 1; jr <= i__2; ++jr) {
2175 i__4 = jr + jc * a_dim1;
2176 a[i__4].r = 0., a[i__4].i = 0.;
2183 } else if (ipack >= 5) {
2185 /* Packed Band -- */
2186 /* 1st row is now in A( UUB+2-j, j), zero above it */
2187 /* m-th row is now in A( M+UUB-j,j), zero below it */
2188 /* last non-zero diagonal is now in A( UUB+LLB+1,j ), */
2189 /* zero below it, too. */
2191 ir1 = uub + llb + 2;
2194 for (jc = 1; jc <= i__1; ++jc) {
2195 i__2 = uub + 1 - jc;
2196 for (jr = 1; jr <= i__2; ++jr) {
2197 i__4 = jr + jc * a_dim1;
2198 a[i__4].r = 0., a[i__4].i = 0.;
2203 i__3 = ir1, i__5 = ir2 - jc;
2204 i__2 = 1, i__4 = f2cmin(i__3,i__5);
2206 for (jr = f2cmax(i__2,i__4); jr <= i__6; ++jr) {
2207 i__2 = jr + jc * a_dim1;
2208 a[i__2].r = 0., a[i__2].i = 0.;