14 typedef long long BLASLONG;
15 typedef unsigned long long BLASULONG;
17 typedef long BLASLONG;
18 typedef unsigned long BLASULONG;
22 typedef BLASLONG blasint;
24 #define blasabs(x) llabs(x)
26 #define blasabs(x) labs(x)
30 #define blasabs(x) abs(x)
33 typedef blasint integer;
35 typedef unsigned int uinteger;
36 typedef char *address;
37 typedef short int shortint;
39 typedef double doublereal;
40 typedef struct { real r, i; } complex;
41 typedef struct { doublereal r, i; } doublecomplex;
43 static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
44 static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
45 static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
46 static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
48 static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
49 static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
50 static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
51 static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
53 #define pCf(z) (*_pCf(z))
54 #define pCd(z) (*_pCd(z))
56 typedef short int shortlogical;
57 typedef char logical1;
58 typedef char integer1;
63 /* Extern is for use with -E */
74 /*external read, write*/
83 /*internal read, write*/
113 /*rewind, backspace, endfile*/
125 ftnint *inex; /*parameters in standard's order*/
151 union Multitype { /* for multiple entry points */
162 typedef union Multitype Multitype;
164 struct Vardesc { /* for Namelist */
170 typedef struct Vardesc Vardesc;
177 typedef struct Namelist Namelist;
179 #define abs(x) ((x) >= 0 ? (x) : -(x))
180 #define dabs(x) (fabs(x))
181 #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
182 #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
183 #define dmin(a,b) (f2cmin(a,b))
184 #define dmax(a,b) (f2cmax(a,b))
185 #define bit_test(a,b) ((a) >> (b) & 1)
186 #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
187 #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
189 #define abort_() { sig_die("Fortran abort routine called", 1); }
190 #define c_abs(z) (cabsf(Cf(z)))
191 #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
193 #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
194 #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);}
196 #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
197 #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
199 #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
200 #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
201 #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
202 //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
203 #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
204 #define d_abs(x) (fabs(*(x)))
205 #define d_acos(x) (acos(*(x)))
206 #define d_asin(x) (asin(*(x)))
207 #define d_atan(x) (atan(*(x)))
208 #define d_atn2(x, y) (atan2(*(x),*(y)))
209 #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
210 #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
211 #define d_cos(x) (cos(*(x)))
212 #define d_cosh(x) (cosh(*(x)))
213 #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
214 #define d_exp(x) (exp(*(x)))
215 #define d_imag(z) (cimag(Cd(z)))
216 #define r_imag(z) (cimagf(Cf(z)))
217 #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
218 #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
219 #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
220 #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
221 #define d_log(x) (log(*(x)))
222 #define d_mod(x, y) (fmod(*(x), *(y)))
223 #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
224 #define d_nint(x) u_nint(*(x))
225 #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
226 #define d_sign(a,b) u_sign(*(a),*(b))
227 #define r_sign(a,b) u_sign(*(a),*(b))
228 #define d_sin(x) (sin(*(x)))
229 #define d_sinh(x) (sinh(*(x)))
230 #define d_sqrt(x) (sqrt(*(x)))
231 #define d_tan(x) (tan(*(x)))
232 #define d_tanh(x) (tanh(*(x)))
233 #define i_abs(x) abs(*(x))
234 #define i_dnnt(x) ((integer)u_nint(*(x)))
235 #define i_len(s, n) (n)
236 #define i_nint(x) ((integer)u_nint(*(x)))
237 #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
238 #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
239 #define pow_si(B,E) spow_ui(*(B),*(E))
240 #define pow_ri(B,E) spow_ui(*(B),*(E))
241 #define pow_di(B,E) dpow_ui(*(B),*(E))
242 #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
243 #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
244 #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
245 #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; }
246 #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
247 #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
248 #define sig_die(s, kill) { exit(1); }
249 #define s_stop(s, n) {exit(0);}
250 static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
251 #define z_abs(z) (cabs(Cd(z)))
252 #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
253 #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
254 #define myexit_() break;
255 #define mycycle() continue;
256 #define myceiling(w) {ceil(w)}
257 #define myhuge(w) {HUGE_VAL}
258 //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
259 #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
261 /* procedure parameter types for -A and -C++ */
263 #define F2C_proc_par_types 1
265 typedef logical (*L_fp)(...);
267 typedef logical (*L_fp)();
270 static float spow_ui(float x, integer n) {
271 float pow=1.0; unsigned long int u;
273 if(n < 0) n = -n, x = 1/x;
282 static double dpow_ui(double x, integer n) {
283 double pow=1.0; unsigned long int u;
285 if(n < 0) n = -n, x = 1/x;
295 static _Fcomplex cpow_ui(complex x, integer n) {
296 complex pow={1.0,0.0}; unsigned long int u;
298 if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
300 if(u & 01) pow.r *= x.r, pow.i *= x.i;
301 if(u >>= 1) x.r *= x.r, x.i *= x.i;
305 _Fcomplex p={pow.r, pow.i};
309 static _Complex float cpow_ui(_Complex float x, integer n) {
310 _Complex float pow=1.0; unsigned long int u;
312 if(n < 0) n = -n, x = 1/x;
323 static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
324 _Dcomplex pow={1.0,0.0}; unsigned long int u;
326 if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
328 if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
329 if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
333 _Dcomplex p = {pow._Val[0], pow._Val[1]};
337 static _Complex double zpow_ui(_Complex double x, integer n) {
338 _Complex double pow=1.0; unsigned long int u;
340 if(n < 0) n = -n, x = 1/x;
350 static integer pow_ii(integer x, integer n) {
351 integer pow; unsigned long int u;
353 if (n == 0 || x == 1) pow = 1;
354 else if (x != -1) pow = x == 0 ? 1/x : 0;
357 if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
367 static integer dmaxloc_(double *w, integer s, integer e, integer *n)
369 double m; integer i, mi;
370 for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
371 if (w[i-1]>m) mi=i ,m=w[i-1];
374 static integer smaxloc_(float *w, integer s, integer e, integer *n)
376 float m; integer i, mi;
377 for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
378 if (w[i-1]>m) mi=i ,m=w[i-1];
381 static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
382 integer n = *n_, incx = *incx_, incy = *incy_, i;
384 _Fcomplex zdotc = {0.0, 0.0};
385 if (incx == 1 && incy == 1) {
386 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
387 zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
388 zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
391 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
392 zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
393 zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
399 _Complex float zdotc = 0.0;
400 if (incx == 1 && incy == 1) {
401 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
402 zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
405 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
406 zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
412 static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
413 integer n = *n_, incx = *incx_, incy = *incy_, i;
415 _Dcomplex zdotc = {0.0, 0.0};
416 if (incx == 1 && incy == 1) {
417 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
418 zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
419 zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
422 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
423 zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
424 zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
430 _Complex double zdotc = 0.0;
431 if (incx == 1 && incy == 1) {
432 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
433 zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
436 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
437 zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
443 static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
444 integer n = *n_, incx = *incx_, incy = *incy_, i;
446 _Fcomplex zdotc = {0.0, 0.0};
447 if (incx == 1 && incy == 1) {
448 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
449 zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
450 zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
453 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
454 zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
455 zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
461 _Complex float zdotc = 0.0;
462 if (incx == 1 && incy == 1) {
463 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
464 zdotc += Cf(&x[i]) * Cf(&y[i]);
467 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
468 zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
474 static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
475 integer n = *n_, incx = *incx_, incy = *incy_, i;
477 _Dcomplex zdotc = {0.0, 0.0};
478 if (incx == 1 && incy == 1) {
479 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
480 zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
481 zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
484 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
485 zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
486 zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
492 _Complex double zdotc = 0.0;
493 if (incx == 1 && incy == 1) {
494 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
495 zdotc += Cd(&x[i]) * Cd(&y[i]);
498 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
499 zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
505 /* -- translated by f2c (version 20000121).
506 You must link the resulting object file with the libraries:
507 -lf2c -lm (in that order)
513 /* Table of constant values */
515 static complex c_b1 = {0.f,0.f};
516 static complex c_b2 = {1.f,0.f};
517 static integer c__1 = 1;
518 static integer c__0 = 0;
519 static integer c__5 = 5;
521 /* > \brief \b CLATME */
523 /* =========== DOCUMENTATION =========== */
525 /* Online html documentation available at */
526 /* http://www.netlib.org/lapack/explore-html/ */
531 /* SUBROUTINE CLATME( N, DIST, ISEED, D, MODE, COND, DMAX, */
533 /* UPPER, SIM, DS, MODES, CONDS, KL, KU, ANORM, */
535 /* LDA, WORK, INFO ) */
537 /* CHARACTER DIST, RSIGN, SIM, UPPER */
538 /* INTEGER INFO, KL, KU, LDA, MODE, MODES, N */
539 /* REAL ANORM, COND, CONDS */
541 /* INTEGER ISEED( 4 ) */
543 /* COMPLEX A( LDA, * ), D( * ), WORK( * ) */
546 /* > \par Purpose: */
551 /* > CLATME generates random non-symmetric square matrices with */
552 /* > specified eigenvalues for testing LAPACK programs. */
554 /* > CLATME operates by applying the following sequence of */
557 /* > 1. Set the diagonal to D, where D may be input or */
558 /* > computed according to MODE, COND, DMAX, and RSIGN */
559 /* > as described below. */
561 /* > 2. If UPPER='T', the upper triangle of A is set to random values */
562 /* > out of distribution DIST. */
564 /* > 3. If SIM='T', A is multiplied on the left by a random matrix */
565 /* > X, whose singular values are specified by DS, MODES, and */
566 /* > CONDS, and on the right by X inverse. */
568 /* > 4. If KL < N-1, the lower bandwidth is reduced to KL using */
569 /* > Householder transformations. If KU < N-1, the upper */
570 /* > bandwidth is reduced to KU. */
572 /* > 5. If ANORM is not negative, the matrix is scaled to have */
573 /* > maximum-element-norm ANORM. */
575 /* > (Note: since the matrix cannot be reduced beyond Hessenberg form, */
576 /* > no packing options are available.) */
585 /* > The number of columns (or rows) of A. Not modified. */
588 /* > \param[in] DIST */
590 /* > DIST is CHARACTER*1 */
591 /* > On entry, DIST specifies the type of distribution to be used */
592 /* > to generate the random eigen-/singular values, and on the */
593 /* > upper triangle (see UPPER). */
594 /* > 'U' => UNIFORM( 0, 1 ) ( 'U' for uniform ) */
595 /* > 'S' => UNIFORM( -1, 1 ) ( 'S' for symmetric ) */
596 /* > 'N' => NORMAL( 0, 1 ) ( 'N' for normal ) */
597 /* > 'D' => uniform on the complex disc |z| < 1. */
598 /* > Not modified. */
601 /* > \param[in,out] ISEED */
603 /* > ISEED is INTEGER array, dimension ( 4 ) */
604 /* > On entry ISEED specifies the seed of the random number */
605 /* > generator. They should lie between 0 and 4095 inclusive, */
606 /* > and ISEED(4) should be odd. The random number generator */
607 /* > uses a linear congruential sequence limited to small */
608 /* > integers, and so should produce machine independent */
609 /* > random numbers. The values of ISEED are changed on */
610 /* > exit, and can be used in the next call to CLATME */
611 /* > to continue the same random number sequence. */
612 /* > Changed on exit. */
615 /* > \param[in,out] D */
617 /* > D is COMPLEX array, dimension ( N ) */
618 /* > This array is used to specify the eigenvalues of A. If */
619 /* > MODE=0, then D is assumed to contain the eigenvalues */
620 /* > otherwise they will be computed according to MODE, COND, */
621 /* > DMAX, and RSIGN and placed in D. */
622 /* > Modified if MODE is nonzero. */
625 /* > \param[in] MODE */
627 /* > MODE is INTEGER */
628 /* > On entry this describes how the eigenvalues are to */
629 /* > be specified: */
630 /* > MODE = 0 means use D as input */
631 /* > MODE = 1 sets D(1)=1 and D(2:N)=1.0/COND */
632 /* > MODE = 2 sets D(1:N-1)=1 and D(N)=1.0/COND */
633 /* > MODE = 3 sets D(I)=COND**(-(I-1)/(N-1)) */
634 /* > MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */
635 /* > MODE = 5 sets D to random numbers in the range */
636 /* > ( 1/COND , 1 ) such that their logarithms */
637 /* > are uniformly distributed. */
638 /* > MODE = 6 set D to random numbers from same distribution */
639 /* > as the rest of the matrix. */
640 /* > MODE < 0 has the same meaning as ABS(MODE), except that */
641 /* > the order of the elements of D is reversed. */
642 /* > Thus if MODE is between 1 and 4, D has entries ranging */
643 /* > from 1 to 1/COND, if between -1 and -4, D has entries */
644 /* > ranging from 1/COND to 1, */
645 /* > Not modified. */
648 /* > \param[in] COND */
651 /* > On entry, this is used as described under MODE above. */
652 /* > If used, it must be >= 1. Not modified. */
655 /* > \param[in] DMAX */
657 /* > DMAX is COMPLEX */
658 /* > If MODE is neither -6, 0 nor 6, the contents of D, as */
659 /* > computed according to MODE and COND, will be scaled by */
660 /* > DMAX / f2cmax(abs(D(i))). Note that DMAX need not be */
661 /* > positive or real: if DMAX is negative or complex (or zero), */
662 /* > D will be scaled by a negative or complex number (or zero). */
663 /* > If RSIGN='F' then the largest (absolute) eigenvalue will be */
664 /* > equal to DMAX. */
665 /* > Not modified. */
668 /* > \param[in] RSIGN */
670 /* > RSIGN is CHARACTER*1 */
671 /* > If MODE is not 0, 6, or -6, and RSIGN='T', then the */
672 /* > elements of D, as computed according to MODE and COND, will */
673 /* > be multiplied by a random complex number from the unit */
674 /* > circle |z| = 1. If RSIGN='F', they will not be. RSIGN may */
675 /* > only have the values 'T' or 'F'. */
676 /* > Not modified. */
679 /* > \param[in] UPPER */
681 /* > UPPER is CHARACTER*1 */
682 /* > If UPPER='T', then the elements of A above the diagonal */
683 /* > will be set to random numbers out of DIST. If UPPER='F', */
684 /* > they will not. UPPER may only have the values 'T' or 'F'. */
685 /* > Not modified. */
688 /* > \param[in] SIM */
690 /* > SIM is CHARACTER*1 */
691 /* > If SIM='T', then A will be operated on by a "similarity */
692 /* > transform", i.e., multiplied on the left by a matrix X and */
693 /* > on the right by X inverse. X = U S V, where U and V are */
694 /* > random unitary matrices and S is a (diagonal) matrix of */
695 /* > singular values specified by DS, MODES, and CONDS. If */
696 /* > SIM='F', then A will not be transformed. */
697 /* > Not modified. */
700 /* > \param[in,out] DS */
702 /* > DS is REAL array, dimension ( N ) */
703 /* > This array is used to specify the singular values of X, */
704 /* > in the same way that D specifies the eigenvalues of A. */
705 /* > If MODE=0, the DS contains the singular values, which */
706 /* > may not be zero. */
707 /* > Modified if MODE is nonzero. */
710 /* > \param[in] MODES */
712 /* > MODES is INTEGER */
715 /* > \param[in] CONDS */
717 /* > CONDS is REAL */
718 /* > Similar to MODE and COND, but for specifying the diagonal */
719 /* > of S. MODES=-6 and +6 are not allowed (since they would */
720 /* > result in randomly ill-conditioned eigenvalues.) */
723 /* > \param[in] KL */
725 /* > KL is INTEGER */
726 /* > This specifies the lower bandwidth of the matrix. KL=1 */
727 /* > specifies upper Hessenberg form. If KL is at least N-1, */
728 /* > then A will have full lower bandwidth. */
729 /* > Not modified. */
732 /* > \param[in] KU */
734 /* > KU is INTEGER */
735 /* > This specifies the upper bandwidth of the matrix. KU=1 */
736 /* > specifies lower Hessenberg form. If KU is at least N-1, */
737 /* > then A will have full upper bandwidth; if KU and KL */
738 /* > are both at least N-1, then A will be dense. Only one of */
739 /* > KU and KL may be less than N-1. */
740 /* > Not modified. */
743 /* > \param[in] ANORM */
745 /* > ANORM is REAL */
746 /* > If ANORM is not negative, then A will be scaled by a non- */
747 /* > negative real number to make the maximum-element-norm of A */
749 /* > Not modified. */
752 /* > \param[out] A */
754 /* > A is COMPLEX array, dimension ( LDA, N ) */
755 /* > On exit A is the desired test matrix. */
759 /* > \param[in] LDA */
761 /* > LDA is INTEGER */
762 /* > LDA specifies the first dimension of A as declared in the */
763 /* > calling program. LDA must be at least M. */
764 /* > Not modified. */
767 /* > \param[out] WORK */
769 /* > WORK is COMPLEX array, dimension ( 3*N ) */
774 /* > \param[out] INFO */
776 /* > INFO is INTEGER */
777 /* > Error code. On exit, INFO will be set to one of the */
778 /* > following values: */
779 /* > 0 => normal return */
780 /* > -1 => N negative */
781 /* > -2 => DIST illegal string */
782 /* > -5 => MODE not in range -6 to 6 */
783 /* > -6 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
784 /* > -9 => RSIGN is not 'T' or 'F' */
785 /* > -10 => UPPER is not 'T' or 'F' */
786 /* > -11 => SIM is not 'T' or 'F' */
787 /* > -12 => MODES=0 and DS has a zero singular value. */
788 /* > -13 => MODES is not in the range -5 to 5. */
789 /* > -14 => MODES is nonzero and CONDS is less than 1. */
790 /* > -15 => KL is less than 1. */
791 /* > -16 => KU is less than 1, or KL and KU are both less than */
793 /* > -19 => LDA is less than M. */
794 /* > 1 => Error return from CLATM1 (computing D) */
795 /* > 2 => Cannot scale to DMAX (f2cmax. eigenvalue is 0) */
796 /* > 3 => Error return from SLATM1 (computing DS) */
797 /* > 4 => Error return from CLARGE */
798 /* > 5 => Zero singular value from SLATM1. */
804 /* > \author Univ. of Tennessee */
805 /* > \author Univ. of California Berkeley */
806 /* > \author Univ. of Colorado Denver */
807 /* > \author NAG Ltd. */
809 /* > \date December 2016 */
811 /* > \ingroup complex_matgen */
813 /* ===================================================================== */
814 /* Subroutine */ int clatme_(integer *n, char *dist, integer *iseed, complex *
815 d__, integer *mode, real *cond, complex *dmax__, char *rsign, char *
816 upper, char *sim, real *ds, integer *modes, real *conds, integer *kl,
817 integer *ku, real *anorm, complex *a, integer *lda, complex *work,
820 /* System generated locals */
821 integer a_dim1, a_offset, i__1, i__2;
825 /* Local variables */
830 extern /* Subroutine */ int cgerc_(integer *, integer *, complex *,
831 complex *, integer *, complex *, integer *, complex *, integer *);
833 extern /* Subroutine */ int cscal_(integer *, complex *, complex *,
835 extern logical lsame_(char *, char *);
836 extern /* Subroutine */ int cgemv_(char *, integer *, integer *, complex *
837 , complex *, integer *, complex *, integer *, complex *, complex *
841 integer icols, idist;
842 extern /* Subroutine */ int ccopy_(integer *, complex *, integer *,
843 complex *, integer *);
845 extern /* Subroutine */ int clatm1_(integer *, real *, integer *, integer
846 *, integer *, complex *, integer *, integer *), slatm1_(integer *,
847 real *, integer *, integer *, integer *, real *, integer *,
850 extern real clange_(char *, integer *, integer *, complex *, integer *,
853 extern /* Subroutine */ int clarge_(integer *, complex *, integer *,
854 integer *, complex *, integer *), clarfg_(integer *, complex *,
855 complex *, integer *, complex *), clacgv_(integer *, complex *,
857 //extern /* Complex */ VOID clarnd_(complex *, integer *, integer *);
858 extern complex clarnd_(integer *, integer *);
860 extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer
861 *), claset_(char *, integer *, integer *, complex *, complex *,
862 complex *, integer *), xerbla_(char *, integer *),
863 clarnv_(integer *, integer *, integer *, complex *);
864 integer irsign, iupper;
870 /* -- LAPACK computational routine (version 3.7.0) -- */
871 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
872 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
876 /* ===================================================================== */
879 /* 1) Decode and Test the input parameters. */
880 /* Initialize flags & seed. */
882 /* Parameter adjustments */
887 a_offset = 1 + a_dim1 * 1;
894 /* Quick return if possible */
902 if (lsame_(dist, "U")) {
904 } else if (lsame_(dist, "S")) {
906 } else if (lsame_(dist, "N")) {
908 } else if (lsame_(dist, "D")) {
916 if (lsame_(rsign, "T")) {
918 } else if (lsame_(rsign, "F")) {
926 if (lsame_(upper, "T")) {
928 } else if (lsame_(upper, "F")) {
936 if (lsame_(sim, "T")) {
938 } else if (lsame_(sim, "F")) {
944 /* Check DS, if MODES=0 and ISIM=1 */
947 if (*modes == 0 && isim == 1) {
949 for (j = 1; j <= i__1; ++j) {
957 /* Set INFO if an error */
961 } else if (idist == -1) {
963 } else if (abs(*mode) > 6) {
965 } else if (*mode != 0 && abs(*mode) != 6 && *cond < 1.f) {
967 } else if (irsign == -1) {
969 } else if (iupper == -1) {
971 } else if (isim == -1) {
975 } else if (isim == 1 && abs(*modes) > 5) {
977 } else if (isim == 1 && *modes != 0 && *conds < 1.f) {
979 } else if (*kl < 1) {
981 } else if (*ku < 1 || *ku < *n - 1 && *kl < *n - 1) {
983 } else if (*lda < f2cmax(1,*n)) {
989 xerbla_("CLATME", &i__1);
993 /* Initialize random number generator */
995 for (i__ = 1; i__ <= 4; ++i__) {
996 iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
1000 if (iseed[4] % 2 != 1) {
1004 /* 2) Set up diagonal of A */
1006 /* Compute D according to COND and MODE */
1008 clatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], n, &iinfo);
1013 if (*mode != 0 && abs(*mode) != 6) {
1017 temp = c_abs(&d__[1]);
1019 for (i__ = 2; i__ <= i__1; ++i__) {
1021 r__1 = temp, r__2 = c_abs(&d__[i__]);
1022 temp = f2cmax(r__1,r__2);
1027 q__1.r = dmax__->r / temp, q__1.i = dmax__->i / temp;
1028 alpha.r = q__1.r, alpha.i = q__1.i;
1034 cscal_(n, &alpha, &d__[1], &c__1);
1038 claset_("Full", n, n, &c_b1, &c_b1, &a[a_offset], lda);
1040 ccopy_(n, &d__[1], &c__1, &a[a_offset], &i__1);
1042 /* 3) If UPPER='T', set upper triangle of A to random numbers. */
1046 for (jc = 2; jc <= i__1; ++jc) {
1048 clarnv_(&idist, &iseed[1], &i__2, &a[jc * a_dim1 + 1]);
1053 /* 4) If SIM='T', apply similarity transformation. */
1056 /* Transform is X A X , where X = U S V, thus */
1058 /* it is U S V A V' (1/S) U' */
1062 /* Compute S (singular values of the eigenvector matrix) */
1063 /* according to CONDS and MODES */
1065 slatm1_(modes, conds, &c__0, &c__0, &iseed[1], &ds[1], n, &iinfo);
1071 /* Multiply by V and V' */
1073 clarge_(n, &a[a_offset], lda, &iseed[1], &work[1], &iinfo);
1079 /* Multiply by S and (1/S) */
1082 for (j = 1; j <= i__1; ++j) {
1083 csscal_(n, &ds[j], &a[j + a_dim1], lda);
1086 csscal_(n, &r__1, &a[j * a_dim1 + 1], &c__1);
1094 /* Multiply by U and U' */
1096 clarge_(n, &a[a_offset], lda, &iseed[1], &work[1], &iinfo);
1103 /* 5) Reduce the bandwidth. */
1107 /* Reduce bandwidth -- kill column */
1110 for (jcr = *kl + 1; jcr <= i__1; ++jcr) {
1112 irows = *n + 1 - jcr;
1113 icols = *n + *kl - jcr;
1115 ccopy_(&irows, &a[jcr + ic * a_dim1], &c__1, &work[1], &c__1);
1116 xnorms.r = work[1].r, xnorms.i = work[1].i;
1117 clarfg_(&irows, &xnorms, &work[2], &c__1, &tau);
1118 r_cnjg(&q__1, &tau);
1119 tau.r = q__1.r, tau.i = q__1.i;
1120 work[1].r = 1.f, work[1].i = 0.f;
1121 //clarnd_(&q__1, &c__5, &iseed[1]);
1122 q__1=clarnd_(&c__5, &iseed[1]);
1123 alpha.r = q__1.r, alpha.i = q__1.i;
1125 cgemv_("C", &irows, &icols, &c_b2, &a[jcr + (ic + 1) * a_dim1],
1126 lda, &work[1], &c__1, &c_b1, &work[irows + 1], &c__1);
1127 q__1.r = -tau.r, q__1.i = -tau.i;
1128 cgerc_(&irows, &icols, &q__1, &work[1], &c__1, &work[irows + 1], &
1129 c__1, &a[jcr + (ic + 1) * a_dim1], lda);
1131 cgemv_("N", n, &irows, &c_b2, &a[jcr * a_dim1 + 1], lda, &work[1],
1132 &c__1, &c_b1, &work[irows + 1], &c__1);
1133 r_cnjg(&q__2, &tau);
1134 q__1.r = -q__2.r, q__1.i = -q__2.i;
1135 cgerc_(n, &irows, &q__1, &work[irows + 1], &c__1, &work[1], &c__1,
1136 &a[jcr * a_dim1 + 1], lda);
1138 i__2 = jcr + ic * a_dim1;
1139 a[i__2].r = xnorms.r, a[i__2].i = xnorms.i;
1141 claset_("Full", &i__2, &c__1, &c_b1, &c_b1, &a[jcr + 1 + ic *
1145 cscal_(&i__2, &alpha, &a[jcr + ic * a_dim1], lda);
1146 r_cnjg(&q__1, &alpha);
1147 cscal_(n, &q__1, &a[jcr * a_dim1 + 1], &c__1);
1150 } else if (*ku < *n - 1) {
1152 /* Reduce upper bandwidth -- kill a row at a time. */
1155 for (jcr = *ku + 1; jcr <= i__1; ++jcr) {
1157 irows = *n + *ku - jcr;
1158 icols = *n + 1 - jcr;
1160 ccopy_(&icols, &a[ir + jcr * a_dim1], lda, &work[1], &c__1);
1161 xnorms.r = work[1].r, xnorms.i = work[1].i;
1162 clarfg_(&icols, &xnorms, &work[2], &c__1, &tau);
1163 r_cnjg(&q__1, &tau);
1164 tau.r = q__1.r, tau.i = q__1.i;
1165 work[1].r = 1.f, work[1].i = 0.f;
1167 clacgv_(&i__2, &work[2], &c__1);
1168 //clarnd_(&q__1, &c__5, &iseed[1]);
1169 q__1=clarnd_(&c__5, &iseed[1]);
1170 alpha.r = q__1.r, alpha.i = q__1.i;
1172 cgemv_("N", &irows, &icols, &c_b2, &a[ir + 1 + jcr * a_dim1], lda,
1173 &work[1], &c__1, &c_b1, &work[icols + 1], &c__1);
1174 q__1.r = -tau.r, q__1.i = -tau.i;
1175 cgerc_(&irows, &icols, &q__1, &work[icols + 1], &c__1, &work[1], &
1176 c__1, &a[ir + 1 + jcr * a_dim1], lda);
1178 cgemv_("C", &icols, n, &c_b2, &a[jcr + a_dim1], lda, &work[1], &
1179 c__1, &c_b1, &work[icols + 1], &c__1);
1180 r_cnjg(&q__2, &tau);
1181 q__1.r = -q__2.r, q__1.i = -q__2.i;
1182 cgerc_(&icols, n, &q__1, &work[1], &c__1, &work[icols + 1], &c__1,
1183 &a[jcr + a_dim1], lda);
1185 i__2 = ir + jcr * a_dim1;
1186 a[i__2].r = xnorms.r, a[i__2].i = xnorms.i;
1188 claset_("Full", &c__1, &i__2, &c_b1, &c_b1, &a[ir + (jcr + 1) *
1192 cscal_(&i__2, &alpha, &a[ir + jcr * a_dim1], &c__1);
1193 r_cnjg(&q__1, &alpha);
1194 cscal_(n, &q__1, &a[jcr + a_dim1], lda);
1199 /* Scale the matrix to have norm ANORM */
1201 if (*anorm >= 0.f) {
1202 temp = clange_("M", n, n, &a[a_offset], lda, tempa);
1204 ralpha = *anorm / temp;
1206 for (j = 1; j <= i__1; ++j) {
1207 csscal_(n, &ralpha, &a[j * a_dim1 + 1], &c__1);