NumCpp  2.6.2
A Templatized Header Only C++ Implementation of the Python NumPy Library
laguerre.hpp
Go to the documentation of this file.
1 
28 #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/laguerre.hpp"
40 #endif
41 
42 namespace nc
43 {
44  namespace polynomial
45  {
46  //============================================================================
47  // Method Description:
57  template<typename dtype>
58  double laguerre(uint32 n, dtype x)
59  {
61 
62 #ifdef __cpp_lib_math_special_functions
63  return std::laguerre(n, static_cast<double>(x));
64 #else
65  return boost::math::laguerre(n, static_cast<double>(x));
66 #endif
67  }
68 
69  //============================================================================
70  // Method Description:
81  template<typename dtype>
82  double laguerre(uint32 n, uint32 m, dtype x)
83  {
85 
86 #ifdef __cpp_lib_math_special_functions
87  return std::assoc_laguerre(m, n, static_cast<double>(x));
88 #else
89  return boost::math::laguerre(m, n, static_cast<double>(x));
90 #endif
91  }
92 
93  //============================================================================
94  // Method Description:
104  template<typename dtype>
106  {
107  NdArray<double> returnArray(inArrayX.shape());
108 
109  const auto function = [n](dtype x) -> double
110  {
111  return laguerre(n, x);
112  };
113 
114  stl_algorithms::transform(inArrayX.cbegin(), inArrayX.cend(), returnArray.begin(), function);
115 
116  return returnArray;
117  }
118 
119  //============================================================================
120  // Method Description:
131  template<typename dtype>
133  {
134  NdArray<double> returnArray(inArrayX.shape());
135 
136  const auto function = [n, m](dtype x) -> double
137  {
138  return laguerre(n, m, x);
139  };
140 
141  stl_algorithms::transform(inArrayX.cbegin(), inArrayX.cend(), returnArray.begin(), function);
142 
143  return returnArray;
144  }
145  } // namespace polynomial
146 } // namespace nc
147 
148 #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
NdArray< double > laguerre(uint32 n, uint32 m, const NdArray< dtype > &inArrayX)
Definition: laguerre.hpp:132
double laguerre(uint32 n, dtype x)
Definition: laguerre.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