$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r82689 - in trunk: boost/math/special_functions libs/math/test/compile_test
From: john_at_[hidden]
Date: 2013-02-06 20:24:14
Author: johnmaddock
Date: 2013-02-02 12:32:50 EST (Sat, 02 Feb 2013)
New Revision: 82689
URL: http://svn.boost.org/trac/boost/changeset/82689
Log:
Tweak airy zero interfaces.
Change output_iterator template param to OutputIterator.
Change iterator based functions to return iterator result.
Text files modified: 
   trunk/boost/math/special_functions/airy.hpp       |   148 ++++++++++++++++++++++----------------- 
   trunk/boost/math/special_functions/bessel.hpp     |    26 +++---                                  
   trunk/boost/math/special_functions/math_fwd.hpp   |    78 ++++++++++++++------                    
   trunk/libs/math/test/compile_test/instantiate.hpp |    26 +++++-                                  
   4 files changed, 173 insertions(+), 105 deletions(-)
Modified: trunk/boost/math/special_functions/airy.hpp
==============================================================================
--- trunk/boost/math/special_functions/airy.hpp	(original)
+++ trunk/boost/math/special_functions/airy.hpp	2013-02-02 12:32:50 EST (Sat, 02 Feb 2013)
@@ -153,13 +153,11 @@
    }
 }
 
-template <class T>
-T airy_ai_zero_imp(T dummy, unsigned m)
+template <class T, class Policy>
+T airy_ai_zero_imp(unsigned m, const Policy& pol)
 {
    BOOST_MATH_STD_USING // ADL of std names, needed for log, sqrt.
 
-   static_cast<void>(dummy);
-
    // Handle cases when the zero'th zero is requested.
    // Return NaN if NaN is available or return 0 if NaN is not available.
    if(m == 0U)
@@ -188,7 +186,7 @@
    // Perform the root-finding using Newton-Raphson iteration from Boost.Math.
    const T am =
       boost::math::tools::newton_raphson_iterate(
-         boost::math::detail::airy_zero::airy_ai_zero_detail::function_object<T, policies::policy<> >(policies::policy<>()),
+         boost::math::detail::airy_zero::airy_ai_zero_detail::function_object<T, Policy>(pol),
          guess_root,
          T(guess_root - tolerance),
          T(guess_root + tolerance),
@@ -200,28 +198,11 @@
    return am;
 }
 
-template <class output_iterator, class T>
-void airy_ai_zero_imp(T dummy,
-                      unsigned number_of_zeros,
-                      unsigned start_index,
-                      output_iterator out_it)
-{
-   static_cast<void>(dummy);
-
-   for(unsigned i = 0; i < number_of_zeros; ++i)
-   {
-      *out_it = boost::math::detail::airy_ai_zero_imp<T>(T(), start_index + i);
-      ++out_it;
-   }
-}
-
-template <class T>
-T airy_bi_zero_imp(T dummy, unsigned m)
+template <class T, class Policy>
+T airy_bi_zero_imp(unsigned m, const Policy& pol)
 {
    BOOST_MATH_STD_USING // ADL of std names, needed for log, sqrt.
 
-   static_cast<void>(dummy);
-
    // Handle cases when the zero'th zero is requested.
    // Return NaN if NaN is available or return 0 if NaN is not available.
    if(m == 0U)
@@ -251,7 +232,7 @@
    // Perform the root-finding using Newton-Raphson iteration from Boost.Math.
    const T bm =
       boost::math::tools::newton_raphson_iterate(
-         boost::math::detail::airy_zero::airy_bi_zero_detail::function_object<T, policies::policy<> >(policies::policy<>()),
+         boost::math::detail::airy_zero::airy_bi_zero_detail::function_object<T, Policy>(pol),
          guess_root,
          T(guess_root - tolerance),
          T(guess_root + tolerance),
@@ -263,21 +244,6 @@
    return bm;
 }
 
-template <class output_iterator, class T>
-void airy_bi_zero_imp(T dummy,
-                      unsigned number_of_zeros,
-                      unsigned start_index,
-                      output_iterator out_it)
-{
-   static_cast<void>(dummy);
-
-   for(unsigned i = 0; i < number_of_zeros; ++i)
-   {
-      *out_it = boost::math::detail::airy_bi_zero_imp<T>(T(), start_index + i);
-      ++out_it;
-   }
-}
-
 } // namespace detail
 
 template <class T, class Policy>
@@ -368,48 +334,100 @@
    return airy_bi_prime(x, policies::policy<>());
 }
 
