NumCpp  2.4.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
expint.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #if defined(__cpp_lib_math_special_functions) || !defined(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/expint.hpp"
40 #endif
41 
42 #include <type_traits>
43 
44 namespace nc
45 {
46  namespace special
47  {
48  //============================================================================
49  // Method Description:
58  template<typename dtype>
59  auto expint(dtype inX)
60  {
62 
63 #ifdef __cpp_lib_math_special_functions
64  return std::expint(inX);
65 #else
66  return boost::math::expint(inX);
67 #endif
68  }
69 
70  //============================================================================
71  // Method Description:
80  template<typename dtype>
81  auto expint(const NdArray<dtype>& inArrayX)
82  {
83  NdArray<decltype(expint(dtype{ 0 }))> returnArray(inArrayX.shape());
84 
85  stl_algorithms::transform(inArrayX.cbegin(), inArrayX.cend(), returnArray.begin(),
86  [](dtype inX) -> auto
87  {
88  return expint(inX);
89  });
90 
91  return returnArray;
92  }
93  } // namespace special
94 } // namespace nc
95 
96 #endif // #if defined(__cpp_lib_math_special_functions) || !defined(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::special::expint
auto expint(dtype inX)
Definition: expint.hpp:59
nc::NdArray::cend
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1487
nc
Definition: Coordinate.hpp:44
nc::special::expint
auto expint(const NdArray< dtype > &inArrayX)
Definition: expint.hpp:81
nc::NdArray::cbegin
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1143
StlAlgorithms.hpp
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1087