Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:40:14

0001 
0002 //  (C) Copyright John Maddock 2006.
0003 //  Use, modification and distribution are subject to the
0004 //  Boost Software License, Version 1.0. (See accompanying file
0005 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef BOOST_MATH_SPECIAL_HERMITE_HPP
0008 #define BOOST_MATH_SPECIAL_HERMITE_HPP
0009 
0010 #ifdef _MSC_VER
0011 #pragma once
0012 #endif
0013 
0014 #include <boost/math/special_functions/math_fwd.hpp>
0015 #include <boost/math/tools/config.hpp>
0016 #include <boost/math/policies/error_handling.hpp>
0017 
0018 namespace boost{
0019 namespace math{
0020 
0021 // Recurrence relation for Hermite polynomials:
0022 template <class T1, class T2, class T3>
0023 inline typename tools::promote_args<T1, T2, T3>::type 
0024    hermite_next(unsigned n, T1 x, T2 Hn, T3 Hnm1)
0025 {
0026    using promoted_type = tools::promote_args_t<T1, T2, T3>;
0027    return (2 * promoted_type(x) * promoted_type(Hn) - 2 * n * promoted_type(Hnm1));
0028 }
0029 
0030 namespace detail{
0031 
0032 // Implement Hermite polynomials via recurrence:
0033 template <class T>
0034 T hermite_imp(unsigned n, T x)
0035 {
0036    T p0 = 1;
0037    T p1 = 2 * x;
0038 
0039    if(n == 0)
0040       return p0;
0041 
0042    unsigned c = 1;
0043 
0044    while(c < n)
0045    {
0046       std::swap(p0, p1);
0047       p1 = static_cast<T>(hermite_next(c, x, p0, p1));
0048       ++c;
0049    }
0050    return p1;
0051 }
0052 
0053 } // namespace detail
0054 
0055 template <class T, class Policy>
0056 inline typename tools::promote_args<T>::type 
0057    hermite(unsigned n, T x, const Policy&)
0058 {
0059    typedef typename tools::promote_args<T>::type result_type;
0060    typedef typename policies::evaluation<result_type, Policy>::type value_type;
0061    return policies::checked_narrowing_cast<result_type, Policy>(detail::hermite_imp(n, static_cast<value_type>(x)), "boost::math::hermite<%1%>(unsigned, %1%)");
0062 }
0063 
0064 template <class T>
0065 inline typename tools::promote_args<T>::type 
0066    hermite(unsigned n, T x)
0067 {
0068    return boost::math::hermite(n, x, policies::policy<>());
0069 }
0070 
0071 } // namespace math
0072 } // namespace boost
0073 
0074 #endif // BOOST_MATH_SPECIAL_HERMITE_HPP
0075 
0076 
0077