NumCpp  2.11.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
ellint_2.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 
37 #include "NumCpp/NdArray.hpp"
38 
39 #ifndef __cpp_lib_math_special_functions
40 #include "boost/math/special_functions/ellint_2.hpp"
41 #endif
42 
43 #include <type_traits>
44 
45 namespace nc::special
46 {
47  //============================================================================
48  // Method Description:
57  template<typename dtype1, typename dtype2>
58  auto ellint_2(dtype1 inK, dtype2 inP)
59  {
62 
63 #ifdef __cpp_lib_math_special_functions
64  return std::ellint_2(inK, inP);
65 #else
66  return boost::math::ellint_2(inK, inP);
67 #endif
68  }
69 
70  //============================================================================
71  // Method Description:
80  template<typename dtype1, typename dtype2>
81  auto ellint_2(const NdArray<dtype1>& inArrayK, const NdArray<dtype2>& inArrayP)
82  {
83  if (inArrayK.size() != inArrayP.size())
84  {
85  THROW_INVALID_ARGUMENT_ERROR("Shapes of inArrayK and inArrayP must match.");
86  }
87 
88  NdArray<decltype(ellint_2(dtype1{ 0 }, dtype2{ 0 }))> returnArray(inArrayK.shape());
89 
91  inArrayK.cbegin(),
92  inArrayK.cend(),
93  inArrayP.cbegin(),
94  returnArray.begin(),
95  [](dtype1 inK, dtype2 inP) -> auto{ return ellint_2(inK, inP); });
96 
97  return returnArray;
98  }
99 } // namespace nc::special
100 
101 #endif // #if defined(__cpp_lib_math_special_functions) || !defined(NUMCPP_NO_USE_BOOST)
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:39
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:138
size_type size() const noexcept
Definition: NdArrayCore.hpp:4477
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1318
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1626
iterator begin() noexcept
Definition: NdArrayCore.hpp:1268
const Shape & shape() const noexcept
Definition: NdArrayCore.hpp:4464
Definition: airy_ai.hpp:39
auto ellint_2(const NdArray< dtype1 > &inArrayK, const NdArray< dtype2 > &inArrayP)
Definition: ellint_2.hpp:81
auto ellint_2(dtype1 inK, dtype2 inP)
Definition: ellint_2.hpp:58
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:775