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 doublecomplex c_b2 = {1.,0.};
518 static integer c__1 = 1;
519 static integer c__0 = 0;
520 static integer c__5 = 5;
522 /* > \brief \b ZLATME */
524 /* =========== DOCUMENTATION =========== */
526 /* Online html documentation available at */
527 /* http://www.netlib.org/lapack/explore-html/ */
532 /* SUBROUTINE ZLATME( N, DIST, ISEED, D, MODE, COND, DMAX, */
534 /* UPPER, SIM, DS, MODES, CONDS, KL, KU, ANORM, */
536 /* LDA, WORK, INFO ) */
538 /* CHARACTER DIST, RSIGN, SIM, UPPER */
539 /* INTEGER INFO, KL, KU, LDA, MODE, MODES, N */
540 /* DOUBLE PRECISION ANORM, COND, CONDS */
541 /* COMPLEX*16 DMAX */
542 /* INTEGER ISEED( 4 ) */
543 /* DOUBLE PRECISION DS( * ) */
544 /* COMPLEX*16 A( LDA, * ), D( * ), WORK( * ) */
547 /* > \par Purpose: */
552 /* > ZLATME generates random non-symmetric square matrices with */
553 /* > specified eigenvalues for testing LAPACK programs. */
555 /* > ZLATME operates by applying the following sequence of */
558 /* > 1. Set the diagonal to D, where D may be input or */
559 /* > computed according to MODE, COND, DMAX, and RSIGN */
560 /* > as described below. */
562 /* > 2. If UPPER='T', the upper triangle of A is set to random values */
563 /* > out of distribution DIST. */
565 /* > 3. If SIM='T', A is multiplied on the left by a random matrix */
566 /* > X, whose singular values are specified by DS, MODES, and */
567 /* > CONDS, and on the right by X inverse. */
569 /* > 4. If KL < N-1, the lower bandwidth is reduced to KL using */
570 /* > Householder transformations. If KU < N-1, the upper */
571 /* > bandwidth is reduced to KU. */
573 /* > 5. If ANORM is not negative, the matrix is scaled to have */
574 /* > maximum-element-norm ANORM. */
576 /* > (Note: since the matrix cannot be reduced beyond Hessenberg form, */
577 /* > no packing options are available.) */
586 /* > The number of columns (or rows) of A. Not modified. */
589 /* > \param[in] DIST */
591 /* > DIST is CHARACTER*1 */
592 /* > On entry, DIST specifies the type of distribution to be used */
593 /* > to generate the random eigen-/singular values, and on the */
594 /* > upper triangle (see UPPER). */
595 /* > 'U' => UNIFORM( 0, 1 ) ( 'U' for uniform ) */
596 /* > 'S' => UNIFORM( -1, 1 ) ( 'S' for symmetric ) */
597 /* > 'N' => NORMAL( 0, 1 ) ( 'N' for normal ) */
598 /* > 'D' => uniform on the complex disc |z| < 1. */
599 /* > Not modified. */
602 /* > \param[in,out] ISEED */
604 /* > ISEED is INTEGER array, dimension ( 4 ) */
605 /* > On entry ISEED specifies the seed of the random number */
606 /* > generator. They should lie between 0 and 4095 inclusive, */
607 /* > and ISEED(4) should be odd. The random number generator */
608 /* > uses a linear congruential sequence limited to small */
609 /* > integers, and so should produce machine independent */
610 /* > random numbers. The values of ISEED are changed on */
611 /* > exit, and can be used in the next call to ZLATME */
612 /* > to continue the same random number sequence. */
613 /* > Changed on exit. */
616 /* > \param[in,out] D */
618 /* > D is COMPLEX*16 array, dimension ( N ) */
619 /* > This array is used to specify the eigenvalues of A. If */
620 /* > MODE=0, then D is assumed to contain the eigenvalues */
621 /* > otherwise they will be computed according to MODE, COND, */
622 /* > DMAX, and RSIGN and placed in D. */
623 /* > Modified if MODE is nonzero. */
626 /* > \param[in] MODE */
628 /* > MODE is INTEGER */
629 /* > On entry this describes how the eigenvalues are to */
630 /* > be specified: */
631 /* > MODE = 0 means use D as input */
632 /* > MODE = 1 sets D(1)=1 and D(2:N)=1.0/COND */
633 /* > MODE = 2 sets D(1:N-1)=1 and D(N)=1.0/COND */
634 /* > MODE = 3 sets D(I)=COND**(-(I-1)/(N-1)) */
635 /* > MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */
636 /* > MODE = 5 sets D to random numbers in the range */
637 /* > ( 1/COND , 1 ) such that their logarithms */
638 /* > are uniformly distributed. */
639 /* > MODE = 6 set D to random numbers from same distribution */
640 /* > as the rest of the matrix. */
641 /* > MODE < 0 has the same meaning as ABS(MODE), except that */
642 /* > the order of the elements of D is reversed. */
643 /* > Thus if MODE is between 1 and 4, D has entries ranging */
644 /* > from 1 to 1/COND, if between -1 and -4, D has entries */
645 /* > ranging from 1/COND to 1, */
646 /* > Not modified. */
649 /* > \param[in] COND */
651 /* > COND is DOUBLE PRECISION */
652 /* > On entry, this is used as described under MODE above. */
653 /* > If used, it must be >= 1. Not modified. */
656 /* > \param[in] DMAX */
658 /* > DMAX is COMPLEX*16 */
659 /* > If MODE is neither -6, 0 nor 6, the contents of D, as */
660 /* > computed according to MODE and COND, will be scaled by */
661 /* > DMAX / f2cmax(abs(D(i))). Note that DMAX need not be */
662 /* > positive or real: if DMAX is negative or complex (or zero), */
663 /* > D will be scaled by a negative or complex number (or zero). */
664 /* > If RSIGN='F' then the largest (absolute) eigenvalue will be */
665 /* > equal to DMAX. */
666 /* > Not modified. */
669 /* > \param[in] RSIGN */
671 /* > RSIGN is CHARACTER*1 */
672 /* > If MODE is not 0, 6, or -6, and RSIGN='T', then the */
673 /* > elements of D, as computed according to MODE and COND, will */
674 /* > be multiplied by a random complex number from the unit */
675 /* > circle |z| = 1. If RSIGN='F', they will not be. RSIGN may */
676 /* > only have the values 'T' or 'F'. */
677 /* > Not modified. */
680 /* > \param[in] UPPER */
682 /* > UPPER is CHARACTER*1 */
683 /* > If UPPER='T', then the elements of A above the diagonal */
684 /* > will be set to random numbers out of DIST. If UPPER='F', */
685 /* > they will not. UPPER may only have the values 'T' or 'F'. */
686 /* > Not modified. */
689 /* > \param[in] SIM */
691 /* > SIM is CHARACTER*1 */
692 /* > If SIM='T', then A will be operated on by a "similarity */
693 /* > transform", i.e., multiplied on the left by a matrix X and */
694 /* > on the right by X inverse. X = U S V, where U and V are */
695 /* > random unitary matrices and S is a (diagonal) matrix of */
696 /* > singular values specified by DS, MODES, and CONDS. If */
697 /* > SIM='F', then A will not be transformed. */
698 /* > Not modified. */
701 /* > \param[in,out] DS */
703 /* > DS is DOUBLE PRECISION array, dimension ( N ) */
704 /* > This array is used to specify the singular values of X, */
705 /* > in the same way that D specifies the eigenvalues of A. */
706 /* > If MODE=0, the DS contains the singular values, which */
707 /* > may not be zero. */
708 /* > Modified if MODE is nonzero. */
711 /* > \param[in] MODES */
713 /* > MODES is INTEGER */
716 /* > \param[in] CONDS */
718 /* > CONDS is DOUBLE PRECISION */
719 /* > Similar to MODE and COND, but for specifying the diagonal */
720 /* > of S. MODES=-6 and +6 are not allowed (since they would */
721 /* > result in randomly ill-conditioned eigenvalues.) */
724 /* > \param[in] KL */
726 /* > KL is INTEGER */
727 /* > This specifies the lower bandwidth of the matrix. KL=1 */
728 /* > specifies upper Hessenberg form. If KL is at least N-1, */
729 /* > then A will have full lower bandwidth. */
730 /* > Not modified. */
733 /* > \param[in] KU */
735 /* > KU is INTEGER */
736 /* > This specifies the upper bandwidth of the matrix. KU=1 */
737 /* > specifies lower Hessenberg form. If KU is at least N-1, */
738 /* > then A will have full upper bandwidth; if KU and KL */
739 /* > are both at least N-1, then A will be dense. Only one of */
740 /* > KU and KL may be less than N-1. */
741 /* > Not modified. */
744 /* > \param[in] ANORM */
746 /* > ANORM is DOUBLE PRECISION */
747 /* > If ANORM is not negative, then A will be scaled by a non- */
748 /* > negative real number to make the maximum-element-norm of A */
750 /* > Not modified. */
753 /* > \param[out] A */
755 /* > A is COMPLEX*16 array, dimension ( LDA, N ) */
756 /* > On exit A is the desired test matrix. */
760 /* > \param[in] LDA */
762 /* > LDA is INTEGER */
763 /* > LDA specifies the first dimension of A as declared in the */
764 /* > calling program. LDA must be at least M. */
765 /* > Not modified. */
768 /* > \param[out] WORK */
770 /* > WORK is COMPLEX*16 array, dimension ( 3*N ) */
775 /* > \param[out] INFO */
777 /* > INFO is INTEGER */
778 /* > Error code. On exit, INFO will be set to one of the */
779 /* > following values: */
780 /* > 0 => normal return */
781 /* > -1 => N negative */
782 /* > -2 => DIST illegal string */
783 /* > -5 => MODE not in range -6 to 6 */
784 /* > -6 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
785 /* > -9 => RSIGN is not 'T' or 'F' */
786 /* > -10 => UPPER is not 'T' or 'F' */
787 /* > -11 => SIM is not 'T' or 'F' */
788 /* > -12 => MODES=0 and DS has a zero singular value. */
789 /* > -13 => MODES is not in the range -5 to 5. */
790 /* > -14 => MODES is nonzero and CONDS is less than 1. */
791 /* > -15 => KL is less than 1. */
792 /* > -16 => KU is less than 1, or KL and KU are both less than */
794 /* > -19 => LDA is less than M. */
795 /* > 1 => Error return from ZLATM1 (computing D) */
796 /* > 2 => Cannot scale to DMAX (f2cmax. eigenvalue is 0) */
797 /* > 3 => Error return from DLATM1 (computing DS) */
798 /* > 4 => Error return from ZLARGE */
799 /* > 5 => Zero singular value from DLATM1. */
805 /* > \author Univ. of Tennessee */
806 /* > \author Univ. of California Berkeley */
807 /* > \author Univ. of Colorado Denver */
808 /* > \author NAG Ltd. */
810 /* > \date December 2016 */
812 /* > \ingroup complex16_matgen */
814 /* ===================================================================== */
815 /* Subroutine */ int zlatme_(integer *n, char *dist, integer *iseed,
816 doublecomplex *d__, integer *mode, doublereal *cond, doublecomplex *
817 dmax__, char *rsign, char *upper, char *sim, doublereal *ds, integer *
818 modes, doublereal *conds, integer *kl, integer *ku, doublereal *anorm,
819 doublecomplex *a, integer *lda, doublecomplex *work, integer *info)
821 /* System generated locals */
822 integer a_dim1, a_offset, i__1, i__2;
823 doublereal d__1, d__2;
824 doublecomplex z__1, z__2;
826 /* Local variables */
832 extern logical lsame_(char *, char *);
836 extern /* Subroutine */ int zgerc_(integer *, integer *, doublecomplex *,
837 doublecomplex *, integer *, doublecomplex *, integer *,
838 doublecomplex *, integer *);
840 extern /* Subroutine */ int zscal_(integer *, doublecomplex *,
841 doublecomplex *, integer *), zgemv_(char *, integer *, integer *,
842 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
843 integer *, doublecomplex *, doublecomplex *, integer *);
845 extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *,
846 doublecomplex *, integer *), dlatm1_(integer *, doublereal *,
847 integer *, integer *, integer *, doublereal *, integer *, integer
848 *), zlatm1_(integer *, doublereal *, integer *, integer *,
849 integer *, doublecomplex *, integer *, integer *);
852 extern /* Subroutine */ int xerbla_(char *, integer *);
853 extern doublereal zlange_(char *, integer *, integer *, doublecomplex *,
854 integer *, doublereal *);
855 extern /* Subroutine */ int zdscal_(integer *, doublereal *,
856 doublecomplex *, integer *), zlarge_(integer *, doublecomplex *,
857 integer *, integer *, doublecomplex *, integer *), zlarfg_(
858 integer *, doublecomplex *, doublecomplex *, integer *,
859 doublecomplex *), zlacgv_(integer *, doublecomplex *, integer *);
860 //extern /* Double Complex */ VOID zlarnd_(doublecomplex *, integer *,
861 extern doublecomplex zlarnd_(integer *,
864 extern /* Subroutine */ int zlaset_(char *, integer *, integer *,
865 doublecomplex *, doublecomplex *, doublecomplex *, integer *);
867 extern /* Subroutine */ int zlarnv_(integer *, integer *, integer *,
869 doublecomplex xnorms;
874 /* -- LAPACK computational routine (version 3.7.0) -- */
875 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
876 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
880 /* ===================================================================== */
883 /* 1) Decode and Test the input parameters. */
884 /* Initialize flags & seed. */
886 /* Parameter adjustments */
891 a_offset = 1 + a_dim1 * 1;
898 /* Quick return if possible */
906 if (lsame_(dist, "U")) {
908 } else if (lsame_(dist, "S")) {
910 } else if (lsame_(dist, "N")) {
912 } else if (lsame_(dist, "D")) {
920 if (lsame_(rsign, "T")) {
922 } else if (lsame_(rsign, "F")) {
930 if (lsame_(upper, "T")) {
932 } else if (lsame_(upper, "F")) {
940 if (lsame_(sim, "T")) {
942 } else if (lsame_(sim, "F")) {
948 /* Check DS, if MODES=0 and ISIM=1 */
951 if (*modes == 0 && isim == 1) {
953 for (j = 1; j <= i__1; ++j) {
961 /* Set INFO if an error */
965 } else if (idist == -1) {
967 } else if (abs(*mode) > 6) {
969 } else if (*mode != 0 && abs(*mode) != 6 && *cond < 1.) {
971 } else if (irsign == -1) {
973 } else if (iupper == -1) {
975 } else if (isim == -1) {
979 } else if (isim == 1 && abs(*modes) > 5) {
981 } else if (isim == 1 && *modes != 0 && *conds < 1.) {
983 } else if (*kl < 1) {
985 } else if (*ku < 1 || *ku < *n - 1 && *kl < *n - 1) {
987 } else if (*lda < f2cmax(1,*n)) {
993 xerbla_("ZLATME", &i__1);
997 /* Initialize random number generator */
999 for (i__ = 1; i__ <= 4; ++i__) {
1000 iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
1004 if (iseed[4] % 2 != 1) {
1008 /* 2) Set up diagonal of A */
1010 /* Compute D according to COND and MODE */
1012 zlatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], n, &iinfo);
1017 if (*mode != 0 && abs(*mode) != 6) {
1021 temp = z_abs(&d__[1]);
1023 for (i__ = 2; i__ <= i__1; ++i__) {
1025 d__1 = temp, d__2 = z_abs(&d__[i__]);
1026 temp = f2cmax(d__1,d__2);
1031 z__1.r = dmax__->r / temp, z__1.i = dmax__->i / temp;
1032 alpha.r = z__1.r, alpha.i = z__1.i;
1038 zscal_(n, &alpha, &d__[1], &c__1);
1042 zlaset_("Full", n, n, &c_b1, &c_b1, &a[a_offset], lda);
1044 zcopy_(n, &d__[1], &c__1, &a[a_offset], &i__1);
1046 /* 3) If UPPER='T', set upper triangle of A to random numbers. */
1050 for (jc = 2; jc <= i__1; ++jc) {
1052 zlarnv_(&idist, &iseed[1], &i__2, &a[jc * a_dim1 + 1]);
1057 /* 4) If SIM='T', apply similarity transformation. */
1060 /* Transform is X A X , where X = U S V, thus */
1062 /* it is U S V A V' (1/S) U' */
1066 /* Compute S (singular values of the eigenvector matrix) */
1067 /* according to CONDS and MODES */
1069 dlatm1_(modes, conds, &c__0, &c__0, &iseed[1], &ds[1], n, &iinfo);
1075 /* Multiply by V and V' */
1077 zlarge_(n, &a[a_offset], lda, &iseed[1], &work[1], &iinfo);
1083 /* Multiply by S and (1/S) */
1086 for (j = 1; j <= i__1; ++j) {
1087 zdscal_(n, &ds[j], &a[j + a_dim1], lda);
1090 zdscal_(n, &d__1, &a[j * a_dim1 + 1], &c__1);
1098 /* Multiply by U and U' */
1100 zlarge_(n, &a[a_offset], lda, &iseed[1], &work[1], &iinfo);
1107 /* 5) Reduce the bandwidth. */
1111 /* Reduce bandwidth -- kill column */
1114 for (jcr = *kl + 1; jcr <= i__1; ++jcr) {
1116 irows = *n + 1 - jcr;
1117 icols = *n + *kl - jcr;
1119 zcopy_(&irows, &a[jcr + ic * a_dim1], &c__1, &work[1], &c__1);
1120 xnorms.r = work[1].r, xnorms.i = work[1].i;
1121 zlarfg_(&irows, &xnorms, &work[2], &c__1, &tau);
1122 d_cnjg(&z__1, &tau);
1123 tau.r = z__1.r, tau.i = z__1.i;
1124 work[1].r = 1., work[1].i = 0.;
1125 //zlarnd_(&z__1, &c__5, &iseed[1]);
1126 z__1=zlarnd_(&c__5, &iseed[1]);
1127 alpha.r = z__1.r, alpha.i = z__1.i;
1129 zgemv_("C", &irows, &icols, &c_b2, &a[jcr + (ic + 1) * a_dim1],
1130 lda, &work[1], &c__1, &c_b1, &work[irows + 1], &c__1);
1131 z__1.r = -tau.r, z__1.i = -tau.i;
1132 zgerc_(&irows, &icols, &z__1, &work[1], &c__1, &work[irows + 1], &
1133 c__1, &a[jcr + (ic + 1) * a_dim1], lda);
1135 zgemv_("N", n, &irows, &c_b2, &a[jcr * a_dim1 + 1], lda, &work[1],
1136 &c__1, &c_b1, &work[irows + 1], &c__1);
1137 d_cnjg(&z__2, &tau);
1138 z__1.r = -z__2.r, z__1.i = -z__2.i;
1139 zgerc_(n, &irows, &z__1, &work[irows + 1], &c__1, &work[1], &c__1,
1140 &a[jcr * a_dim1 + 1], lda);
1142 i__2 = jcr + ic * a_dim1;
1143 a[i__2].r = xnorms.r, a[i__2].i = xnorms.i;
1145 zlaset_("Full", &i__2, &c__1, &c_b1, &c_b1, &a[jcr + 1 + ic *
1149 zscal_(&i__2, &alpha, &a[jcr + ic * a_dim1], lda);
1150 d_cnjg(&z__1, &alpha);
1151 zscal_(n, &z__1, &a[jcr * a_dim1 + 1], &c__1);
1154 } else if (*ku < *n - 1) {
1156 /* Reduce upper bandwidth -- kill a row at a time. */
1159 for (jcr = *ku + 1; jcr <= i__1; ++jcr) {
1161 irows = *n + *ku - jcr;
1162 icols = *n + 1 - jcr;
1164 zcopy_(&icols, &a[ir + jcr * a_dim1], lda, &work[1], &c__1);
1165 xnorms.r = work[1].r, xnorms.i = work[1].i;
1166 zlarfg_(&icols, &xnorms, &work[2], &c__1, &tau);
1167 d_cnjg(&z__1, &tau);
1168 tau.r = z__1.r, tau.i = z__1.i;
1169 work[1].r = 1., work[1].i = 0.;
1171 zlacgv_(&i__2, &work[2], &c__1);
1172 //zlarnd_(&z__1, &c__5, &iseed[1]);
1173 z__1 = zlarnd_(&c__5, &iseed[1]);
1174 alpha.r = z__1.r, alpha.i = z__1.i;
1176 zgemv_("N", &irows, &icols, &c_b2, &a[ir + 1 + jcr * a_dim1], lda,
1177 &work[1], &c__1, &c_b1, &work[icols + 1], &c__1);
1178 z__1.r = -tau.r, z__1.i = -tau.i;
1179 zgerc_(&irows, &icols, &z__1, &work[icols + 1], &c__1, &work[1], &
1180 c__1, &a[ir + 1 + jcr * a_dim1], lda);
1182 zgemv_("C", &icols, n, &c_b2, &a[jcr + a_dim1], lda, &work[1], &
1183 c__1, &c_b1, &work[icols + 1], &c__1);
1184 d_cnjg(&z__2, &tau);
1185 z__1.r = -z__2.r, z__1.i = -z__2.i;
1186 zgerc_(&icols, n, &z__1, &work[1], &c__1, &work[icols + 1], &c__1,
1187 &a[jcr + a_dim1], lda);
1189 i__2 = ir + jcr * a_dim1;
1190 a[i__2].r = xnorms.r, a[i__2].i = xnorms.i;
1192 zlaset_("Full", &c__1, &i__2, &c_b1, &c_b1, &a[ir + (jcr + 1) *
1196 zscal_(&i__2, &alpha, &a[ir + jcr * a_dim1], &c__1);
1197 d_cnjg(&z__1, &alpha);
1198 zscal_(n, &z__1, &a[jcr + a_dim1], lda);
1203 /* Scale the matrix to have norm ANORM */
1206 temp = zlange_("M", n, n, &a[a_offset], lda, tempa);
1208 ralpha = *anorm / temp;
1210 for (j = 1; j <= i__1; ++j) {
1211 zdscal_(n, &ralpha, &a[j * a_dim1 + 1], &c__1);