-template <class T>
-inline typename tools::promote_args<T>::type airy_ai_zero(T dummy, unsigned m)
+template <class T, class Policy>
+inline T airy_ai_zero(unsigned m, const Policy& pol)
 {
    BOOST_FPU_EXCEPTION_GUARD
-   typedef typename tools::promote_args<T>::type result_type;
-   BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<result_type>::is_integer, "Airy dummy parameter must be a floating-point type.");
-   return policies::checked_narrowing_cast<result_type, policies::policy<> >(detail::airy_ai_zero_imp<result_type>(dummy, m), "boost::math::airy_ai_zero<%1%>(%1%)");
+   typedef typename policies::evaluation<T, Policy>::type value_type;
+   typedef typename policies::normalise<
+      Policy, 
+      policies::promote_float<false>, 
+      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.");
+   return policies::checked_narrowing_cast<T, Policy>(detail::airy_ai_zero_imp<T>(m, pol), "boost::math::airy_ai_zero<%1%>(unsigned)");
+}
+
+template <class T>
+inline T airy_ai_zero(unsigned m)
+{
+   return airy_ai_zero<T>(m, policies::policy<>());
 }
 
-template <class output_iterator, class T>
-inline void airy_ai_zero(T dummy,
+template <class T, class OutputIterator, class Policy>
+inline OutputIterator airy_ai_zero(
                          unsigned number_of_zeros,
                          unsigned start_index,
-                         output_iterator out_it)
+                         OutputIterator out_it,
+                         const Policy& pol)
+{
+   typedef T result_type;
+   BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<result_type>::is_integer, "Airy output type must be a floating-point type.");
+
+   for(unsigned i = 0; i < number_of_zeros; ++i)
+   {
+      *out_it = boost::math::airy_ai_zero<result_type>(start_index + i, pol);
+      ++out_it;
+   }
+   return out_it;
+}
+
+template <class T, class OutputIterator>
+inline OutputIterator airy_ai_zero(
+                         unsigned number_of_zeros,
+                         unsigned start_index,
+                         OutputIterator out_it)
+{
+   return airy_ai_zero<T>(number_of_zeros, start_index, out_it, policies::policy<>());
+}
+
+template <class T, class Policy>
+inline T airy_bi_zero(unsigned m, const Policy& pol)
 {
    BOOST_FPU_EXCEPTION_GUARD
-   static_cast<void>(dummy);
-   typedef typename tools::promote_args<T>::type result_type;
-   BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<result_type>::is_integer, "Airy dummy parameter must be a floating-point type.");
-   boost::math::detail::airy_ai_zero_imp<output_iterator, result_type>(result_type(), number_of_zeros, start_index, out_it);
+   typedef typename policies::evaluation<T, Policy>::type value_type;
+   typedef typename policies::normalise<
+      Policy, 
+      policies::promote_float<false>, 
+      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.");
+   return policies::checked_narrowing_cast<T, Policy>(detail::airy_bi_zero_imp<T>(m, pol), "boost::math::airy_bi_zero<%1%>(unsigned)");
 }
 
 template <class T>
-inline typename tools::promote_args<T>::type airy_bi_zero(T dummy, unsigned m)
+inline T airy_bi_zero(unsigned m)
 {
-   BOOST_FPU_EXCEPTION_GUARD
-   typedef typename tools::promote_args<T>::type result_type;
-   BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<result_type>::is_integer, "Airy dummy parameter must be a floating-point type.");
-   return policies::checked_narrowing_cast<result_type, policies::policy<> >(detail::airy_bi_zero_imp<result_type>(result_type(), m), "boost::math::airy_bi_zero<%1%>(%1%)");
+   return airy_bi_zero<T>(m, policies::policy<>());
 }
 
