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__0 = 0;
516 static integer c__1 = 1;
518 /* > \brief \b CLATMR */
520 /* =========== DOCUMENTATION =========== */
522 /* Online html documentation available at */
523 /* http://www.netlib.org/lapack/explore-html/ */
528 /* SUBROUTINE CLATMR( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, */
529 /* RSIGN, GRADE, DL, MODEL, CONDL, DR, MODER, */
530 /* CONDR, PIVTNG, IPIVOT, KL, KU, SPARSE, ANORM, */
531 /* PACK, A, LDA, IWORK, INFO ) */
533 /* CHARACTER DIST, GRADE, PACK, PIVTNG, RSIGN, SYM */
534 /* INTEGER INFO, KL, KU, LDA, M, MODE, MODEL, MODER, N */
535 /* REAL ANORM, COND, CONDL, CONDR, SPARSE */
537 /* INTEGER IPIVOT( * ), ISEED( 4 ), IWORK( * ) */
538 /* COMPLEX A( LDA, * ), D( * ), DL( * ), DR( * ) */
541 /* > \par Purpose: */
546 /* > CLATMR generates random matrices of various types for testing */
547 /* > LAPACK programs. */
549 /* > CLATMR operates by applying the following sequence of */
552 /* > Generate a matrix A with random entries of distribution DIST */
553 /* > which is symmetric if SYM='S', Hermitian if SYM='H', and */
554 /* > nonsymmetric if SYM='N'. */
556 /* > Set the diagonal to D, where D may be input or */
557 /* > computed according to MODE, COND, DMAX and RSIGN */
558 /* > as described below. */
560 /* > Grade the matrix, if desired, from the left and/or right */
561 /* > as specified by GRADE. The inputs DL, MODEL, CONDL, DR, */
562 /* > MODER and CONDR also determine the grading as described */
565 /* > Permute, if desired, the rows and/or columns as specified by */
566 /* > PIVTNG and IPIVOT. */
568 /* > Set random entries to zero, if desired, to get a random sparse */
569 /* > matrix as specified by SPARSE. */
571 /* > Make A a band matrix, if desired, by zeroing out the matrix */
572 /* > outside a band of lower bandwidth KL and upper bandwidth KU. */
574 /* > Scale A, if desired, to have maximum entry ANORM. */
576 /* > Pack the matrix if desired. Options specified by PACK are: */
578 /* > zero out upper half (if symmetric or Hermitian) */
579 /* > zero out lower half (if symmetric or Hermitian) */
580 /* > store the upper half columnwise (if symmetric or Hermitian */
581 /* > or square upper triangular) */
582 /* > store the lower half columnwise (if symmetric or Hermitian */
583 /* > or square lower triangular) */
584 /* > same as upper half rowwise if symmetric */
585 /* > same as conjugate upper half rowwise if Hermitian */
586 /* > store the lower triangle in banded format */
587 /* > (if symmetric or Hermitian) */
588 /* > store the upper triangle in banded format */
589 /* > (if symmetric or Hermitian) */
590 /* > store the entire matrix in banded format */
592 /* > Note: If two calls to CLATMR differ only in the PACK parameter, */
593 /* > they will generate mathematically equivalent matrices. */
595 /* > If two calls to CLATMR both have full bandwidth (KL = M-1 */
596 /* > and KU = N-1), and differ only in the PIVTNG and PACK */
597 /* > parameters, then the matrices generated will differ only */
598 /* > in the order of the rows and/or columns, and otherwise */
599 /* > contain the same data. This consistency cannot be and */
600 /* > is not maintained with less than full bandwidth. */
609 /* > Number of rows of A. Not modified. */
615 /* > Number of columns of A. Not modified. */
618 /* > \param[in] DIST */
620 /* > DIST is CHARACTER*1 */
621 /* > On entry, DIST specifies the type of distribution to be used */
622 /* > to generate a random matrix . */
623 /* > 'U' => real and imaginary parts are independent */
624 /* > UNIFORM( 0, 1 ) ( 'U' for uniform ) */
625 /* > 'S' => real and imaginary parts are independent */
626 /* > UNIFORM( -1, 1 ) ( 'S' for symmetric ) */
627 /* > 'N' => real and imaginary parts are independent */
628 /* > NORMAL( 0, 1 ) ( 'N' for normal ) */
629 /* > 'D' => uniform on interior of unit disk ( 'D' for disk ) */
630 /* > Not modified. */
633 /* > \param[in,out] ISEED */
635 /* > ISEED is INTEGER array, dimension (4) */
636 /* > On entry ISEED specifies the seed of the random number */
637 /* > generator. They should lie between 0 and 4095 inclusive, */
638 /* > and ISEED(4) should be odd. The random number generator */
639 /* > uses a linear congruential sequence limited to small */
640 /* > integers, and so should produce machine independent */
641 /* > random numbers. The values of ISEED are changed on */
642 /* > exit, and can be used in the next call to CLATMR */
643 /* > to continue the same random number sequence. */
644 /* > Changed on exit. */
647 /* > \param[in] SYM */
649 /* > SYM is CHARACTER*1 */
650 /* > If SYM='S', generated matrix is symmetric. */
651 /* > If SYM='H', generated matrix is Hermitian. */
652 /* > If SYM='N', generated matrix is nonsymmetric. */
653 /* > Not modified. */
656 /* > \param[in,out] D */
658 /* > D is COMPLEX array, dimension (f2cmin(M,N)) */
659 /* > On entry this array specifies the diagonal entries */
660 /* > of the diagonal of A. D may either be specified */
661 /* > on entry, or set according to MODE and COND as described */
662 /* > below. If the matrix is Hermitian, the real part of D */
663 /* > will be taken. May be changed on exit if MODE is nonzero. */
666 /* > \param[in] MODE */
668 /* > MODE is INTEGER */
669 /* > On entry describes how D is to be used: */
670 /* > MODE = 0 means use D as input */
671 /* > MODE = 1 sets D(1)=1 and D(2:N)=1.0/COND */
672 /* > MODE = 2 sets D(1:N-1)=1 and D(N)=1.0/COND */
673 /* > MODE = 3 sets D(I)=COND**(-(I-1)/(N-1)) */
674 /* > MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */
675 /* > MODE = 5 sets D to random numbers in the range */
676 /* > ( 1/COND , 1 ) such that their logarithms */
677 /* > are uniformly distributed. */
678 /* > MODE = 6 set D to random numbers from same distribution */
679 /* > as the rest of the matrix. */
680 /* > MODE < 0 has the same meaning as ABS(MODE), except that */
681 /* > the order of the elements of D is reversed. */
682 /* > Thus if MODE is positive, D has entries ranging from */
683 /* > 1 to 1/COND, if negative, from 1/COND to 1, */
684 /* > Not modified. */
687 /* > \param[in] COND */
690 /* > On entry, used as described under MODE above. */
691 /* > If used, it must be >= 1. Not modified. */
694 /* > \param[in] DMAX */
696 /* > DMAX is COMPLEX */
697 /* > If MODE neither -6, 0 nor 6, the diagonal is scaled by */
698 /* > DMAX / f2cmax(abs(D(i))), so that maximum absolute entry */
699 /* > of diagonal is abs(DMAX). If DMAX is complex (or zero), */
700 /* > diagonal will be scaled by a complex number (or zero). */
703 /* > \param[in] RSIGN */
705 /* > RSIGN is CHARACTER*1 */
706 /* > If MODE neither -6, 0 nor 6, specifies sign of diagonal */
708 /* > 'T' => diagonal entries are multiplied by a random complex */
709 /* > number uniformly distributed with absolute value 1 */
710 /* > 'F' => diagonal unchanged */
711 /* > Not modified. */
714 /* > \param[in] GRADE */
716 /* > GRADE is CHARACTER*1 */
717 /* > Specifies grading of matrix as follows: */
718 /* > 'N' => no grading */
719 /* > 'L' => matrix premultiplied by diag( DL ) */
720 /* > (only if matrix nonsymmetric) */
721 /* > 'R' => matrix postmultiplied by diag( DR ) */
722 /* > (only if matrix nonsymmetric) */
723 /* > 'B' => matrix premultiplied by diag( DL ) and */
724 /* > postmultiplied by diag( DR ) */
725 /* > (only if matrix nonsymmetric) */
726 /* > 'H' => matrix premultiplied by diag( DL ) and */
727 /* > postmultiplied by diag( CONJG(DL) ) */
728 /* > (only if matrix Hermitian or nonsymmetric) */
729 /* > 'S' => matrix premultiplied by diag( DL ) and */
730 /* > postmultiplied by diag( DL ) */
731 /* > (only if matrix symmetric or nonsymmetric) */
732 /* > 'E' => matrix premultiplied by diag( DL ) and */
733 /* > postmultiplied by inv( diag( DL ) ) */
734 /* > ( 'S' for similarity ) */
735 /* > (only if matrix nonsymmetric) */
736 /* > Note: if GRADE='S', then M must equal N. */
737 /* > Not modified. */
740 /* > \param[in,out] DL */
742 /* > DL is COMPLEX array, dimension (M) */
743 /* > If MODEL=0, then on entry this array specifies the diagonal */
744 /* > entries of a diagonal matrix used as described under GRADE */
745 /* > above. If MODEL is not zero, then DL will be set according */
746 /* > to MODEL and CONDL, analogous to the way D is set according */
747 /* > to MODE and COND (except there is no DMAX parameter for DL). */
748 /* > If GRADE='E', then DL cannot have zero entries. */
749 /* > Not referenced if GRADE = 'N' or 'R'. Changed on exit. */
752 /* > \param[in] MODEL */
754 /* > MODEL is INTEGER */
755 /* > This specifies how the diagonal array DL is to be computed, */
756 /* > just as MODE specifies how D is to be computed. */
757 /* > Not modified. */
760 /* > \param[in] CONDL */
762 /* > CONDL is REAL */
763 /* > When MODEL is not zero, this specifies the condition number */
764 /* > of the computed DL. Not modified. */
767 /* > \param[in,out] DR */
769 /* > DR is COMPLEX array, dimension (N) */
770 /* > If MODER=0, then on entry this array specifies the diagonal */
771 /* > entries of a diagonal matrix used as described under GRADE */
772 /* > above. If MODER is not zero, then DR will be set according */
773 /* > to MODER and CONDR, analogous to the way D is set according */
774 /* > to MODE and COND (except there is no DMAX parameter for DR). */
775 /* > Not referenced if GRADE = 'N', 'L', 'H' or 'S'. */
776 /* > Changed on exit. */
779 /* > \param[in] MODER */
781 /* > MODER is INTEGER */
782 /* > This specifies how the diagonal array DR is to be computed, */
783 /* > just as MODE specifies how D is to be computed. */
784 /* > Not modified. */
787 /* > \param[in] CONDR */
789 /* > CONDR is REAL */
790 /* > When MODER is not zero, this specifies the condition number */
791 /* > of the computed DR. Not modified. */
794 /* > \param[in] PIVTNG */
796 /* > PIVTNG is CHARACTER*1 */
797 /* > On entry specifies pivoting permutations as follows: */
798 /* > 'N' or ' ' => none. */
799 /* > 'L' => left or row pivoting (matrix must be nonsymmetric). */
800 /* > 'R' => right or column pivoting (matrix must be */
801 /* > nonsymmetric). */
802 /* > 'B' or 'F' => both or full pivoting, i.e., on both sides. */
803 /* > In this case, M must equal N */
805 /* > If two calls to CLATMR both have full bandwidth (KL = M-1 */
806 /* > and KU = N-1), and differ only in the PIVTNG and PACK */
807 /* > parameters, then the matrices generated will differ only */
808 /* > in the order of the rows and/or columns, and otherwise */
809 /* > contain the same data. This consistency cannot be */
810 /* > maintained with less than full bandwidth. */
813 /* > \param[in] IPIVOT */
815 /* > IPIVOT is INTEGER array, dimension (N or M) */
816 /* > This array specifies the permutation used. After the */
817 /* > basic matrix is generated, the rows, columns, or both */
818 /* > are permuted. If, say, row pivoting is selected, CLATMR */
819 /* > starts with the *last* row and interchanges the M-th and */
820 /* > IPIVOT(M)-th rows, then moves to the next-to-last row, */
821 /* > interchanging the (M-1)-th and the IPIVOT(M-1)-th rows, */
822 /* > and so on. In terms of "2-cycles", the permutation is */
823 /* > (1 IPIVOT(1)) (2 IPIVOT(2)) ... (M IPIVOT(M)) */
824 /* > where the rightmost cycle is applied first. This is the */
825 /* > *inverse* of the effect of pivoting in LINPACK. The idea */
826 /* > is that factoring (with pivoting) an identity matrix */
827 /* > which has been inverse-pivoted in this way should */
828 /* > result in a pivot vector identical to IPIVOT. */
829 /* > Not referenced if PIVTNG = 'N'. Not modified. */
832 /* > \param[in] KL */
834 /* > KL is INTEGER */
835 /* > On entry specifies the lower bandwidth of the matrix. For */
836 /* > example, KL=0 implies upper triangular, KL=1 implies upper */
837 /* > Hessenberg, and KL at least M-1 implies the matrix is not */
838 /* > banded. Must equal KU if matrix is symmetric or Hermitian. */
839 /* > Not modified. */
842 /* > \param[in] KU */
844 /* > KU is INTEGER */
845 /* > On entry specifies the upper bandwidth of the matrix. For */
846 /* > example, KU=0 implies lower triangular, KU=1 implies lower */
847 /* > Hessenberg, and KU at least N-1 implies the matrix is not */
848 /* > banded. Must equal KL if matrix is symmetric or Hermitian. */
849 /* > Not modified. */
852 /* > \param[in] SPARSE */
854 /* > SPARSE is REAL */
855 /* > On entry specifies the sparsity of the matrix if a sparse */
856 /* > matrix is to be generated. SPARSE should lie between */
857 /* > 0 and 1. To generate a sparse matrix, for each matrix entry */
858 /* > a uniform ( 0, 1 ) random number x is generated and */
859 /* > compared to SPARSE; if x is larger the matrix entry */
860 /* > is unchanged and if x is smaller the entry is set */
861 /* > to zero. Thus on the average a fraction SPARSE of the */
862 /* > entries will be set to zero. */
863 /* > Not modified. */
866 /* > \param[in] ANORM */
868 /* > ANORM is REAL */
869 /* > On entry specifies maximum entry of output matrix */
870 /* > (output matrix will by multiplied by a constant so that */
871 /* > its largest absolute entry equal ANORM) */
872 /* > if ANORM is nonnegative. If ANORM is negative no scaling */
873 /* > is done. Not modified. */
876 /* > \param[in] PACK */
878 /* > PACK is CHARACTER*1 */
879 /* > On entry specifies packing of matrix as follows: */
880 /* > 'N' => no packing */
881 /* > 'U' => zero out all subdiagonal entries */
882 /* > (if symmetric or Hermitian) */
883 /* > 'L' => zero out all superdiagonal entries */
884 /* > (if symmetric or Hermitian) */
885 /* > 'C' => store the upper triangle columnwise */
886 /* > (only if matrix symmetric or Hermitian or */
887 /* > square upper triangular) */
888 /* > 'R' => store the lower triangle columnwise */
889 /* > (only if matrix symmetric or Hermitian or */
890 /* > square lower triangular) */
891 /* > (same as upper half rowwise if symmetric) */
892 /* > (same as conjugate upper half rowwise if Hermitian) */
893 /* > 'B' => store the lower triangle in band storage scheme */
894 /* > (only if matrix symmetric or Hermitian) */
895 /* > 'Q' => store the upper triangle in band storage scheme */
896 /* > (only if matrix symmetric or Hermitian) */
897 /* > 'Z' => store the entire matrix in band storage scheme */
898 /* > (pivoting can be provided for by using this */
899 /* > option to store A in the trailing rows of */
900 /* > the allocated storage) */
902 /* > Using these options, the various LAPACK packed and banded */
903 /* > storage schemes can be obtained: */
905 /* > PB, HB or TB - use 'B' or 'Q' */
906 /* > PP, HP or TP - use 'C' or 'R' */
908 /* > If two calls to CLATMR differ only in the PACK parameter, */
909 /* > they will generate mathematically equivalent matrices. */
910 /* > Not modified. */
913 /* > \param[in,out] A */
915 /* > A is COMPLEX array, dimension (LDA,N) */
916 /* > On exit A is the desired test matrix. Only those */
917 /* > entries of A which are significant on output */
918 /* > will be referenced (even if A is in packed or band */
919 /* > storage format). The 'unoccupied corners' of A in */
920 /* > band format will be zeroed out. */
923 /* > \param[in] LDA */
925 /* > LDA is INTEGER */
926 /* > on entry LDA specifies the first dimension of A as */
927 /* > declared in the calling program. */
928 /* > If PACK='N', 'U' or 'L', LDA must be at least f2cmax ( 1, M ). */
929 /* > If PACK='C' or 'R', LDA must be at least 1. */
930 /* > If PACK='B', or 'Q', LDA must be MIN ( KU+1, N ) */
931 /* > If PACK='Z', LDA must be at least KUU+KLL+1, where */
932 /* > KUU = MIN ( KU, N-1 ) and KLL = MIN ( KL, M-1 ) */
933 /* > Not modified. */
936 /* > \param[out] IWORK */
938 /* > IWORK is INTEGER array, dimension (N or M) */
939 /* > Workspace. Not referenced if PIVTNG = 'N'. Changed on exit. */
942 /* > \param[out] INFO */
944 /* > INFO is INTEGER */
945 /* > Error parameter on exit: */
946 /* > 0 => normal return */
947 /* > -1 => M negative or unequal to N and SYM='S' or 'H' */
948 /* > -2 => N negative */
949 /* > -3 => DIST illegal string */
950 /* > -5 => SYM illegal string */
951 /* > -7 => MODE not in range -6 to 6 */
952 /* > -8 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
953 /* > -10 => MODE neither -6, 0 nor 6 and RSIGN illegal string */
954 /* > -11 => GRADE illegal string, or GRADE='E' and */
955 /* > M not equal to N, or GRADE='L', 'R', 'B', 'S' or 'E' */
956 /* > and SYM = 'H', or GRADE='L', 'R', 'B', 'H' or 'E' */
957 /* > and SYM = 'S' */
958 /* > -12 => GRADE = 'E' and DL contains zero */
959 /* > -13 => MODEL not in range -6 to 6 and GRADE= 'L', 'B', 'H', */
961 /* > -14 => CONDL less than 1.0, GRADE='L', 'B', 'H', 'S' or 'E', */
962 /* > and MODEL neither -6, 0 nor 6 */
963 /* > -16 => MODER not in range -6 to 6 and GRADE= 'R' or 'B' */
964 /* > -17 => CONDR less than 1.0, GRADE='R' or 'B', and */
965 /* > MODER neither -6, 0 nor 6 */
966 /* > -18 => PIVTNG illegal string, or PIVTNG='B' or 'F' and */
967 /* > M not equal to N, or PIVTNG='L' or 'R' and SYM='S' */
969 /* > -19 => IPIVOT contains out of range number and */
970 /* > PIVTNG not equal to 'N' */
971 /* > -20 => KL negative */
972 /* > -21 => KU negative, or SYM='S' or 'H' and KU not equal to KL */
973 /* > -22 => SPARSE not in range 0. to 1. */
974 /* > -24 => PACK illegal string, or PACK='U', 'L', 'B' or 'Q' */
975 /* > and SYM='N', or PACK='C' and SYM='N' and either KL */
976 /* > not equal to 0 or N not equal to M, or PACK='R' and */
977 /* > SYM='N', and either KU not equal to 0 or N not equal */
979 /* > -26 => LDA too small */
980 /* > 1 => Error return from CLATM1 (computing D) */
981 /* > 2 => Cannot scale diagonal to DMAX (f2cmax. entry is 0) */
982 /* > 3 => Error return from CLATM1 (computing DL) */
983 /* > 4 => Error return from CLATM1 (computing DR) */
984 /* > 5 => ANORM is positive, but matrix constructed prior to */
985 /* > attempting to scale it to have norm ANORM, is zero */
991 /* > \author Univ. of Tennessee */
992 /* > \author Univ. of California Berkeley */
993 /* > \author Univ. of Colorado Denver */
994 /* > \author NAG Ltd. */
996 /* > \date December 2016 */
998 /* > \ingroup complex_matgen */
1000 /* ===================================================================== */
1001 /* Subroutine */ int clatmr_(integer *m, integer *n, char *dist, integer *
1002 iseed, char *sym, complex *d__, integer *mode, real *cond, complex *
1003 dmax__, char *rsign, char *grade, complex *dl, integer *model, real *
1004 condl, complex *dr, integer *moder, real *condr, char *pivtng,
1005 integer *ipivot, integer *kl, integer *ku, real *sparse, real *anorm,
1006 char *pack, complex *a, integer *lda, integer *iwork, integer *info)
1008 /* System generated locals */
1009 integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
1013 /* Local variables */
1016 integer isym, i__, j, k, ipack;
1017 extern logical lsame_(char *, char *);
1020 integer iisub, idist, jjsub, mnmin;
1024 integer mxsub, npvts;
1025 extern /* Subroutine */ int clatm1_(integer *, real *, integer *, integer
1026 *, integer *, complex *, integer *, integer *);
1027 extern /* Complex */ VOID clatm2_(complex *, integer *, integer *,
1028 integer *, integer *, integer *, integer *, integer *, integer *,
1029 complex *, integer *, complex *, complex *, integer *, integer *,
1030 real *), clatm3_(complex *, integer *, integer *, integer *,
1031 integer *, integer *, integer *, integer *, integer *, integer *,
1032 integer *, complex *, integer *, complex *, complex *, integer *,
1035 extern real clangb_(char *, integer *, integer *, integer *, complex *,
1036 integer *, real *), clange_(char *, integer *, integer *,
1037 complex *, integer *, real *);
1039 extern real clansb_(char *, char *, integer *, integer *, complex *,
1041 extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer
1044 extern /* Subroutine */ int xerbla_(char *, integer *);
1046 extern real clansp_(char *, char *, integer *, complex *, real *), clansy_(char *, char *, integer *, complex *, integer *,
1048 integer irsign, ipvtng, kll, kuu;
1051 /* -- LAPACK computational routine (version 3.7.0) -- */
1052 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
1053 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
1057 /* ===================================================================== */
1060 /* 1) Decode and Test the input parameters. */
1061 /* Initialize flags & seed. */
1063 /* Parameter adjustments */
1070 a_offset = 1 + a_dim1 * 1;
1077 /* Quick return if possible */
1079 if (*m == 0 || *n == 0) {
1085 if (lsame_(dist, "U")) {
1087 } else if (lsame_(dist, "S")) {
1089 } else if (lsame_(dist, "N")) {
1091 } else if (lsame_(dist, "D")) {
1099 if (lsame_(sym, "H")) {
1101 } else if (lsame_(sym, "N")) {
1103 } else if (lsame_(sym, "S")) {
1111 if (lsame_(rsign, "F")) {
1113 } else if (lsame_(rsign, "T")) {
1121 if (lsame_(pivtng, "N")) {
1123 } else if (lsame_(pivtng, " ")) {
1125 } else if (lsame_(pivtng, "L")) {
1128 } else if (lsame_(pivtng, "R")) {
1131 } else if (lsame_(pivtng, "B")) {
1133 npvts = f2cmin(*n,*m);
1134 } else if (lsame_(pivtng, "F")) {
1136 npvts = f2cmin(*n,*m);
1143 if (lsame_(grade, "N")) {
1145 } else if (lsame_(grade, "L")) {
1147 } else if (lsame_(grade, "R")) {
1149 } else if (lsame_(grade, "B")) {
1151 } else if (lsame_(grade, "E")) {
1153 } else if (lsame_(grade, "H")) {
1155 } else if (lsame_(grade, "S")) {
1163 if (lsame_(pack, "N")) {
1165 } else if (lsame_(pack, "U")) {
1167 } else if (lsame_(pack, "L")) {
1169 } else if (lsame_(pack, "C")) {
1171 } else if (lsame_(pack, "R")) {
1173 } else if (lsame_(pack, "B")) {
1175 } else if (lsame_(pack, "Q")) {
1177 } else if (lsame_(pack, "Z")) {
1183 /* Set certain internal parameters */
1185 mnmin = f2cmin(*m,*n);
1187 i__1 = *kl, i__2 = *m - 1;
1188 kll = f2cmin(i__1,i__2);
1190 i__1 = *ku, i__2 = *n - 1;
1191 kuu = f2cmin(i__1,i__2);
1193 /* If inv(DL) is used, check to see if DL has a zero entry. */
1196 if (igrade == 4 && *model == 0) {
1198 for (i__ = 1; i__ <= i__1; ++i__) {
1200 if (dl[i__2].r == 0.f && dl[i__2].i == 0.f) {
1207 /* Check values in IPIVOT */
1212 for (j = 1; j <= i__1; ++j) {
1213 if (ipivot[j] <= 0 || ipivot[j] > npvts) {
1220 /* Set INFO if an error */
1224 } else if (*m != *n && (isym == 0 || isym == 2)) {
1226 } else if (*n < 0) {
1228 } else if (idist == -1) {
1230 } else if (isym == -1) {
1232 } else if (*mode < -6 || *mode > 6) {
1234 } else if (*mode != -6 && *mode != 0 && *mode != 6 && *cond < 1.f) {
1236 } else if (*mode != -6 && *mode != 0 && *mode != 6 && irsign == -1) {
1238 } else if (igrade == -1 || igrade == 4 && *m != *n || (igrade == 1 ||
1239 igrade == 2 || igrade == 3 || igrade == 4 || igrade == 6) && isym
1240 == 0 || (igrade == 1 || igrade == 2 || igrade == 3 || igrade == 4
1241 || igrade == 5) && isym == 2) {
1243 } else if (igrade == 4 && dzero) {
1245 } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 ||
1246 igrade == 6) && (*model < -6 || *model > 6)) {
1248 } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 ||
1249 igrade == 6) && (*model != -6 && *model != 0 && *model != 6) && *
1252 } else if ((igrade == 2 || igrade == 3) && (*moder < -6 || *moder > 6)) {
1254 } else if ((igrade == 2 || igrade == 3) && (*moder != -6 && *moder != 0 &&
1255 *moder != 6) && *condr < 1.f) {
1257 } else if (ipvtng == -1 || ipvtng == 3 && *m != *n || (ipvtng == 1 ||
1258 ipvtng == 2) && (isym == 0 || isym == 2)) {
1260 } else if (ipvtng != 0 && badpvt) {
1262 } else if (*kl < 0) {
1264 } else if (*ku < 0 || (isym == 0 || isym == 2) && *kl != *ku) {
1266 } else if (*sparse < 0.f || *sparse > 1.f) {
1268 } else if (ipack == -1 || (ipack == 1 || ipack == 2 || ipack == 5 ||
1269 ipack == 6) && isym == 1 || ipack == 3 && isym == 1 && (*kl != 0
1270 || *m != *n) || ipack == 4 && isym == 1 && (*ku != 0 || *m != *n))
1273 } else if ((ipack == 0 || ipack == 1 || ipack == 2) && *lda < f2cmax(1,*m) ||
1274 (ipack == 3 || ipack == 4) && *lda < 1 || (ipack == 5 || ipack ==
1275 6) && *lda < kuu + 1 || ipack == 7 && *lda < kll + kuu + 1) {
1281 xerbla_("CLATMR", &i__1);
1285 /* Decide if we can pivot consistently */
1288 if (kuu == *n - 1 && kll == *m - 1) {
1292 /* Initialize random number generator */
1294 for (i__ = 1; i__ <= 4; ++i__) {
1295 iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
1299 iseed[4] = (iseed[4] / 2 << 1) + 1;
1301 /* 2) Set up D, DL, and DR, if indicated. */
1303 /* Compute D according to COND and MODE */
1305 clatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, info);
1310 if (*mode != 0 && *mode != -6 && *mode != 6) {
1314 temp = c_abs(&d__[1]);
1316 for (i__ = 2; i__ <= i__1; ++i__) {
1318 r__1 = temp, r__2 = c_abs(&d__[i__]);
1319 temp = f2cmax(r__1,r__2);
1322 if (temp == 0.f && (dmax__->r != 0.f || dmax__->i != 0.f)) {
1327 q__1.r = dmax__->r / temp, q__1.i = dmax__->i / temp;
1328 calpha.r = q__1.r, calpha.i = q__1.i;
1330 calpha.r = 1.f, calpha.i = 0.f;
1333 for (i__ = 1; i__ <= i__1; ++i__) {
1336 q__1.r = calpha.r * d__[i__3].r - calpha.i * d__[i__3].i, q__1.i =
1337 calpha.r * d__[i__3].i + calpha.i * d__[i__3].r;
1338 d__[i__2].r = q__1.r, d__[i__2].i = q__1.i;
1344 /* If matrix Hermitian, make D real */
1348 for (i__ = 1; i__ <= i__1; ++i__) {
1352 d__[i__2].r = r__1, d__[i__2].i = 0.f;
1357 /* Compute DL if grading set */
1359 if (igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 || igrade ==
1361 clatm1_(model, condl, &c__0, &idist, &iseed[1], &dl[1], m, info);
1368 /* Compute DR if grading set */
1370 if (igrade == 2 || igrade == 3) {
1371 clatm1_(moder, condr, &c__0, &idist, &iseed[1], &dr[1], n, info);
1378 /* 3) Generate IWORK if pivoting */
1382 for (i__ = 1; i__ <= i__1; ++i__) {
1388 for (i__ = 1; i__ <= i__1; ++i__) {
1391 iwork[i__] = iwork[k];
1396 for (i__ = npvts; i__ >= 1; --i__) {
1399 iwork[i__] = iwork[k];
1406 /* 4) Generate matrices for each kind of PACKing */
1407 /* Always sweep matrix columnwise (if symmetric, upper */
1408 /* half only) so that matrix generated does not depend */
1413 /* Use CLATM3 so matrices generated with differing PIVOTing only */
1414 /* differ only in the order of their rows and/or columns. */
1419 for (j = 1; j <= i__1; ++j) {
1421 for (i__ = 1; i__ <= i__2; ++i__) {
1422 clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1423 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1424 dr[1], &ipvtng, &iwork[1], sparse);
1425 ctemp.r = q__1.r, ctemp.i = q__1.i;
1426 i__3 = isub + jsub * a_dim1;
1427 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1428 i__3 = jsub + isub * a_dim1;
1429 r_cnjg(&q__1, &ctemp);
1430 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1435 } else if (isym == 1) {
1437 for (j = 1; j <= i__1; ++j) {
1439 for (i__ = 1; i__ <= i__2; ++i__) {
1440 clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1441 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1442 dr[1], &ipvtng, &iwork[1], sparse);
1443 ctemp.r = q__1.r, ctemp.i = q__1.i;
1444 i__3 = isub + jsub * a_dim1;
1445 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1450 } else if (isym == 2) {
1452 for (j = 1; j <= i__1; ++j) {
1454 for (i__ = 1; i__ <= i__2; ++i__) {
1455 clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1456 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1457 dr[1], &ipvtng, &iwork[1], sparse);
1458 ctemp.r = q__1.r, ctemp.i = q__1.i;
1459 i__3 = isub + jsub * a_dim1;
1460 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1461 i__3 = jsub + isub * a_dim1;
1462 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1469 } else if (ipack == 1) {
1472 for (j = 1; j <= i__1; ++j) {
1474 for (i__ = 1; i__ <= i__2; ++i__) {
1475 clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1476 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1477 , &ipvtng, &iwork[1], sparse);
1478 ctemp.r = q__1.r, ctemp.i = q__1.i;
1479 mnsub = f2cmin(isub,jsub);
1480 mxsub = f2cmax(isub,jsub);
1481 if (mxsub == isub && isym == 0) {
1482 i__3 = mnsub + mxsub * a_dim1;
1483 r_cnjg(&q__1, &ctemp);
1484 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1486 i__3 = mnsub + mxsub * a_dim1;
1487 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1489 if (mnsub != mxsub) {
1490 i__3 = mxsub + mnsub * a_dim1;
1491 a[i__3].r = 0.f, a[i__3].i = 0.f;
1498 } else if (ipack == 2) {
1501 for (j = 1; j <= i__1; ++j) {
1503 for (i__ = 1; i__ <= i__2; ++i__) {
1504 clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1505 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1506 , &ipvtng, &iwork[1], sparse);
1507 ctemp.r = q__1.r, ctemp.i = q__1.i;
1508 mnsub = f2cmin(isub,jsub);
1509 mxsub = f2cmax(isub,jsub);
1510 if (mxsub == jsub && isym == 0) {
1511 i__3 = mxsub + mnsub * a_dim1;
1512 r_cnjg(&q__1, &ctemp);
1513 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1515 i__3 = mxsub + mnsub * a_dim1;
1516 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1518 if (mnsub != mxsub) {
1519 i__3 = mnsub + mxsub * a_dim1;
1520 a[i__3].r = 0.f, a[i__3].i = 0.f;
1527 } else if (ipack == 3) {
1530 for (j = 1; j <= i__1; ++j) {
1532 for (i__ = 1; i__ <= i__2; ++i__) {
1533 clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1534 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1535 , &ipvtng, &iwork[1], sparse);
1536 ctemp.r = q__1.r, ctemp.i = q__1.i;
1538 /* Compute K = location of (ISUB,JSUB) entry in packed */
1541 mnsub = f2cmin(isub,jsub);
1542 mxsub = f2cmax(isub,jsub);
1543 k = mxsub * (mxsub - 1) / 2 + mnsub;
1545 /* Convert K to (IISUB,JJSUB) location */
1547 jjsub = (k - 1) / *lda + 1;
1548 iisub = k - *lda * (jjsub - 1);
1550 if (mxsub == isub && isym == 0) {
1551 i__3 = iisub + jjsub * a_dim1;
1552 r_cnjg(&q__1, &ctemp);
1553 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1555 i__3 = iisub + jjsub * a_dim1;
1556 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1563 } else if (ipack == 4) {
1566 for (j = 1; j <= i__1; ++j) {
1568 for (i__ = 1; i__ <= i__2; ++i__) {
1569 clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1570 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1571 , &ipvtng, &iwork[1], sparse);
1572 ctemp.r = q__1.r, ctemp.i = q__1.i;
1574 /* Compute K = location of (I,J) entry in packed array */
1576 mnsub = f2cmin(isub,jsub);
1577 mxsub = f2cmax(isub,jsub);
1581 k = *n * (*n + 1) / 2 - (*n - mnsub + 1) * (*n -
1582 mnsub + 2) / 2 + mxsub - mnsub + 1;
1585 /* Convert K to (IISUB,JJSUB) location */
1587 jjsub = (k - 1) / *lda + 1;
1588 iisub = k - *lda * (jjsub - 1);
1590 if (mxsub == jsub && isym == 0) {
1591 i__3 = iisub + jjsub * a_dim1;
1592 r_cnjg(&q__1, &ctemp);
1593 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1595 i__3 = iisub + jjsub * a_dim1;
1596 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1603 } else if (ipack == 5) {
1606 for (j = 1; j <= i__1; ++j) {
1608 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1610 i__3 = j - i__ + 1 + (i__ + *n) * a_dim1;
1611 a[i__3].r = 0.f, a[i__3].i = 0.f;
1613 clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1614 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1615 dr[1], &ipvtng, &iwork[1], sparse);
1616 ctemp.r = q__1.r, ctemp.i = q__1.i;
1617 mnsub = f2cmin(isub,jsub);
1618 mxsub = f2cmax(isub,jsub);
1619 if (mxsub == jsub && isym == 0) {
1620 i__3 = mxsub - mnsub + 1 + mnsub * a_dim1;
1621 r_cnjg(&q__1, &ctemp);
1622 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1624 i__3 = mxsub - mnsub + 1 + mnsub * a_dim1;
1625 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1633 } else if (ipack == 6) {
1636 for (j = 1; j <= i__1; ++j) {
1638 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1639 clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1640 idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1641 , &ipvtng, &iwork[1], sparse);
1642 ctemp.r = q__1.r, ctemp.i = q__1.i;
1643 mnsub = f2cmin(isub,jsub);
1644 mxsub = f2cmax(isub,jsub);
1645 if (mxsub == isub && isym == 0) {
1646 i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
1647 r_cnjg(&q__1, &ctemp);
1648 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1650 i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
1651 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1658 } else if (ipack == 7) {
1662 for (j = 1; j <= i__1; ++j) {
1664 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1665 clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1666 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1667 dr[1], &ipvtng, &iwork[1], sparse);
1668 ctemp.r = q__1.r, ctemp.i = q__1.i;
1669 mnsub = f2cmin(isub,jsub);
1670 mxsub = f2cmax(isub,jsub);
1672 i__3 = j - i__ + 1 + kuu + (i__ + *n) * a_dim1;
1673 a[i__3].r = 0.f, a[i__3].i = 0.f;
1675 if (mxsub == isub && isym == 0) {
1676 i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
1677 r_cnjg(&q__1, &ctemp);
1678 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1680 i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
1681 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1683 if (i__ >= 1 && mnsub != mxsub) {
1684 if (mnsub == isub && isym == 0) {
1685 i__3 = mxsub - mnsub + 1 + kuu + mnsub *
1687 r_cnjg(&q__1, &ctemp);
1688 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1690 i__3 = mxsub - mnsub + 1 + kuu + mnsub *
1692 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1699 } else if (isym == 1) {
1701 for (j = 1; j <= i__1; ++j) {
1703 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1704 clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
1705 idist, &iseed[1], &d__[1], &igrade, &dl[1], &
1706 dr[1], &ipvtng, &iwork[1], sparse);
1707 ctemp.r = q__1.r, ctemp.i = q__1.i;
1708 i__3 = isub - jsub + kuu + 1 + jsub * a_dim1;
1709 a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
1725 for (j = 1; j <= i__1; ++j) {
1727 for (i__ = 1; i__ <= i__2; ++i__) {
1728 i__3 = i__ + j * a_dim1;
1729 clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
1730 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1732 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1733 i__3 = j + i__ * a_dim1;
1734 r_cnjg(&q__1, &a[i__ + j * a_dim1]);
1735 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1740 } else if (isym == 1) {
1742 for (j = 1; j <= i__1; ++j) {
1744 for (i__ = 1; i__ <= i__2; ++i__) {
1745 i__3 = i__ + j * a_dim1;
1746 clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
1747 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1749 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1754 } else if (isym == 2) {
1756 for (j = 1; j <= i__1; ++j) {
1758 for (i__ = 1; i__ <= i__2; ++i__) {
1759 i__3 = i__ + j * a_dim1;
1760 clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
1761 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1763 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1764 i__3 = j + i__ * a_dim1;
1765 i__4 = i__ + j * a_dim1;
1766 a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
1773 } else if (ipack == 1) {
1776 for (j = 1; j <= i__1; ++j) {
1778 for (i__ = 1; i__ <= i__2; ++i__) {
1779 i__3 = i__ + j * a_dim1;
1780 clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1],
1781 &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
1783 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1785 i__3 = j + i__ * a_dim1;
1786 a[i__3].r = 0.f, a[i__3].i = 0.f;
1793 } else if (ipack == 2) {
1796 for (j = 1; j <= i__1; ++j) {
1798 for (i__ = 1; i__ <= i__2; ++i__) {
1800 i__3 = j + i__ * a_dim1;
1801 clatm2_(&q__2, m, n, &i__, &j, kl, ku, &idist, &iseed[
1802 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1804 r_cnjg(&q__1, &q__2);
1805 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1807 i__3 = j + i__ * a_dim1;
1808 clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
1809 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1811 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1814 i__3 = i__ + j * a_dim1;
1815 a[i__3].r = 0.f, a[i__3].i = 0.f;
1822 } else if (ipack == 3) {
1827 for (j = 1; j <= i__1; ++j) {
1829 for (i__ = 1; i__ <= i__2; ++i__) {
1835 i__3 = isub + jsub * a_dim1;
1836 clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1],
1837 &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
1839 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1845 } else if (ipack == 4) {
1847 if (isym == 0 || isym == 2) {
1849 for (j = 1; j <= i__1; ++j) {
1851 for (i__ = 1; i__ <= i__2; ++i__) {
1853 /* Compute K = location of (I,J) entry in packed array */
1858 k = *n * (*n + 1) / 2 - (*n - i__ + 1) * (*n -
1859 i__ + 2) / 2 + j - i__ + 1;
1862 /* Convert K to (ISUB,JSUB) location */
1864 jsub = (k - 1) / *lda + 1;
1865 isub = k - *lda * (jsub - 1);
1867 i__3 = isub + jsub * a_dim1;
1868 clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
1869 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1871 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1873 i__3 = isub + jsub * a_dim1;
1874 r_cnjg(&q__1, &a[isub + jsub * a_dim1]);
1875 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1885 for (j = 1; j <= i__1; ++j) {
1887 for (i__ = j; i__ <= i__2; ++i__) {
1893 i__3 = isub + jsub * a_dim1;
1894 clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
1895 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1897 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1904 } else if (ipack == 5) {
1907 for (j = 1; j <= i__1; ++j) {
1909 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1911 i__3 = j - i__ + 1 + (i__ + *n) * a_dim1;
1912 a[i__3].r = 0.f, a[i__3].i = 0.f;
1915 i__3 = j - i__ + 1 + i__ * a_dim1;
1916 clatm2_(&q__2, m, n, &i__, &j, kl, ku, &idist, &
1917 iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1918 , &ipvtng, &iwork[1], sparse);
1919 r_cnjg(&q__1, &q__2);
1920 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1922 i__3 = j - i__ + 1 + i__ * a_dim1;
1923 clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &
1924 iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
1925 , &ipvtng, &iwork[1], sparse);
1926 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1934 } else if (ipack == 6) {
1937 for (j = 1; j <= i__1; ++j) {
1939 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1940 i__3 = i__ - j + kuu + 1 + j * a_dim1;
1941 clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1],
1942 &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
1944 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1950 } else if (ipack == 7) {
1954 for (j = 1; j <= i__1; ++j) {
1956 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1957 i__3 = i__ - j + kuu + 1 + j * a_dim1;
1958 clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
1959 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1961 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1963 i__3 = j - i__ + 1 + kuu + (i__ + *n) * a_dim1;
1964 a[i__3].r = 0.f, a[i__3].i = 0.f;
1966 if (i__ >= 1 && i__ != j) {
1968 i__3 = j - i__ + 1 + kuu + i__ * a_dim1;
1969 r_cnjg(&q__1, &a[i__ - j + kuu + 1 + j *
1971 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1973 i__3 = j - i__ + 1 + kuu + i__ * a_dim1;
1974 i__4 = i__ - j + kuu + 1 + j * a_dim1;
1975 a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
1982 } else if (isym == 1) {
1984 for (j = 1; j <= i__1; ++j) {
1986 for (i__ = j - kuu; i__ <= i__2; ++i__) {
1987 i__3 = i__ - j + kuu + 1 + j * a_dim1;
1988 clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
1989 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
1991 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
2002 /* 5) Scaling the norm */
2005 onorm = clange_("M", m, n, &a[a_offset], lda, tempa);
2006 } else if (ipack == 1) {
2007 onorm = clansy_("M", "U", n, &a[a_offset], lda, tempa);
2008 } else if (ipack == 2) {
2009 onorm = clansy_("M", "L", n, &a[a_offset], lda, tempa);
2010 } else if (ipack == 3) {
2011 onorm = clansp_("M", "U", n, &a[a_offset], tempa);
2012 } else if (ipack == 4) {
2013 onorm = clansp_("M", "L", n, &a[a_offset], tempa);
2014 } else if (ipack == 5) {
2015 onorm = clansb_("M", "L", n, &kll, &a[a_offset], lda, tempa);
2016 } else if (ipack == 6) {
2017 onorm = clansb_("M", "U", n, &kuu, &a[a_offset], lda, tempa);
2018 } else if (ipack == 7) {
2019 onorm = clangb_("M", n, &kll, &kuu, &a[a_offset], lda, tempa);
2022 if (*anorm >= 0.f) {
2024 if (*anorm > 0.f && onorm == 0.f) {
2026 /* Desired scaling impossible */
2031 } else if (*anorm > 1.f && onorm < 1.f || *anorm < 1.f && onorm > 1.f)
2034 /* Scale carefully to avoid over / underflow */
2038 for (j = 1; j <= i__1; ++j) {
2040 csscal_(m, &r__1, &a[j * a_dim1 + 1], &c__1);
2041 csscal_(m, anorm, &a[j * a_dim1 + 1], &c__1);
2045 } else if (ipack == 3 || ipack == 4) {
2047 i__1 = *n * (*n + 1) / 2;
2049 csscal_(&i__1, &r__1, &a[a_offset], &c__1);
2050 i__1 = *n * (*n + 1) / 2;
2051 csscal_(&i__1, anorm, &a[a_offset], &c__1);
2053 } else if (ipack >= 5) {
2056 for (j = 1; j <= i__1; ++j) {
2057 i__2 = kll + kuu + 1;
2059 csscal_(&i__2, &r__1, &a[j * a_dim1 + 1], &c__1);
2060 i__2 = kll + kuu + 1;
2061 csscal_(&i__2, anorm, &a[j * a_dim1 + 1], &c__1);
2069 /* Scale straightforwardly */
2073 for (j = 1; j <= i__1; ++j) {
2074 r__1 = *anorm / onorm;
2075 csscal_(m, &r__1, &a[j * a_dim1 + 1], &c__1);
2079 } else if (ipack == 3 || ipack == 4) {
2081 i__1 = *n * (*n + 1) / 2;
2082 r__1 = *anorm / onorm;
2083 csscal_(&i__1, &r__1, &a[a_offset], &c__1);
2085 } else if (ipack >= 5) {
2088 for (j = 1; j <= i__1; ++j) {
2089 i__2 = kll + kuu + 1;
2090 r__1 = *anorm / onorm;
2091 csscal_(&i__2, &r__1, &a[j * a_dim1 + 1], &c__1);