]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/math/include/boost/math/special_functions/hermite.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / math / include / boost / math / special_functions / hermite.hpp
CommitLineData
7c673cae
FG
1
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)
6
7#ifndef BOOST_MATH_SPECIAL_HERMITE_HPP
8#define BOOST_MATH_SPECIAL_HERMITE_HPP
9
10#ifdef _MSC_VER
11#pragma once
12#endif
13
14#include <boost/math/special_functions/math_fwd.hpp>
15#include <boost/math/tools/config.hpp>
16#include <boost/math/policies/error_handling.hpp>
17
18namespace boost{
19namespace math{
20
21// Recurrance relation for Hermite polynomials:
22template <class T1, class T2, class T3>
23inline typename tools::promote_args<T1, T2, T3>::type
24 hermite_next(unsigned n, T1 x, T2 Hn, T3 Hnm1)
25{
26 return (2 * x * Hn - 2 * n * Hnm1);
27}
28
29namespace detail{
30
31// Implement Hermite polynomials via recurrance:
32template <class T>
33T hermite_imp(unsigned n, T x)
34{
35 T p0 = 1;
36 T p1 = 2 * x;
37
38 if(n == 0)
39 return p0;
40
41 unsigned c = 1;
42
43 while(c < n)
44 {
45 std::swap(p0, p1);
46 p1 = hermite_next(c, x, p0, p1);
47 ++c;
48 }
49 return p1;
50}
51
52} // namespace detail
53
54template <class T, class Policy>
55inline typename tools::promote_args<T>::type
56 hermite(unsigned n, T x, const Policy&)
57{
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%)");
61}
62
63template <class T>
64inline typename tools::promote_args<T>::type
65 hermite(unsigned n, T x)
66{
67 return boost::math::hermite(n, x, policies::policy<>());
68}
69
70} // namespace math
71} // namespace boost
72
73#endif // BOOST_MATH_SPECIAL_HERMITE_HPP
74
75
76