NumCpp  2.4.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
ellint_3.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #if defined(__cpp_lib_math_special_functions) || !defined(NO_USE_BOOST)
31 
35 #include "NumCpp/NdArray.hpp"
36 
37 #ifdef __cpp_lib_math_special_functions
38 #include <cmath>
39 #else
40 #include "boost/math/special_functions/ellint_3.hpp"
41 #endif
42 
43 #include <type_traits>
44 
45 namespace nc
46 {
47  namespace special
48  {
49  //============================================================================
50  // Method Description:
61  template<typename dtype1, typename dtype2, typename dtype3>
62  auto ellint_3(dtype1 inK, dtype2 inV, dtype3 inP)
63  {
67 
68 #ifdef __cpp_lib_math_special_functions
69  return std::ellint_3(inK, inV, inP);
70 #else
71  return boost::math::ellint_3(inK, inV, inP);
72 #endif
73  }
74 
75  //============================================================================
76  // Method Description:
87  template<typename dtype1, typename dtype2, typename dtype3>
88  auto ellint_3(const NdArray<dtype1>& inArrayK, const NdArray<dtype2>& inArrayV, const NdArray<dtype3>& inArrayP)
89  {
90  if (inArrayK.size() != inArrayV.size() ||
91  inArrayK.size() != inArrayP.size())
92  {
93  THROW_INVALID_ARGUMENT_ERROR("Shapes of inArrayK, inArrayV, and inArrayP must match.");
94  }
95 
96  NdArray<decltype(ellint_3(dtype1{ 0 }, dtype2{ 0 }, dtype3{ 0 }))> returnArray(inArrayK.shape());
97 
98  for (uint32 i = 0; i < inArrayK.size(); ++i)
99  {
100  returnArray[i] = ellint_3(inArrayK[i], inArrayV[i], inArrayP[i]);
101  }
102 
103  return returnArray;
104  }
105  } // namespace special
106 } // namespace nc
107 
108 #endif // #if defined(__cpp_lib_math_special_functions) || !defined(NO_USE_BOOST)
StaticAsserts.hpp
nc::NdArray::shape
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4356
Error.hpp
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
nc::NdArray
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:71
nc::uint32
std::uint32_t uint32
Definition: Types.hpp:40
NdArray.hpp
nc::special::ellint_3
auto ellint_3(dtype1 inK, dtype2 inV, dtype3 inP)
Definition: ellint_3.hpp:62
nc::NdArray::size
size_type size() const noexcept
Definition: NdArrayCore.hpp:4370
nc::special::ellint_3
auto ellint_3(const NdArray< dtype1 > &inArrayK, const NdArray< dtype2 > &inArrayV, const NdArray< dtype3 > &inArrayP)
Definition: ellint_3.hpp:88
nc
Definition: Coordinate.hpp:44
THROW_INVALID_ARGUMENT_ERROR
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
StlAlgorithms.hpp