quadrule.h
1 #ifndef GAUSSHERMITE_H
2 #define GAUSSHERMITE_H
3 
4 #include <algorithm>
5 #include <RcppArmadillo.h>
6 
7 class QuadRule {
8 private:
9  arma::vec x;
10  arma::vec w;
11 public:
12  arma::vec Weight() {
13  return(w);
14  }
15  arma::vec Abscissa() {
16  return(x);
17  }
18  QuadRule(int n=1) :
19  x(std::min(n+(n%2==0),21)),
20  w(std::min(n+(n%2==0),21)) {
21  switch(n) {
22  case 0:
23  break;
24  case 1:
25  x[0] = 0;
26  w[0] = 1.77245385090552;
27  break;
28  case 2:
29  case 3:
30  x[0] = 1.22474487139159;
31  x[1] = 8.88178419700125e-16;
32  x[2] = -1.22474487139159;
33  w[0] = 0.29540897515092;
34  w[1] = 1.18163590060368;
35  w[2] = 0.295408975150921;
36  break;
37  case 4:
38  case 5:
39  x[0] = 2.02018287045609;
40  x[1] = 0.95857246461382;
41  x[2] = 8.88178419700125e-16;
42  x[3] = -0.958572464613816;
43  x[4] = -2.02018287045608;
44  w[0] = 0.0199532420590458;
45  w[1] = 0.39361932315224;
46  w[2] = 0.945308720482942;
47  w[3] = 0.393619323152242;
48  w[4] = 0.0199532420590459;
49  break;
50  case 6:
51  case 7:
52  x[0] = 2.65196135683523;
53  x[1] = 1.67355162876747;
54  x[2] = 0.816287882858967;
55  x[3] = 1.33226762955019e-15;
56  x[4] = -0.816287882858962;
57  x[5] = -1.67355162876746;
58  x[6] = -2.65196135683523;
59  w[0] = 0.000971781245099515;
60  w[1] = 0.0545155828191268;
61  w[2] = 0.425607252610126;
62  w[3] = 0.810264617556808;
63  w[4] = 0.425607252610129;
64  w[5] = 0.0545155828191272;
65  w[6] = 0.000971781245099528;
66  break;
67  case 8:
68  case 9:
69  x[0] = 3.19099320178153;
70  x[1] = 2.26658058453184;
71  x[2] = 1.46855328921667;
72  x[3] = 0.723551018752838;
73  x[4] = 0;
74  x[5] = -0.723551018752837;
75  x[6] = -1.46855328921667;
76  x[7] = -2.26658058453184;
77  x[8] = -3.19099320178153;
78  w[0] = 3.96069772632642e-05;
79  w[1] = 0.00494362427553695;
80  w[2] = 0.088474527394377;
81  w[3] = 0.432651559002555;
82  w[4] = 0.720235215606052;
83  w[5] = 0.432651559002555;
84  w[6] = 0.0884745273943762;
85  w[7] = 0.00494362427553692;
86  w[8] = 3.96069772632637e-05;
87  break;
88  case 10:
89  case 11:
90  x[0] = 3.66847084655958;
91  x[1] = 2.78329009978165;
92  x[2] = 2.02594801582575;
93  x[3] = 1.32655708449493;
94  x[4] = 0.6568095668821;
95  x[5] = 8.88178419700125e-16;
96  x[6] = -0.656809566882099;
97  x[7] = -1.32655708449493;
98  x[8] = -2.02594801582576;
99  x[9] = -2.78329009978165;
100  x[10] = -3.66847084655958;
101  w[0] = 1.43956039371425e-06;
102  w[1] = 0.000346819466323343;
103  w[2] = 0.0119113954449115;
104  w[3] = 0.117227875167709;
105  w[4] = 0.429359752356122;
106  w[5] = 0.654759286914593;
107  w[6] = 0.429359752356126;
108  w[7] = 0.117227875167708;
109  w[8] = 0.0119113954449111;
110  w[9] = 0.000346819466323334;
111  w[10] = 1.43956039371421e-06;
112  break;
113  case 12:
114  case 13:
115  x[0] = 4.10133759617864;
116  x[1] = 3.24660897837241;
117  x[2] = 2.51973568567824;
118  x[3] = 1.85310765160151;
119  x[4] = 1.22005503659075;
120  x[5] = 0.605763879171061;
121  x[6] = 8.88178419700125e-16;
122  x[7] = -0.605763879171056;
123  x[8] = -1.22005503659075;
124  x[9] = -1.85310765160151;
125  x[10] = -2.51973568567824;
126  x[11] = -3.24660897837241;
127  x[12] = -4.10133759617864;
128  w[0] = 4.82573185007318e-08;
129  w[1] = 2.04303604027071e-05;
130  w[2] = 0.00120745999271939;
131  w[3] = 0.02086277529617;
132  w[4] = 0.140323320687024;
133  w[5] = 0.42161629689854;
134  w[6] = 0.604393187921162;
135  w[7] = 0.421616296898545;
136  w[8] = 0.140323320687024;
137  w[9] = 0.0208627752961696;
138  w[10] = 0.00120745999271937;
139  w[11] = 2.04303604027065e-05;
140  w[12] = 4.82573185007304e-08;
141  break;
142  case 14:
143  case 15:
144  x[0] = 4.49999070730939;
145  x[1] = 3.66995037340445;
146  x[2] = 2.96716692790561;
147  x[3] = 2.32573248617386;
148  x[4] = 1.71999257518649;
149  x[5] = 1.13611558521092;
150  x[6] = 0.565069583255578;
151  x[7] = 3.5527136788005e-15;
152  x[8] = -0.565069583255571;
153  x[9] = -1.13611558521092;
154  x[10] = -1.71999257518648;
155  x[11] = -2.32573248617385;
156  x[12] = -2.9671669279056;
157  x[13] = -3.66995037340444;
158  x[14] = -4.49999070730938;
159  w[0] = 1.52247580425353e-09;
160  w[1] = 1.05911554771107e-06;
161  w[2] = 0.0001000044412325;
162  w[3] = 0.00277806884291275;
163  w[4] = 0.0307800338725461;
164  w[5] = 0.158488915795935;
165  w[6] = 0.412028687498897;
166  w[7] = 0.564100308726416;
167  w[8] = 0.412028687498902;
168  w[9] = 0.158488915795936;
169  w[10] = 0.0307800338725457;
170  w[11] = 0.00277806884291278;
171  w[12] = 0.0001000044412325;
172  w[13] = 1.05911554771112e-06;
173  w[14] = 1.52247580425367e-09;
174  break;
175  case 16:
176  case 17:
177  x[0] = 4.8713451936744;
178  x[1] = 4.06194667587547;
179  x[2] = 3.37893209114149;
180  x[3] = 2.75776291570389;
181  x[4] = 2.17350282666662;
182  x[5] = 1.61292431422123;
183  x[6] = 1.06764872574345;
184  x[7] = 0.531633001342657;
185  x[8] = 8.88178419700125e-16;
186  x[9] = -0.531633001342652;
187  x[10] = -1.06764872574345;
188  x[11] = -1.61292431422123;
189  x[12] = -2.17350282666662;
190  x[13] = -2.75776291570389;
191  x[14] = -3.37893209114149;
192  x[15] = -4.06194667587547;
193  x[16] = -4.8713451936744;
194  w[0] = 4.58057893079867e-11;
195  w[1] = 4.97707898163089e-08;
196  w[2] = 7.11228914002143e-06;
197  w[3] = 0.000298643286697756;
198  w[4] = 0.00506734995762757;
199  w[5] = 0.0409200341497567;
200  w[6] = 0.172648297670097;
201  w[7] = 0.401826469470411;
202  w[8] = 0.530917937624859;
203  w[9] = 0.401826469470415;
204  w[10] = 0.172648297670098;
205  w[11] = 0.0409200341497562;
206  w[12] = 0.00506734995762745;
207  w[13] = 0.000298643286697756;
208  w[14] = 7.11228914002152e-06;
209  w[15] = 4.97707898163081e-08;
210  w[16] = 4.58057893079847e-11;
211  break;
212  case 18:
213  case 19:
214  x[0] = 5.22027169053748;
215  x[1] = 4.42853280660378;
216  x[2] = 3.76218735196402;
217  x[3] = 3.1578488183476;
218  x[4] = 2.59113378979454;
219  x[5] = 2.04923170985062;
220  x[6] = 1.52417061939354;
221  x[7] = 1.01036838713431;
222  x[8] = 0.503520163423889;
223  x[9] = 0;
224  x[10] = -0.503520163423885;
225  x[11] = -1.01036838713431;
226  x[12] = -1.52417061939353;
227  x[13] = -2.04923170985062;
228  x[14] = -2.59113378979454;
229  x[15] = -3.1578488183476;
230  x[16] = -3.76218735196401;
231  x[17] = -4.42853280660377;
232  x[18] = -5.22027169053748;
233  w[0] = 1.32629709449852e-12;
234  w[1] = 2.16305100986354e-09;
235  w[2] = 4.48824314722315e-07;
236  w[3] = 2.72091977631616e-05;
237  w[4] = 0.000670877521407184;
238  w[5] = 0.00798886677772307;
239  w[6] = 0.0508103869090527;
240  w[7] = 0.183632701306996;
241  w[8] = 0.391608988613028;
242  w[9] = 0.502974888276183;
243  w[10] = 0.391608988613033;
244  w[11] = 0.183632701306998;
245  w[12] = 0.0508103869090517;
246  w[13] = 0.00798886677772294;
247  w[14] = 0.000670877521407195;
248  w[15] = 2.72091977631622e-05;
249  w[16] = 4.48824314722318e-07;
250  w[17] = 2.1630510098636e-09;
251  w[18] = 1.32629709449851e-12;
252  break;
253  default:
254  x[0] = 5.55035187326468;
255  x[1] = 4.77399234341122;
256  x[2] = 4.12199554749184;
257  x[3] = 3.53197287713768;
258  x[4] = 2.9799912077046;
259  x[5] = 2.45355212451284;
260  x[6] = 1.94496294918625;
261  x[7] = 1.44893425065073;
262  x[8] = 0.96149963441837;
263  x[9] = 0.479450707079108;
264  x[10] = 0;
265  x[11] = -0.479450707079105;
266  x[12] = -0.961499634418367;
267  x[13] = -1.44893425065073;
268  x[14] = -1.94496294918625;
269  x[15] = -2.45355212451284;
270  x[16] = -2.9799912077046;
271  x[17] = -3.53197287713767;
272  x[18] = -4.12199554749184;
273  x[19] = -4.77399234341122;
274  x[20] = -5.55035187326468;
275  w[0] = 3.72036507013603e-14;
276  w[1] = 8.81861124205004e-11;
277  w[2] = 2.5712301800593e-08;
278  w[3] = 2.17188489805666e-06;
279  w[4] = 7.47839886731003e-05;
280  w[5] = 0.00125498204172641;
281  w[6] = 0.0114140658374345;
282  w[7] = 0.0601796466589129;
283  w[8] = 0.192120324066999;
284  w[9] = 0.381669073613499;
285  w[10] = 0.479023703120173;
286  w[11] = 0.381669073613504;
287  w[12] = 0.192120324067;
288  w[13] = 0.0601796466589117;
289  w[14] = 0.0114140658374341;
290  w[15] = 0.0012549820417264;
291  w[16] = 7.47839886730978e-05;
292  w[17] = 2.17188489805664e-06;
293  w[18] = 2.57123018005922e-08;
294  w[19] = 8.81861124204988e-11;
295  w[20] = 3.72036507013564e-14;
296  break;
297  }
298 
299  }
300 };
301 
302 #endif /* GAUSSHERMITE_H */