12 #include "../Eigen/SpecialFunctions"
15 template<
typename Derived>
20 template<
typename XprType>
25 template<
typename X,
typename Y>
46 Scalar plusinf = std::numeric_limits<Scalar>::infinity();
47 Scalar nan = std::numeric_limits<Scalar>::quiet_NaN();
49 Index rows = internal::random<Index>(1,30);
55 #if EIGEN_HAS_C99_MATH
60 #endif // EIGEN_HAS_C99_MATH
64 #if EIGEN_HAS_C99_MATH
83 ArrayType a_m1 =
a - one;
87 ArrayType gamma_a_m1_x =
Eigen::igamma(a_m1,
x) * a_m1.lgamma().exp();
106 int max_exponent = std::numeric_limits<Scalar>::max_exponent10;
107 ArrayType
a =
m1.abs() *
Scalar(
pow(10., max_exponent - 1));
108 ArrayType
x =
m2.abs() *
Scalar(
pow(10., max_exponent - 1));
109 for (
int i = 0;
i <
a.size(); ++
i) {
123 {
Scalar(0.0), nan, nan, nan, nan, nan},
131 Scalar(0.06564245437845008),
Scalar(0.5665298796332909),
136 Scalar(0.5042041932513908)}};
138 {nan, nan, nan, nan, nan, nan},
140 Scalar(0.22313016014842982),
Scalar(0.018315638888734182),
143 Scalar(0.04601170568923136),
Scalar(0.9999992477923555),
151 Scalar(0.49579580674813944)}};
153 for (
int i = 0;
i < 6; ++
i) {
154 for (
int j = 0;
j < 6; ++
j) {
170 #endif // EIGEN_HAS_C99_MATH
174 ArrayType
x(7),
res(7),
ref(7);
175 x << 0.5, 0.2, 0.8, 0.9, 0.1, 0.99, 0.01;
176 ref << 0., -0.8416212335729142, 0.8416212335729142, 1.2815515655446004, -1.2815515655446004, 2.3263478740408408, -2.3263478740408408;
183 ArrayType
m1 = ArrayType::Random(32);
194 ArrayType
x(10),
q(10),
res(10),
ref(10);
195 x << 1.5, 4, 10.5, 10000.5, 3, 1, 0.9, 2, 3, 4;
196 q << 2, 1.5, 3, 1.0001, -2.5, 1.2345, 1.2345, -1, -2, -3;
197 ref << 1.61237534869, 0.234848505667, 1.03086757337e-5, 0.367879440865, 0.054102025820864097, plusinf, nan, plusinf, nan, plusinf;
205 ArrayType
x(9),
res(9),
ref(9);
206 x << 1, 1.5, 4, -10.5, 10000.5, 0, -1, -2, -3;
207 ref << -0.5772156649015329, 0.03648997397857645, 1.2561176684318, 2.398239129535781, 9.210340372392849, nan, nan, nan, nan;
214 #if EIGEN_HAS_C99_MATH
216 ArrayType
n(16),
x(16),
res(16),
ref(16);
217 n << 1, 1, 1, 1.5, 17, 31, 28, 8, 42, 147, 170, -1, 0, 1, 2, 3;
218 x << 2, 3, 25.5, 1.5, 4.7, 11.8, 17.7, 30.2, 15.8, 54.1, 64, -1, -2, -3, -4, -5;
219 ref << 0.644934066848, 0.394934066848, 0.0399946696496, nan, 293.334565435, 0.445487887616, -2.47810300902e-07, -8.29668781082e-09, -0.434562276666, 0.567742190178, -0.0108615497927, nan, nan, plusinf, nan, plusinf;
234 #if EIGEN_HAS_C99_MATH
251 a << 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
252 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
253 0.03062277660168379, 0.03062277660168379, 0.03062277660168379,
254 0.03062277660168379, 0.03062277660168379, 0.03062277660168379,
255 0.03062277660168379, 0.03062277660168379, 0.03062277660168379,
256 0.03062277660168379, 0.03062277660168379, 0.03062277660168379,
257 0.03062277660168379, 0.03062277660168379, 0.03062277660168379,
258 0.03062277660168379, 0.03062277660168379, 0.03062277660168379,
259 0.03062277660168379, 0.03062277660168379, 0.03062277660168379,
260 0.03062277660168379, 0.03062277660168379, 0.03062277660168379,
261 0.03062277660168379, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999,
262 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999,
263 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999,
264 31.62177660168379, 31.62177660168379, 31.62177660168379,
265 31.62177660168379, 31.62177660168379, 31.62177660168379,
266 31.62177660168379, 31.62177660168379, 31.62177660168379,
267 31.62177660168379, 31.62177660168379, 31.62177660168379,
268 31.62177660168379, 31.62177660168379, 31.62177660168379,
269 31.62177660168379, 31.62177660168379, 31.62177660168379,
270 31.62177660168379, 31.62177660168379, 31.62177660168379,
271 31.62177660168379, 31.62177660168379, 31.62177660168379,
272 31.62177660168379, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999,
273 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999,
274 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999,
275 999.999, 999.999, 999.999;
277 b << 0.0, 0.0, 0.0, 0.0, 0.0, 0.03062277660168379, 0.03062277660168379,
278 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.999,
279 0.999, 0.999, 0.999, 0.999, 31.62177660168379, 31.62177660168379,
280 31.62177660168379, 31.62177660168379, 31.62177660168379, 999.999,
281 999.999, 999.999, 999.999, 999.999, 0.0, 0.0, 0.0, 0.0, 0.0,
282 0.03062277660168379, 0.03062277660168379, 0.03062277660168379,
283 0.03062277660168379, 0.03062277660168379, 0.999, 0.999, 0.999, 0.999,
284 0.999, 31.62177660168379, 31.62177660168379, 31.62177660168379,
285 31.62177660168379, 31.62177660168379, 999.999, 999.999, 999.999,
286 999.999, 999.999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03062277660168379,
287 0.03062277660168379, 0.03062277660168379, 0.03062277660168379,
288 0.03062277660168379, 0.999, 0.999, 0.999, 0.999, 0.999,
289 31.62177660168379, 31.62177660168379, 31.62177660168379,
290 31.62177660168379, 31.62177660168379, 999.999, 999.999, 999.999,
291 999.999, 999.999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03062277660168379,
292 0.03062277660168379, 0.03062277660168379, 0.03062277660168379,
293 0.03062277660168379, 0.999, 0.999, 0.999, 0.999, 0.999,
294 31.62177660168379, 31.62177660168379, 31.62177660168379,
295 31.62177660168379, 31.62177660168379, 999.999, 999.999, 999.999,
296 999.999, 999.999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03062277660168379,
297 0.03062277660168379, 0.03062277660168379, 0.03062277660168379,
298 0.03062277660168379, 0.999, 0.999, 0.999, 0.999, 0.999,
299 31.62177660168379, 31.62177660168379, 31.62177660168379,
300 31.62177660168379, 31.62177660168379, 999.999, 999.999, 999.999,
303 x << -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5,
304 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2,
305 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1,
306 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1,
307 -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8,
308 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5,
309 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2,
310 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1,
311 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5,
314 v << nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
315 nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
316 nan, nan, nan, 0.47972119876364683, 0.5, 0.5202788012363533, nan, nan,
317 0.9518683957740043, 0.9789663010413743, 0.9931729188073435, nan, nan,
318 0.999995949033062, 0.9999999999993698, 0.9999999999999999, nan, nan,
319 0.9999999999999999, 0.9999999999999999, 0.9999999999999999, nan, nan,
320 nan, nan, nan, nan, nan, 0.006827081192655869, 0.0210336989586256,
321 0.04813160422599567, nan, nan, 0.20014344256217678, 0.5000000000000001,
322 0.7998565574378232, nan, nan, 0.9991401428435834, 0.999999999698403,
323 0.9999999999999999, nan, nan, 0.9999999999999999, 0.9999999999999999,
324 0.9999999999999999, nan, nan, nan, nan, nan, nan, nan,
325 1.0646600232370887e-25, 6.301722877826246e-13, 4.050966937974938e-06,
326 nan, nan, 7.864342668429763e-23, 3.015969667594166e-10,
327 0.0008598571564165444, nan, nan, 6.031987710123844e-08,
328 0.5000000000000007, 0.9999999396801229, nan, nan, 0.9999999999999999,
329 0.9999999999999999, 0.9999999999999999, nan, nan, nan, nan, nan, nan,
330 nan, 0.0, 7.029920380986636e-306, 2.2450728208591345e-101, nan, nan,
331 0.0, 9.275871147869727e-302, 1.2232913026152827e-97, nan, nan, 0.0,
332 3.0891393081932924e-252, 2.9303043666183996e-60, nan, nan,
333 2.248913486879199e-196, 0.5000000000004947, 0.9999999999999999, nan;
341 ArrayType
m1 = ArrayType::Random(32);
342 ArrayType
m2 = ArrayType::Random(32);
343 ArrayType
m3 = ArrayType::Random(32);
344 ArrayType one = ArrayType::Constant(32,
Scalar(1.0));
348 ArrayType
x =
m3.abs();
370 ArrayType num =
x.pow(
a) * (one -
x).pow(
b);
371 ArrayType denom =
a * (
a.lgamma() +
b.lgamma() - (
a +
b).lgamma()).exp();
376 if (
sizeof(
Scalar) >= 8) {
387 ArrayType num =
x.pow(
a) * (one -
x).pow(
b);
388 ArrayType denom =
b * (
a.lgamma() +
b.lgamma() - (
a +
b).lgamma()).exp();
393 #endif // EIGEN_HAS_C99_MATH
422 #if EIGEN_HAS_C99_MATH
430 a << 0.01, 0.01, 0.01, 0.01, 0.01, 0.1, 0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0,
431 1.0, 1.0, 10.0, 10.0, 10.0, 10.0, 10.0, 100.0, 100.0, 100.0, 100.0,
432 100.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0;
434 x << 1.25668890405e-26, 1.17549435082e-38, 1.20938905072e-05,
435 1.17549435082e-38, 1.17549435082e-38, 5.66572070696e-16,
436 0.0132865061065, 0.0200034203853, 6.29263709118e-17, 1.37160367764e-06,
437 0.333412038288, 1.18135687766, 0.580629033777, 0.170631439426,
438 0.786686768458, 7.63873279537, 13.1944344379, 11.896042354,
439 10.5830172417, 10.5020942233, 92.8918587747, 95.003720371,
440 86.3715926467, 96.0330217672, 82.6389930677, 968.702906754,
441 969.463546828, 1001.79726022, 955.047416547, 1044.27458568;
443 v << -32.7256441441, -36.4394150514, -9.66467612263, -36.4394150514,
444 -36.4394150514, -1.0891900302, -2.66351229645, -2.48666868596,
445 -0.929700494428, -3.56327722764, -0.455320135314, -0.391437214323,
446 -0.491352055991, -0.350454834292, -0.471773162921, -0.104084440522,
447 -0.0723646747909, -0.0992828975532, -0.121638215446, -0.122619605294,
448 -0.0317670267286, -0.0359974812869, -0.0154359225363, -0.0375775365921,
449 -0.00794899153653, -0.00777303219211, -0.00796085782042,
450 -0.0125850719397, -0.00455500206958, -0.00476436993148;
458 ArrayType sample(30);
462 alpha << 0.01, 0.01, 0.01, 0.01, 0.01, 0.1, 0.1, 0.1, 0.1, 0.1, 1.0, 1.0,
463 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 10.0, 10.0, 100.0, 100.0, 100.0, 100.0,
464 100.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0;
466 sample << 1.25668890405e-26, 1.17549435082e-38, 1.20938905072e-05,
467 1.17549435082e-38, 1.17549435082e-38, 5.66572070696e-16,
468 0.0132865061065, 0.0200034203853, 6.29263709118e-17, 1.37160367764e-06,
469 0.333412038288, 1.18135687766, 0.580629033777, 0.170631439426,
470 0.786686768458, 7.63873279537, 13.1944344379, 11.896042354,
471 10.5830172417, 10.5020942233, 92.8918587747, 95.003720371,
472 86.3715926467, 96.0330217672, 82.6389930677, 968.702906754,
473 969.463546828, 1001.79726022, 955.047416547, 1044.27458568;
475 v << 7.42424742367e-23, 1.02004297287e-34, 0.0130155240738,
476 1.02004297287e-34, 1.02004297287e-34, 1.96505168277e-13, 0.525575786243,
477 0.713903991771, 2.32077561808e-14, 0.000179348049886, 0.635500453302,
478 1.27561284917, 0.878125852156, 0.41565819538, 1.03606488534,
479 0.885964824887, 1.16424049334, 1.10764479598, 1.04590810812,
480 1.04193666963, 0.965193152414, 0.976217589464, 0.93008035061,
481 0.98153216096, 0.909196397698, 0.98434963993, 0.984738050206,
482 1.00106492525, 0.97734200649, 1.02198794179;
487 #endif // EIGEN_HAS_C99_MATH