NumCpp  2.6.2
A Templatized Header Only C++ Implementation of the Python NumPy Library
comp_ellint_3.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 
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:
60  template<typename dtype1, typename dtype2>
61  auto comp_ellint_3(dtype1 inK, dtype2 inV)
62  {
65 
66 #ifdef __cpp_lib_math_special_functions
67  return std::comp_ellint_3(inK, inV);
68 #else
69  return boost::math::ellint_3(inK, inV);
70 #endif
71  }
72 
73  //============================================================================
74  // Method Description:
84  template<typename dtype1, typename dtype2>
85  auto comp_ellint_3(const NdArray<dtype1>& inArrayK, const NdArray<dtype2>& inArrayV)
86  {
87  if (inArrayK.size() != inArrayV.size())
88  {
89  THROW_INVALID_ARGUMENT_ERROR("Shapes of inArrayk and inArrayV must match.");
90  }
91 
92  NdArray<decltype(comp_ellint_3(dtype1{ 0 }, dtype2{ 0 }))> returnArray(inArrayK.shape());
93 
94  stl_algorithms::transform(inArrayK.cbegin(), inArrayK.cend(), inArrayV.cbegin(), returnArray.begin(),
95  [](dtype1 inK, dtype2 inV) -> auto
96  {
97  return comp_ellint_3(inK, inV);
98  });
99 
100  return returnArray;
101  }
102  } // namespace special
103 } // namespace nc
104 
105 #endif // #if defined(__cpp_lib_math_special_functions) || !defined(NUMCPP_NO_USE_BOOST)
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
#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
size_type size() const noexcept
Definition: NdArrayCore.hpp:4497
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
auto comp_ellint_3(const NdArray< dtype1 > &inArrayK, const NdArray< dtype2 > &inArrayV)
Definition: comp_ellint_3.hpp:85
auto comp_ellint_3(dtype1 inK, dtype2 inV)
Definition: comp_ellint_3.hpp:61
auto ellint_3(dtype1 inK, dtype2 inV, dtype3 inP)
Definition: ellint_3.hpp:62
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:702
Definition: Coordinate.hpp:45