NumCpp  2.4.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
log_gamma.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #ifndef NO_USE_BOOST
31 
34 #include "NumCpp/NdArray.hpp"
35 
36 #include "boost/math/special_functions/gamma.hpp"
37 
38 namespace nc
39 {
40  namespace special
41  {
42  //============================================================================
43  // Method Description:
52  template<typename dtype>
53  auto log_gamma(dtype inValue)
54  {
56 
57  return boost::math::lgamma(inValue);
58  }
59 
60  //============================================================================
61  // Method Description:
70  template<typename dtype>
71  auto log_gamma(const NdArray<dtype>& inArray)
72  {
73  NdArray<decltype(log_gamma(dtype{0}))> returnArray(inArray.shape());
74 
75  stl_algorithms::transform(inArray.cbegin(), inArray.cend(), returnArray.begin(),
76  [](dtype inValue) -> auto
77  {
78  return log_gamma(inValue);
79  });
80 
81  return returnArray;
82  }
83  } // namespace special
84 } // namespace nc
85 
86 #endif // #ifndef NO_USE_BOOST
StaticAsserts.hpp
nc::NdArray::shape
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4356
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
nc::NdArray< dtype >
nc::stl_algorithms::transform
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:702
NdArray.hpp
nc::NdArray::cend
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1487
nc
Definition: Coordinate.hpp:44
nc::NdArray::cbegin
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1143
StlAlgorithms.hpp
nc::special::log_gamma
auto log_gamma(dtype inValue)
Definition: log_gamma.hpp:53
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1087