Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/math/special_functions/hermite.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
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 | |
18 namespace boost{ | |
19 namespace math{ | |
20 | |
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) | |
25 { | |
26 return (2 * x * Hn - 2 * n * Hnm1); | |
27 } | |
28 | |
29 namespace detail{ | |
30 | |
31 // Implement Hermite polynomials via recurrance: | |
32 template <class T> | |
33 T 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 | |
54 template <class T, class Policy> | |
55 inline 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 | |
63 template <class T> | |
64 inline 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 |