NumCpp  2.5.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
spherical_bessel_jn.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #if defined(__cpp_lib_math_special_functions) || !defined(NUMCPP_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 namespace nc
43 {
44  namespace special
45  {
46  //============================================================================
47  // Method Description:
57  template<typename dtype>
58  auto spherical_bessel_jn(uint32 inV, dtype inX)
59  {
61 
62 #ifdef __cpp_lib_math_special_functions
63  return std::sph_bessel(inV, inX);
64 #else
65  return boost::math::sph_bessel(inV, inX);
66 #endif
67  }
68 
69  //============================================================================
70  // Method Description:
80  template<typename dtype>
81  auto spherical_bessel_jn(uint32 inV, const NdArray<dtype>& inArrayX)
82  {
83  NdArray<decltype(spherical_bessel_jn(inV, dtype{0}))> returnArray(inArrayX.shape());
84 
85  stl_algorithms::transform(inArrayX.cbegin(), inArrayX.cend(), returnArray.begin(),
86  [inV](dtype inX) -> auto
87  {
88  return spherical_bessel_jn(inV, inX);
89  });
90 
91  return returnArray;
92  }
93  } // namespace special
94 } // namespace nc
95 
96 #endif // #if defined(__cpp_lib_math_special_functions) || !defined(NUMCPP_NO_USE_BOOST)
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1270
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4483
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1614
iterator begin() noexcept
Definition: NdArrayCore.hpp:1214
auto spherical_bessel_jn(uint32 inV, dtype inX)
Definition: spherical_bessel_jn.hpp:58
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:702
Definition: Coordinate.hpp:45
std::uint32_t uint32
Definition: Types.hpp:40