NumCpp  2.8.0
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
45 {
46  namespace special
47  {
48  //============================================================================
49  // Method Description:
58  template<typename dtype1, typename dtype2>
59  auto beta(dtype1 a, dtype2 b)
60  {
63 
64 #ifdef __cpp_lib_math_special_functions
65  return std::beta(a, b);
66 #else
67  return boost::math::beta(a, b);
68 #endif
69  }
70 
71  //============================================================================
72  // Method Description:
81  template<typename dtype1, typename dtype2>
82  auto beta(const NdArray<dtype1>& inArrayA, const NdArray<dtype2>& inArrayB)
83  {
84  NdArray<decltype(beta(dtype1{ 0 }, dtype2{ 0 }))> returnArray(inArrayB.shape());
85 
87  inArrayA.cbegin(),
88  inArrayA.cend(),
89  inArrayB.cbegin(),
90  returnArray.begin(),
91  [](dtype1 a, dtype2 b) -> auto{ return beta(a, b); });
92 
93  return returnArray;
94  }
95  } // namespace special
96 } // namespace nc
97 
98 #endif // #if defined(__cpp_lib_math_special_functions) || !defined(NUMCPP_NO_USE_BOOST)
#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
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1221
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4276
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1529
iterator begin() noexcept
Definition: NdArrayCore.hpp:1171
auto beta(dtype1 a, dtype2 b)
Definition: Special/beta.hpp:59
auto beta(const NdArray< dtype1 > &inArrayA, const NdArray< dtype2 > &inArrayB)
Definition: Special/beta.hpp:82
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:784
Definition: Coordinate.hpp:45