NumCpp  2.4.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
bessel_jn.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/bessel.hpp"
40 #endif
41 
42 #include <type_traits>
43 
44 namespace nc
45 {
46  namespace special
47  {
48  //============================================================================
49  // Method Description:
59  template<typename dtype1, typename dtype2>
60  auto bessel_jn(dtype1 inV, dtype2 inX)
61  {
64 
65 #ifdef __cpp_lib_math_special_functions
66  return std::cyl_bessel_j(inV, inX);
67 #else
68  return boost::math::cyl_bessel_j(inV, inX);
69 #endif
70  }
71 
72  //============================================================================
73  // Method Description:
83  template<typename dtype1, typename dtype2>
84  auto bessel_jn(dtype1 inV, const NdArray<dtype2>& inArrayX)
85  {
86  NdArray<decltype(bessel_jn(dtype1{ 0 }, dtype2{ 0 }))> returnArray(inArrayX.shape());
87 
88  stl_algorithms::transform(inArrayX.cbegin(), inArrayX.cend(), returnArray.begin(),
89  [inV](dtype2 inX) -> auto
90  {
91  return bessel_jn(inV, inX);
92  });
93 
94  return returnArray;
95  }
96  } // namespace special
97 } // namespace nc
98 
99 #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
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:71
nc::stl_algorithms::transform
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:702
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::special::bessel_jn
auto bessel_jn(dtype1 inV, dtype2 inX)
Definition: bessel_jn.hpp:60
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1087