File indexing completed on 2025-09-17 08:36:13
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_MATH_SPECIAL_HERMITE_HPP
0009 #define BOOST_MATH_SPECIAL_HERMITE_HPP
0010
0011 #ifdef _MSC_VER
0012 #pragma once
0013 #endif
0014
0015 #include <boost/math/tools/config.hpp>
0016 #include <boost/math/tools/promotion.hpp>
0017 #include <boost/math/special_functions/math_fwd.hpp>
0018 #include <boost/math/policies/error_handling.hpp>
0019
0020 namespace boost{
0021 namespace math{
0022
0023
0024 template <class T1, class T2, class T3>
0025 BOOST_MATH_GPU_ENABLED inline typename tools::promote_args<T1, T2, T3>::type
0026 hermite_next(unsigned n, T1 x, T2 Hn, T3 Hnm1)
0027 {
0028 using promoted_type = tools::promote_args_t<T1, T2, T3>;
0029 return (2 * promoted_type(x) * promoted_type(Hn) - 2 * n * promoted_type(Hnm1));
0030 }
0031
0032 namespace detail{
0033
0034
0035 template <class T>
0036 BOOST_MATH_GPU_ENABLED T hermite_imp(unsigned n, T x)
0037 {
0038 T p0 = 1;
0039 T p1 = 2 * x;
0040
0041 if(n == 0)
0042 return p0;
0043
0044 unsigned c = 1;
0045
0046 while(c < n)
0047 {
0048 BOOST_MATH_GPU_SAFE_SWAP(p0, p1);
0049 p1 = static_cast<T>(hermite_next(c, x, p0, p1));
0050 ++c;
0051 }
0052 return p1;
0053 }
0054
0055 }
0056
0057 template <class T, class Policy>
0058 BOOST_MATH_GPU_ENABLED inline typename tools::promote_args<T>::type
0059 hermite(unsigned n, T x, const Policy&)
0060 {
0061 typedef typename tools::promote_args<T>::type result_type;
0062 typedef typename policies::evaluation<result_type, Policy>::type value_type;
0063 return policies::checked_narrowing_cast<result_type, Policy>(detail::hermite_imp(n, static_cast<value_type>(x)), "boost::math::hermite<%1%>(unsigned, %1%)");
0064 }
0065
0066 template <class T>
0067 BOOST_MATH_GPU_ENABLED inline typename tools::promote_args<T>::type
0068 hermite(unsigned n, T x)
0069 {
0070 return boost::math::hermite(n, x, policies::policy<>());
0071 }
0072
0073 }
0074 }
0075
0076 #endif
0077
0078
0079