2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-28 07:22:12 +00:00

In Bessel / Airy zeros, reliance on numeric_limits for non-specialized types corrected.

This commit is contained in:
Christopher Kormanyos
2014-01-29 22:38:13 +01:00
parent eee4394266
commit ca054f9e78
2 changed files with 56 additions and 10 deletions

View File

@@ -7,6 +7,7 @@
#ifndef BOOST_MATH_AIRY_HPP
#define BOOST_MATH_AIRY_HPP
#include <limits>
#include <boost/math/special_functions/bessel.hpp>
#include <boost/math/special_functions/cbrt.hpp>
#include <boost/math/special_functions/detail/airy_ai_bi_zero.hpp>
@@ -359,7 +360,12 @@ inline T airy_ai_zero(int m, const Policy& /*pol*/)
policies::promote_double<false>,
policies::discrete_quantile<>,
policies::assert_undefined<> >::type forwarding_policy;
BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<T>::is_integer, "Airy return type must be a floating-point type.");
BOOST_STATIC_ASSERT_MSG( false == std::numeric_limits<T>::is_specialized
|| ( true == std::numeric_limits<T>::is_specialized
&& false == std::numeric_limits<T>::is_integer),
"Airy value type must be a floating-point type.");
return policies::checked_narrowing_cast<T, Policy>(detail::airy_ai_zero_imp<value_type>(m, forwarding_policy()), "boost::math::airy_ai_zero<%1%>(unsigned)");
}
@@ -377,7 +383,11 @@ inline OutputIterator airy_ai_zero(
const Policy& pol)
{
typedef T result_type;
BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<result_type>::is_integer, "Airy return type must be a floating-point type.");
BOOST_STATIC_ASSERT_MSG( false == std::numeric_limits<T>::is_specialized
|| ( true == std::numeric_limits<T>::is_specialized
&& false == std::numeric_limits<T>::is_integer),
"Airy value type must be a floating-point type.");
for(unsigned i = 0; i < static_cast<int>(number_of_zeros); ++i)
{
@@ -407,7 +417,12 @@ inline T airy_bi_zero(int m, const Policy& /*pol*/)
policies::promote_double<false>,
policies::discrete_quantile<>,
policies::assert_undefined<> >::type forwarding_policy;
BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<T>::is_integer, "Airy return type must be a floating-point type.");
BOOST_STATIC_ASSERT_MSG( false == std::numeric_limits<T>::is_specialized
|| ( true == std::numeric_limits<T>::is_specialized
&& false == std::numeric_limits<T>::is_integer),
"Airy value type must be a floating-point type.");
return policies::checked_narrowing_cast<T, Policy>(detail::airy_bi_zero_imp<value_type>(m, forwarding_policy()), "boost::math::airy_bi_zero<%1%>(unsigned)");
}
@@ -425,7 +440,11 @@ inline OutputIterator airy_bi_zero(
const Policy& pol)
{
typedef T result_type;
BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<result_type>::is_integer, "Airy return type must be a floating-point type.");
BOOST_STATIC_ASSERT_MSG( false == std::numeric_limits<T>::is_specialized
|| ( true == std::numeric_limits<T>::is_specialized
&& false == std::numeric_limits<T>::is_integer),
"Airy value type must be a floating-point type.");
for(int i = 0; i < static_cast<int>(number_of_zeros); ++i)
{

View File

@@ -15,6 +15,7 @@
# pragma once
#endif
#include <limits>
#include <boost/math/special_functions/detail/bessel_jy.hpp>
#include <boost/math/special_functions/detail/bessel_jn.hpp>
#include <boost/math/special_functions/detail/bessel_yn.hpp>
@@ -666,14 +667,23 @@ inline typename detail::bessel_traits<T, T, Policy>::result_type cyl_bessel_j_ze
policies::promote_double<false>,
policies::discrete_quantile<>,
policies::assert_undefined<> >::type forwarding_policy;
BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<value_type>::is_integer, "Order must be a floating-point type.");
BOOST_STATIC_ASSERT_MSG( false == std::numeric_limits<T>::is_specialized
|| ( true == std::numeric_limits<T>::is_specialized
&& false == std::numeric_limits<T>::is_integer),
"Order must be a floating-point type.");
return policies::checked_narrowing_cast<result_type, Policy>(detail::cyl_bessel_j_zero_imp<value_type>(v, m, forwarding_policy()), "boost::math::cyl_bessel_j_zero<%1%>(%1%,%1%)");
}
template <class T>
inline typename detail::bessel_traits<T, T, policies::policy<> >::result_type cyl_bessel_j_zero(T v, int m)
{
BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<T>::is_integer, "Order must be a floating-point type.");
BOOST_STATIC_ASSERT_MSG( false == std::numeric_limits<T>::is_specialized
|| ( true == std::numeric_limits<T>::is_specialized
&& false == std::numeric_limits<T>::is_integer),
"Order must be a floating-point type.");
return cyl_bessel_j_zero<T, policies::policy<> >(v, m, policies::policy<>());
}
@@ -684,7 +694,11 @@ inline OutputIterator cyl_bessel_j_zero(T v,
OutputIterator out_it,
const Policy& pol)
{
BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<T>::is_integer, "Order must be a floating-point type.");
BOOST_STATIC_ASSERT_MSG( false == std::numeric_limits<T>::is_specialized
|| ( true == std::numeric_limits<T>::is_specialized
&& false == std::numeric_limits<T>::is_integer),
"Order must be a floating-point type.");
for(int i = 0; i < static_cast<int>(number_of_zeros); ++i)
{
*out_it = boost::math::cyl_bessel_j_zero(v, start_index + i, pol);
@@ -714,14 +728,23 @@ inline typename detail::bessel_traits<T, T, Policy>::result_type cyl_neumann_zer
policies::promote_double<false>,
policies::discrete_quantile<>,
policies::assert_undefined<> >::type forwarding_policy;
BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<value_type>::is_integer, "Order must be a floating-point type.");
BOOST_STATIC_ASSERT_MSG( false == std::numeric_limits<T>::is_specialized
|| ( true == std::numeric_limits<T>::is_specialized
&& false == std::numeric_limits<T>::is_integer),
"Order must be a floating-point type.");
return policies::checked_narrowing_cast<result_type, Policy>(detail::cyl_neumann_zero_imp<value_type>(v, m, forwarding_policy()), "boost::math::cyl_neumann_zero<%1%>(%1%,%1%)");
}
template <class T>
inline typename detail::bessel_traits<T, T, policies::policy<> >::result_type cyl_neumann_zero(T v, int m)
{
BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<T>::is_integer, "Order must be a floating-point type.");
BOOST_STATIC_ASSERT_MSG( false == std::numeric_limits<T>::is_specialized
|| ( true == std::numeric_limits<T>::is_specialized
&& false == std::numeric_limits<T>::is_integer),
"Order must be a floating-point type.");
return cyl_neumann_zero<T, policies::policy<> >(v, m, policies::policy<>());
}
@@ -732,7 +755,11 @@ inline OutputIterator cyl_neumann_zero(T v,
OutputIterator out_it,
const Policy& pol)
{
BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<T>::is_integer, "Order must be a floating-point type.");
BOOST_STATIC_ASSERT_MSG( false == std::numeric_limits<T>::is_specialized
|| ( true == std::numeric_limits<T>::is_specialized
&& false == std::numeric_limits<T>::is_integer),
"Order must be a floating-point type.");
for(int i = 0; i < static_cast<int>(number_of_zeros); ++i)
{
*out_it = boost::math::cyl_neumann_zero(v, start_index + i, pol);