NumCpp  2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
ellint_2.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
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
43namespace nc::special
44{
45 //============================================================================
46 // Method Description:
55 template<typename dtype1, typename dtype2>
56 auto ellint_2(dtype1 inK, dtype2 inP)
57 {
60
61#ifdef __cpp_lib_math_special_functions
62 return std::ellint_2(inK, inP);
63#else
64 return boost::math::ellint_2(inK, inP);
65#endif
66 }
67
68 //============================================================================
69 // Method Description:
78 template<typename dtype1, typename dtype2>
79 auto ellint_2(const NdArray<dtype1>& inArrayK, const NdArray<dtype2>& inArrayP)
80 {
81 if (inArrayK.size() != inArrayP.size())
82 {
83 THROW_INVALID_ARGUMENT_ERROR("Shapes of inArrayK and inArrayP must match.");
84 }
85
86 NdArray<decltype(ellint_2(dtype1{ 0 }, dtype2{ 0 }))> returnArray(inArrayK.shape());
87
89 inArrayK.cend(),
90 inArrayP.cbegin(),
91 returnArray.begin(),
92 [](dtype1 inK, dtype2 inP) -> auto { return ellint_2(inK, inP); });
93
94 return returnArray;
95 }
96} // namespace nc::special
97
98#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:135
size_type size() const noexcept
Definition NdArrayCore.hpp:4600
const_iterator cbegin() const noexcept
Definition NdArrayCore.hpp:1361
const Shape & shape() const noexcept
Definition NdArrayCore.hpp:4587
const_iterator cend() const noexcept
Definition NdArrayCore.hpp:1669
Definition airy_ai.hpp:39
auto ellint_2(dtype1 inK, dtype2 inP)
Definition ellint_2.hpp:56
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition StlAlgorithms.hpp:776