NumCpp  2.8.0
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 #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/bessel.hpp"
40 #endif
41 
42 namespace nc
43 {
44  namespace special
45  {
46  //============================================================================
47  // Method Description:
56  template<typename dtype>
57  auto spherical_bessel_jn(uint32 inV, dtype inX)
58  {
60 
61 #ifdef __cpp_lib_math_special_functions
62  return std::sph_bessel(inV, inX);
63 #else
64  return boost::math::sph_bessel(inV, inX);
65 #endif
66  }
67 
68  //============================================================================
69  // Method Description:
78  template<typename dtype>
79  auto spherical_bessel_jn(uint32 inV, const NdArray<dtype>& inArrayX)
80  {
81  NdArray<decltype(spherical_bessel_jn(inV, dtype{ 0 }))> returnArray(inArrayX.shape());
82 
84  inArrayX.cbegin(),
85  inArrayX.cend(),
86  returnArray.begin(),
87  [inV](dtype inX) -> auto{ return spherical_bessel_jn(inV, inX); });
88 
89  return returnArray;
90  }
91  } // namespace special
92 } // namespace nc
93 
94 #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: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
auto spherical_bessel_jn(uint32 inV, dtype inX)
Definition: spherical_bessel_jn.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