NumCpp  2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
blackman.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <cmath>
31
34#include "NumCpp/NdArray.hpp"
35
36namespace 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., mDouble, m, EndPoint::YES))
61 {
62 const auto nOverM = n / mDouble;
63 result[i++] =
64 0.42 - 0.5 * std::cos(2. * constants::pi * nOverM) + 0.08 * std::cos(4. * constants::pi * nOverM);
65 }
66
67 return result;
68 }
69} // 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, EndPoint endPoint=EndPoint::YES)
Definition: linspace.hpp:61
auto cos(dtype inValue) noexcept
Definition: cos.hpp:49
NdArray< double > blackman(int32 m)
Definition: blackman.hpp:49
std::int32_t int32
Definition: Types.hpp:36