NumCpp  2.11.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
hamming.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include <cmath>
31 
34 #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  const auto twoPiDivMMinus1 = (2. * constants::pi) / (mDouble - 1.);
58 
59  NdArray<double> result(1, m);
60  int32 i = 0;
61  for (auto n : linspace(0., mDouble - 1., m, true))
62  {
63  result[i++] = 0.54 - 0.46 * std::cos(twoPiDivMMinus1 * n);
64  }
65 
66  return result;
67  }
68 } // namespace nc
constexpr double pi
Pi.
Definition: Core/Constants.hpp:39
Definition: Cartesian.hpp:40
NdArray< dtype > linspace(dtype inStart, dtype inStop, uint32 inNum=50, bool endPoint=true)
Definition: linspace.hpp:60
auto cos(dtype inValue) noexcept
Definition: cos.hpp:49
std::int32_t int32
Definition: Types.hpp:36
NdArray< double > hamming(int32 m)
Definition: hamming.hpp:49