14 typedef long long BLASLONG;
15 typedef unsigned long long BLASULONG;
17 typedef long BLASLONG;
18 typedef unsigned long BLASULONG;
22 typedef BLASLONG blasint;
24 #define blasabs(x) llabs(x)
26 #define blasabs(x) labs(x)
30 #define blasabs(x) abs(x)
33 typedef blasint integer;
35 typedef unsigned int uinteger;
36 typedef char *address;
37 typedef short int shortint;
39 typedef double doublereal;
40 typedef struct { real r, i; } complex;
41 typedef struct { doublereal r, i; } doublecomplex;
43 static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
44 static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
45 static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
46 static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
48 static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
49 static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
50 static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
51 static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
53 #define pCf(z) (*_pCf(z))
54 #define pCd(z) (*_pCd(z))
56 typedef short int shortlogical;
57 typedef char logical1;
58 typedef char integer1;
63 /* Extern is for use with -E */
74 /*external read, write*/
83 /*internal read, write*/
113 /*rewind, backspace, endfile*/
125 ftnint *inex; /*parameters in standard's order*/
151 union Multitype { /* for multiple entry points */
162 typedef union Multitype Multitype;
164 struct Vardesc { /* for Namelist */
170 typedef struct Vardesc Vardesc;
177 typedef struct Namelist Namelist;
179 #define abs(x) ((x) >= 0 ? (x) : -(x))
180 #define dabs(x) (fabs(x))
181 #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
182 #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
183 #define dmin(a,b) (f2cmin(a,b))
184 #define dmax(a,b) (f2cmax(a,b))
185 #define bit_test(a,b) ((a) >> (b) & 1)
186 #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
187 #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
189 #define abort_() { sig_die("Fortran abort routine called", 1); }
190 #define c_abs(z) (cabsf(Cf(z)))
191 #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
193 #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
194 #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);}
196 #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
197 #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
199 #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
200 #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
201 #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
202 //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
203 #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
204 #define d_abs(x) (fabs(*(x)))
205 #define d_acos(x) (acos(*(x)))
206 #define d_asin(x) (asin(*(x)))
207 #define d_atan(x) (atan(*(x)))
208 #define d_atn2(x, y) (atan2(*(x),*(y)))
209 #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
210 #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
211 #define d_cos(x) (cos(*(x)))
212 #define d_cosh(x) (cosh(*(x)))
213 #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
214 #define d_exp(x) (exp(*(x)))
215 #define d_imag(z) (cimag(Cd(z)))
216 #define r_imag(z) (cimagf(Cf(z)))
217 #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
218 #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
219 #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
220 #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
221 #define d_log(x) (log(*(x)))
222 #define d_mod(x, y) (fmod(*(x), *(y)))
223 #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
224 #define d_nint(x) u_nint(*(x))
225 #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
226 #define d_sign(a,b) u_sign(*(a),*(b))
227 #define r_sign(a,b) u_sign(*(a),*(b))
228 #define d_sin(x) (sin(*(x)))
229 #define d_sinh(x) (sinh(*(x)))
230 #define d_sqrt(x) (sqrt(*(x)))
231 #define d_tan(x) (tan(*(x)))
232 #define d_tanh(x) (tanh(*(x)))
233 #define i_abs(x) abs(*(x))
234 #define i_dnnt(x) ((integer)u_nint(*(x)))
235 #define i_len(s, n) (n)
236 #define i_nint(x) ((integer)u_nint(*(x)))
237 #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
238 #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
239 #define pow_si(B,E) spow_ui(*(B),*(E))
240 #define pow_ri(B,E) spow_ui(*(B),*(E))
241 #define pow_di(B,E) dpow_ui(*(B),*(E))
242 #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
243 #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
244 #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
245 #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; }
246 #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
247 #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
248 #define sig_die(s, kill) { exit(1); }
249 #define s_stop(s, n) {exit(0);}
250 static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
251 #define z_abs(z) (cabs(Cd(z)))
252 #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
253 #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
254 #define myexit_() break;
255 #define mycycle() continue;
256 #define myceiling(w) {ceil(w)}
257 #define myhuge(w) {HUGE_VAL}
258 //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
259 #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
261 /* procedure parameter types for -A and -C++ */
263 #define F2C_proc_par_types 1
265 typedef logical (*L_fp)(...);
267 typedef logical (*L_fp)();
270 static float spow_ui(float x, integer n) {
271 float pow=1.0; unsigned long int u;
273 if(n < 0) n = -n, x = 1/x;
282 static double dpow_ui(double x, integer n) {
283 double pow=1.0; unsigned long int u;
285 if(n < 0) n = -n, x = 1/x;
295 static _Fcomplex cpow_ui(complex x, integer n) {
296 complex pow={1.0,0.0}; unsigned long int u;
298 if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
300 if(u & 01) pow.r *= x.r, pow.i *= x.i;
301 if(u >>= 1) x.r *= x.r, x.i *= x.i;
305 _Fcomplex p={pow.r, pow.i};
309 static _Complex float cpow_ui(_Complex float x, integer n) {
310 _Complex float pow=1.0; unsigned long int u;
312 if(n < 0) n = -n, x = 1/x;
323 static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
324 _Dcomplex pow={1.0,0.0}; unsigned long int u;
326 if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
328 if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
329 if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
333 _Dcomplex p = {pow._Val[0], pow._Val[1]};
337 static _Complex double zpow_ui(_Complex double x, integer n) {
338 _Complex double pow=1.0; unsigned long int u;
340 if(n < 0) n = -n, x = 1/x;
350 static integer pow_ii(integer x, integer n) {
351 integer pow; unsigned long int u;
353 if (n == 0 || x == 1) pow = 1;
354 else if (x != -1) pow = x == 0 ? 1/x : 0;
357 if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
367 static integer dmaxloc_(double *w, integer s, integer e, integer *n)
369 double m; integer i, mi;
370 for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
371 if (w[i-1]>m) mi=i ,m=w[i-1];
374 static integer smaxloc_(float *w, integer s, integer e, integer *n)
376 float m; integer i, mi;
377 for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
378 if (w[i-1]>m) mi=i ,m=w[i-1];
381 static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
382 integer n = *n_, incx = *incx_, incy = *incy_, i;
384 _Fcomplex zdotc = {0.0, 0.0};
385 if (incx == 1 && incy == 1) {
386 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
387 zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
388 zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
391 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
392 zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
393 zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
399 _Complex float zdotc = 0.0;
400 if (incx == 1 && incy == 1) {
401 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
402 zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
405 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
406 zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
412 static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
413 integer n = *n_, incx = *incx_, incy = *incy_, i;
415 _Dcomplex zdotc = {0.0, 0.0};
416 if (incx == 1 && incy == 1) {
417 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
418 zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
419 zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
422 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
423 zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
424 zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
430 _Complex double zdotc = 0.0;
431 if (incx == 1 && incy == 1) {
432 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
433 zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
436 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
437 zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
443 static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
444 integer n = *n_, incx = *incx_, incy = *incy_, i;
446 _Fcomplex zdotc = {0.0, 0.0};
447 if (incx == 1 && incy == 1) {
448 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
449 zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
450 zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
453 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
454 zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
455 zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
461 _Complex float zdotc = 0.0;
462 if (incx == 1 && incy == 1) {
463 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
464 zdotc += Cf(&x[i]) * Cf(&y[i]);
467 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
468 zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
474 static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
475 integer n = *n_, incx = *incx_, incy = *incy_, i;
477 _Dcomplex zdotc = {0.0, 0.0};
478 if (incx == 1 && incy == 1) {
479 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
480 zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
481 zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
484 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
485 zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
486 zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
492 _Complex double zdotc = 0.0;
493 if (incx == 1 && incy == 1) {
494 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
495 zdotc += Cd(&x[i]) * Cd(&y[i]);
498 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
499 zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
505 /* -- translated by f2c (version 20000121).
506 You must link the resulting object file with the libraries:
507 -lf2c -lm (in that order)
513 /* Table of constant values */
515 static integer c__1 = 1;
516 static doublereal c_b23 = 0.;
517 static integer c__0 = 0;
518 static doublereal c_b39 = 1.;
520 /* > \brief \b DLATME */
522 /* =========== DOCUMENTATION =========== */
524 /* Online html documentation available at */
525 /* http://www.netlib.org/lapack/explore-html/ */
530 /* SUBROUTINE DLATME( N, DIST, ISEED, D, MODE, COND, DMAX, EI, */
532 /* UPPER, SIM, DS, MODES, CONDS, KL, KU, ANORM, */
534 /* LDA, WORK, INFO ) */
536 /* CHARACTER DIST, RSIGN, SIM, UPPER */
537 /* INTEGER INFO, KL, KU, LDA, MODE, MODES, N */
538 /* DOUBLE PRECISION ANORM, COND, CONDS, DMAX */
539 /* CHARACTER EI( * ) */
540 /* INTEGER ISEED( 4 ) */
541 /* DOUBLE PRECISION A( LDA, * ), D( * ), DS( * ), WORK( * ) */
544 /* > \par Purpose: */
549 /* > DLATME generates random non-symmetric square matrices with */
550 /* > specified eigenvalues for testing LAPACK programs. */
552 /* > DLATME operates by applying the following sequence of */
555 /* > 1. Set the diagonal to D, where D may be input or */
556 /* > computed according to MODE, COND, DMAX, and RSIGN */
557 /* > as described below. */
559 /* > 2. If complex conjugate pairs are desired (MODE=0 and EI(1)='R', */
560 /* > or MODE=5), certain pairs of adjacent elements of D are */
561 /* > interpreted as the real and complex parts of a complex */
562 /* > conjugate pair; A thus becomes block diagonal, with 1x1 */
563 /* > and 2x2 blocks. */
565 /* > 3. If UPPER='T', the upper triangle of A is set to random values */
566 /* > out of distribution DIST. */
568 /* > 4. If SIM='T', A is multiplied on the left by a random matrix */
569 /* > X, whose singular values are specified by DS, MODES, and */
570 /* > CONDS, and on the right by X inverse. */
572 /* > 5. If KL < N-1, the lower bandwidth is reduced to KL using */
573 /* > Householder transformations. If KU < N-1, the upper */
574 /* > bandwidth is reduced to KU. */
576 /* > 6. If ANORM is not negative, the matrix is scaled to have */
577 /* > maximum-element-norm ANORM. */
579 /* > (Note: since the matrix cannot be reduced beyond Hessenberg form, */
580 /* > no packing options are available.) */
589 /* > The number of columns (or rows) of A. Not modified. */
592 /* > \param[in] DIST */
594 /* > DIST is CHARACTER*1 */
595 /* > On entry, DIST specifies the type of distribution to be used */
596 /* > to generate the random eigen-/singular values, and for the */
597 /* > upper triangle (see UPPER). */
598 /* > 'U' => UNIFORM( 0, 1 ) ( 'U' for uniform ) */
599 /* > 'S' => UNIFORM( -1, 1 ) ( 'S' for symmetric ) */
600 /* > 'N' => NORMAL( 0, 1 ) ( 'N' for normal ) */
601 /* > Not modified. */
604 /* > \param[in,out] ISEED */
606 /* > ISEED is INTEGER array, dimension ( 4 ) */
607 /* > On entry ISEED specifies the seed of the random number */
608 /* > generator. They should lie between 0 and 4095 inclusive, */
609 /* > and ISEED(4) should be odd. The random number generator */
610 /* > uses a linear congruential sequence limited to small */
611 /* > integers, and so should produce machine independent */
612 /* > random numbers. The values of ISEED are changed on */
613 /* > exit, and can be used in the next call to DLATME */
614 /* > to continue the same random number sequence. */
615 /* > Changed on exit. */
618 /* > \param[in,out] D */
620 /* > D is DOUBLE PRECISION array, dimension ( N ) */
621 /* > This array is used to specify the eigenvalues of A. If */
622 /* > MODE=0, then D is assumed to contain the eigenvalues (but */
623 /* > see the description of EI), otherwise they will be */
624 /* > computed according to MODE, COND, DMAX, and RSIGN and */
626 /* > Modified if MODE is nonzero. */
629 /* > \param[in] MODE */
631 /* > MODE is INTEGER */
632 /* > On entry this describes how the eigenvalues are to */
633 /* > be specified: */
634 /* > MODE = 0 means use D (with EI) as input */
635 /* > MODE = 1 sets D(1)=1 and D(2:N)=1.0/COND */
636 /* > MODE = 2 sets D(1:N-1)=1 and D(N)=1.0/COND */
637 /* > MODE = 3 sets D(I)=COND**(-(I-1)/(N-1)) */
638 /* > MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */
639 /* > MODE = 5 sets D to random numbers in the range */
640 /* > ( 1/COND , 1 ) such that their logarithms */
641 /* > are uniformly distributed. Each odd-even pair */
642 /* > of elements will be either used as two real */
643 /* > eigenvalues or as the real and imaginary part */
644 /* > of a complex conjugate pair of eigenvalues; */
645 /* > the choice of which is done is random, with */
646 /* > 50-50 probability, for each pair. */
647 /* > MODE = 6 set D to random numbers from same distribution */
648 /* > as the rest of the matrix. */
649 /* > MODE < 0 has the same meaning as ABS(MODE), except that */
650 /* > the order of the elements of D is reversed. */
651 /* > Thus if MODE is between 1 and 4, D has entries ranging */
652 /* > from 1 to 1/COND, if between -1 and -4, D has entries */
653 /* > ranging from 1/COND to 1, */
654 /* > Not modified. */
657 /* > \param[in] COND */
659 /* > COND is DOUBLE PRECISION */
660 /* > On entry, this is used as described under MODE above. */
661 /* > If used, it must be >= 1. Not modified. */
664 /* > \param[in] DMAX */
666 /* > DMAX is DOUBLE PRECISION */
667 /* > If MODE is neither -6, 0 nor 6, the contents of D, as */
668 /* > computed according to MODE and COND, will be scaled by */
669 /* > DMAX / f2cmax(abs(D(i))). Note that DMAX need not be */
670 /* > positive: if DMAX is negative (or zero), D will be */
671 /* > scaled by a negative number (or zero). */
672 /* > Not modified. */
675 /* > \param[in] EI */
677 /* > EI is CHARACTER*1 array, dimension ( N ) */
678 /* > If MODE is 0, and EI(1) is not ' ' (space character), */
679 /* > this array specifies which elements of D (on input) are */
680 /* > real eigenvalues and which are the real and imaginary parts */
681 /* > of a complex conjugate pair of eigenvalues. The elements */
682 /* > of EI may then only have the values 'R' and 'I'. If */
683 /* > EI(j)='R' and EI(j+1)='I', then the j-th eigenvalue is */
684 /* > CMPLX( D(j) , D(j+1) ), and the (j+1)-th is the complex */
685 /* > conjugate thereof. If EI(j)=EI(j+1)='R', then the j-th */
686 /* > eigenvalue is D(j) (i.e., real). EI(1) may not be 'I', */
687 /* > nor may two adjacent elements of EI both have the value 'I'. */
688 /* > If MODE is not 0, then EI is ignored. If MODE is 0 and */
689 /* > EI(1)=' ', then the eigenvalues will all be real. */
690 /* > Not modified. */
693 /* > \param[in] RSIGN */
695 /* > RSIGN is CHARACTER*1 */
696 /* > If MODE is not 0, 6, or -6, and RSIGN='T', then the */
697 /* > elements of D, as computed according to MODE and COND, will */
698 /* > be multiplied by a random sign (+1 or -1). If RSIGN='F', */
699 /* > they will not be. RSIGN may only have the values 'T' or */
701 /* > Not modified. */
704 /* > \param[in] UPPER */
706 /* > UPPER is CHARACTER*1 */
707 /* > If UPPER='T', then the elements of A above the diagonal */
708 /* > (and above the 2x2 diagonal blocks, if A has complex */
709 /* > eigenvalues) will be set to random numbers out of DIST. */
710 /* > If UPPER='F', they will not. UPPER may only have the */
711 /* > values 'T' or 'F'. */
712 /* > Not modified. */
715 /* > \param[in] SIM */
717 /* > SIM is CHARACTER*1 */
718 /* > If SIM='T', then A will be operated on by a "similarity */
719 /* > transform", i.e., multiplied on the left by a matrix X and */
720 /* > on the right by X inverse. X = U S V, where U and V are */
721 /* > random unitary matrices and S is a (diagonal) matrix of */
722 /* > singular values specified by DS, MODES, and CONDS. If */
723 /* > SIM='F', then A will not be transformed. */
724 /* > Not modified. */
727 /* > \param[in,out] DS */
729 /* > DS is DOUBLE PRECISION array, dimension ( N ) */
730 /* > This array is used to specify the singular values of X, */
731 /* > in the same way that D specifies the eigenvalues of A. */
732 /* > If MODE=0, the DS contains the singular values, which */
733 /* > may not be zero. */
734 /* > Modified if MODE is nonzero. */
737 /* > \param[in] MODES */
739 /* > MODES is INTEGER */
742 /* > \param[in] CONDS */
744 /* > CONDS is DOUBLE PRECISION */
745 /* > Same as MODE and COND, but for specifying the diagonal */
746 /* > of S. MODES=-6 and +6 are not allowed (since they would */
747 /* > result in randomly ill-conditioned eigenvalues.) */
750 /* > \param[in] KL */
752 /* > KL is INTEGER */
753 /* > This specifies the lower bandwidth of the matrix. KL=1 */
754 /* > specifies upper Hessenberg form. If KL is at least N-1, */
755 /* > then A will have full lower bandwidth. KL must be at */
757 /* > Not modified. */
760 /* > \param[in] KU */
762 /* > KU is INTEGER */
763 /* > This specifies the upper bandwidth of the matrix. KU=1 */
764 /* > specifies lower Hessenberg form. If KU is at least N-1, */
765 /* > then A will have full upper bandwidth; if KU and KL */
766 /* > are both at least N-1, then A will be dense. Only one of */
767 /* > KU and KL may be less than N-1. KU must be at least 1. */
768 /* > Not modified. */
771 /* > \param[in] ANORM */
773 /* > ANORM is DOUBLE PRECISION */
774 /* > If ANORM is not negative, then A will be scaled by a non- */
775 /* > negative real number to make the maximum-element-norm of A */
777 /* > Not modified. */
780 /* > \param[out] A */
782 /* > A is DOUBLE PRECISION array, dimension ( LDA, N ) */
783 /* > On exit A is the desired test matrix. */
787 /* > \param[in] LDA */
789 /* > LDA is INTEGER */
790 /* > LDA specifies the first dimension of A as declared in the */
791 /* > calling program. LDA must be at least N. */
792 /* > Not modified. */
795 /* > \param[out] WORK */
797 /* > WORK is DOUBLE PRECISION array, dimension ( 3*N ) */
802 /* > \param[out] INFO */
804 /* > INFO is INTEGER */
805 /* > Error code. On exit, INFO will be set to one of the */
806 /* > following values: */
807 /* > 0 => normal return */
808 /* > -1 => N negative */
809 /* > -2 => DIST illegal string */
810 /* > -5 => MODE not in range -6 to 6 */
811 /* > -6 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
812 /* > -8 => EI(1) is not ' ' or 'R', EI(j) is not 'R' or 'I', or */
813 /* > two adjacent elements of EI are 'I'. */
814 /* > -9 => RSIGN is not 'T' or 'F' */
815 /* > -10 => UPPER is not 'T' or 'F' */
816 /* > -11 => SIM is not 'T' or 'F' */
817 /* > -12 => MODES=0 and DS has a zero singular value. */
818 /* > -13 => MODES is not in the range -5 to 5. */
819 /* > -14 => MODES is nonzero and CONDS is less than 1. */
820 /* > -15 => KL is less than 1. */
821 /* > -16 => KU is less than 1, or KL and KU are both less than */
823 /* > -19 => LDA is less than N. */
824 /* > 1 => Error return from DLATM1 (computing D) */
825 /* > 2 => Cannot scale to DMAX (f2cmax. eigenvalue is 0) */
826 /* > 3 => Error return from DLATM1 (computing DS) */
827 /* > 4 => Error return from DLARGE */
828 /* > 5 => Zero singular value from DLATM1. */
834 /* > \author Univ. of Tennessee */
835 /* > \author Univ. of California Berkeley */
836 /* > \author Univ. of Colorado Denver */
837 /* > \author NAG Ltd. */
839 /* > \date December 2016 */
841 /* > \ingroup double_matgen */
843 /* ===================================================================== */
844 /* Subroutine */ int dlatme_(integer *n, char *dist, integer *iseed,
845 doublereal *d__, integer *mode, doublereal *cond, doublereal *dmax__,
846 char *ei, char *rsign, char *upper, char *sim, doublereal *ds,
847 integer *modes, doublereal *conds, integer *kl, integer *ku,
848 doublereal *anorm, doublereal *a, integer *lda, doublereal *work,
851 /* System generated locals */
852 integer a_dim1, a_offset, i__1, i__2;
853 doublereal d__1, d__2, d__3;
855 /* Local variables */
857 extern /* Subroutine */ int dger_(integer *, integer *, doublereal *,
858 doublereal *, integer *, doublereal *, integer *, doublereal *,
865 extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
867 extern logical lsame_(char *, char *);
868 extern /* Subroutine */ int dgemv_(char *, integer *, integer *,
869 doublereal *, doublereal *, integer *, doublereal *, integer *,
870 doublereal *, doublereal *, integer *);
876 extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *,
877 doublereal *, integer *);
879 extern /* Subroutine */ int dlatm1_(integer *, doublereal *, integer *,
880 integer *, integer *, doublereal *, integer *, integer *);
882 extern doublereal dlange_(char *, integer *, integer *, doublereal *,
883 integer *, doublereal *);
885 extern /* Subroutine */ int dlarge_(integer *, doublereal *, integer *,
886 integer *, doublereal *, integer *), dlarfg_(integer *,
887 doublereal *, doublereal *, integer *, doublereal *);
888 extern doublereal dlaran_(integer *);
889 extern /* Subroutine */ int dlaset_(char *, integer *, integer *,
890 doublereal *, doublereal *, doublereal *, integer *),
891 xerbla_(char *, integer *), dlarnv_(integer *, integer *,
892 integer *, doublereal *);
893 integer irsign, iupper;
899 /* -- LAPACK computational routine (version 3.7.0) -- */
900 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
901 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
905 /* ===================================================================== */
908 /* 1) Decode and Test the input parameters. */
909 /* Initialize flags & seed. */
911 /* Parameter adjustments */
917 a_offset = 1 + a_dim1 * 1;
924 /* Quick return if possible */
932 if (lsame_(dist, "U")) {
934 } else if (lsame_(dist, "S")) {
936 } else if (lsame_(dist, "N")) {
946 if (lsame_(ei + 1, " ") || *mode != 0) {
949 if (lsame_(ei + 1, "R")) {
951 for (j = 2; j <= i__1; ++j) {
952 if (lsame_(ei + j, "I")) {
953 if (lsame_(ei + (j - 1), "I")) {
957 if (! lsame_(ei + j, "R")) {
970 if (lsame_(rsign, "T")) {
972 } else if (lsame_(rsign, "F")) {
980 if (lsame_(upper, "T")) {
982 } else if (lsame_(upper, "F")) {
990 if (lsame_(sim, "T")) {
992 } else if (lsame_(sim, "F")) {
998 /* Check DS, if MODES=0 and ISIM=1 */
1001 if (*modes == 0 && isim == 1) {
1003 for (j = 1; j <= i__1; ++j) {
1011 /* Set INFO if an error */
1015 } else if (idist == -1) {
1017 } else if (abs(*mode) > 6) {
1019 } else if (*mode != 0 && abs(*mode) != 6 && *cond < 1.) {
1023 } else if (irsign == -1) {
1025 } else if (iupper == -1) {
1027 } else if (isim == -1) {
1031 } else if (isim == 1 && abs(*modes) > 5) {
1033 } else if (isim == 1 && *modes != 0 && *conds < 1.) {
1035 } else if (*kl < 1) {
1037 } else if (*ku < 1 || *ku < *n - 1 && *kl < *n - 1) {
1039 } else if (*lda < f2cmax(1,*n)) {
1045 xerbla_("DLATME", &i__1);
1049 /* Initialize random number generator */
1051 for (i__ = 1; i__ <= 4; ++i__) {
1052 iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
1056 if (iseed[4] % 2 != 1) {
1060 /* 2) Set up diagonal of A */
1062 /* Compute D according to COND and MODE */
1064 dlatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], n, &iinfo);
1069 if (*mode != 0 && abs(*mode) != 6) {
1075 for (i__ = 2; i__ <= i__1; ++i__) {
1077 d__2 = temp, d__3 = (d__1 = d__[i__], abs(d__1));
1078 temp = f2cmax(d__2,d__3);
1083 alpha = *dmax__ / temp;
1084 } else if (*dmax__ != 0.) {
1091 dscal_(n, &alpha, &d__[1], &c__1);
1095 dlaset_("Full", n, n, &c_b23, &c_b23, &a[a_offset], lda);
1097 dcopy_(n, &d__[1], &c__1, &a[a_offset], &i__1);
1099 /* Set up complex conjugate pairs */
1104 for (j = 2; j <= i__1; ++j) {
1105 if (lsame_(ei + j, "I")) {
1106 a[j - 1 + j * a_dim1] = a[j + j * a_dim1];
1107 a[j + (j - 1) * a_dim1] = -a[j + j * a_dim1];
1108 a[j + j * a_dim1] = a[j - 1 + (j - 1) * a_dim1];
1114 } else if (abs(*mode) == 5) {
1117 for (j = 2; j <= i__1; j += 2) {
1118 if (dlaran_(&iseed[1]) > .5) {
1119 a[j - 1 + j * a_dim1] = a[j + j * a_dim1];
1120 a[j + (j - 1) * a_dim1] = -a[j + j * a_dim1];
1121 a[j + j * a_dim1] = a[j - 1 + (j - 1) * a_dim1];
1127 /* 3) If UPPER='T', set upper triangle of A to random numbers. */
1128 /* (but don't modify the corners of 2x2 blocks.) */
1132 for (jc = 2; jc <= i__1; ++jc) {
1133 if (a[jc - 1 + jc * a_dim1] != 0.) {
1138 dlarnv_(&idist, &iseed[1], &jr, &a[jc * a_dim1 + 1]);
1143 /* 4) If SIM='T', apply similarity transformation. */
1146 /* Transform is X A X , where X = U S V, thus */
1148 /* it is U S V A V' (1/S) U' */
1152 /* Compute S (singular values of the eigenvector matrix) */
1153 /* according to CONDS and MODES */
1155 dlatm1_(modes, conds, &c__0, &c__0, &iseed[1], &ds[1], n, &iinfo);
1161 /* Multiply by V and V' */
1163 dlarge_(n, &a[a_offset], lda, &iseed[1], &work[1], &iinfo);
1169 /* Multiply by S and (1/S) */
1172 for (j = 1; j <= i__1; ++j) {
1173 dscal_(n, &ds[j], &a[j + a_dim1], lda);
1176 dscal_(n, &d__1, &a[j * a_dim1 + 1], &c__1);
1184 /* Multiply by U and U' */
1186 dlarge_(n, &a[a_offset], lda, &iseed[1], &work[1], &iinfo);
1193 /* 5) Reduce the bandwidth. */
1197 /* Reduce bandwidth -- kill column */
1200 for (jcr = *kl + 1; jcr <= i__1; ++jcr) {
1202 irows = *n + 1 - jcr;
1203 icols = *n + *kl - jcr;
1205 dcopy_(&irows, &a[jcr + ic * a_dim1], &c__1, &work[1], &c__1);
1207 dlarfg_(&irows, &xnorms, &work[2], &c__1, &tau);
1210 dgemv_("T", &irows, &icols, &c_b39, &a[jcr + (ic + 1) * a_dim1],
1211 lda, &work[1], &c__1, &c_b23, &work[irows + 1], &c__1);
1213 dger_(&irows, &icols, &d__1, &work[1], &c__1, &work[irows + 1], &
1214 c__1, &a[jcr + (ic + 1) * a_dim1], lda);
1216 dgemv_("N", n, &irows, &c_b39, &a[jcr * a_dim1 + 1], lda, &work[1]
1217 , &c__1, &c_b23, &work[irows + 1], &c__1);
1219 dger_(n, &irows, &d__1, &work[irows + 1], &c__1, &work[1], &c__1,
1220 &a[jcr * a_dim1 + 1], lda);
1222 a[jcr + ic * a_dim1] = xnorms;
1224 dlaset_("Full", &i__2, &c__1, &c_b23, &c_b23, &a[jcr + 1 + ic *
1228 } else if (*ku < *n - 1) {
1230 /* Reduce upper bandwidth -- kill a row at a time. */
1233 for (jcr = *ku + 1; jcr <= i__1; ++jcr) {
1235 irows = *n + *ku - jcr;
1236 icols = *n + 1 - jcr;
1238 dcopy_(&icols, &a[ir + jcr * a_dim1], lda, &work[1], &c__1);
1240 dlarfg_(&icols, &xnorms, &work[2], &c__1, &tau);
1243 dgemv_("N", &irows, &icols, &c_b39, &a[ir + 1 + jcr * a_dim1],
1244 lda, &work[1], &c__1, &c_b23, &work[icols + 1], &c__1);
1246 dger_(&irows, &icols, &d__1, &work[icols + 1], &c__1, &work[1], &
1247 c__1, &a[ir + 1 + jcr * a_dim1], lda);
1249 dgemv_("C", &icols, n, &c_b39, &a[jcr + a_dim1], lda, &work[1], &
1250 c__1, &c_b23, &work[icols + 1], &c__1);
1252 dger_(&icols, n, &d__1, &work[1], &c__1, &work[icols + 1], &c__1,
1253 &a[jcr + a_dim1], lda);
1255 a[ir + jcr * a_dim1] = xnorms;
1257 dlaset_("Full", &c__1, &i__2, &c_b23, &c_b23, &a[ir + (jcr + 1) *
1263 /* Scale the matrix to have norm ANORM */
1266 temp = dlange_("M", n, n, &a[a_offset], lda, tempa);
1268 alpha = *anorm / temp;
1270 for (j = 1; j <= i__1; ++j) {
1271 dscal_(n, &alpha, &a[j * a_dim1 + 1], &c__1);