NumCpp  2.13.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
hanning.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 const auto twoPiDivMMinus1 = (2. * constants::pi) / (mDouble - 1.);
58
60 int32 i = 0;
61 for (auto n : linspace(0., mDouble - 1., m, EndPoint::YES))
62 {
63 result[i++] = 0.5 - 0.5 * std::cos(twoPiDivMMinus1 * n);
64 }
65
66 return result;
67 }
68} // namespace nc
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
constexpr double pi
Pi.
Definition Core/Constants.hpp:39
Definition Cartesian.hpp:40
NdArray< double > hanning(int32 m)
Definition hanning.hpp:49
NdArray< dtype > linspace(dtype inStart, dtype inStop, uint32 inNum=50, EndPoint endPoint=EndPoint::YES)
Definition linspace.hpp:61
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59
std::int32_t int32
Definition Types.hpp:36