NumCpp  2.7.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
blackman.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include <cmath>
31 
32 #include "NumCpp/NdArray.hpp"
35 
36 namespace nc
37 {
38  //============================================================================
39  // Method Description:
50  {
51  if (m < 1)
52  {
53  return {};
54  }
55 
56  const auto mDouble = static_cast<double>(m);
57 
58  NdArray<double> result(1, m);
59  int32 i = 0;
60  for (auto n : linspace(0.0, mDouble, m, true))
61  {
62  const auto nOverM = n / mDouble;
63  result[i++] = 0.42 - 0.5 * std::cos(2.0 * constants::pi * nOverM)
64  + 0.08 * std::cos(4.0 * constants::pi * nOverM);
65  }
66 
67  return result;
68  }
69 } // namespace nc
constexpr double pi
Pi.
Definition: Constants.hpp:43
Definition: Coordinate.hpp:45
NdArray< dtype > linspace(dtype inStart, dtype inStop, uint32 inNum=50, bool endPoint=true)
Definition: linspace.hpp:61
auto cos(dtype inValue) noexcept
Definition: cos.hpp:49
std::int32_t int32
Definition: Types.hpp:36
NdArray< double > blackman(int32 m)
Definition: blackman.hpp:49