NumCpp
2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
hamming.hpp
Go to the documentation of this file.
1
28
#pragma once
29
30
#include <cmath>
31
32
#include "
NumCpp/Core/Constants.hpp
"
33
#include "
NumCpp/Functions/linspace.hpp
"
34
#include "
NumCpp/NdArray.hpp
"
35
36
namespace
nc
37
{
38
//============================================================================
39
// Method Description:
49
inline
NdArray<double>
hamming
(
int32
m)
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,
EndPoint::YES
))
62
{
63
result[i++] = 0.54 - 0.46 *
std::cos
(twoPiDivMMinus1 * n);
64
}
65
66
return
result;
67
}
68
}
// namespace nc
Constants.hpp
NdArray.hpp
nc::NdArray< double >
linspace.hpp
nc::constants::pi
constexpr double pi
Pi.
Definition:
Core/Constants.hpp:39
nc
Definition:
Cartesian.hpp:40
nc::linspace
NdArray< dtype > linspace(dtype inStart, dtype inStop, uint32 inNum=50, EndPoint endPoint=EndPoint::YES)
Definition:
linspace.hpp:61
nc::cos
auto cos(dtype inValue) noexcept
Definition:
cos.hpp:49
nc::hamming
NdArray< double > hamming(int32 m)
Definition:
hamming.hpp:49
nc::int32
std::int32_t int32
Definition:
Types.hpp:36
nc::EndPoint::YES
@ YES
include
NumCpp
Functions
hamming.hpp
Generated by
1.9.4