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 integer c__0 = 0;
517 static integer c__1 = 1;
519 /* > \brief \b ZLATMR */
521 /* =========== DOCUMENTATION =========== */
523 /* Online html documentation available at */
524 /* http://www.netlib.org/lapack/explore-html/ */
529 /* SUBROUTINE ZLATMR( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, */
530 /* RSIGN, GRADE, DL, MODEL, CONDL, DR, MODER, */
531 /* CONDR, PIVTNG, IPIVOT, KL, KU, SPARSE, ANORM, */
532 /* PACK, A, LDA, IWORK, INFO ) */
534 /* CHARACTER DIST, GRADE, PACK, PIVTNG, RSIGN, SYM */
535 /* INTEGER INFO, KL, KU, LDA, M, MODE, MODEL, MODER, N */
536 /* DOUBLE PRECISION ANORM, COND, CONDL, CONDR, SPARSE */
537 /* COMPLEX*16 DMAX */
538 /* INTEGER IPIVOT( * ), ISEED( 4 ), IWORK( * ) */
539 /* COMPLEX*16 A( LDA, * ), D( * ), DL( * ), DR( * ) */
542 /* > \par Purpose: */
547 /* > ZLATMR generates random matrices of various types for testing */
548 /* > LAPACK programs. */
550 /* > ZLATMR operates by applying the following sequence of */
553 /* > Generate a matrix A with random entries of distribution DIST */
554 /* > which is symmetric if SYM='S', Hermitian if SYM='H', and */
555 /* > nonsymmetric if SYM='N'. */
557 /* > 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 /* > Grade the matrix, if desired, from the left and/or right */
562 /* > as specified by GRADE. The inputs DL, MODEL, CONDL, DR, */
563 /* > MODER and CONDR also determine the grading as described */
566 /* > Permute, if desired, the rows and/or columns as specified by */
567 /* > PIVTNG and IPIVOT. */
569 /* > Set random entries to zero, if desired, to get a random sparse */
570 /* > matrix as specified by SPARSE. */
572 /* > Make A a band matrix, if desired, by zeroing out the matrix */
573 /* > outside a band of lower bandwidth KL and upper bandwidth KU. */
575 /* > Scale A, if desired, to have maximum entry ANORM. */
577 /* > Pack the matrix if desired. Options specified by PACK are: */
579 /* > zero out upper half (if symmetric or Hermitian) */
580 /* > zero out lower half (if symmetric or Hermitian) */
581 /* > store the upper half columnwise (if symmetric or Hermitian */
582 /* > or square upper triangular) */
583 /* > store the lower half columnwise (if symmetric or Hermitian */
584 /* > or square lower triangular) */
585 /* > same as upper half rowwise if symmetric */
586 /* > same as conjugate upper half rowwise if Hermitian */
587 /* > store the lower triangle in banded format */
588 /* > (if symmetric or Hermitian) */
589 /* > store the upper triangle in banded format */
590 /* > (if symmetric or Hermitian) */
591 /* > store the entire matrix in banded format */
593 /* > Note: If two calls to ZLATMR differ only in the PACK parameter, */
594 /* > they will generate mathematically equivalent matrices. */
596 /* > If two calls to ZLATMR both have full bandwidth (KL = M-1 */
597 /* > and KU = N-1), and differ only in the PIVTNG and PACK */
598 /* > parameters, then the matrices generated will differ only */
599 /* > in the order of the rows and/or columns, and otherwise */
600 /* > contain the same data. This consistency cannot be and */
601 /* > is not maintained with less than full bandwidth. */
610 /* > Number of rows of A. Not modified. */
616 /* > Number of columns of A. Not modified. */
619 /* > \param[in] DIST */
621 /* > DIST is CHARACTER*1 */
622 /* > On entry, DIST specifies the type of distribution to be used */
623 /* > to generate a random matrix . */
624 /* > 'U' => real and imaginary parts are independent */
625 /* > UNIFORM( 0, 1 ) ( 'U' for uniform ) */
626 /* > 'S' => real and imaginary parts are independent */
627 /* > UNIFORM( -1, 1 ) ( 'S' for symmetric ) */
628 /* > 'N' => real and imaginary parts are independent */
629 /* > NORMAL( 0, 1 ) ( 'N' for normal ) */
630 /* > 'D' => uniform on interior of unit disk ( 'D' for disk ) */
631 /* > Not modified. */
634 /* > \param[in,out] ISEED */
636 /* > ISEED is INTEGER array, dimension (4) */
637 /* > On entry ISEED specifies the seed of the random number */
638 /* > generator. They should lie between 0 and 4095 inclusive, */
639 /* > and ISEED(4) should be odd. The random number generator */
640 /* > uses a linear congruential sequence limited to small */
641 /* > integers, and so should produce machine independent */
642 /* > random numbers. The values of ISEED are changed on */
643 /* > exit, and can be used in the next call to ZLATMR */
644 /* > to continue the same random number sequence. */
645 /* > Changed on exit. */
648 /* > \param[in] SYM */
650 /* > SYM is CHARACTER*1 */
651 /* > If SYM='S', generated matrix is symmetric. */
652 /* > If SYM='H', generated matrix is Hermitian. */
653 /* > If SYM='N', generated matrix is nonsymmetric. */
654 /* > Not modified. */
657 /* > \param[in,out] D */
659 /* > D is COMPLEX*16 array, dimension (f2cmin(M,N)) */
660 /* > On entry this array specifies the diagonal entries */
661 /* > of the diagonal of A. D may either be specified */
662 /* > on entry, or set according to MODE and COND as described */
663 /* > below. If the matrix is Hermitian, the real part of D */
664 /* > will be taken. May be changed on exit if MODE is nonzero. */
667 /* > \param[in] MODE */
669 /* > MODE is INTEGER */
670 /* > On entry describes how D is to be used: */
671 /* > MODE = 0 means use D as input */
672 /* > MODE = 1 sets D(1)=1 and D(2:N)=1.0/COND */
673 /* > MODE = 2 sets D(1:N-1)=1 and D(N)=1.0/COND */
674 /* > MODE = 3 sets D(I)=COND**(-(I-1)/(N-1)) */
675 /* > MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */
676 /* > MODE = 5 sets D to random numbers in the range */
677 /* > ( 1/COND , 1 ) such that their logarithms */
678 /* > are uniformly distributed. */
679 /* > MODE = 6 set D to random numbers from same distribution */
680 /* > as the rest of the matrix. */
681 /* > MODE < 0 has the same meaning as ABS(MODE), except that */
682 /* > the order of the elements of D is reversed. */
683 /* > Thus if MODE is positive, D has entries ranging from */
684 /* > 1 to 1/COND, if negative, from 1/COND to 1, */
685 /* > Not modified. */
688 /* > \param[in] COND */
690 /* > COND is DOUBLE PRECISION */
691 /* > On entry, used as described under MODE above. */
692 /* > If used, it must be >= 1. Not modified. */
695 /* > \param[in] DMAX */
697 /* > DMAX is COMPLEX*16 */
698 /* > If MODE neither -6, 0 nor 6, the diagonal is scaled by */
699 /* > DMAX / f2cmax(abs(D(i))), so that maximum absolute entry */
700 /* > of diagonal is abs(DMAX). If DMAX is complex (or zero), */
701 /* > diagonal will be scaled by a complex number (or zero). */
704 /* > \param[in] RSIGN */
706 /* > RSIGN is CHARACTER*1 */
707 /* > If MODE neither -6, 0 nor 6, specifies sign of diagonal */
709 /* > 'T' => diagonal entries are multiplied by a random complex */
710 /* > number uniformly distributed with absolute value 1 */
711 /* > 'F' => diagonal unchanged */
712 /* > Not modified. */
715 /* > \param[in] GRADE */
717 /* > GRADE is CHARACTER*1 */
718 /* > Specifies grading of matrix as follows: */
719 /* > 'N' => no grading */
720 /* > 'L' => matrix premultiplied by diag( DL ) */
721 /* > (only if matrix nonsymmetric) */
722 /* > 'R' => matrix postmultiplied by diag( DR ) */
723 /* > (only if matrix nonsymmetric) */
724 /* > 'B' => matrix premultiplied by diag( DL ) and */
725 /* > postmultiplied by diag( DR ) */
726 /* > (only if matrix nonsymmetric) */
727 /* > 'H' => matrix premultiplied by diag( DL ) and */
728 /* > postmultiplied by diag( CONJG(DL) ) */
729 /* > (only if matrix Hermitian or nonsymmetric) */
730 /* > 'S' => matrix premultiplied by diag( DL ) and */
731 /* > postmultiplied by diag( DL ) */
732 /* > (only if matrix symmetric or nonsymmetric) */
733 /* > 'E' => matrix premultiplied by diag( DL ) and */
734 /* > postmultiplied by inv( diag( DL ) ) */
735 /* > ( 'S' for similarity ) */
736 /* > (only if matrix nonsymmetric) */
737 /* > Note: if GRADE='S', then M must equal N. */
738 /* > Not modified. */
741 /* > \param[in,out] DL */
743 /* > DL is COMPLEX*16 array, dimension (M) */
744 /* > If MODEL=0, then on entry this array specifies the diagonal */
745 /* > entries of a diagonal matrix used as described under GRADE */
746 /* > above. If MODEL is not zero, then DL will be set according */
747 /* > to MODEL and CONDL, analogous to the way D is set according */
748 /* > to MODE and COND (except there is no DMAX parameter for DL). */
749 /* > If GRADE='E', then DL cannot have zero entries. */
750 /* > Not referenced if GRADE = 'N' or 'R'. Changed on exit. */
753 /* > \param[in] MODEL */
755 /* > MODEL is INTEGER */
756 /* > This specifies how the diagonal array DL is to be computed, */
757 /* > just as MODE specifies how D is to be computed. */
758 /* > Not modified. */
761 /* > \param[in] CONDL */
763 /* > CONDL is DOUBLE PRECISION */
764 /* > When MODEL is not zero, this specifies the condition number */
765 /* > of the computed DL. Not modified. */
768 /* > \param[in,out] DR */
770 /* > DR is COMPLEX*16 array, dimension (N) */
771 /* > If MODER=0, then on entry this array specifies the diagonal */
772 /* > entries of a diagonal matrix used as described under GRADE */
773 /* > above. If MODER is not zero, then DR will be set according */
774 /* > to MODER and CONDR, analogous to the way D is set according */
775 /* > to MODE and COND (except there is no DMAX parameter for DR). */
776 /* > Not referenced if GRADE = 'N', 'L', 'H' or 'S'. */
777 /* > Changed on exit. */
780 /* > \param[in] MODER */
782 /* > MODER is INTEGER */
783 /* > This specifies how the diagonal array DR is to be computed, */
784 /* > just as MODE specifies how D is to be computed. */
785 /* > Not modified. */
788 /* > \param[in] CONDR */
790 /* > CONDR is DOUBLE PRECISION */
791 /* > When MODER is not zero, this specifies the condition number */
792 /* > of the computed DR. Not modified. */
795 /* > \param[in] PIVTNG */
797 /* > PIVTNG is CHARACTER*1 */
798 /* > On entry specifies pivoting permutations as follows: */
799 /* > 'N' or ' ' => none. */
800 /* > 'L' => left or row pivoting (matrix must be nonsymmetric). */
801 /* > 'R' => right or column pivoting (matrix must be */
802 /* > nonsymmetric). */
803 /* > 'B' or 'F' => both or full pivoting, i.e., on both sides. */
804 /* > In this case, M must equal N */
806 /* > If two calls to ZLATMR both have full bandwidth (KL = M-1 */
807 /* > and KU = N-1), and differ only in the PIVTNG and PACK */
808 /* > parameters, then the matrices generated will differ only */
809 /* > in the order of the rows and/or columns, and otherwise */
810 /* > contain the same data. This consistency cannot be */
811 /* > maintained with less than full bandwidth. */
814 /* > \param[in] IPIVOT */
816 /* > IPIVOT is INTEGER array, dimension (N or M) */
817 /* > This array specifies the permutation used. After the */
818 /* > basic matrix is generated, the rows, columns, or both */
819 /* > are permuted. If, say, row pivoting is selected, ZLATMR */
820 /* > starts with the *last* row and interchanges the M-th and */
821 /* > IPIVOT(M)-th rows, then moves to the next-to-last row, */
822 /* > interchanging the (M-1)-th and the IPIVOT(M-1)-th rows, */
823 /* > and so on. In terms of "2-cycles", the permutation is */
824 /* > (1 IPIVOT(1)) (2 IPIVOT(2)) ... (M IPIVOT(M)) */
825 /* > where the rightmost cycle is applied first. This is the */
826 /* > *inverse* of the effect of pivoting in LINPACK. The idea */
827 /* > is that factoring (with pivoting) an identity matrix */
828 /* > which has been inverse-pivoted in this way should */
829 /* > result in a pivot vector identical to IPIVOT. */
830 /* > Not referenced if PIVTNG = 'N'. Not modified. */
833 /* > \param[in] KL */
835 /* > KL is INTEGER */
836 /* > On entry specifies the lower bandwidth of the matrix. For */
837 /* > example, KL=0 implies upper triangular, KL=1 implies upper */
838 /* > Hessenberg, and KL at least M-1 implies the matrix is not */
839 /* > banded. Must equal KU if matrix is symmetric or Hermitian. */
840 /* > Not modified. */
843 /* > \param[in] KU */
845 /* > KU is INTEGER */
846 /* > On entry specifies the upper bandwidth of the matrix. For */
847 /* > example, KU=0 implies lower triangular, KU=1 implies lower */
848 /* > Hessenberg, and KU at least N-1 implies the matrix is not */
849 /* > banded. Must equal KL if matrix is symmetric or Hermitian. */
850 /* > Not modified. */
853 /* > \param[in] SPARSE */
855 /* > SPARSE is DOUBLE PRECISION */
856 /* > On entry specifies the sparsity of the matrix if a sparse */
857 /* > matrix is to be generated. SPARSE should lie between */
858 /* > 0 and 1. To generate a sparse matrix, for each matrix entry */
859 /* > a uniform ( 0, 1 ) random number x is generated and */
860 /* > compared to SPARSE; if x is larger the matrix entry */
861 /* > is unchanged and if x is smaller the entry is set */
862 /* > to zero. Thus on the average a fraction SPARSE of the */
863 /* > entries will be set to zero. */
864 /* > Not modified. */
867 /* > \param[in] ANORM */
869 /* > ANORM is DOUBLE PRECISION */
870 /* > On entry specifies maximum entry of output matrix */
871 /* > (output matrix will by multiplied by a constant so that */
872 /* > its largest absolute entry equal ANORM) */
873 /* > if ANORM is nonnegative. If ANORM is negative no scaling */
874 /* > is done. Not modified. */
877 /* > \param[in] PACK */
879 /* > PACK is CHARACTER*1 */
880 /* > On entry specifies packing of matrix as follows: */
881 /* > 'N' => no packing */
882 /* > 'U' => zero out all subdiagonal entries */
883 /* > (if symmetric or Hermitian) */
884 /* > 'L' => zero out all superdiagonal entries */
885 /* > (if symmetric or Hermitian) */
886 /* > 'C' => store the upper triangle columnwise */
887 /* > (only if matrix symmetric or Hermitian or */
888 /* > square upper triangular) */
889 /* > 'R' => store the lower triangle columnwise */
890 /* > (only if matrix symmetric or Hermitian or */
891 /* > square lower triangular) */
892 /* > (same as upper half rowwise if symmetric) */
893 /* > (same as conjugate upper half rowwise if Hermitian) */
894 /* > 'B' => store the lower triangle in band storage scheme */
895 /* > (only if matrix symmetric or Hermitian) */
896 /* > 'Q' => store the upper triangle in band storage scheme */
897 /* > (only if matrix symmetric or Hermitian) */
898 /* > 'Z' => store the entire matrix in band storage scheme */
899 /* > (pivoting can be provided for by using this */
900 /* > option to store A in the trailing rows of */
901 /* > the allocated storage) */
903 /* > Using these options, the various LAPACK packed and banded */
904 /* > storage schemes can be obtained: */
906 /* > PB, HB or TB - use 'B' or 'Q' */
907 /* > PP, HP or TP - use 'C' or 'R' */
909 /* > If two calls to ZLATMR differ only in the PACK parameter, */
910 /* > they will generate mathematically equivalent matrices. */
911 /* > Not modified. */
914 /* > \param[in,out] A */
916 /* > A is COMPLEX*16 array, dimension (LDA,N) */
917 /* > On exit A is the desired test matrix. Only those */
918 /* > entries of A which are significant on output */
919 /* > will be referenced (even if A is in packed or band */
920 /* > storage format). The 'unoccupied corners' of A in */
921 /* > band format will be zeroed out. */
924 /* > \param[in] LDA */
926 /* > LDA is INTEGER */
927 /* > on entry LDA specifies the first dimension of A as */
928 /* > declared in the calling program. */
929 /* > If PACK='N', 'U' or 'L', LDA must be at least f2cmax ( 1, M ). */
930 /* > If PACK='C' or 'R', LDA must be at least 1. */
931 /* > If PACK='B', or 'Q', LDA must be MIN ( KU+1, N ) */
932 /* > If PACK='Z', LDA must be at least KUU+KLL+1, where */
933 /* > KUU = MIN ( KU, N-1 ) and KLL = MIN ( KL, M-1 ) */
934 /* > Not modified. */
937 /* > \param[out] IWORK */
939 /* > IWORK is INTEGER array, dimension (N or M) */
940 /* > Workspace. Not referenced if PIVTNG = 'N'. Changed on exit. */
943 /* > \param[out] INFO */
945 /* > INFO is INTEGER */
946 /* > Error parameter on exit: */
947 /* > 0 => normal return */
948 /* > -1 => M negative or unequal to N and SYM='S' or 'H' */
949 /* > -2 => N negative */
950 /* > -3 => DIST illegal string */
951 /* > -5 => SYM illegal string */
952 /* > -7 => MODE not in range -6 to 6 */
953 /* > -8 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
954 /* > -10 => MODE neither -6, 0 nor 6 and RSIGN illegal string */
955 /* > -11 => GRADE illegal string, or GRADE='E' and */
956 /* > M not equal to N, or GRADE='L', 'R', 'B', 'S' or 'E' */
957 /* > and SYM = 'H', or GRADE='L', 'R', 'B', 'H' or 'E' */
958 /* > and SYM = 'S' */
959 /* > -12 => GRADE = 'E' and DL contains zero */
960 /* > -13 => MODEL not in range -6 to 6 and GRADE= 'L', 'B', 'H', */
962 /* > -14 => CONDL less than 1.0, GRADE='L', 'B', 'H', 'S' or 'E', */
963 /* > and MODEL neither -6, 0 nor 6 */
964 /* > -16 => MODER not in range -6 to 6 and GRADE= 'R' or 'B' */
965 /* > -17 => CONDR less than 1.0, GRADE='R' or 'B', and */
966 /* > MODER neither -6, 0 nor 6 */
967 /* > -18 => PIVTNG illegal string, or PIVTNG='B' or 'F' and */
968 /* > M not equal to N, or PIVTNG='L' or 'R' and SYM='S' */
970 /* > -19 => IPIVOT contains out of range number and */
971 /* > PIVTNG not equal to 'N' */
972 /* > -20 => KL negative */
973 /* > -21 => KU negative, or SYM='S' or 'H' and KU not equal to KL */
974 /* > -22 => SPARSE not in range 0. to 1. */
975 /* > -24 => PACK illegal string, or PACK='U', 'L', 'B' or 'Q' */
976 /* > and SYM='N', or PACK='C' and SYM='N' and either KL */
977 /* > not equal to 0 or N not equal to M, or PACK='R' and */
978 /* > SYM='N', and either KU not equal to 0 or N not equal */
980 /* > -26 => LDA too small */
981 /* > 1 => Error return from ZLATM1 (computing D) */
982 /* > 2 => Cannot scale diagonal to DMAX (f2cmax. entry is 0) */
983 /* > 3 => Error return from ZLATM1 (computing DL) */
984 /* > 4 => Error return from ZLATM1 (computing DR) */
985 /* > 5 => ANORM is positive, but matrix constructed prior to */
986 /* > attempting to scale it to have norm ANORM, is zero */
992 /* > \author Univ. of Tennessee */
993 /* > \author Univ. of California Berkeley */
994 /* > \author Univ. of Colorado Denver */
995 /* > \author NAG Ltd. */
997 /* > \date December 2016 */
999 /* > \ingroup complex16_matgen */
1001 /* ===================================================================== */
1002 /* Subroutine */ int zlatmr_(integer *m, integer *n, char *dist, integer *
1003 iseed, char *sym, doublecomplex *d__, integer *mode, doublereal *cond,
1004 doublecomplex *dmax__, char *rsign, char *grade, doublecomplex *dl,
1005 integer *model, doublereal *condl, doublecomplex *dr, integer *moder,
1006 doublereal *condr, char *pivtng, integer *ipivot, integer *kl,
1007 integer *ku, doublereal *sparse, doublereal *anorm, char *pack,
1008 doublecomplex *a, integer *lda, integer *iwork, integer *info)
1010 /* System generated locals */
1011 integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
1012 doublereal d__1, d__2;
1013 doublecomplex z__1, z__2;
1015 /* Local variables */
1018 integer isym, i__, j, k, ipack;
1019 extern logical lsame_(char *, char *);
1020 doublereal tempa[1];
1021 doublecomplex ctemp;
1022 integer iisub, idist, jjsub, mnmin;
1026 integer mxsub, npvts;
1027 extern /* Subroutine */ int zlatm1_(integer *, doublereal *, integer *,
1028 integer *, integer *, doublecomplex *, integer *, integer *);
1029 extern /* Double Complex */ VOID zlatm2_(doublecomplex *, integer *,
1030 integer *, integer *, integer *, integer *, integer *, integer *,
1031 integer *, doublecomplex *, integer *, doublecomplex *,
1032 doublecomplex *, integer *, integer *, doublereal *), zlatm3_(
1033 doublecomplex *, integer *, integer *, integer *, integer *,
1034 integer *, integer *, integer *, integer *, integer *, integer *,
1035 doublecomplex *, integer *, doublecomplex *, doublecomplex *,
1036 integer *, integer *, doublereal *);
1037 doublecomplex calpha;
1040 extern doublereal zlangb_(char *, integer *, integer *, integer *,
1041 doublecomplex *, integer *, doublereal *);
1042 extern /* Subroutine */ int xerbla_(char *, integer *);
1044 extern doublereal zlange_(char *, integer *, integer *, doublecomplex *,
1045 integer *, doublereal *);
1046 extern /* Subroutine */ int zdscal_(integer *, doublereal *,
1047 doublecomplex *, integer *);
1048 extern doublereal zlansb_(char *, char *, integer *, integer *,
1049 doublecomplex *, integer *, doublereal *);
1050 integer irsign, ipvtng;
1051 extern doublereal zlansp_(char *, char *, integer *, doublecomplex *,
1052 doublereal *), zlansy_(char *, char *, integer *,
1053 doublecomplex *, integer *, doublereal *);
1057 /* -- LAPACK computational routine (version 3.7.0) -- */
1058 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
1059 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
1063 /* ===================================================================== */
1066 /* 1) Decode and Test the input parameters. */
1067 /* Initialize flags & seed. */
1069 /* Parameter adjustments */
1076 a_offset = 1 + a_dim1 * 1;
1083 /* Quick return if possible */
1085 if (*m == 0 || *n == 0) {
1091 if (lsame_(dist, "U")) {
1093 } else if (lsame_(dist, "S")) {
1095 } else if (lsame_(dist, "N")) {
1097 } else if (lsame_(dist, "D")) {
1105 if (lsame_(sym, "H")) {
1107 } else if (lsame_(sym, "N")) {
1109 } else if (lsame_(sym, "S")) {
1117 if (lsame_(rsign, "F")) {
1119 } else if (lsame_(rsign, "T")) {
1127 if (lsame_(pivtng, "N")) {
1129 } else if (lsame_(pivtng, " ")) {
1131 } else if (lsame_(pivtng, "L")) {
1134 } else if (lsame_(pivtng, "R")) {
1137 } else if (lsame_(pivtng, "B")) {
1139 npvts = f2cmin(*n,*m);
1140 } else if (lsame_(pivtng, "F")) {
1142 npvts = f2cmin(*n,*m);
1149 if (lsame_(grade, "N")) {
1151 } else if (lsame_(grade, "L")) {
1153 } else if (lsame_(grade, "R")) {
1155 } else if (lsame_(grade, "B")) {
1157 } else if (lsame_(grade, "E")) {
1159 } else if (lsame_(grade, "H")) {
1161 } else if (lsame_(grade, "S")) {
1169 if (lsame_(pack, "N")) {
1171 } else if (lsame_(pack, "U")) {
1173 } else if (lsame_(pack, "L")) {
1175 } else if (lsame_(pack, "C")) {
1177 } else if (lsame_(pack, "R")) {
1179 } else if (lsame_(pack, "B")) {
1181 } else if (lsame_(pack, "Q")) {
1183 } else if (lsame_(pack, "Z")) {
1189 /* Set certain internal parameters */
1191 mnmin = f2cmin(*m,*n);
1193 i__1 = *kl, i__2 = *m - 1;
1194 kll = f2cmin(i__1,i__2);
1196 i__1 = *ku, i__2 = *n - 1;
1197 kuu = f2cmin(i__1,i__2);
1199 /* If inv(DL) is used, check to see if DL has a zero entry. */
1202 if (igrade == 4 && *model == 0) {
1204 for (i__ = 1; i__ <= i__1; ++i__) {
1206 if (dl[i__2].r == 0. && dl[i__2].i == 0.) {
1213 /* Check values in IPIVOT */
1218 for (j = 1; j <= i__1; ++j) {
1219 if (ipivot[j] <= 0 || ipivot[j] > npvts) {
1226 /* Set INFO if an error */
1230 } else if (*m != *n && (isym == 0 || isym == 2)) {
1232 } else if (*n < 0) {
1234 } else if (idist == -1) {
1236 } else if (isym == -1) {
1238 } else if (*mode < -6 || *mode > 6) {
1240 } else if (*mode != -6 && *mode != 0 && *mode != 6 && *cond < 1.) {
1242 } else if (*mode != -6 && *mode != 0 && *mode != 6 && irsign == -1) {
1244 } else if (igrade == -1 || igrade == 4 && *m != *n || (igrade == 1 ||
1245 igrade == 2 || igrade == 3 || igrade == 4 || igrade == 6) && isym
1246 == 0 || (igrade == 1 || igrade == 2 || igrade == 3 || igrade == 4
1247 || igrade == 5) && isym == 2) {
1249 } else if (igrade == 4 && dzero) {
1251 } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 ||
1252 igrade == 6) && (*model < -6 || *model > 6)) {
1254 } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 ||
1255 igrade == 6) && (*model != -6 && *model != 0 && *model != 6) && *
1258 } else if ((igrade == 2 || igrade == 3) && (*moder < -6 || *moder > 6)) {
1260 } else if ((igrade == 2 || igrade == 3) && (*moder != -6 && *moder != 0 &&
1261 *moder != 6) && *condr < 1.) {
1263 } else if (ipvtng == -1 || ipvtng == 3 && *m != *n || (ipvtng == 1 ||
1264 ipvtng == 2) && (isym == 0 || isym == 2)) {
1266 } else if (ipvtng != 0 && badpvt) {
1268 } else if (*kl < 0) {
1270 } else if (*ku < 0 || (isym == 0 || isym == 2) && *kl != *ku) {
1272 } else if (*sparse < 0. || *sparse > 1.) {
1274 } else if (ipack == -1 || (ipack == 1 || ipack == 2 || ipack == 5 ||
1275 ipack == 6) && isym == 1 || ipack == 3 && isym == 1 && (*kl != 0
1276 || *m != *n) || ipack == 4 && isym == 1 && (*ku != 0 || *m != *n))
1279 } else if ((ipack == 0 || ipack == 1 || ipack == 2) && *lda < f2cmax(1,*m) ||
1280 (ipack == 3 || ipack == 4) && *lda < 1 || (ipack == 5 || ipack ==
1281 6) && *lda < kuu + 1 || ipack == 7 && *lda < kll + kuu + 1) {
1287 xerbla_("ZLATMR", &i__1);
1291 /* Decide if we can pivot consistently */
1294 if (kuu == *n - 1 && kll == *m - 1) {
1298 /* Initialize random number generator */
1300 for (i__ = 1; i__ <= 4; ++i__) {
1301 iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
1305 iseed[4] = (iseed[4] / 2 << 1) + 1;
1307 /* 2) Set up D, DL, and DR, if indicated. */
1309 /* Compute D according to COND and MODE */
1311 zlatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, info);
1316 if (*mode != 0 && *mode != -6 && *mode != 6) {
1320 temp = z_abs(&d__[1]);
1322 for (i__ = 2; i__ <= i__1; ++i__) {
1324 d__1 = temp, d__2 = z_abs(&d__[i__]);
1325 temp = f2cmax(d__1,d__2);
1328 if (temp == 0. && (dmax__->r != 0. || dmax__->i != 0.)) {
1333 z__1.r = dmax__->r / temp, z__1.i = dmax__->i / temp;
1334 calpha.r = z__1.r, calpha.i = z__1.i;
1336 calpha.r = 1., calpha.i = 0.;
1339 for (i__ = 1; i__ <= i__1; ++i__) {
1342 z__1.r = calpha.r * d__[i__3].r - calpha.i * d__[i__3].i, z__1.i =
1343 calpha.r * d__[i__3].i + calpha.i * d__[i__3].r;
1344 d__[i__2].r = z__1.r, d__[i__2].i = z__1.i;
1350 /* If matrix Hermitian, make D real */
1354 for (i__ = 1; i__ <= i__1; ++i__) {
1358 d__[i__2].r = d__1, d__[i__2].i = 0.;
1363 /* Compute DL if grading set */
1365 if (igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 || igrade ==
1367 zlatm1_(model, condl, &c__0, &idist, &iseed[1], &dl[1], m, info);
1374 /* Compute DR if grading set */
1376 if (igrade == 2 || igrade == 3) {
1377 zlatm1_(moder, condr, &c__0, &idist, &iseed[1], &dr[1], n, info);
1384 /* 3) Generate IWORK if pivoting */
1388 for (i__ = 1; i__ <= i__1; ++i__) {
1394 for (i__ = 1; i__ <= i__1; ++i__) {
1397 iwork[i__] = iwork[k];
1402 for (i__ = npvts; i__ >= 1; --i__) {
1405 iwork[i__] = iwork[k];
1412 /* 4) Generate matrices for each kind of PACKing */
1413 /* Always sweep matrix columnwise (if symmetric, upper */
1414 /* half only) so that matrix generated does not depend */
1419 /* Use ZLATM3 so matrices generated with differing PIVOTing only */
1420 /* differ only in the order of their rows and/or columns. */
1425 for (j = 1; j <= i__1; ++j) {
1427 for (i__ = 1; i__ <= i__2; ++i__) {
1428 zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1429 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1430 dr[1], &ipvtng, &iwork[1], sparse);
1431 ctemp.r = z__1.r, ctemp.i = z__1.i;
1432 i__3 = isub + jsub * a_dim1;
1433 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1434 i__3 = jsub + isub * a_dim1;
1435 d_cnjg(&z__1, &ctemp);
1436 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1441 } else if (isym == 1) {
1443 for (j = 1; j <= i__1; ++j) {
1445 for (i__ = 1; i__ <= i__2; ++i__) {
1446 zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1447 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1448 dr[1], &ipvtng, &iwork[1], sparse);
1449 ctemp.r = z__1.r, ctemp.i = z__1.i;
1450 i__3 = isub + jsub * a_dim1;
1451 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1456 } else if (isym == 2) {
1458 for (j = 1; j <= i__1; ++j) {
1460 for (i__ = 1; i__ <= i__2; ++i__) {
1461 zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1462 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1463 dr[1], &ipvtng, &iwork[1], sparse);
1464 ctemp.r = z__1.r, ctemp.i = z__1.i;
1465 i__3 = isub + jsub * a_dim1;
1466 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1467 i__3 = jsub + isub * a_dim1;
1468 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1475 } else if (ipack == 1) {
1478 for (j = 1; j <= i__1; ++j) {
1480 for (i__ = 1; i__ <= i__2; ++i__) {
1481 zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1482 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1483 , &ipvtng, &iwork[1], sparse);
1484 ctemp.r = z__1.r, ctemp.i = z__1.i;
1485 mnsub = f2cmin(isub,jsub);
1486 mxsub = f2cmax(isub,jsub);
1487 if (mxsub == isub && isym == 0) {
1488 i__3 = mnsub + mxsub * a_dim1;
1489 d_cnjg(&z__1, &ctemp);
1490 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1492 i__3 = mnsub + mxsub * a_dim1;
1493 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1495 if (mnsub != mxsub) {
1496 i__3 = mxsub + mnsub * a_dim1;
1497 a[i__3].r = 0., a[i__3].i = 0.;
1504 } else if (ipack == 2) {
1507 for (j = 1; j <= i__1; ++j) {
1509 for (i__ = 1; i__ <= i__2; ++i__) {
1510 zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1511 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1512 , &ipvtng, &iwork[1], sparse);
1513 ctemp.r = z__1.r, ctemp.i = z__1.i;
1514 mnsub = f2cmin(isub,jsub);
1515 mxsub = f2cmax(isub,jsub);
1516 if (mxsub == jsub && isym == 0) {
1517 i__3 = mxsub + mnsub * a_dim1;
1518 d_cnjg(&z__1, &ctemp);
1519 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1521 i__3 = mxsub + mnsub * a_dim1;
1522 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1524 if (mnsub != mxsub) {
1525 i__3 = mnsub + mxsub * a_dim1;
1526 a[i__3].r = 0., a[i__3].i = 0.;
1533 } else if (ipack == 3) {
1536 for (j = 1; j <= i__1; ++j) {
1538 for (i__ = 1; i__ <= i__2; ++i__) {
1539 zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1540 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1541 , &ipvtng, &iwork[1], sparse);
1542 ctemp.r = z__1.r, ctemp.i = z__1.i;
1544 /* Compute K = location of (ISUB,JSUB) entry in packed */
1547 mnsub = f2cmin(isub,jsub);
1548 mxsub = f2cmax(isub,jsub);
1549 k = mxsub * (mxsub - 1) / 2 + mnsub;
1551 /* Convert K to (IISUB,JJSUB) location */
1553 jjsub = (k - 1) / *lda + 1;
1554 iisub = k - *lda * (jjsub - 1);
1556 if (mxsub == isub && isym == 0) {
1557 i__3 = iisub + jjsub * a_dim1;
1558 d_cnjg(&z__1, &ctemp);
1559 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1561 i__3 = iisub + jjsub * a_dim1;
1562 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1569 } else if (ipack == 4) {
1572 for (j = 1; j <= i__1; ++j) {
1574 for (i__ = 1; i__ <= i__2; ++i__) {
1575 zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1576 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1577 , &ipvtng, &iwork[1], sparse);
1578 ctemp.r = z__1.r, ctemp.i = z__1.i;
1580 /* Compute K = location of (I,J) entry in packed array */
1582 mnsub = f2cmin(isub,jsub);
1583 mxsub = f2cmax(isub,jsub);
1587 k = *n * (*n + 1) / 2 - (*n - mnsub + 1) * (*n -
1588 mnsub + 2) / 2 + mxsub - mnsub + 1;
1591 /* Convert K to (IISUB,JJSUB) location */
1593 jjsub = (k - 1) / *lda + 1;
1594 iisub = k - *lda * (jjsub - 1);
1596 if (mxsub == jsub && isym == 0) {
1597 i__3 = iisub + jjsub * a_dim1;
1598 d_cnjg(&z__1, &ctemp);
1599 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1601 i__3 = iisub + jjsub * a_dim1;
1602 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1609 } else if (ipack == 5) {
1612 for (j = 1; j <= i__1; ++j) {
1614 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1616 i__3 = j - i__ + 1 + (i__ + *n) * a_dim1;
1617 a[i__3].r = 0., a[i__3].i = 0.;
1619 zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1620 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1621 dr[1], &ipvtng, &iwork[1], sparse);
1622 ctemp.r = z__1.r, ctemp.i = z__1.i;
1623 mnsub = f2cmin(isub,jsub);
1624 mxsub = f2cmax(isub,jsub);
1625 if (mxsub == jsub && isym == 0) {
1626 i__3 = mxsub - mnsub + 1 + mnsub * a_dim1;
1627 d_cnjg(&z__1, &ctemp);
1628 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1630 i__3 = mxsub - mnsub + 1 + mnsub * a_dim1;
1631 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1639 } else if (ipack == 6) {
1642 for (j = 1; j <= i__1; ++j) {
1644 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1645 zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1646 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1647 , &ipvtng, &iwork[1], sparse);
1648 ctemp.r = z__1.r, ctemp.i = z__1.i;
1649 mnsub = f2cmin(isub,jsub);
1650 mxsub = f2cmax(isub,jsub);
1651 if (mxsub == isub && isym == 0) {
1652 i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
1653 d_cnjg(&z__1, &ctemp);
1654 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1656 i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
1657 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1664 } else if (ipack == 7) {
1668 for (j = 1; j <= i__1; ++j) {
1670 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1671 zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1672 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1673 dr[1], &ipvtng, &iwork[1], sparse);
1674 ctemp.r = z__1.r, ctemp.i = z__1.i;
1675 mnsub = f2cmin(isub,jsub);
1676 mxsub = f2cmax(isub,jsub);
1678 i__3 = j - i__ + 1 + kuu + (i__ + *n) * a_dim1;
1679 a[i__3].r = 0., a[i__3].i = 0.;
1681 if (mxsub == isub && isym == 0) {
1682 i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
1683 d_cnjg(&z__1, &ctemp);
1684 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1686 i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
1687 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1689 if (i__ >= 1 && mnsub != mxsub) {
1690 if (mnsub == isub && isym == 0) {
1691 i__3 = mxsub - mnsub + 1 + kuu + mnsub *
1693 d_cnjg(&z__1, &ctemp);
1694 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1696 i__3 = mxsub - mnsub + 1 + kuu + mnsub *
1698 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1705 } else if (isym == 1) {
1707 for (j = 1; j <= i__1; ++j) {
1709 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1710 zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1711 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1712 dr[1], &ipvtng, &iwork[1], sparse);
1713 ctemp.r = z__1.r, ctemp.i = z__1.i;
1714 i__3 = isub - jsub + kuu + 1 + jsub * a_dim1;
1715 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1731 for (j = 1; j <= i__1; ++j) {
1733 for (i__ = 1; i__ <= i__2; ++i__) {
1734 i__3 = i__ + j * a_dim1;
1735 zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
1736 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1738 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1739 i__3 = j + i__ * a_dim1;
1740 d_cnjg(&z__1, &a[i__ + j * a_dim1]);
1741 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1746 } else if (isym == 1) {
1748 for (j = 1; j <= i__1; ++j) {
1750 for (i__ = 1; i__ <= i__2; ++i__) {
1751 i__3 = i__ + j * a_dim1;
1752 zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
1753 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1755 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1760 } else if (isym == 2) {
1762 for (j = 1; j <= i__1; ++j) {
1764 for (i__ = 1; i__ <= i__2; ++i__) {
1765 i__3 = i__ + j * a_dim1;
1766 zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
1767 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1769 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1770 i__3 = j + i__ * a_dim1;
1771 i__4 = i__ + j * a_dim1;
1772 a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
1779 } else if (ipack == 1) {
1782 for (j = 1; j <= i__1; ++j) {
1784 for (i__ = 1; i__ <= i__2; ++i__) {
1785 i__3 = i__ + j * a_dim1;
1786 zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1],
1787 &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
1789 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1791 i__3 = j + i__ * a_dim1;
1792 a[i__3].r = 0., a[i__3].i = 0.;
1799 } else if (ipack == 2) {
1802 for (j = 1; j <= i__1; ++j) {
1804 for (i__ = 1; i__ <= i__2; ++i__) {
1806 i__3 = j + i__ * a_dim1;
1807 zlatm2_(&z__2, m, n, &i__, &j, kl, ku, &idist, &iseed[
1808 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1810 d_cnjg(&z__1, &z__2);
1811 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1813 i__3 = j + i__ * a_dim1;
1814 zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
1815 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1817 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1820 i__3 = i__ + j * a_dim1;
1821 a[i__3].r = 0., a[i__3].i = 0.;
1828 } else if (ipack == 3) {
1833 for (j = 1; j <= i__1; ++j) {
1835 for (i__ = 1; i__ <= i__2; ++i__) {
1841 i__3 = isub + jsub * a_dim1;
1842 zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1],
1843 &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
1845 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1851 } else if (ipack == 4) {
1853 if (isym == 0 || isym == 2) {
1855 for (j = 1; j <= i__1; ++j) {
1857 for (i__ = 1; i__ <= i__2; ++i__) {
1859 /* Compute K = location of (I,J) entry in packed array */
1864 k = *n * (*n + 1) / 2 - (*n - i__ + 1) * (*n -
1865 i__ + 2) / 2 + j - i__ + 1;
1868 /* Convert K to (ISUB,JSUB) location */
1870 jsub = (k - 1) / *lda + 1;
1871 isub = k - *lda * (jsub - 1);
1873 i__3 = isub + jsub * a_dim1;
1874 zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
1875 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1877 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1879 i__3 = isub + jsub * a_dim1;
1880 d_cnjg(&z__1, &a[isub + jsub * a_dim1]);
1881 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1891 for (j = 1; j <= i__1; ++j) {
1893 for (i__ = j; i__ <= i__2; ++i__) {
1899 i__3 = isub + jsub * a_dim1;
1900 zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
1901 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1903 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1910 } else if (ipack == 5) {
1913 for (j = 1; j <= i__1; ++j) {
1915 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1917 i__3 = j - i__ + 1 + (i__ + *n) * a_dim1;
1918 a[i__3].r = 0., a[i__3].i = 0.;
1921 i__3 = j - i__ + 1 + i__ * a_dim1;
1922 zlatm2_(&z__2, m, n, &i__, &j, kl, ku, &idist, &
1923 iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1924 , &ipvtng, &iwork[1], sparse);
1925 d_cnjg(&z__1, &z__2);
1926 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1928 i__3 = j - i__ + 1 + i__ * a_dim1;
1929 zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &
1930 iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1931 , &ipvtng, &iwork[1], sparse);
1932 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1940 } else if (ipack == 6) {
1943 for (j = 1; j <= i__1; ++j) {
1945 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1946 i__3 = i__ - j + kuu + 1 + j * a_dim1;
1947 zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1],
1948 &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
1950 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1956 } else if (ipack == 7) {
1960 for (j = 1; j <= i__1; ++j) {
1962 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1963 i__3 = i__ - j + kuu + 1 + j * a_dim1;
1964 zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
1965 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1967 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1969 i__3 = j - i__ + 1 + kuu + (i__ + *n) * a_dim1;
1970 a[i__3].r = 0., a[i__3].i = 0.;
1972 if (i__ >= 1 && i__ != j) {
1974 i__3 = j - i__ + 1 + kuu + i__ * a_dim1;
1975 d_cnjg(&z__1, &a[i__ - j + kuu + 1 + j *
1977 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
1979 i__3 = j - i__ + 1 + kuu + i__ * a_dim1;
1980 i__4 = i__ - j + kuu + 1 + j * a_dim1;
1981 a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
1988 } else if (isym == 1) {
1990 for (j = 1; j <= i__1; ++j) {
1992 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1993 i__3 = i__ - j + kuu + 1 + j * a_dim1;
1994 zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
1995 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1997 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
2008 /* 5) Scaling the norm */
2011 onorm = zlange_("M", m, n, &a[a_offset], lda, tempa);
2012 } else if (ipack == 1) {
2013 onorm = zlansy_("M", "U", n, &a[a_offset], lda, tempa);
2014 } else if (ipack == 2) {
2015 onorm = zlansy_("M", "L", n, &a[a_offset], lda, tempa);
2016 } else if (ipack == 3) {
2017 onorm = zlansp_("M", "U", n, &a[a_offset], tempa);
2018 } else if (ipack == 4) {
2019 onorm = zlansp_("M", "L", n, &a[a_offset], tempa);
2020 } else if (ipack == 5) {
2021 onorm = zlansb_("M", "L", n, &kll, &a[a_offset], lda, tempa);
2022 } else if (ipack == 6) {
2023 onorm = zlansb_("M", "U", n, &kuu, &a[a_offset], lda, tempa);
2024 } else if (ipack == 7) {
2025 onorm = zlangb_("M", n, &kll, &kuu, &a[a_offset], lda, tempa);
2030 if (*anorm > 0. && onorm == 0.) {
2032 /* Desired scaling impossible */
2037 } else if (*anorm > 1. && onorm < 1. || *anorm < 1. && onorm > 1.) {
2039 /* Scale carefully to avoid over / underflow */
2043 for (j = 1; j <= i__1; ++j) {
2045 zdscal_(m, &d__1, &a[j * a_dim1 + 1], &c__1);
2046 zdscal_(m, anorm, &a[j * a_dim1 + 1], &c__1);
2050 } else if (ipack == 3 || ipack == 4) {
2052 i__1 = *n * (*n + 1) / 2;
2054 zdscal_(&i__1, &d__1, &a[a_offset], &c__1);
2055 i__1 = *n * (*n + 1) / 2;
2056 zdscal_(&i__1, anorm, &a[a_offset], &c__1);
2058 } else if (ipack >= 5) {
2061 for (j = 1; j <= i__1; ++j) {
2062 i__2 = kll + kuu + 1;
2064 zdscal_(&i__2, &d__1, &a[j * a_dim1 + 1], &c__1);
2065 i__2 = kll + kuu + 1;
2066 zdscal_(&i__2, anorm, &a[j * a_dim1 + 1], &c__1);
2074 /* Scale straightforwardly */
2078 for (j = 1; j <= i__1; ++j) {
2079 d__1 = *anorm / onorm;
2080 zdscal_(m, &d__1, &a[j * a_dim1 + 1], &c__1);
2084 } else if (ipack == 3 || ipack == 4) {
2086 i__1 = *n * (*n + 1) / 2;
2087 d__1 = *anorm / onorm;
2088 zdscal_(&i__1, &d__1, &a[a_offset], &c__1);
2090 } else if (ipack >= 5) {
2093 for (j = 1; j <= i__1; ++j) {
2094 i__2 = kll + kuu + 1;
2095 d__1 = *anorm / onorm;
2096 zdscal_(&i__2, &d__1, &a[j * a_dim1 + 1], &c__1);