NumCpp  2.7.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
laguerre.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/laguerre.hpp"
40 #endif
41 
42 namespace nc
43 {
44  namespace polynomial
45  {
46  //============================================================================
47  // Method Description:
56  template<typename dtype>
57  double laguerre(uint32 n, dtype x)
58  {
60 
61 #ifdef __cpp_lib_math_special_functions
62  return std::laguerre(n, static_cast<double>(x));
63 #else
64  return boost::math::laguerre(n, static_cast<double>(x));
65 #endif
66  }
67 
68  //============================================================================
69  // Method Description:
79  template<typename dtype>
80  double laguerre(uint32 n, uint32 m, dtype x)
81  {
83 
84 #ifdef __cpp_lib_math_special_functions
85  return std::assoc_laguerre(m, n, static_cast<double>(x));
86 #else
87  return boost::math::laguerre(m, n, static_cast<double>(x));
88 #endif
89  }
90 
91  //============================================================================
92  // Method Description:
101  template<typename dtype>
103  {
104  NdArray<double> returnArray(inArrayX.shape());
105 
106  const auto function = [n](dtype x) -> double
107  {
108  return laguerre(n, x);
109  };
110 
111  stl_algorithms::transform(inArrayX.cbegin(), inArrayX.cend(), returnArray.begin(), function);
112 
113  return returnArray;
114  }
115 
116  //============================================================================
117  // Method Description:
127  template<typename dtype>
129  {
130  NdArray<double> returnArray(inArrayX.shape());
131 
132  const auto function = [n, m](dtype x) -> double
133  {
134  return laguerre(n, m, x);
135  };
136 
137  stl_algorithms::transform(inArrayX.cbegin(), inArrayX.cend(), returnArray.begin(), function);
138 
139  return returnArray;
140  }
141  } // namespace polynomial
142 } // namespace nc
143 
144 #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:1216
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4283
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1524
iterator begin() noexcept
Definition: NdArrayCore.hpp:1166
NdArray< double > laguerre(uint32 n, uint32 m, const NdArray< dtype > &inArrayX)
Definition: laguerre.hpp:128
double laguerre(uint32 n, dtype x)
Definition: laguerre.hpp:57
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