STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions
poly_hermite.tcc File Reference

Macros

#define _GLIBCXX_TR1_POLY_HERMITE_TCC   1
 

Functions

namespace std _GLIBCXX_VISIBILITY (default)
 

Detailed Description

This is an internal header file, included by other library headers. Do not attempt to use it directly. {tr1/cmath}

Macro Definition Documentation

#define _GLIBCXX_TR1_POLY_HERMITE_TCC   1

Function Documentation

namespace std _GLIBCXX_VISIBILITY ( default  )

This routine returns the Hermite polynomial of order n: $ H_n(x) $ by recursion on n.

The Hermite polynomial is defined by:

\[ H_n(x) = (-1)^n e^{x^2} \frac{d^n}{dx^n} e^{-x^2} \]

Parameters
__nThe order of the Hermite polynomial.
__xThe argument of the Hermite polynomial.
Returns
The value of the Hermite polynomial of order n and argument x.

This routine returns the Hermite polynomial of order n: $ H_n(x) $.

The Hermite polynomial is defined by:

\[ H_n(x) = (-1)^n e^{x^2} \frac{d^n}{dx^n} e^{-x^2} \]

Parameters
__nThe order of the Hermite polynomial.
__xThe argument of the Hermite polynomial.
Returns
The value of the Hermite polynomial of order n and argument x.
43 {
44 namespace tr1
45 {
46  // [5.2] Special functions
47 
48  // Implementation-space details.
49  namespace __detail
50  {
51  _GLIBCXX_BEGIN_NAMESPACE_VERSION
52 
67  template<typename _Tp>
68  _Tp
69  __poly_hermite_recursion(unsigned int __n, _Tp __x)
70  {
71  // Compute H_0.
72  _Tp __H_0 = 1;
73  if (__n == 0)
74  return __H_0;
75 
76  // Compute H_1.
77  _Tp __H_1 = 2 * __x;
78  if (__n == 1)
79  return __H_1;
80 
81  // Compute H_n.
82  _Tp __H_n, __H_nm1, __H_nm2;
83  unsigned int __i;
84  for (__H_nm2 = __H_0, __H_nm1 = __H_1, __i = 2; __i <= __n; ++__i)
85  {
86  __H_n = 2 * (__x * __H_nm1 - (__i - 1) * __H_nm2);
87  __H_nm2 = __H_nm1;
88  __H_nm1 = __H_n;
89  }
90 
91  return __H_n;
92  }
93 
94 
109  template<typename _Tp>
110  inline _Tp
111  __poly_hermite(unsigned int __n, _Tp __x)
112  {
113  if (__isnan(__x))
114  return std::numeric_limits<_Tp>::quiet_NaN();
115  else
116  return __poly_hermite_recursion(__n, __x);
117  }
118 
119  _GLIBCXX_END_NAMESPACE_VERSION
120  } // namespace std::tr1::__detail
121 }
122 }