-template <class output_iterator, class T>
-inline void airy_bi_zero(T dummy,
+template <class T, class OutputIterator, class Policy>
+inline OutputIterator airy_bi_zero(
                          unsigned number_of_zeros,
                          unsigned start_index,
-                         output_iterator out_it)
+                         OutputIterator out_it,
+                         const Policy& pol)
 {
-   BOOST_FPU_EXCEPTION_GUARD
-   static_cast<void>(dummy);
-   typedef typename tools::promote_args<T>::type result_type;
-   BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<result_type>::is_integer, "Airy dummy parameter must be a floating-point type.");
-   boost::math::detail::airy_bi_zero_imp<output_iterator, result_type>(result_type(), number_of_zeros, start_index, out_it);
+   typedef T result_type;
+   BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<result_type>::is_integer, "Airy output type must be a floating-point type.");
+
+   for(unsigned i = 0; i < number_of_zeros; ++i)
+   {
+      *out_it = boost::math::airy_bi_zero<result_type>(start_index + i, pol);
+      ++out_it;
+   }
+   return out_it;
+}
+
+template <class T, class OutputIterator>
+inline OutputIterator airy_bi_zero(
+                         unsigned number_of_zeros,
+                         unsigned start_index,
+                         OutputIterator out_it)
+{
+   return airy_bi_zero<T>(number_of_zeros, start_index, out_it, policies::policy<>());
 }
 
 }} // namespaces
Modified: trunk/boost/math/special_functions/bessel.hpp
==============================================================================
--- trunk/boost/math/special_functions/bessel.hpp	(original)
+++ trunk/boost/math/special_functions/bessel.hpp	2013-02-02 12:32:50 EST (Sat, 02 Feb 2013)
@@ -555,11 +555,11 @@
    return cyl_bessel_j_zero<T, policies::policy<> >(v, m, policies::policy<>());
 }
 
-template <class output_iterator, class T, class Policy>
-inline void cyl_bessel_j_zero(T v,
+template <class T, class OutputIterator, class Policy>
+inline OutputIterator cyl_bessel_j_zero(T v,
                               unsigned number_of_zeros,
                               unsigned start_index,
-                              output_iterator out_it,
+                              OutputIterator out_it,
                               const Policy& pol)
 {
    BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<T>::is_integer, "Order must be a floating-point type.");
@@ -568,13 +568,14 @@
       *out_it = boost::math::cyl_bessel_j_zero(v, start_index + i, pol);
       ++out_it;
    }
+   return out_it;
 }
 
-template <class output_iterator, class T>
-inline void cyl_bessel_j_zero(T v,
+template <class T, class OutputIterator>
+inline OutputIterator cyl_bessel_j_zero(T v,
                               unsigned number_of_zeros,
                               unsigned start_index,
-                              output_iterator out_it)
+                              OutputIterator out_it)
 {
    return cyl_bessel_j_zero(v, number_of_zeros, start_index, out_it, policies::policy<>());
 }
@@ -596,11 +597,11 @@
    return cyl_neumann_zero<T, policies::policy<> >(v, m, policies::policy<>());
 }
 
-template <class output_iterator, class T, class Policy>
-inline void cyl_neumann_zero(T v,
+template <class T, class OutputIterator, class Policy>
+inline OutputIterator cyl_neumann_zero(T v,
                              unsigned number_of_zeros,
                              unsigned start_index,
-                             output_iterator out_it,
+                             OutputIterator out_it,
                              const Policy& pol)
 {
    BOOST_STATIC_ASSERT_MSG(false == std::numeric_limits<T>::is_integer, "Order must be a floating-point type.");
@@ -609,13 +610,14 @@
       *out_it = boost::math::cyl_neumann_zero(v, start_index + i, pol);
       ++out_it;
    }
+   return out_it;
 }
 
-template <class output_iterator, class T>
-inline void cyl_neumann_zero(T v,
+template <class T, class OutputIterator>
+inline OutputIterator cyl_neumann_zero(T v,
                              unsigned number_of_zeros,
                              unsigned start_index,
-                             output_iterator out_it)
+                             OutputIterator out_it)
 {
    return cyl_neumann_zero(v, number_of_zeros, start_index, out_it, policies::policy<>());
 }
