Chris@202: /* iparmq.f -- translated by f2c (version 20061008). Chris@202: You must link the resulting object file with libf2c: Chris@202: on Microsoft Windows system, link with libf2c.lib; Chris@202: on Linux or Unix systems, link with .../path/to/libf2c.a -lm Chris@202: or, if you install libf2c.a in a standard place, with -lf2c -lm Chris@202: -- in that order, at the end of the command line, as in Chris@202: cc *.o -lf2c -lm Chris@202: Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., Chris@202: Chris@202: http://www.netlib.org/f2c/libf2c.zip Chris@202: */ Chris@202: Chris@202: #include "f2c.h" Chris@202: #include "blaswrap.h" Chris@202: Chris@202: integer iparmq_(integer *ispec, char *name__, char *opts, integer *n, integer Chris@202: *ilo, integer *ihi, integer *lwork) Chris@202: { Chris@202: /* System generated locals */ Chris@202: integer ret_val, i__1, i__2; Chris@202: real r__1; Chris@202: Chris@202: /* Builtin functions */ Chris@202: double log(doublereal); Chris@202: integer i_nint(real *); Chris@202: Chris@202: /* Local variables */ Chris@202: integer nh, ns; Chris@202: Chris@202: Chris@202: /* -- LAPACK auxiliary routine (version 3.2) -- */ Chris@202: /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ Chris@202: /* November 2006 */ Chris@202: Chris@202: /* .. Scalar Arguments .. */ Chris@202: Chris@202: /* Purpose */ Chris@202: /* ======= */ Chris@202: Chris@202: /* This program sets problem and machine dependent parameters */ Chris@202: /* useful for xHSEQR and its subroutines. It is called whenever */ Chris@202: /* ILAENV is called with 12 <= ISPEC <= 16 */ Chris@202: Chris@202: /* Arguments */ Chris@202: /* ========= */ Chris@202: Chris@202: /* ISPEC (input) integer scalar */ Chris@202: /* ISPEC specifies which tunable parameter IPARMQ should */ Chris@202: /* return. */ Chris@202: Chris@202: /* ISPEC=12: (INMIN) Matrices of order nmin or less */ Chris@202: /* are sent directly to xLAHQR, the implicit */ Chris@202: /* double shift QR algorithm. NMIN must be */ Chris@202: /* at least 11. */ Chris@202: Chris@202: /* ISPEC=13: (INWIN) Size of the deflation window. */ Chris@202: /* This is best set greater than or equal to */ Chris@202: /* the number of simultaneous shifts NS. */ Chris@202: /* Larger matrices benefit from larger deflation */ Chris@202: /* windows. */ Chris@202: Chris@202: /* ISPEC=14: (INIBL) Determines when to stop nibbling and */ Chris@202: /* invest in an (expensive) multi-shift QR sweep. */ Chris@202: /* If the aggressive early deflation subroutine */ Chris@202: /* finds LD converged eigenvalues from an order */ Chris@202: /* NW deflation window and LD.GT.(NW*NIBBLE)/100, */ Chris@202: /* then the next QR sweep is skipped and early */ Chris@202: /* deflation is applied immediately to the */ Chris@202: /* remaining active diagonal block. Setting */ Chris@202: /* IPARMQ(ISPEC=14) = 0 causes TTQRE to skip a */ Chris@202: /* multi-shift QR sweep whenever early deflation */ Chris@202: /* finds a converged eigenvalue. Setting */ Chris@202: /* IPARMQ(ISPEC=14) greater than or equal to 100 */ Chris@202: /* prevents TTQRE from skipping a multi-shift */ Chris@202: /* QR sweep. */ Chris@202: Chris@202: /* ISPEC=15: (NSHFTS) The number of simultaneous shifts in */ Chris@202: /* a multi-shift QR iteration. */ Chris@202: Chris@202: /* ISPEC=16: (IACC22) IPARMQ is set to 0, 1 or 2 with the */ Chris@202: /* following meanings. */ Chris@202: /* 0: During the multi-shift QR sweep, */ Chris@202: /* xLAQR5 does not accumulate reflections and */ Chris@202: /* does not use matrix-matrix multiply to */ Chris@202: /* update the far-from-diagonal matrix */ Chris@202: /* entries. */ Chris@202: /* 1: During the multi-shift QR sweep, */ Chris@202: /* xLAQR5 and/or xLAQRaccumulates reflections and uses */ Chris@202: /* matrix-matrix multiply to update the */ Chris@202: /* far-from-diagonal matrix entries. */ Chris@202: /* 2: During the multi-shift QR sweep. */ Chris@202: /* xLAQR5 accumulates reflections and takes */ Chris@202: /* advantage of 2-by-2 block structure during */ Chris@202: /* matrix-matrix multiplies. */ Chris@202: /* (If xTRMM is slower than xGEMM, then */ Chris@202: /* IPARMQ(ISPEC=16)=1 may be more efficient than */ Chris@202: /* IPARMQ(ISPEC=16)=2 despite the greater level of */ Chris@202: /* arithmetic work implied by the latter choice.) */ Chris@202: Chris@202: /* NAME (input) character string */ Chris@202: /* Name of the calling subroutine */ Chris@202: Chris@202: /* OPTS (input) character string */ Chris@202: /* This is a concatenation of the string arguments to */ Chris@202: /* TTQRE. */ Chris@202: Chris@202: /* N (input) integer scalar */ Chris@202: /* N is the order of the Hessenberg matrix H. */ Chris@202: Chris@202: /* ILO (input) INTEGER */ Chris@202: /* IHI (input) INTEGER */ Chris@202: /* It is assumed that H is already upper triangular */ Chris@202: /* in rows and columns 1:ILO-1 and IHI+1:N. */ Chris@202: Chris@202: /* LWORK (input) integer scalar */ Chris@202: /* The amount of workspace available. */ Chris@202: Chris@202: /* Further Details */ Chris@202: /* =============== */ Chris@202: Chris@202: /* Little is known about how best to choose these parameters. */ Chris@202: /* It is possible to use different values of the parameters */ Chris@202: /* for each of CHSEQR, DHSEQR, SHSEQR and ZHSEQR. */ Chris@202: Chris@202: /* It is probably best to choose different parameters for */ Chris@202: /* different matrices and different parameters at different */ Chris@202: /* times during the iteration, but this has not been */ Chris@202: /* implemented --- yet. */ Chris@202: Chris@202: Chris@202: /* The best choices of most of the parameters depend */ Chris@202: /* in an ill-understood way on the relative execution */ Chris@202: /* rate of xLAQR3 and xLAQR5 and on the nature of each */ Chris@202: /* particular eigenvalue problem. Experiment may be the */ Chris@202: /* only practical way to determine which choices are most */ Chris@202: /* effective. */ Chris@202: Chris@202: /* Following is a list of default values supplied by IPARMQ. */ Chris@202: /* These defaults may be adjusted in order to attain better */ Chris@202: /* performance in any particular computational environment. */ Chris@202: Chris@202: /* IPARMQ(ISPEC=12) The xLAHQR vs xLAQR0 crossover point. */ Chris@202: /* Default: 75. (Must be at least 11.) */ Chris@202: Chris@202: /* IPARMQ(ISPEC=13) Recommended deflation window size. */ Chris@202: /* This depends on ILO, IHI and NS, the */ Chris@202: /* number of simultaneous shifts returned */ Chris@202: /* by IPARMQ(ISPEC=15). The default for */ Chris@202: /* (IHI-ILO+1).LE.500 is NS. The default */ Chris@202: /* for (IHI-ILO+1).GT.500 is 3*NS/2. */ Chris@202: Chris@202: /* IPARMQ(ISPEC=14) Nibble crossover point. Default: 14. */ Chris@202: Chris@202: /* IPARMQ(ISPEC=15) Number of simultaneous shifts, NS. */ Chris@202: /* a multi-shift QR iteration. */ Chris@202: Chris@202: /* If IHI-ILO+1 is ... */ Chris@202: Chris@202: /* greater than ...but less ... the */ Chris@202: /* or equal to ... than default is */ Chris@202: Chris@202: /* 0 30 NS = 2+ */ Chris@202: /* 30 60 NS = 4+ */ Chris@202: /* 60 150 NS = 10 */ Chris@202: /* 150 590 NS = ** */ Chris@202: /* 590 3000 NS = 64 */ Chris@202: /* 3000 6000 NS = 128 */ Chris@202: /* 6000 infinity NS = 256 */ Chris@202: Chris@202: /* (+) By default matrices of this order are */ Chris@202: /* passed to the implicit double shift routine */ Chris@202: /* xLAHQR. See IPARMQ(ISPEC=12) above. These */ Chris@202: /* values of NS are used only in case of a rare */ Chris@202: /* xLAHQR failure. */ Chris@202: Chris@202: /* (**) The asterisks (**) indicate an ad-hoc */ Chris@202: /* function increasing from 10 to 64. */ Chris@202: Chris@202: /* IPARMQ(ISPEC=16) Select structured matrix multiply. */ Chris@202: /* (See ISPEC=16 above for details.) */ Chris@202: /* Default: 3. */ Chris@202: Chris@202: /* ================================================================ */ Chris@202: /* .. Parameters .. */ Chris@202: /* .. */ Chris@202: /* .. Local Scalars .. */ Chris@202: /* .. */ Chris@202: /* .. Intrinsic Functions .. */ Chris@202: /* .. */ Chris@202: /* .. Executable Statements .. */ Chris@202: if (*ispec == 15 || *ispec == 13 || *ispec == 16) { Chris@202: Chris@202: /* ==== Set the number simultaneous shifts ==== */ Chris@202: Chris@202: nh = *ihi - *ilo + 1; Chris@202: ns = 2; Chris@202: if (nh >= 30) { Chris@202: ns = 4; Chris@202: } Chris@202: if (nh >= 60) { Chris@202: ns = 10; Chris@202: } Chris@202: if (nh >= 150) { Chris@202: /* Computing MAX */ Chris@202: r__1 = log((real) nh) / log(2.f); Chris@202: i__1 = 10, i__2 = nh / i_nint(&r__1); Chris@202: ns = max(i__1,i__2); Chris@202: } Chris@202: if (nh >= 590) { Chris@202: ns = 64; Chris@202: } Chris@202: if (nh >= 3000) { Chris@202: ns = 128; Chris@202: } Chris@202: if (nh >= 6000) { Chris@202: ns = 256; Chris@202: } Chris@202: /* Computing MAX */ Chris@202: i__1 = 2, i__2 = ns - ns % 2; Chris@202: ns = max(i__1,i__2); Chris@202: } Chris@202: Chris@202: if (*ispec == 12) { Chris@202: Chris@202: Chris@202: /* ===== Matrices of order smaller than NMIN get sent */ Chris@202: /* . to xLAHQR, the classic double shift algorithm. */ Chris@202: /* . This must be at least 11. ==== */ Chris@202: Chris@202: ret_val = 75; Chris@202: Chris@202: } else if (*ispec == 14) { Chris@202: Chris@202: /* ==== INIBL: skip a multi-shift qr iteration and */ Chris@202: /* . whenever aggressive early deflation finds */ Chris@202: /* . at least (NIBBLE*(window size)/100) deflations. ==== */ Chris@202: Chris@202: ret_val = 14; Chris@202: Chris@202: } else if (*ispec == 15) { Chris@202: Chris@202: /* ==== NSHFTS: The number of simultaneous shifts ===== */ Chris@202: Chris@202: ret_val = ns; Chris@202: Chris@202: } else if (*ispec == 13) { Chris@202: Chris@202: /* ==== NW: deflation window size. ==== */ Chris@202: Chris@202: if (nh <= 500) { Chris@202: ret_val = ns; Chris@202: } else { Chris@202: ret_val = ns * 3 / 2; Chris@202: } Chris@202: Chris@202: } else if (*ispec == 16) { Chris@202: Chris@202: /* ==== IACC22: Whether to accumulate reflections */ Chris@202: /* . before updating the far-from-diagonal elements */ Chris@202: /* . and whether to use 2-by-2 block structure while */ Chris@202: /* . doing it. A small amount of work could be saved */ Chris@202: /* . by making this choice dependent also upon the */ Chris@202: /* . NH=IHI-ILO+1. */ Chris@202: Chris@202: ret_val = 0; Chris@202: if (ns >= 14) { Chris@202: ret_val = 1; Chris@202: } Chris@202: if (ns >= 14) { Chris@202: ret_val = 2; Chris@202: } Chris@202: Chris@202: } else { Chris@202: /* ===== invalid value of ispec ===== */ Chris@202: ret_val = -1; Chris@202: Chris@202: } Chris@202: Chris@202: /* ==== End of IPARMQ ==== */ Chris@202: Chris@202: return ret_val; Chris@202: } /* iparmq_ */