NumCpp  2.4.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
hermite.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #if defined(__cpp_lib_math_special_functions) || !defined(NO_USE_BOOST)
31 
34 #include "NumCpp/NdArray.hpp"
35 
36 #ifdef __cpp_lib_math_special_functions
37 #include <cmath>
38 #else
39 #include "boost/math/special_functions/hermite.hpp"
40 #endif
41 
42 namespace nc
43 {
44  namespace polynomial
45  {
46  //============================================================================
47  // Method Description:
57  template<typename dtype>
58  double hermite(uint32 n, dtype x)
59  {
61 
62 #ifdef __cpp_lib_math_special_functions
63  return std::hermite(n, static_cast<double>(x));
64 #else
65  return boost::math::hermite(n, static_cast<double>(x));
66 #endif
67  }
68 
69  //============================================================================
70  // Method Description:
80  template<typename dtype>
82  {
83  NdArray<double> returnArray(inArrayX.shape());
84 
85  const auto function = [n](dtype x) -> double
86  {
87  return hermite(n, x);
88  };
89 
90  stl_algorithms::transform(inArrayX.cbegin(), inArrayX.cend(), returnArray.begin(), function);
91 
92  return returnArray;
93  }
94  } // namespace polynomial
95 } // namespace nc
96 
97 #endif // #if defined(__cpp_lib_math_special_functions) || !defined(NO_USE_BOOST)
StaticAsserts.hpp
nc::NdArray::shape
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4356
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
nc::NdArray< double >
nc::stl_algorithms::transform
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:702
nc::uint32
std::uint32_t uint32
Definition: Types.hpp:40
nc::polynomial::hermite
NdArray< double > hermite(uint32 n, const NdArray< dtype > &inArrayX)
Definition: hermite.hpp:81
NdArray.hpp
nc::NdArray::cend
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1487
nc
Definition: Coordinate.hpp:44
nc::NdArray::cbegin
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1143
StlAlgorithms.hpp
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1087
nc::polynomial::hermite
double hermite(uint32 n, dtype x)
Definition: hermite.hpp:58