Modified: trunk/boost/math/special_functions/math_fwd.hpp
==============================================================================
--- trunk/boost/math/special_functions/math_fwd.hpp	(original)
+++ trunk/boost/math/special_functions/math_fwd.hpp	2013-02-02 12:32:50 EST (Sat, 02 Feb 2013)
@@ -620,17 +620,17 @@
    template <class T>
    typename detail::bessel_traits<T, T, policies::policy<> >::result_type cyl_bessel_j_zero(T v, unsigned m);
 
-   template <class output_iterator, class T>
-   void cyl_bessel_j_zero(T v,
+   template <class T, class OutputIterator>
+   OutputIterator cyl_bessel_j_zero(T v,
                           unsigned number_of_zeros,
                           unsigned start_index,
-                          output_iterator out_it);
+                          OutputIterator out_it);
 
-   template <class output_iterator, class T, class Policy>
-   void cyl_bessel_j_zero(T v,
+   template <class T, class OutputIterator, class Policy>
+   OutputIterator cyl_bessel_j_zero(T v,
                           unsigned number_of_zeros,
                           unsigned start_index,
-                          output_iterator out_it,
+                          OutputIterator out_it,
                           const Policy&);
 
    template <class T, class Policy>
@@ -639,17 +639,17 @@
    template <class T>
    typename detail::bessel_traits<T, T, policies::policy<> >::result_type cyl_neumann_zero(T v, unsigned m);
 
-   template <class output_iterator, class T>
-   void cyl_neumann_zero(T v,
+   template <class T, class OutputIterator>
+   OutputIterator cyl_neumann_zero(T v,
                          unsigned number_of_zeros,
                          unsigned start_index,
-                         output_iterator out_it);
+                         OutputIterator out_it);
 
-   template <class output_iterator, class T, class Policy>
-   void cyl_neumann_zero(T v,
+   template <class T, class OutputIterator, class Policy>
+   OutputIterator cyl_neumann_zero(T v,
                          unsigned number_of_zeros,
                          unsigned start_index,
-                         output_iterator out_it,
+                         OutputIterator out_it,
                          const Policy&);
 
    template <class T1, class T2>
@@ -700,23 +700,39 @@
    template <class T>
    typename tools::promote_args<T>::type airy_bi_prime(T x);
 
+   template <class T>
+   T airy_ai_zero(unsigned m);
    template <class T, class Policy>
-   typename tools::promote_args<T>::type airy_ai_zero(T dummy, unsigned m);
+   T airy_ai_zero(unsigned m, const Policy&);
 
-   template <class output_iterator, class T>
-   void airy_ai_zero(T dummy,
+   template <class OutputIterator>
+   OutputIterator airy_ai_zero(
+                     unsigned number_of_zeros,
+                     unsigned start_index,
+                     OutputIterator out_it);
+   template <class OutputIterator, class Policy>
+   OutputIterator airy_ai_zero(
                      unsigned number_of_zeros,
                      unsigned start_index,
-                     output_iterator out_it);
+                     OutputIterator out_it,
+                     const Policy&);
 
+   template <class T>
+   T airy_bi_zero(unsigned m);
    template <class T, class Policy>
-   typename tools::promote_args<T>::type airy_bi_zero(T dummy, unsigned m);
+   T airy_bi_zero(unsigned m, const Policy&);
 
-   template <class output_iterator, class T>
-   void airy_bi_zero(T dummy,
+   template <class OutputIterator>
+   OutputIterator airy_bi_zero(
+                     unsigned number_of_zeros,
+                     unsigned start_index,
+                     OutputIterator out_it);
+   template <class OutputIterator, class Policy>
+   OutputIterator airy_bi_zero(
                      unsigned number_of_zeros,
                      unsigned start_index,
-                     output_iterator out_it);
+                     OutputIterator out_it,
+                     const Policy&);
 
    template <class T, class Policy>
    typename tools::promote_args<T>::type sin_pi(T x, const Policy&);
@@ -1202,22 +1218,22 @@
    inline typename boost::math::detail::bessel_traits<T, T, Policy >::result_type cyl_bessel_j_zero(T v, unsigned m)\
    { return boost::math::cyl_bessel_j_zero(v, m, Policy()); }\
 \
-template <class output_iterator, class T>\
+template <class OutputIterator, class T>\
    inline void cyl_bessel_j_zero(T v,\
                                  unsigned number_of_zeros,\
                                  unsigned start_index,\
-                                 output_iterator out_it)\
+                                 OutputIterator out_it)\
    { boost::math::cyl_bessel_j_zero(v, number_of_zeros, start_index, out_it, Policy()); }\
 \
    template <class T>\
    inline typename boost::math::detail::bessel_traits<T, T, Policy >::result_type cyl_neumann_zero(T v, unsigned m)\
    { return boost::math::cyl_neumann_zero(v, m, Policy()); }\
 \
-template <class output_iterator, class T>\
+template <class OutputIterator, class T>\
    inline void cyl_neumann_zero(T v,\
                                 unsigned number_of_zeros,\
                                 unsigned start_index,\
-                                output_iterator out_it)\
+                                OutputIterator out_it)\
    { boost::math::cyl_neumann_zero(v, number_of_zeros, start_index, out_it, Policy()); }\
 \
    template <class T>\
