Update to 2.0.0 tree from current Fremantle build
[opencv] / 3rdparty / lapack / iparmq.c
1 #include "clapack.h"
2
3 integer iparmq_(integer *ispec, char *name__, char *opts, integer *n, integer 
4         *ilo, integer *ihi, integer *lwork)
5 {
6     /* System generated locals */
7     integer ret_val, i__1, i__2;
8     real r__1;
9
10     /* Builtin functions */
11     double log(doublereal);
12     integer i_nint(real *);
13
14     /* Local variables */
15     integer nh, ns;
16
17
18 /*  -- LAPACK auxiliary routine (version 3.1) -- */
19 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
20 /*     November 2006 */
21
22 /*     .. Scalar Arguments .. */
23
24 /*  Purpose */
25 /*  ======= */
26
27 /*       This program sets problem and machine dependent parameters */
28 /*       useful for xHSEQR and its subroutines. It is called whenever */
29 /*       ILAENV is called with 12 <= ISPEC <= 16 */
30
31 /*  Arguments */
32 /*  ========= */
33
34 /*       ISPEC  (input) integer scalar */
35 /*              ISPEC specifies which tunable parameter IPARMQ should */
36 /*              return. */
37
38 /*              ISPEC=12: (INMIN)  Matrices of order nmin or less */
39 /*                        are sent directly to xLAHQR, the implicit */
40 /*                        double shift QR algorithm.  NMIN must be */
41 /*                        at least 11. */
42
43 /*              ISPEC=13: (INWIN)  Size of the deflation window. */
44 /*                        This is best set greater than or equal to */
45 /*                        the number of simultaneous shifts NS. */
46 /*                        Larger matrices benefit from larger deflation */
47 /*                        windows. */
48
49 /*              ISPEC=14: (INIBL) Determines when to stop nibbling and */
50 /*                        invest in an (expensive) multi-shift QR sweep. */
51 /*                        If the aggressive early deflation subroutine */
52 /*                        finds LD converged eigenvalues from an order */
53 /*                        NW deflation window and LD.GT.(NW*NIBBLE)/100, */
54 /*                        then the next QR sweep is skipped and early */
55 /*                        deflation is applied immediately to the */
56 /*                        remaining active diagonal block.  Setting */
57 /*                        IPARMQ(ISPEC=14) = 0 causes TTQRE to skip a */
58 /*                        multi-shift QR sweep whenever early deflation */
59 /*                        finds a converged eigenvalue.  Setting */
60 /*                        IPARMQ(ISPEC=14) greater than or equal to 100 */
61 /*                        prevents TTQRE from skipping a multi-shift */
62 /*                        QR sweep. */
63
64 /*              ISPEC=15: (NSHFTS) The number of simultaneous shifts in */
65 /*                        a multi-shift QR iteration. */
66
67 /*              ISPEC=16: (IACC22) IPARMQ is set to 0, 1 or 2 with the */
68 /*                        following meanings. */
69 /*                        0:  During the multi-shift QR sweep, */
70 /*                            xLAQR5 does not accumulate reflections and */
71 /*                            does not use matrix-matrix multiply to */
72 /*                            update the far-from-diagonal matrix */
73 /*                            entries. */
74 /*                        1:  During the multi-shift QR sweep, */
75 /*                            xLAQR5 and/or xLAQRaccumulates reflections and uses */
76 /*                            matrix-matrix multiply to update the */
77 /*                            far-from-diagonal matrix entries. */
78 /*                        2:  During the multi-shift QR sweep. */
79 /*                            xLAQR5 accumulates reflections and takes */
80 /*                            advantage of 2-by-2 block structure during */
81 /*                            matrix-matrix multiplies. */
82 /*                        (If xTRMM is slower than xGEMM, then */
83 /*                        IPARMQ(ISPEC=16)=1 may be more efficient than */
84 /*                        IPARMQ(ISPEC=16)=2 despite the greater level of */
85 /*                        arithmetic work implied by the latter choice.) */
86
87 /*       NAME    (input) character string */
88 /*               Name of the calling subroutine */
89
90 /*       OPTS    (input) character string */
91 /*               This is a concatenation of the string arguments to */
92 /*               TTQRE. */
93
94 /*       N       (input) integer scalar */
95 /*               N is the order of the Hessenberg matrix H. */
96
97 /*       ILO     (input) INTEGER */
98 /*       IHI     (input) INTEGER */
99 /*               It is assumed that H is already upper triangular */
100 /*               in rows and columns 1:ILO-1 and IHI+1:N. */
101
102 /*       LWORK   (input) integer scalar */
103 /*               The amount of workspace available. */
104
105 /*  Further Details */
106 /*  =============== */
107
108 /*       Little is known about how best to choose these parameters. */
109 /*       It is possible to use different values of the parameters */
110 /*       for each of CHSEQR, DHSEQR, SHSEQR and ZHSEQR. */
111
112 /*       It is probably best to choose different parameters for */
113 /*       different matrices and different parameters at different */
114 /*       times during the iteration, but this has not been */
115 /*       implemented --- yet. */
116
117
118 /*       The best choices of most of the parameters depend */
119 /*       in an ill-understood way on the relative execution */
120 /*       rate of xLAQR3 and xLAQR5 and on the nature of each */
121 /*       particular eigenvalue problem.  Experiment may be the */
122 /*       only practical way to determine which choices are most */
123 /*       effective. */
124
125 /*       Following is a list of default values supplied by IPARMQ. */
126 /*       These defaults may be adjusted in order to attain better */
127 /*       performance in any particular computational environment. */
128
129 /*       IPARMQ(ISPEC=12) The xLAHQR vs xLAQR0 crossover point. */
130 /*                        Default: 75. (Must be at least 11.) */
131
132 /*       IPARMQ(ISPEC=13) Recommended deflation window size. */
133 /*                        This depends on ILO, IHI and NS, the */
134 /*                        number of simultaneous shifts returned */
135 /*                        by IPARMQ(ISPEC=15).  The default for */
136 /*                        (IHI-ILO+1).LE.500 is NS.  The default */
137 /*                        for (IHI-ILO+1).GT.500 is 3*NS/2. */
138
139 /*       IPARMQ(ISPEC=14) Nibble crossover point.  Default: 14. */
140
141 /*       IPARMQ(ISPEC=15) Number of simultaneous shifts, NS. */
142 /*                        a multi-shift QR iteration. */
143
144 /*                        If IHI-ILO+1 is ... */
145
146 /*                        greater than      ...but less    ... the */
147 /*                        or equal to ...      than        default is */
148
149 /*                                0               30       NS =   2+ */
150 /*                               30               60       NS =   4+ */
151 /*                               60              150       NS =  10 */
152 /*                              150              590       NS =  ** */
153 /*                              590             3000       NS =  64 */
154 /*                             3000             6000       NS = 128 */
155 /*                             6000             infinity   NS = 256 */
156
157 /*                    (+)  By default matrices of this order are */
158 /*                         passed to the implicit double shift routine */
159 /*                         xLAHQR.  See IPARMQ(ISPEC=12) above.   These */
160 /*                         values of NS are used only in case of a rare */
161 /*                         xLAHQR failure. */
162
163 /*                    (**) The asterisks (**) indicate an ad-hoc */
164 /*                         function increasing from 10 to 64. */
165
166 /*       IPARMQ(ISPEC=16) Select structured matrix multiply. */
167 /*                        (See ISPEC=16 above for details.) */
168 /*                        Default: 3. */
169
170 /*     ================================================================ */
171 /*     .. Parameters .. */
172 /*     .. */
173 /*     .. Local Scalars .. */
174 /*     .. */
175 /*     .. Intrinsic Functions .. */
176 /*     .. */
177 /*     .. Executable Statements .. */
178     if (*ispec == 15 || *ispec == 13 || *ispec == 16) {
179
180 /*        ==== Set the number simultaneous shifts ==== */
181
182         nh = *ihi - *ilo + 1;
183         ns = 2;
184         if (nh >= 30) {
185             ns = 4;
186         }
187         if (nh >= 60) {
188             ns = 10;
189         }
190         if (nh >= 150) {
191 /* Computing MAX */
192             r__1 = (real)(log((doublereal) nh) / log(2.));
193             i__1 = 10, i__2 = nh / i_nint(&r__1);
194             ns = max(i__1,i__2);
195         }
196         if (nh >= 590) {
197             ns = 64;
198         }
199         if (nh >= 3000) {
200             ns = 128;
201         }
202         if (nh >= 6000) {
203             ns = 256;
204         }
205 /* Computing MAX */
206         i__1 = 2, i__2 = ns - ns % 2;
207         ns = max(i__1,i__2);
208     }
209
210     if (*ispec == 12) {
211
212
213 /*        ===== Matrices of order smaller than NMIN get sent */
214 /*        .     to xLAHQR, the classic double shift algorithm. */
215 /*        .     This must be at least 11. ==== */
216
217         ret_val = 75;
218
219     } else if (*ispec == 14) {
220
221 /*        ==== INIBL: skip a multi-shift qr iteration and */
222 /*        .    whenever aggressive early deflation finds */
223 /*        .    at least (NIBBLE*(window size)/100) deflations. ==== */
224
225         ret_val = 14;
226
227     } else if (*ispec == 15) {
228
229 /*        ==== NSHFTS: The number of simultaneous shifts ===== */
230
231         ret_val = ns;
232
233     } else if (*ispec == 13) {
234
235 /*        ==== NW: deflation window size.  ==== */
236
237         if (nh <= 500) {
238             ret_val = ns;
239         } else {
240             ret_val = ns * 3 / 2;
241         }
242
243     } else if (*ispec == 16) {
244
245 /*        ==== IACC22: Whether to accumulate reflections */
246 /*        .     before updating the far-from-diagonal elements */
247 /*        .     and whether to use 2-by-2 block structure while */
248 /*        .     doing it.  A small amount of work could be saved */
249 /*        .     by making this choice dependent also upon the */
250 /*        .     NH=IHI-ILO+1. */
251
252         ret_val = 0;
253         if (ns >= 14) {
254             ret_val = 1;
255         }
256         if (ns >= 14) {
257             ret_val = 2;
258         }
259
260     } else {
261 /*        ===== invalid value of ispec ===== */
262         ret_val = -1;
263
264     }
265
266 /*     ==== End of IPARMQ ==== */
267
268     return ret_val;
269 } /* iparmq_ */