2 // (C) Copyright John Maddock 2006.
3 // Use, modification and distribution are subject to the
4 // Boost Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_MATH_SPECIAL_HERMITE_HPP
8 #define BOOST_MATH_SPECIAL_HERMITE_HPP
14 #include <boost/math/special_functions/math_fwd.hpp>
15 #include <boost/math/tools/config.hpp>
16 #include <boost/math/policies/error_handling.hpp>
21 // Recurrance relation for Hermite polynomials:
22 template <class T1, class T2, class T3>
23 inline typename tools::promote_args<T1, T2, T3>::type
24 hermite_next(unsigned n, T1 x, T2 Hn, T3 Hnm1)
26 return (2 * x * Hn - 2 * n * Hnm1);
31 // Implement Hermite polynomials via recurrance:
33 T hermite_imp(unsigned n, T x)
46 p1 = hermite_next(c, x, p0, p1);
54 template <class T, class Policy>
55 inline typename tools::promote_args<T>::type
56 hermite(unsigned n, T x, const Policy&)
58 typedef typename tools::promote_args<T>::type result_type;
59 typedef typename policies::evaluation<result_type, Policy>::type value_type;
60 return policies::checked_narrowing_cast<result_type, Policy>(detail::hermite_imp(n, static_cast<value_type>(x)), "boost::math::hermite<%1%>(unsigned, %1%)");
64 inline typename tools::promote_args<T>::type
65 hermite(unsigned n, T x)
67 return boost::math::hermite(n, x, policies::policy<>());
73 #endif // BOOST_MATH_SPECIAL_HERMITE_HPP