NumCpp  2.8.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 #include <cmath>
31 
32 #if defined(__cpp_lib_math_special_functions) || !defined(NUMCPP_NO_USE_BOOST)
33 
36 #include "NumCpp/NdArray.hpp"
37 
38 #ifndef __cpp_lib_math_special_functions
39 #include "boost/math/special_functions/hermite.hpp"
40 #endif
41 
42 namespace nc
43 {
44  namespace polynomial
45  {
46  //============================================================================
47  // Method Description:
56  template<typename dtype>
57  double hermite(uint32 n, dtype x)
58  {
60 
61 #ifdef __cpp_lib_math_special_functions
62  return std::hermite(n, static_cast<double>(x));
63 #else
64  return boost::math::hermite(n, static_cast<double>(x));
65 #endif
66  }
67 
68  //============================================================================
69  // Method Description:
78  template<typename dtype>
80  {
81  NdArray<double> returnArray(inArrayX.shape());
82 
83  const auto function = [n](dtype x) -> double { return hermite(n, x); };
84 
85  stl_algorithms::transform(inArrayX.cbegin(), inArrayX.cend(), returnArray.begin(), function);
86 
87  return returnArray;
88  }
89  } // namespace polynomial
90 } // namespace nc
91 
92 #endif // #if defined(__cpp_lib_math_special_functions) || !defined(NUMCPP_NO_USE_BOOST)
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1221
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4276
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1529
iterator begin() noexcept
Definition: NdArrayCore.hpp:1171
NdArray< double > hermite(uint32 n, const NdArray< dtype > &inArrayX)
Definition: hermite.hpp:79
double hermite(uint32 n, dtype x)
Definition: hermite.hpp:57
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:784
Definition: Coordinate.hpp:45
std::uint32_t uint32
Definition: Types.hpp:40