NumCpp  1.0
A C++ implementation of the Python Numpy library
sinc.hpp
Go to the documentation of this file.
1 #pragma once
30 
31 #include "NumCpp/NdArray.hpp"
34 
35 #include <cmath>
36 
37 namespace nc
38 {
39  //============================================================================
40  // Method Description:
52  template<typename dtype>
53  auto sinc(dtype inValue) noexcept
54  {
56 
57  return std::sin(constants::pi * inValue) / (constants::pi * inValue);
58  }
59 
60  //============================================================================
61  // Method Description:
73  template<typename dtype>
74  auto sinc(const NdArray<dtype>& inArray)
75  {
76  NdArray<decltype(sinc(dtype{0}))> returnArray(inArray.shape());
77  stl_algorithms::transform(inArray.cbegin(), inArray.cend(), returnArray.begin(),
78  [](dtype inValue) noexcept -> auto
79  {
80  return sinc(inValue);
81  });
82 
83  return returnArray;
84  }
85 }
StaticAsserts.hpp
nc::NdArray::shape
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4296
STATIC_ASSERT_ARITHMETIC_OR_COMPLEX
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition: StaticAsserts.hpp:51
nc::NdArray< dtype >
NdArray.hpp
nc::NdArray::cend
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1491
nc::sin
auto sin(dtype inValue) noexcept
Definition: sin.hpp:52
nc::constants::pi
constexpr double pi
Pi.
Definition: Constants.hpp:44
nc
Definition: Coordinate.hpp:45
nc::stl_algorithms::transform
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction) noexcept
Definition: StlAlgorithms.hpp:703
nc::NdArray::cbegin
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1147
StlAlgorithms.hpp
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1091
nc::sinc
auto sinc(dtype inValue) noexcept
Definition: sinc.hpp:53