NumCpp  2.7.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
kaiser.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include <cmath>
31 
32 #include "NumCpp/NdArray.hpp"
34 #include "NumCpp/Utils/sqr.hpp"
35 
36 namespace nc
37 {
38  //============================================================================
39  // Method Description:
48  inline NdArray<double> kaiser(int32 m, double beta)
49  {
50  if (m < 1)
51  {
52  return {};
53  }
54 
55  const auto mDouble = static_cast<double>(m);
56  const auto mMinus1 = mDouble - 1.0;
57  const auto mMinus1Over2 = mMinus1 / 2.0;
58  const auto mMinus1Squared = utils::sqr(mMinus1);
59  const auto i0Beta = special::bessel_in(0, beta);
60 
61  NdArray<double> result(1, m);
62  int32 i = 0;
63  for (auto n : linspace(-mMinus1Over2, mMinus1Over2, m, true))
64  {
65  auto value = beta * std::sqrt(1.0 - (4.0 * utils::sqr(n)) / mMinus1Squared);
66  result[i++] = special::bessel_in(0, value) / i0Beta;
67  }
68 
69  return result;
70  }
71 } // namespace nc
dtype beta(dtype inAlpha, dtype inBeta)
Definition: Random/beta.hpp:59
auto bessel_in(dtype1 inV, dtype2 inX)
Definition: bessel_in.hpp:59
constexpr dtype sqr(dtype inValue) noexcept
Definition: sqr.hpp:44
Definition: Coordinate.hpp:45
NdArray< double > kaiser(int32 m, double beta)
Definition: kaiser.hpp:48
NdArray< dtype > linspace(dtype inStart, dtype inStop, uint32 inNum=50, bool endPoint=true)
Definition: linspace.hpp:61
std::int32_t int32
Definition: Types.hpp:36
auto sqrt(dtype inValue) noexcept
Definition: sqrt.hpp:48