NumCpp  2.10.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
Special/beta.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 
36 #include "NumCpp/NdArray.hpp"
37 
38 #ifndef __cpp_lib_math_special_functions
39 #include "boost/math/special_functions/beta.hpp"
40 #endif
41 
42 #include <type_traits>
43 
44 namespace nc::special
45 {
46  //============================================================================
47  // Method Description:
56  template<typename dtype1, typename dtype2>
57  auto beta(dtype1 a, dtype2 b)
58  {
61 
62 #ifdef __cpp_lib_math_special_functions
63  return std::beta(a, b);
64 #else
65  return boost::math::beta(a, b);
66 #endif
67  }
68 
69  //============================================================================
70  // Method Description:
79  template<typename dtype1, typename dtype2>
80  auto beta(const NdArray<dtype1>& inArrayA, const NdArray<dtype2>& inArrayB)
81  {
82  NdArray<decltype(beta(dtype1{ 0 }, dtype2{ 0 }))> returnArray(inArrayB.shape());
83 
85  inArrayA.cbegin(),
86  inArrayA.cend(),
87  inArrayB.cbegin(),
88  returnArray.begin(),
89  [](dtype1 a, dtype2 b) -> auto{ return beta(a, b); });
90 
91  return returnArray;
92  }
93 } // namespace nc::special
94 
95 #endif // #if defined(__cpp_lib_math_special_functions) || !defined(NUMCPP_NO_USE_BOOST)
#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
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1308
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4402
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1616
iterator begin() noexcept
Definition: NdArrayCore.hpp:1258
Definition: airy_ai.hpp:39
auto beta(dtype1 a, dtype2 b)
Definition: Special/beta.hpp:57
auto beta(const NdArray< dtype1 > &inArrayA, const NdArray< dtype2 > &inArrayB)
Definition: Special/beta.hpp:80
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:775