NumCpp  2.3.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 
32 #include "NumCpp/NdArray.hpp"
33 
34 #include "boost/math/special_functions/gamma.hpp"
35 
36 namespace nc
37 {
38  namespace special
39  {
40  //============================================================================
41  // Method Description:
49  template<typename dtype>
50  auto log_gamma(dtype inValue)
51  {
53 
54  return boost::math::lgamma(inValue);
55  }
56 
57  //============================================================================
58  // Method Description:
66  template<typename dtype>
67  auto log_gamma(const NdArray<dtype>& inArray)
68  {
69  NdArray<decltype(log_gamma(dtype{0}))> returnArray(inArray.shape());
70 
71  stl_algorithms::transform(inArray.cbegin(), inArray.cend(), returnArray.begin(),
72  [](dtype inValue) -> auto
73  {
74  return log_gamma(inValue);
75  });
76 
77  return returnArray;
78  }
79  } // namespace special
80 } // namespace nc
StaticAsserts.hpp
nc::NdArray::shape
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4311
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:1490
nc
Definition: Coordinate.hpp:44
nc::NdArray::cbegin
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1146
StlAlgorithms.hpp
nc::special::log_gamma
auto log_gamma(dtype inValue)
Definition: log_gamma.hpp:50
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1090