NumCpp  2.5.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 #if defined(__cpp_lib_math_special_functions) || !defined(NUMCPP_NO_USE_BOOST)
31 
34 #include "NumCpp/NdArray.hpp"
35 
36 #ifdef __cpp_lib_math_special_functions
37 #include <cmath>
38 #else
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:
59  template<typename dtype1, typename dtype2>
60  auto beta(dtype1 a, dtype2 b)
61  {
64 
65 #ifdef __cpp_lib_math_special_functions
66  return std::beta(a, b);
67 #else
68  return boost::math::beta(a, b);
69 #endif
70  }
71 
72  //============================================================================
73  // Method Description:
83  template<typename dtype1, typename dtype2>
84  auto beta(const NdArray<dtype1>& inArrayA, const NdArray<dtype2>& inArrayB)
85  {
86  NdArray<decltype(beta(dtype1{ 0 }, dtype2{ 0 }))> returnArray(inArrayB.shape());
87 
88  stl_algorithms::transform(inArrayA.cbegin(), inArrayA.cend(), inArrayB.cbegin(), returnArray.begin(),
89  [](dtype1 a, dtype2 b) -> auto
90  {
91  return beta(a, b);
92  });
93 
94  return returnArray;
95  }
96  } // namespace special
97 } // namespace nc
98 
99 #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: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 beta(dtype1 a, dtype2 b)
Definition: Special/beta.hpp:60
auto beta(const NdArray< dtype1 > &inArrayA, const NdArray< dtype2 > &inArrayB)
Definition: Special/beta.hpp:84
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:702
Definition: Coordinate.hpp:45