diff --git a/include/boost/math/special_functions.hpp b/include/boost/math/special_functions.hpp index 3468af2b6..f33f985e2 100644 --- a/include/boost/math/special_functions.hpp +++ b/include/boost/math/special_functions.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/include/boost/math/special_functions/ellint_d.hpp b/include/boost/math/special_functions/ellint_d.hpp index 0e1074a09..5bd065d6e 100644 --- a/include/boost/math/special_functions/ellint_d.hpp +++ b/include/boost/math/special_functions/ellint_d.hpp @@ -11,8 +11,8 @@ // that the code continues to work no matter how many digits // type T has. -#ifndef BOOST_MATH_ELLINT_2_HPP -#define BOOST_MATH_ELLINT_2_HPP +#ifndef BOOST_MATH_ELLINT_D_HPP +#define BOOST_MATH_ELLINT_D_HPP #ifdef _MSC_VER #pragma once @@ -122,6 +122,8 @@ T ellint_d_imp(T k, const Policy& pol) { return static_cast(1); } + if(fabs(k) <= tools::root_epsilon()) + return constants::pi() / 4; T x = 0; T t = k * k; @@ -174,5 +176,5 @@ inline typename tools::promote_args::type ellint_d(T1 k, T2 phi, const P }} // namespaces -#endif // BOOST_MATH_ELLINT_2_HPP +#endif // BOOST_MATH_ELLINT_D_HPP diff --git a/include/boost/math/special_functions/math_fwd.hpp b/include/boost/math/special_functions/math_fwd.hpp index a350e44dc..d9586fa2d 100644 --- a/include/boost/math/special_functions/math_fwd.hpp +++ b/include/boost/math/special_functions/math_fwd.hpp @@ -330,6 +330,15 @@ namespace boost template typename tools::promote_args::type ellint_1(T1 k, T2 phi, const Policy& pol); + template + typename tools::promote_args::type ellint_d(T k); + + template + typename tools::promote_args::type ellint_d(T1 k, T2 phi); + + template + typename tools::promote_args::type ellint_d(T1 k, T2 phi, const Policy& pol); + namespace detail{ template @@ -1167,6 +1176,12 @@ namespace boost \ template \ inline typename boost::math::tools::promote_args::type ellint_2(T1 k, T2 phi){ return boost::math::ellint_2(k, phi, Policy()); }\ +\ + template \ + inline typename boost::math::tools::promote_args::type ellint_d(T k){ return boost::math::ellint_d(k, Policy()); }\ +\ + template \ + inline typename boost::math::tools::promote_args::type ellint_d(T1 k, T2 phi){ return boost::math::ellint_d(k, phi, Policy()); }\ \ template \ inline typename boost::math::tools::promote_args::type ellint_1(T k){ return boost::math::ellint_1(k, Policy()); }\ diff --git a/test/compile_test/instantiate.hpp b/test/compile_test/instantiate.hpp index 2b77707d0..c008b556c 100644 --- a/test/compile_test/instantiate.hpp +++ b/test/compile_test/instantiate.hpp @@ -239,6 +239,7 @@ void instantiate(RealType) boost::math::ellint_2(v1, v2); boost::math::ellint_3(v1, v2); boost::math::ellint_3(v1, v2, v3); + boost::math::ellint_d(v1); boost::math::ellint_rc(v1, v2); boost::math::ellint_rd(v1, v2, v3); boost::math::ellint_rf(v1, v2, v3); @@ -432,6 +433,8 @@ void instantiate(RealType) boost::math::ellint_rf(v1 * 1, v2 + 0, v3 / 1); boost::math::ellint_rg(v1 * 1, v2 + 0, v3 / 1); boost::math::ellint_rj(v1 * 1, v2 + 0, v3 / 1, v1 * 1); + boost::math::ellint_d(v1 * 1); + boost::math::ellint_d(v1 * 1, v2 + 0); boost::math::jacobi_elliptic(v1 * 1, v2 + 0, &v1, &v2); boost::math::jacobi_cd(v1 * 1, v2 + 0); boost::math::jacobi_cn(v1 * 1, v2 + 0); @@ -595,6 +598,8 @@ void instantiate(RealType) boost::math::ellint_2(v1, v2, pol); boost::math::ellint_3(v1, v2, pol); boost::math::ellint_3(v1, v2, v3, pol); + boost::math::ellint_d(v1, pol); + boost::math::ellint_d(v1, v2, pol); boost::math::ellint_rc(v1, v2, pol); boost::math::ellint_rd(v1, v2, v3, pol); boost::math::ellint_rf(v1, v2, v3, pol); @@ -785,6 +790,8 @@ void instantiate(RealType) test::ellint_2(v1, v2); test::ellint_3(v1, v2); test::ellint_3(v1, v2, v3); + test::ellint_d(v1); + test::ellint_d(v1, v2); test::ellint_rc(v1, v2); test::ellint_rd(v1, v2, v3); test::ellint_rf(v1, v2, v3); @@ -991,6 +998,9 @@ void instantiate_mixed(RealType) boost::math::ellint_3(fr, lr); boost::math::ellint_3(s, l, i); boost::math::ellint_3(fr, dr, lr); + boost::math::ellint_d(i); + boost::math::ellint_d(i, l); + boost::math::ellint_d(fr, lr); boost::math::ellint_rc(i, s); boost::math::ellint_rc(fr, lr); boost::math::ellint_rd(s, i, l); @@ -1132,6 +1142,9 @@ void instantiate_mixed(RealType) boost::math::ellint_3(fr, lr, pol); boost::math::ellint_3(s, l, i, pol); boost::math::ellint_3(fr, dr, lr, pol); + boost::math::ellint_d(i, pol); + boost::math::ellint_d(i, l, pol); + boost::math::ellint_d(fr, lr, pol); boost::math::ellint_rc(i, s, pol); boost::math::ellint_rc(fr, lr, pol); boost::math::ellint_rd(s, i, l, pol); @@ -1276,6 +1289,9 @@ void instantiate_mixed(RealType) test::ellint_3(fr, lr); test::ellint_3(s, l, i); test::ellint_3(fr, dr, lr); + test::ellint_d(i); + test::ellint_d(i, l); + test::ellint_d(fr, lr); test::ellint_rc(i, s); test::ellint_rc(fr, lr); test::ellint_rd(s, i, l); diff --git a/test/compile_test/sf_ellint_d_incl_test.cpp b/test/compile_test/sf_ellint_d_incl_test.cpp new file mode 100644 index 000000000..c7c4249a5 --- /dev/null +++ b/test/compile_test/sf_ellint_d_incl_test.cpp @@ -0,0 +1,29 @@ +// Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Basic sanity check that header +// #includes all the files that it needs to. +// +#include +// +// Note this header includes no other headers, this is +// important if this test is to be meaningful: +// +#include "test_compile_result.hpp" + +void compile_and_link_test() +{ + check_result(boost::math::ellint_d(f, f)); + check_result(boost::math::ellint_d(d, d)); +#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS + check_result(boost::math::ellint_d(l, l)); +#endif + + check_result(boost::math::ellint_d(f)); + check_result(boost::math::ellint_d(d)); +#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS + check_result(boost::math::ellint_d(l)); +#endif +} diff --git a/test/test_ellint_d.hpp b/test/test_ellint_d.hpp index a31b11ee0..88e7ac193 100644 --- a/test/test_ellint_d.hpp +++ b/test/test_ellint_d.hpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include "functor.hpp" @@ -96,9 +95,10 @@ void test_spots(T, const char* type_name) // Function values calculated on http://functions.wolfram.com/ // Note that Mathematica's EllipticE accepts k^2 as the second parameter. - static const boost::array, 2> data2 = {{ + static const boost::array, 3> data2 = {{ { { SC_(0.5), SC_(0.87315258189267554964563356323264341) } }, { { SC_(1.0) / 1024, SC_(0.78539844427788694671464428063604776) } }, + { { boost::math::tools::root_epsilon(), SC_(0.78539816339744830961566084581987572) } } }}; do_test_ellint_d1(data2, type_name, "Elliptic Integral E: Mathworld Data"); diff --git a/test/test_instances/double_test_instances_4.cpp b/test/test_instances/double_test_instances_4.cpp index 437bb5bdb..f78783d92 100644 --- a/test/test_instances/double_test_instances_4.cpp +++ b/test/test_instances/double_test_instances_4.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/test/test_instances/float_test_instances_4.cpp b/test/test_instances/float_test_instances_4.cpp index 0be679981..3dd89365d 100644 --- a/test/test_instances/float_test_instances_4.cpp +++ b/test/test_instances/float_test_instances_4.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/test/test_instances/ldouble_test_instances_4.cpp b/test/test_instances/ldouble_test_instances_4.cpp index 5d2fc9ad2..e95c06bd8 100644 --- a/test/test_instances/ldouble_test_instances_4.cpp +++ b/test/test_instances/ldouble_test_instances_4.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/test/test_instances/real_concept_test_instances_4.cpp b/test/test_instances/real_concept_test_instances_4.cpp index 36dbd7e0d..b6b66b025 100644 --- a/test/test_instances/real_concept_test_instances_4.cpp +++ b/test/test_instances/real_concept_test_instances_4.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/test/test_instances/test_instances.hpp b/test/test_instances/test_instances.hpp index 58dec8d91..138231193 100644 --- a/test/test_instances/test_instances.hpp +++ b/test/test_instances/test_instances.hpp @@ -218,6 +218,12 @@ namespace boost{ namespace math{ template tools::promote_args::type ellint_2(BOOST_MATH_TEST_TYPE k, BOOST_MATH_TEST_TYPE phi, const policies::policy<>& pol); + template tools::promote_args::type ellint_d(BOOST_MATH_TEST_TYPE k); + + template tools::promote_args::type ellint_d(BOOST_MATH_TEST_TYPE k, BOOST_MATH_TEST_TYPE phi); + + template tools::promote_args::type ellint_d(BOOST_MATH_TEST_TYPE k, BOOST_MATH_TEST_TYPE phi, const policies::policy<>& pol); + template tools::promote_args::type ellint_1(BOOST_MATH_TEST_TYPE k); template tools::promote_args::type ellint_1(BOOST_MATH_TEST_TYPE k, BOOST_MATH_TEST_TYPE phi);