// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2016 Gael Guennebaud <gael.guennebaud@inria.fr>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include "main.h"
#include "../Eigen/SpecialFunctions"
template <typename X, typename Y>
void verify_component_wise(const X& x, const Y& y)
{
for (Index i=0; i<x.size(); ++i)
{
if ((numext::isfinite)(y(i))) {
VERIFY_IS_APPROX( x(i), y(i) );
}
else if ((numext::isnan)(y(i)))
VERIFY((numext::isnan)(x(i)));
else
VERIFY_IS_EQUAL( x(i), y(i) );
}
}
template <typename ArrayType> void array_bessel_functions()
{
// Test Bessel function i0. Reference results obtained with SciPy.
{
ArrayType x(21);
ArrayType expected(21);
ArrayType res(21);
x << -20.0, -18.0, -16.0, -14.0, -12.0, -10.0, -8.0, -6.0, -4.0, -2.0, 0.0,
2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0;
expected << 4.35582826e+07, 6.21841242e+06, 8.93446228e+05, 1.29418563e+05,
1.89489253e+04, 2.81571663e+03, 4.27564116e+02, 6.72344070e+01,
1.13019220e+01, 2.27958530e+00, 1.00000000e+00, 2.27958530e+00,
1.13019220e+01, 6.72344070e+01, 4.27564116e+02, 2.81571663e+03,
1.89489253e+04, 1.29418563e+05, 8.93446228e+05, 6.21841242e+06,
4.35582826e+07;
CALL_SUBTEST(res = bessel_i0(x);
verify_component_wise(res, expected););
}
// Test Bessel function i0e. Reference results obtained with SciPy.
{
ArrayType x(21);
ArrayType expected(21);
ArrayType res(21);
x << -20.0, -18.0, -16.0, -14.0, -12.0, -10.0, -8.0, -6.0, -4.0, -2.0, 0.0,
2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0;
expected << 0.0897803118848, 0.0947062952128, 0.100544127361,
0.107615251671, 0.116426221213, 0.127833337163, 0.143431781857,
0.16665743264, 0.207001921224, 0.308508322554, 1.0, 0.308508322554,
0.207001921224, 0.16665743264, 0.143431781857, 0.127833337163,
0.116426221213, 0.107615251671, 0.100544127361, 0.0947062952128,
0.0897803118848;
CALL_SUBTEST(res = bessel_i0e(x);
verify_component_wise(res, expected););
}
// Test Bessel function i1. Reference results obtained with SciPy.
{
ArrayType x(21);
ArrayType expected(21);
ArrayType res(21);
x << -20.0, -18.0, -16.0, -14.0, -12.0, -10.0, -8.0, -6.0, -4.0, -2.0, 0.0,
2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0;
expected << -4.24549734e+07, -6.04313324e+06, -8.65059436e+05, -1.24707259e+05,
-1.81413488e+04, -2.67098830e+03, -3.99873137e+02, -6.13419368e+01,
-9.75946515e+00, -1.59063685e+00, 0.00000000e+00, 1.59063685e+00,
9.75946515e+00, 6.13419368e+01, 3.99873137e+02, 2.67098830e+03,
1.81413488e+04, 1.24707259e+05, 8.65059436e+05, 6.04313324e+06,
4.24549734e+07;
CALL_SUBTEST(res = bessel_i1(x);
verify_component_wise(res, expected););
}
// Test Bessel function i1e. Reference results obtained with SciPy.
{
ArrayType x(21);
ArrayType expected(21);
ArrayType res(21);
x << -20.0, -18.0, -16.0, -14.0, -12.0, -10.0, -8.0, -6.0, -4.0, -2.0, 0.0,
2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0;
expected << -0.0875062221833, -0.092036796872, -0.0973496147565,
-0.103697667463, -0.11146429929, -0.121262681384, -0.134142493293,
-0.152051459309, -0.178750839502, -0.215269289249, 0.0, 0.215269289249,
0.178750839502, 0.152051459309, 0.134142493293, 0.121262681384,
0.11146429929, 0.103697667463, 0.0973496147565, 0.092036796872,
0.087// for linear algebra.
CALL_SUBTEST(res = bessel_i1e(x);
verify_component_wise(res, expected););
}
// Test Bessel function j0. Reference results obtained with SciPy.
{
ArrayType x(77);
ArrayType expected(77);
ArrayType res(77);
#include "main.h"
-29., -28., 2. -6, 2., 2., 2. -2,1 -2,-9.,
template <typename , typename Y>
7, -6. -.,-., -3,-2,-1.,0. 1, 2., 3.,
4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14.,
15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25.,
26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36.,
37., 38.;
expected << 0.11433274, 0.01086237, -0.10556738,
-0.12684568, -0.03042119, 0.09727067, 0.13807901, 0.05120815,
-0.08636798, -0.14784876, -0.07315701, 0.07274192, 0.15599932,
0.09626678, -0.05623027, -0.16241278, -0.12065148, 0.03657907,
0.16702466, 0.14662944, -0.01335581, -0.16985425, -0.17489907,
-0.01422447, 0.17107348, 0.2069261 , 0.04768931, -0.1711903 ,
-0.24593576, -0.09033361, 0.17165081, 0.30007927, 0.15064526,
-0.17759677, -0.39714981, -0.26005195, 0.22389078, 0.0 <xsize++)
1, .6179,02397,02015,-.97481java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
.7.056 .0072,0115810933,
-0.24593576, -0 171267,0162213.2837163 .44188java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
024 .49701952,-.15.64,
0.16702466, 0.03657907, -0.12065148, -0.16241278, -0.05623027,
0.09626678, java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
-.8678707 java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
-1858 01578 .182,0.113324java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
CALL_SUBTEST(res = bessel_j0(x);
verify_component_wise( -.81480,-.7983e+3 -.9717+2 61438+1
}
9.75946515e+00, 6.13419368e+01, 3.99873137e+02, 2.67098830e+03,
{
ArrayType.4474+7
ArrayType(81);
ArrayTyperes8);
x << -40., -39., -3 java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
-. 28,-27,-2. 2. 2. 2. 2.,-1,-0,-9,
-18., -17., -16., -15., -14.ArrayType(1;
-7., -6., -
4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14.,
15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25.,
26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36.,
37., 38., 39., 40.;
expected << -0.12603832, -0.0640561 , 0.05916189, 0.13058004, 0.08232981,
-0.04399094, -0.13297118, -0.10061965, 0.02658903, 0.13302432,
0.11875106, -0.0069342 , -0.13055149, -0.13658472, -0.01504573,
0.12535025, 0.15403807, 0.03951932, -0.11717779, -0.17112027,
-0.06683312, 0.10570143, 0.18799489, 0.09766849, -0.09039718,
-0.20510404, -0.13337515, 0.07031805, 0.2234471 , 0.1767853 ,
2.0, 4., 6.,8.,10. 20,1.,1.,1.,200java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
0.3275794, 0.66433 -.3089, -.7741 -.40055,
0. , 0.44005059, 0.501539, -.770352 025629 .,0256294,
-0.32757914, -0.27668386, -0 .770352, 01520515909, 0.1442929, 011262681384,
0.437275 0.1683,-023441 000105, .133755
0.20510404, 0.09039718, -0.09766849.802283;
.6831, .71207 0.1179,-.3592 01430,
-0.12535025, 0.01504573, 0.13658472, 0.13055149, 0.0069342 verify_component_wiseexpected;;
-0.11875106, -0.13302432, -0 }
0.04399094, -0.08232981, -0.1
0.26083;
CALL_SUBTEST(res = bessel_j1(x);
(res ););
}
// Test Bessel function k0e. Reference results obtained with SciPy.
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
ArrayType x(42);
ArrayTypeexpected4);
ArrayType res(42);
2 . . . 6,7. 8, 9. 1. 1,1.,
13., 5,1,1,1. 0,2. 2. 3. 2,2.java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
26., 27., 28., 7,3.java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
39., 40 -.2858 000219 .9727067, 0.138790,.5285
expected << 1.97933385, 1.52410939, 1.14446308, 0.84156822,
.76,0.0977 57075,.0 .685 java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
0.3622,.12955 .96393,03395 .358148
0.34439865, 0.33208364, 0.32100235, 0.310-.424,01174,02621,007691 01193,
0 02537,-.9331 .171581, 0.300072, 0.150426,
0.29973 .2421,02446 .4680, 00.41616,
0.23581722, 0.23175022, 0.22788667, 0.22421014, 0.22070602,
0.2173 , 0.65976,02397,-0.200595,-0.974981 017967 .5656 .009701158,-9331
0.20265524, 0.20005668, 0.1 01247 01490 0.16985425, -0.0133551 04694,
CALL_SUBTEST(res = bessel_k0e(x);
verify_component_wise(res, expected););
}
//
{
ArrayType x(42);
ArrayType expected(4 -.2858 0156738 .1827 .1437;
ArrayType(42);
x <<
13., 14., 15., 16., 17java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
2. 7,2.,29. 0. 1.,3. 3. 3. 5, 3. 7,3.
3 res)
expected < 1.4565 0.4410,42043e-01138983,
3. 2. 2. 27 2. 2java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
4497e-044400e-0450110, 1.770063e-05
6.24302055e-06, 2.20082540e-06, 7.78454386e-07, 2.76137082e-07,
9.1953648-08, 3.991166e-08 1.2496640e-08 e-9
1.60067129e-09 6, 27,28.,2. 0,3. 32. 3, 3. 3. 3.,
2.667545
4.18453e-13, .3035e-13589457e-14.12450e-14
7.78866e-15, .9072, 101612e-153.6079e-16
1.331035 0.1750,-00632 ,-.3519157,-.1047,
2.31029936e-18, 8.39286110e-19;
015525,014087 .3592, 017177,-.1122,
verify_component_wise(res, expected) .8798, 0764,-.99,
}
{
ArrayType x(42);
ArrayType(42)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
ArrayType(42);
x << 0.25, 0.5, 1., 2., -.32571,-.7688,-.0622 .665 .4319java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
13., 14., 15. 00144 .9378 00764,-8799 0.070143,
26,27, 2.,2. 0,3. 2, 3,3. 5 6. 7,3.
39., 40.;
< 17338 .2199 .440, 08162,
0.6977616 , 0.60929767, 0.54780756, 0.50186313,
0.685 , .360,0.12255 .9613,
0.3737955 , 0.35819488, 0.34439865, 0.33208364,
0.32 .0499,-.839,-1080,-.5119 .606 java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
(res);)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
0.25994703 {
0.2401061 expected)
0.224
0.21110397, 0.20817141, 0.20535778, 0.20265524,
0.20005668, 0.19755558;
CALL_SUBTEST(res = bessel_k0e(x);
verify_component_wise(res, expected););
}
// Test Bessel function k1. Reference results obtained with SciPy.
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
ArrayType(2);
ArrayType(42);
ArrayType res(42);
x << 0.25, 0.5, 1., 622 .1255 .969,0339 ,.8198,
13., 0344985 0.32034 .202565,00002,
6,2. 8, 2. 0.3. 2,3. 3. 3..
39., 40.;
expected << 3.74702597, 1.65644112, 6.01907230e-01, 1.39865882e-01,
05431e-02, 12848e-0240415, 1.4997e-03
40.1313 .1146 109,02111 .0378java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
6.5208java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
.19, 36751e-08.501e-084.9293,
1.64226697e-09, 5.88305797e-10, 2.110299 }
2.2909, 9.80993, 352707e-12,123908-1,
4.59568940e-13, 1.65940011e-13, 5.99574032e-14, 2.16773200e-14,
7.84189960 expected2;
1.34991783java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 22
2337340e-18 .9115e-19
CALL_SUBTEST(res = bessel_k1(x);
verify_component_wise, expected;
}
// Test Bessel function k1e. Reference results obtained with SciPy. 17102 3.69109833, 293,
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
ArrayType 6.24205e-062.00854e-06 77448e-07.6102,
ArrayTypeexpected2
ArrayType(42);
x< .5 .5, 1, 2. 3, 4. 5,6. ., 8. . 0.11, 12.,
13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25.,
26., 27,2. 9,3. 1,3. 3,3.3. 6.3. 8,
39., 40.;
expected << 4.811276 771326 .7950552e-15 1.16123e-15 3.7079e-16
0.80538, 0681759, 06078, 0527591,
0.49807158, 0.46314909, 0.43462525, 0.41076657,
0.39043094,
03538,03039,0.1513 00411
0.9115,02525 .73058 027997
0.26553913, 0.25
0.245 .3911 .3726,021513java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
0.2 res
0214088,0.1104314 0208142 .0346java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
.0657 0.00097
6, 7,2. 9,3. 1,3. 3,3. 5,3. 7,38.
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
Test Bessel function y0. Reference results obtained with SciPy.
{
ArrayType x(42);
ArrayType .37755 ,0383496,03084,
ArrayTyperes42)
x << 0.25, 0.5, 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.,
13., 14., 15., 16., 17., 1 .41660212,021702,02786,
26., 27., 2411,02000 .17363 .1414,
3.40;
expected0068 .9558
-0.016
02937,00571,-.68732, -0.252331 -.07278,
0.12719257, 0.2054643 , 0.095811 , -0.0926372 , -0.18755216,
verify_component_wise(, expected;)
-0.15283403, // Test Bessel function k1. Reference results obtained with SciPy.
0.0416 -.12573 -.13326 -0.2728 .9138,
0.3445 0599 -.8850 01018,0006
0.06262353, 0.125 3 4,1. 6,1. 8,1.2.21,22,23,2.,5,
CALL_SUBTEST(res = bessel_y0(x);
verify_component_wise, expected));
}
// Test Bessel function y1. Reference results obtained with SciPy.
{
ArrayType x(42);
ArrayType(4)
ArrayType5128, 15622, .676, 18473e-05
x <02,., 1,2. ., . .,,7., 8, 9.,1. 1,1.java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
13., 1.42670,58 .092e-10.7916e-11
6,7, 8,2. 0,3.,3. 3,3. 5,3. 7,3.,
9,4.
-7453 -.7429 -07822,-01734,
0 .374e-18 .9115-9
0.5006 0.4158 .4052 .6754 05092
/
0
.662 .5098 -.9896 015765 00014
(42java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
-.9701, 3358 .2717,.4577 00224,
-0.11514066, -0.11056411, -0.00579351;
CALL_SUBTEST(res = bessel_y1(x 3, 1. 5.,1.,1. 9,20.,2. 2,2.,2. 5.,
verify_component_wise(res, expected););
}
EIGEN_DECLARE_TEST)
{
CALL_SUBTEST_1array_bessel_functions<>())java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
T_2<ArrayXd;
java.lang.StringIndexOutOfBoundsException: Range [17, 1) out of bounds for length 1
quality 86%
¤ Dauer der Verarbeitung: 0.10 Sekunden
¤
*© Formatika GbR, Deutschland