NumCpp  2.12.1
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#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/laguerre.hpp"
40#endif
41
42namespace nc::polynomial
43{
44 //============================================================================
45 // Method Description:
54 template<typename dtype>
55 double laguerre(uint32 n, dtype x)
56 {
58
59#ifdef __cpp_lib_math_special_functions
60 return std::laguerre(n, static_cast<double>(x));
61#else
62 return boost::math::laguerre(n, static_cast<double>(x));
63#endif
64 }
65
66 //============================================================================
67 // Method Description:
77 template<typename dtype>
78 double laguerre(uint32 n, uint32 m, dtype x)
79 {
81
82#ifdef __cpp_lib_math_special_functions
83 return std::assoc_laguerre(m, n, static_cast<double>(x));
84#else
85 return boost::math::laguerre(m, n, static_cast<double>(x));
86#endif
87 }
88
89 //============================================================================
90 // Method Description:
99 template<typename dtype>
101 {
102 NdArray<double> returnArray(inArrayX.shape());
103
104 const auto function = [n](dtype x) -> double { return laguerre(n, x); };
105
106 stl_algorithms::transform(inArrayX.cbegin(), inArrayX.cend(), returnArray.begin(), function);
107
108 return returnArray;
109 }
110
111 //============================================================================
112 // Method Description:
122 template<typename dtype>
124 {
125 NdArray<double> returnArray(inArrayX.shape());
126
127 const auto function = [n, m](dtype x) -> double { return laguerre(n, m, x); };
128
129 stl_algorithms::transform(inArrayX.cbegin(), inArrayX.cend(), returnArray.begin(), function);
130
131 return returnArray;
132 }
133} // namespace nc::polynomial
134
135#endif // #if defined(__cpp_lib_math_special_functions) || !defined(NUMCPP_NO_USE_BOOST)
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:39
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1365
const Shape & shape() const noexcept
Definition: NdArrayCore.hpp:4511
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1673
iterator begin() noexcept
Definition: NdArrayCore.hpp:1315
Definition: chebyshev_t.hpp:39
NdArray< double > laguerre(uint32 n, uint32 m, const NdArray< dtype > &inArrayX)
Definition: laguerre.hpp:123
double laguerre(uint32 n, dtype x)
Definition: laguerre.hpp:55
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:775
std::uint32_t uint32
Definition: Types.hpp:40