// (C) 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) #ifndef BOOST_MATH_SPECIAL_HERMITE_HPP #define BOOST_MATH_SPECIAL_HERMITE_HPP #ifdef _MSC_VER #pragma once #endif #include #include #include namespace boost{ namespace math{ // Recurrance relation for Hermite polynomials: template inline typename tools::promote_args::type hermite_next(unsigned n, T1 x, T2 Hn, T3 Hnm1) { return (2 * x * Hn - 2 * n * Hnm1); } namespace detail{ // Implement Hermite polynomials via recurrance: template T hermite_imp(unsigned n, T x) { T p0 = 1; T p1 = 2 * x; if(n == 0) return p0; unsigned c = 1; while(c < n) { std::swap(p0, p1); p1 = hermite_next(c, x, p0, p1); ++c; } return p1; } } // namespace detail template inline typename tools::promote_args::type hermite(unsigned n, T x, const Policy&) { typedef typename tools::promote_args::type result_type; typedef typename policies::evaluation::type value_type; return policies::checked_narrowing_cast(detail::hermite_imp(n, static_cast(x)), "boost::math::hermite<%1%>(unsigned, %1%)"); } template inline typename tools::promote_args::type hermite(unsigned n, T x) { return boost::math::hermite(n, x, policies::policy<>()); } } // namespace math } // namespace boost #endif // BOOST_MATH_SPECIAL_HERMITE_HPP