@@ -1368,6 +1384,20 @@
    inline typename boost::math::tools::promote_args<T>::type airy_bi_prime(T x)\
    {  return boost::math::airy_bi_prime(x, Policy());  }\
    \
+   template <class T>\
+   inline T airy_ai_zero(unsigned m)\
+   { return boost::math::airy_ai_zero<T>(m, Policy()); }\
+   template <class T, class OutputIterator>\
+   OutputIterator airy_ai_zero(unsigned number_of_zeros, unsigned start_index, OutputIterator out_it)\
+   { return boost::math::airy_ai_zero<T>(number_of_zeros, start_index, out_it, Policy()); }\
+   \
+   template <class T>\
+   inline T airy_bi_zero(unsigned m)\
+   { return boost::math::airy_bi_zero<T>(m, Policy()); }\
+   template <class T, class OutputIterator>\
+   OutputIterator airy_bi_zero(unsigned number_of_zeros, unsigned start_index, OutputIterator out_it)\
+   { return boost::math::airy_bi_zero<T>(number_of_zeros, start_index, out_it, Policy()); }\
+   \
 
 
 
Modified: trunk/libs/math/test/compile_test/instantiate.hpp
==============================================================================
--- trunk/libs/math/test/compile_test/instantiate.hpp	(original)
+++ trunk/libs/math/test/compile_test/instantiate.hpp	2013-02-02 12:32:50 EST (Sat, 02 Feb 2013)
@@ -287,6 +287,12 @@
    boost::math::airy_bi(v1);
    boost::math::airy_ai_prime(v1);
    boost::math::airy_bi_prime(v1);
+
+   boost::math::airy_ai_zero<RealType>(i);
+   boost::math::airy_bi_zero<RealType>(i);
+   boost::math::airy_ai_zero<RealType>(i, i, oi);
+   boost::math::airy_bi_zero<RealType>(i, i, oi);
+
    boost::math::expint(v1);
    boost::math::expint(i);
    boost::math::expint(i, v2);
@@ -599,6 +605,12 @@
    boost::math::airy_bi(v1, pol);
    boost::math::airy_ai_prime(v1, pol);
    boost::math::airy_bi_prime(v1, pol);
+
+   boost::math::airy_ai_zero<RealType>(i, pol);
+   boost::math::airy_bi_zero<RealType>(i, pol);
+   boost::math::airy_ai_zero<RealType>(i, i, oi, pol);
+   boost::math::airy_bi_zero<RealType>(i, i, oi, pol);
+
    boost::math::expint(v1, pol);
    boost::math::expint(i, pol);
    boost::math::expint(i, v2, pol);
@@ -758,10 +770,16 @@
    test::sph_hankel_2(v1, v2);
    test::sph_hankel_2(i, v2);
 #endif
-   boost::math::airy_ai(i);
-   boost::math::airy_bi(i);
-   boost::math::airy_ai_prime(i);
-   boost::math::airy_bi_prime(i);
+   test::airy_ai(i);
+   test::airy_bi(i);
+   test::airy_ai_prime(i);
+   test::airy_bi_prime(i);
+
+   test::airy_ai_zero<RealType>(i);
+   test::airy_bi_zero<RealType>(i);
+   test::airy_ai_zero<RealType>(i, i, oi);
+   test::airy_bi_zero<RealType>(i, i, oi);
+
    test::expint(v1);
    test::expint(i);
    test::expint(i, v2);