NumCpp  2.9.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
comp_ellint_3.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_3.hpp"
41 #endif
42 
43 #include <type_traits>
44 
45 namespace nc
46 {
47  namespace special
48  {
49  //============================================================================
50  // Method Description:
59  template<typename dtype1, typename dtype2>
60  auto comp_ellint_3(dtype1 inK, dtype2 inV)
61  {
64 
65 #ifdef __cpp_lib_math_special_functions
66  return std::comp_ellint_3(inK, inV);
67 #else
68  return boost::math::ellint_3(inK, inV);
69 #endif
70  }
71 
72  //============================================================================
73  // Method Description:
82  template<typename dtype1, typename dtype2>
83  auto comp_ellint_3(const NdArray<dtype1>& inArrayK, const NdArray<dtype2>& inArrayV)
84  {
85  if (inArrayK.size() != inArrayV.size())
86  {
87  THROW_INVALID_ARGUMENT_ERROR("Shapes of inArrayk and inArrayV must match.");
88  }
89 
90  NdArray<decltype(comp_ellint_3(dtype1{ 0 }, dtype2{ 0 }))> returnArray(inArrayK.shape());
91 
93  inArrayK.cbegin(),
94  inArrayK.cend(),
95  inArrayV.cbegin(),
96  returnArray.begin(),
97  [](dtype1 inK, dtype2 inV) -> auto{ return comp_ellint_3(inK, inV); });
98 
99  return returnArray;
100  }
101  } // namespace special
102 } // namespace nc
103 
104 #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:4105
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1221
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4092
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1529
iterator begin() noexcept
Definition: NdArrayCore.hpp:1171
auto comp_ellint_3(const NdArray< dtype1 > &inArrayK, const NdArray< dtype2 > &inArrayV)
Definition: comp_ellint_3.hpp:83
auto comp_ellint_3(dtype1 inK, dtype2 inV)
Definition: comp_ellint_3.hpp:60
auto ellint_3(dtype1 inK, dtype2 inV, dtype3 inP)
Definition: ellint_3.hpp:61
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:784
Definition: Coordinate.hpp:45